Fix format. Try compile on Windows.

This commit is contained in:
ArthurSonzogni 2020-03-22 22:32:44 +01:00
parent 4ff45ee540
commit a402cb4fbb
67 changed files with 615 additions and 569 deletions

View File

@ -14,19 +14,17 @@ notifications:
jobs:
include:
# ubuntu 16.04, gcc-9
# Ubuntu
- os: linux
dist: bionic
compiler: gcc
addons: { apt: { packages: ["g++-9", "ninja-build"],
sources: ["ubuntu-toolchain-r-test"] } }
# ubuntu 16.04, clang-8
# Ubuntu
- os: linux
dist: bionic
compiler: clang
addons: { apt: { packages: ["clang-8", "ninja-build"],
sources: ["llvm-toolchain-xenial-8"] } }
# OS X High Sierra 10.13
# OS X
- os: osx
# Windows

View File

@ -10,7 +10,6 @@ option(FTXUI_ENABLE_INSTALL "Generate the install target" ON)
enable_testing()
cmake_minimum_required(VERSION 3.0)
find_package(Threads)
add_library(screen
@ -72,10 +71,14 @@ foreach(lib screen dom component)
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE src
PRIVATE
src
)
set_property(TARGET ${lib} PROPERTY CXX_STANDARD 17)
target_compile_options(${lib} PRIVATE -Wall -Werror -pedantic -Wextra -Wno-sign-compare)
target_compile_options(${lib} PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -pedantic -Werror -Wno-sign-compare>
)
endforeach()
if(FTXUI_ENABLE_INSTALL)

View File

@ -1,4 +1,5 @@
#include "ftxui/component/checkbox.hpp"
#include "ftxui/component/component.hpp"
#include "ftxui/component/container.hpp"
#include "ftxui/component/screen_interactive.hpp"
@ -11,6 +12,7 @@ class MyComponent : public Component {
CheckBox box_2_;
CheckBox box_3_;
Container container_ = Container::Vertical();
public:
MyComponent() {
Add(&container_);

View File

@ -2,7 +2,6 @@
#include "ftxui/component/container.hpp"
#include "ftxui/component/input.hpp"
#include "ftxui/component/menu.hpp"
#include "ftxui/component/checkbox.hpp"
#include "ftxui/component/screen_interactive.hpp"
#include "ftxui/component/toggle.hpp"
#include "ftxui/screen/string.hpp"
@ -20,6 +19,7 @@ class MyComponent : public Component {
}
}
// clang-format off
Element Render() override {
Elements content;
for (auto& it : checkbox) {

View File

@ -1,8 +1,8 @@
#include "ftxui/component/checkbox.hpp"
#include "ftxui/component/container.hpp"
#include "ftxui/component/input.hpp"
#include "ftxui/component/menu.hpp"
#include "ftxui/component/radiobox.hpp"
#include "ftxui/component/checkbox.hpp"
#include "ftxui/component/screen_interactive.hpp"
#include "ftxui/component/toggle.hpp"
@ -53,6 +53,7 @@ class MyComponent : public Component {
container.Add(&input);
}
// clang-format off
Element Render(std::wstring name, Component& component) {
return
hbox(
@ -72,6 +73,7 @@ class MyComponent : public Component {
Render(L"input", input) | size(WIDTH, LESS_THAN, 30)
) | border;
}
// clang-format on
};
int main(int argc, const char* argv[]) {

View File

@ -1,5 +1,6 @@
#include <cmath>
#include <thread>
#include "ftxui/component/checkbox.hpp"
#include "ftxui/component/container.hpp"
#include "ftxui/component/input.hpp"
@ -36,6 +37,7 @@ class HTopComponent : public Component {
HTopComponent() {}
~HTopComponent() override {}
// clang-format off
Element Render() override {
return
hbox(
@ -77,6 +79,7 @@ class HTopComponent : public Component {
) | flex
) | flex | border;
}
// clang-format on
};
class CompilerComponent : public Component {
@ -149,7 +152,8 @@ class CompilerComponent : public Component {
flag.Add(&c);
container.Add(&subcontainer);
// Executable ----------------------------------------------------------------
// Executable
// ----------------------------------------------------------------
executable.placeholder = L"executable";
subcontainer.Add(&executable);
@ -165,6 +169,7 @@ class CompilerComponent : public Component {
input_container.Add(&input);
}
// clang-format off
Element Render() override {
return
vbox(
@ -194,6 +199,7 @@ class CompilerComponent : public Component {
hflow(RenderCommandLine())
) | border;
}
// clang-format on
Elements RenderCommandLine() {
Elements line;
@ -220,6 +226,7 @@ class CompilerComponent : public Component {
};
class SpinnerComponent : public Component {
// clang-format off
Element Render() override {
Elements entries;
for(int i = 0; i<22; ++i) {
@ -233,9 +240,11 @@ class SpinnerComponent : public Component {
}
return hflow(std::move(entries)) | border;
}
// clang-format on
};
class ColorComponent : public Component {
// clang-format off
Element Render() override {
return
hbox(
@ -278,10 +287,12 @@ class ColorComponent : public Component {
bgcolor(Color::YellowLight, text(L"YellowLight"))
)
) | hcenter | border;
// clang-format on
}
};
class GaugeComponent : public Component {
// clang-format off
Element RenderGauge(int delta) {
float progress = (shift + delta) % 1000 / 1000.f;
return hbox(text(std::to_wstring(int(progress * 100)) + L"% ") | size(WIDTH, EQUAL, 5),
@ -308,6 +319,7 @@ class GaugeComponent : public Component {
RenderGauge(348) | color(Color::YellowLight)
) | border;
};
// clang-format on
};
class Tab : public Component {
@ -327,11 +339,7 @@ class Tab : public Component {
Add(&main_container);
main_container.Add(&tab_selection);
tab_selection.entries = {
L"htop",
L"color",
L"spinner",
L"gauge",
L"compiler",
L"htop", L"color", L"spinner", L"gauge", L"compiler",
};
main_container.Add(&container);
container.Add(&htop_component);
@ -342,11 +350,8 @@ class Tab : public Component {
}
Element Render() override {
return vbox(
text(L"FTXUI Demo") | bold | hcenter,
tab_selection.Render() | hcenter,
container.Render()
);
return vbox(text(L"FTXUI Demo") | bold | hcenter,
tab_selection.Render() | hcenter, container.Render());
}
};

View File

@ -1,7 +1,8 @@
#include "ftxui/component/input.hpp"
#include <iostream>
#include "ftxui/component/container.hpp"
#include "ftxui/component/input.hpp"
#include "ftxui/component/screen_interactive.hpp"
#include "ftxui/screen/string.hpp"
@ -28,6 +29,7 @@ class MyComponent : public Component {
Input input_2;
Input input_3;
// clang-format off
Element Render() override {
return
border(
@ -38,6 +40,7 @@ class MyComponent : public Component {
)
);
}
// clang-format on
};
int main(int argc, const char* argv[]) {

View File

@ -1,8 +1,9 @@
#include "ftxui/component/menu.hpp"
#include <chrono>
#include <iostream>
#include <thread>
#include "ftxui/component/menu.hpp"
#include "ftxui/component/screen_interactive.hpp"
int main(int argc, const char* argv[]) {

View File

@ -16,21 +16,27 @@ class MyComponent : public Component {
container.Add(&left_menu);
container.Add(&right_menu);
left_menu.entries = {L"0%", L"10%", L"20%", L"30%", L"40%", L"50%",
L"60%", L"70%", L"80%", L"90%"};
right_menu.entries = {L"0%", L"1%", L"2%", L"3%", L"4%", L"5%",
L"6%", L"7%", L"8%", L"9%", L"10%"};
left_menu.entries = {
L"0%", L"10%", L"20%", L"30%", L"40%",
L"50%", L"60%", L"70%", L"80%", L"90%",
};
right_menu.entries = {
L"0%", L"1%", L"2%", L"3%", L"4%", L"5%",
L"6%", L"7%", L"8%", L"9%", L"10%",
};
left_menu.on_enter = [this]() { on_enter(); };
right_menu.on_enter = [this]() { on_enter(); };
}
std::function<void()> on_enter = []() {};
private:
Container container = Container::Horizontal();
Menu left_menu;
Menu right_menu;
// clang-format off
Element Render() override {
int sum = left_menu.selected * 10 + right_menu.selected;
return
@ -61,10 +67,10 @@ class MyComponent : public Component {
)
);
}
// clang-format on
};
int main(int argc, const char *argv[])
{
int main(int argc, const char* argv[]) {
auto screen = ScreenInteractive::TerminalOutput();
MyComponent component;
component.on_enter = screen.ExitLoopClosure();

View File

@ -16,11 +16,7 @@ class MyComponent : public Component {
for (Menu* menu : {&menu_1, &menu_2, &menu_3, &menu_4, &menu_5, &menu_6}) {
container.Add(menu);
menu->entries = {
L"Monkey",
L"Dog",
L"Cat",
L"Bird",
L"Elephant",
L"Monkey", L"Dog", L"Cat", L"Bird", L"Elephant",
};
menu->on_enter = [this]() { on_enter(); };
}
@ -44,6 +40,7 @@ class MyComponent : public Component {
}
std::function<void()> on_enter = []() {};
private:
Container container = Container::Horizontal();
Menu menu_1;
@ -53,6 +50,7 @@ class MyComponent : public Component {
Menu menu_5;
Menu menu_6;
// clang-format off
Element Render() override {
return
hbox(
@ -64,10 +62,10 @@ class MyComponent : public Component {
menu_6.Render() | flex
) | border;
}
// clang-format on
};
int main(int argc, const char *argv[])
{
int main(int argc, const char* argv[]) {
auto screen = ScreenInteractive::TerminalOutput();
MyComponent component;
component.on_enter = screen.ExitLoopClosure();

View File

@ -1,4 +1,5 @@
#include "ftxui/component/radiobox.hpp"
#include "ftxui/component/component.hpp"
#include "ftxui/component/container.hpp"
#include "ftxui/component/screen_interactive.hpp"

View File

@ -45,12 +45,8 @@ class MyComponent : public Component {
std::function<void()> on_enter = []() {};
Element Render() {
return
vbox(
toggle_.Render(),
separator(),
tab_container_.Render()
) | border;
return vbox(toggle_.Render(), separator(), tab_container_.Render()) |
border;
}
private:

View File

@ -1,10 +1,11 @@
#include "ftxui/component/toggle.hpp"
#include <chrono>
#include <iostream>
#include <thread>
#include "ftxui/component/container.hpp"
#include "ftxui/component/screen_interactive.hpp"
#include "ftxui/component/toggle.hpp"
#include "ftxui/screen/string.hpp"
using namespace ftxui;
@ -33,6 +34,7 @@ class MyComponent : public Component {
Toggle toggle_3_;
Toggle toggle_4_;
// clang-format off
Element Render() override {
return
vbox(
@ -44,6 +46,7 @@ class MyComponent : public Component {
hbox(text(L" * Number of elements : "), toggle_4_.Render())
);
}
// clang-format on
};
int main(int argc, const char* argv[]) {

View File

@ -2,12 +2,12 @@
#include <iostream>
#include <thread>
#include "ftxui/screen/screen.hpp"
#include "ftxui/dom/elements.hpp"
#include "ftxui/screen/screen.hpp"
int main(int argc, const char *argv[])
{
int main(int argc, const char* argv[]) {
using namespace ftxui;
// clang-format off
auto document =
hbox(
window(text(L" main frame ") | hcenter,
@ -41,6 +41,7 @@ int main(int argc, const char *argv[])
),
filler()
);
// clang-format on
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document.get());
std::cout << screen.ToString() << std::endl;

View File

@ -1,10 +1,11 @@
#include "ftxui/screen/screen.hpp"
#include "ftxui/dom/elements.hpp"
#include <iostream>
int main(int argc, const char *argv[])
{
#include "ftxui/dom/elements.hpp"
#include "ftxui/screen/screen.hpp"
int main(int argc, const char* argv[]) {
using namespace ftxui;
// clang-format off
auto document =
dbox(
vbox(
@ -16,6 +17,7 @@ int main(int argc, const char *argv[])
) | border,
text(L"overlay") | border | center
);
// clang-format on
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document.get());

View File

@ -2,11 +2,10 @@
#include <iostream>
#include <thread>
#include "ftxui/screen/screen.hpp"
#include "ftxui/dom/elements.hpp"
#include "ftxui/screen/screen.hpp"
int main(int argc, const char *argv[])
{
int main(int argc, const char* argv[]) {
using namespace ftxui;
using namespace std::chrono_literals;
@ -14,12 +13,14 @@ int main(int argc, const char *argv[])
for (float percentage = 0; percentage <= 1.0; percentage += 0.002) {
std::wstring data_downloaded =
std::to_wstring(int(percentage * 5000)) + L"/5000";
// clang-format off
auto document =
hbox(
text(L"downloading:"),
gauge(percentage) | flex,
text(L" " + data_downloaded)
);
// clang-format on
auto screen = Screen(100, 1);
Render(screen, document.get());
std::cout << reset_position << screen.ToString() << std::flush;

View File

@ -2,6 +2,7 @@
#include <cmath>
#include <iostream>
#include <thread>
#include "ftxui/dom/elements.hpp"
#include "ftxui/screen/screen.hpp"
#include "ftxui/screen/string.hpp"
@ -40,6 +41,7 @@ int main(int argc, const char* argv[]) {
std::string reset_position;
for (int i = 0;; ++i) {
// clang-format off
auto document =
hbox(
vbox(
@ -55,6 +57,7 @@ int main(int argc, const char* argv[]) {
)
| border
| size(HEIGHT, GREATER_THAN, 40);
// clang-format on
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document.get());

View File

@ -1,47 +1,32 @@
#include "ftxui/screen/screen.hpp"
#include "ftxui/screen/string.hpp"
#include "ftxui/dom/elements.hpp"
#include <iostream>
int main(int argc, const char *argv[])
{
#include "ftxui/dom/elements.hpp"
#include "ftxui/screen/screen.hpp"
#include "ftxui/screen/string.hpp"
int main(int argc, const char* argv[]) {
using namespace ftxui;
auto make_box = [](size_t dimx, size_t dimy) {
std::wstring title = to_wstring(dimx) + L"x" + to_wstring(dimy);
return
window(
text(title) | hcenter | bold,
text(L"content") | hcenter | dim
) | size(WIDTH, EQUAL, dimx)
| size(HEIGHT, EQUAL, dimy)
;
// clang-format off
return window(text(title) | hcenter | bold,
text(L"content") | hcenter | dim) |
size(WIDTH, EQUAL, dimx) | size(HEIGHT, EQUAL, dimy);
// clang-format on
};
// clang-format off
auto document =
hflow(
make_box(7,7),
make_box(7,5),
make_box(5,7),
make_box(10,4),
make_box(10,4),
make_box(10,4),
make_box(10,4),
make_box(11,4),
make_box(11,4),
make_box(11,4),
make_box(11,4),
make_box(12,4),
make_box(12,5),
make_box(12,4),
make_box(13,4),
make_box(13,3),
make_box(13,3),
make_box(10,3)
) | size(WIDTH, GREATER_THAN, 20)
hflow(make_box(7, 7), make_box(7, 5), make_box(5, 7), make_box(10, 4),
make_box(10, 4), make_box(10, 4), make_box(10, 4), make_box(11, 4),
make_box(11, 4), make_box(11, 4), make_box(11, 4), make_box(12, 4),
make_box(12, 5), make_box(12, 4), make_box(13, 4), make_box(13, 3),
make_box(13, 3), make_box(10, 3))
| size(WIDTH, GREATER_THAN, 20)
| border
| size(HEIGHT, GREATER_THAN, 30)
| size(WIDTH, LESS_THAN, 50)
;
| size(WIDTH, LESS_THAN, 50);
// clang-format on
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document.get());

View File

@ -1,6 +1,7 @@
#include <chrono>
#include <iostream>
#include <thread>
#include "ftxui/dom/elements.hpp"
#include "ftxui/screen/screen.hpp"
#include "ftxui/screen/string.hpp"

View File

@ -1,15 +1,14 @@
#include <chrono>
#include <iostream>
#include <list>
#include <thread>
#include <vector>
#include "ftxui/dom/elements.hpp"
#include "ftxui/screen/screen.hpp"
#include "ftxui/screen/string.hpp"
#include <list>
#include <vector>
int main(int argc, const char *argv[])
{
int main(int argc, const char* argv[]) {
using namespace ftxui;
struct Task {
@ -46,6 +45,7 @@ int main(int argc, const char *argv[])
return text(to_wstring(number)) | size(WIDTH, EQUAL, 3);
};
// clang-format off
auto renderTask = [&](const Task& task) {
auto style = (task.downloaded == task.size) ? dim : bold;
return
@ -87,6 +87,7 @@ int main(int argc, const char *argv[])
hbox(renderSummary(), filler())
);
};
// clang-format on
auto updateModel = [&]() {
for (auto& task : displayed_task) {
@ -112,7 +113,6 @@ int main(int argc, const char *argv[])
std::string reset_position;
for (;;) {
// Draw.
auto document = render();
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));

View File

@ -1,13 +1,15 @@
#include "ftxui/screen/screen.hpp"
#include "ftxui/screen/string.hpp"
#include "ftxui/dom/elements.hpp"
#include <iostream>
int main(int argc, const char *argv[])
{
using namespace ftxui;
std::wstring p = LR"(In probability theory and statistics, Bayes' theorem (alternatively Bayes' law or Bayes' rule) describes the probability of an event, based on prior knowledge of conditions that might be related to the event. For example, if cancer is related to age, then, using Bayes' theorem, a person's age can be used to more accurately assess the probability that they have cancer, compared to the assessment of the probability of cancer made without knowledge of the person's age. One of the many applications of Bayes' theorem is Bayesian inference, a particular approach to statistical inference. When applied, the probabilities involved in Bayes' theorem may have different probability interpretations. With the Bayesian probability interpretation the theorem expresses how a subjective degree of belief should rationally change to account for availability of related evidence. Bayesian inference is fundamental to Bayesian statistics.)";
#include "ftxui/dom/elements.hpp"
#include "ftxui/screen/screen.hpp"
#include "ftxui/screen/string.hpp"
int main(int argc, const char* argv[]) {
using namespace ftxui;
std::wstring p =
LR"(In probability theory and statistics, Bayes' theorem (alternatively Bayes' law or Bayes' rule) describes the probability of an event, based on prior knowledge of conditions that might be related to the event. For example, if cancer is related to age, then, using Bayes' theorem, a person's age can be used to more accurately assess the probability that they have cancer, compared to the assessment of the probability of cancer made without knowledge of the person's age. One of the many applications of Bayes' theorem is Bayesian inference, a particular approach to statistical inference. When applied, the probabilities involved in Bayes' theorem may have different probability interpretations. With the Bayesian probability interpretation the theorem expresses how a subjective degree of belief should rationally change to account for availability of related evidence. Bayesian inference is fundamental to Bayesian statistics.)";
// clang-format off
auto document =
vbox(
hbox(
@ -23,6 +25,7 @@ int main(int argc, const char *argv[])
hflow(paragraph(p)) | border
) | flex
);
// clang-format on
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document.get());

View File

@ -1,10 +1,11 @@
#include "ftxui/screen/screen.hpp"
#include "ftxui/dom/elements.hpp"
#include <iostream>
int main(int argc, const char *argv[])
{
#include "ftxui/dom/elements.hpp"
#include "ftxui/screen/screen.hpp"
int main(int argc, const char* argv[]) {
using namespace ftxui;
// clang-format off
auto document =
hbox(
text(L"left-column"),
@ -17,6 +18,7 @@ int main(int argc, const char *argv[])
separator(),
text(L"right-column")
) | border;
// clang-format on
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document.get());

View File

@ -1,11 +1,12 @@
#include "ftxui/screen/screen.hpp"
#include "ftxui/screen/string.hpp"
#include "ftxui/dom/elements.hpp"
#include <iostream>
int main(int argc, const char *argv[])
{
#include "ftxui/dom/elements.hpp"
#include "ftxui/screen/screen.hpp"
#include "ftxui/screen/string.hpp"
int main(int argc, const char* argv[]) {
using namespace ftxui;
// clang-format off
auto make_box = [](const std::wstring title) {
return
window(
@ -21,6 +22,7 @@ int main(int argc, const char *argv[])
| size(WIDTH, EQUAL, x)
);
}
// clang-format on
auto document = hbox(std::move(content));
auto screen = Screen::Create(Dimension::Fit(document));
Render(screen, document.get());

View File

@ -17,6 +17,7 @@ int main(int argc, const char *argv[])
for(int i = 0; i<22; ++i) {
if (i != 0)
entries.push_back(separator());
// clang-format off
entries.push_back(
hbox(
text(to_wstring(i)) | size(WIDTH, EQUAL, 2),
@ -24,6 +25,7 @@ int main(int argc, const char *argv[])
spinner(i, index) | bold
)
);
// clang-format on
}
auto document = hbox(vbox(std::move(entries)) | border, filler());
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));

View File

@ -1,16 +1,18 @@
#include "ftxui/screen/screen.hpp"
#include "ftxui/dom/elements.hpp"
#include <iostream>
int main(int argc, const char *argv[])
{
#include "ftxui/dom/elements.hpp"
#include "ftxui/screen/screen.hpp"
int main(int argc, const char* argv[]) {
using namespace ftxui;
// clang-format off
auto document =
hbox(
text(L"This text is "),
text(L"blink") | blink,
text(L". Do you like it?")
);
// clang-format on
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document.get());

View File

@ -1,16 +1,18 @@
#include "ftxui/screen/screen.hpp"
#include "ftxui/dom/elements.hpp"
#include <iostream>
int main(int argc, const char *argv[])
{
#include "ftxui/dom/elements.hpp"
#include "ftxui/screen/screen.hpp"
int main(int argc, const char* argv[]) {
using namespace ftxui;
// clang-format off
auto document =
hbox(
text(L"This text is "),
text(L"bold") | bold,
text(L". Do you like it?")
);
// clang-format on
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document.get());

View File

@ -1,10 +1,11 @@
#include "ftxui/screen/screen.hpp"
#include "ftxui/dom/elements.hpp"
#include <iostream>
int main(int argc, const char *argv[])
{
#include "ftxui/dom/elements.hpp"
#include "ftxui/screen/screen.hpp"
int main(int argc, const char* argv[]) {
using namespace ftxui;
// clang-format off
auto document =
hbox(
vbox(
@ -47,6 +48,7 @@ int main(int argc, const char *argv[])
),
filler()
);
// clang-format on
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document.get());

View File

@ -5,12 +5,14 @@
int main(int argc, const char *argv[])
{
using namespace ftxui;
// clang-format off
auto document =
hbox(
text(L"This text is "),
text(L"dim") | dim,
text(L". Do you like it?")
);
// clang-format on
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document.get());

View File

@ -5,6 +5,7 @@
int main(int argc, const char *argv[])
{
using namespace ftxui;
// clang-format off
auto document =
hbox(
text(L"normal") , text(L" ") ,
@ -16,6 +17,7 @@ int main(int argc, const char *argv[])
text(L"color") | color(Color::Blue) , text(L" ") ,
text(L"bgcolor") | bgcolor(Color::Blue)
);
// clang-format on
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document.get());

View File

@ -5,12 +5,14 @@
int main(int argc, const char *argv[])
{
using namespace ftxui;
// clang-format off
auto document =
hbox(
text(L"This text is "),
text(L"inverted") | inverted,
text(L". Do you like it?")
);
// clang-format on
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document.get());

View File

@ -5,12 +5,14 @@
int main(int argc, const char *argv[])
{
using namespace ftxui;
// clang-format off
auto document =
hbox(
text(L"This text is "),
text(L"underlined") | underlined,
text(L". Do you like it?")
);
// clang-format on
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document.get());

View File

@ -6,6 +6,7 @@
int main(int argc, const char *argv[])
{
using namespace ftxui;
// clang-format off
auto document =
vbox(
hbox(
@ -28,6 +29,7 @@ int main(int argc, const char *argv[])
text(L"south-east")
)
);
// clang-format on
auto screen = Screen::Create(Dimension::Full());
Render(screen, document.get());

View File

@ -1,4 +1,5 @@
#include "ftxui/component/checkbox.hpp"
#include <functional>
namespace ftxui {

View File

@ -1,11 +1,16 @@
#include "ftxui/component/component.hpp"
#include <assert.h>
#include <algorithm>
namespace ftxui {
void Component::Detach() { if (!parent_) return; auto it = std::find(std::begin(parent_->children_),
void Component::Detach() {
if (!parent_)
return;
auto it = std::find(std::begin(parent_->children_),
std::end(parent_->children_), this);
parent_->children_.erase(it);
}
void Component::Attach(Component* parent) {

View File

@ -1,5 +1,7 @@
#include "ftxui/component/container.hpp"
#include <algorithm>
namespace ftxui {
// static

View File

@ -1,5 +1,7 @@
#include <iostream>
#include "ftxui/component/event.hpp"
#include <iostream>
#include "ftxui/screen/string.hpp"
namespace ftxui {
@ -93,9 +95,12 @@ Event ParseOSC(std::function<char()> getchar, std::string& input) {
Event ParseESC(std::function<char()> getchar, std::string& input) {
input += getchar();
switch (input.back()) {
case 'P': return ParseDCS(getchar, input);
case '[': return ParseCSI(getchar, input);
case ']': return ParseOSC(getchar, input);
case 'P':
return ParseDCS(getchar, input);
case '[':
return ParseCSI(getchar, input);
case ']':
return ParseOSC(getchar, input);
default:
input += getchar();
return Event::Special(input);

View File

@ -1,5 +1,6 @@
#include "ftxui/component/input.hpp"
#include "ftxui/screen/string.hpp"
#include <algorithm>
namespace ftxui {
@ -31,13 +32,14 @@ Element Input::Render() {
auto focused =
is_focused ? focus : select;
// clang-format off
return
hbox(
text(part_before_cursor),
text(part_at_cursor) | underlined | focused,
text(part_after_cursor)
) | flex | inverted | frame | main_decorator;
// clang-format off
}
bool Input::OnEvent(Event event) {
cursor_position = std::max(0, std::min<int>(content.size(), cursor_position));

View File

@ -1,6 +1,7 @@
#include "ftxui/component/menu.hpp"
#include <algorithm>
#include <iostream>
#include <algorithm>
namespace ftxui {

View File

@ -1,5 +1,6 @@
#include "ftxui/component/radiobox.hpp"
#include <functional>
#include <algorithm>
namespace ftxui {

View File

@ -10,6 +10,7 @@
#include "ftxui/component/component.hpp"
#include "ftxui/screen/string.hpp"
#include "ftxui/screen/terminal.hpp"
#include <algorithm>
#if defined(__clang__) && defined (__APPLE__)
// Quick exit is missing in standard CLang headers

View File

@ -1,4 +1,5 @@
#include "ftxui/component/toggle.hpp"
#include <algorithm>
namespace ftxui {

View File

@ -1,5 +1,5 @@
#include "ftxui/dom/node_decorator.hpp"
#include "ftxui/dom/elements.hpp"
#include "ftxui/dom/node_decorator.hpp"
namespace ftxui {

View File

@ -1,5 +1,5 @@
#include "ftxui/dom/node_decorator.hpp"
#include "ftxui/dom/elements.hpp"
#include "ftxui/dom/node_decorator.hpp"
namespace ftxui {

View File

@ -1,5 +1,5 @@
#include "ftxui/dom/node.hpp"
#include "ftxui/dom/elements.hpp"
#include "ftxui/dom/node.hpp"
namespace ftxui {

View File

@ -1,5 +1,5 @@
#include "ftxui/dom/node_decorator.hpp"
#include "ftxui/dom/elements.hpp"
#include "ftxui/dom/node_decorator.hpp"
namespace ftxui {
@ -47,15 +47,11 @@ std::unique_ptr<Node> bgcolor(Color c, Element child) {
}
Decorator color(Color c) {
return [c](Element child) {
return color(c, std::move(child));
};
return [c](Element child) { return color(c, std::move(child)); };
}
Decorator bgcolor(Color c) {
return [c](Element child) {
return bgcolor(c, std::move(child));
};
return [c](Element child) { return bgcolor(c, std::move(child)); };
}
} // namespace ftxui

View File

@ -1,5 +1,5 @@
#include "ftxui/dom/node.hpp"
#include "ftxui/dom/elements.hpp"
#include "ftxui/dom/node.hpp"
namespace ftxui {

View File

@ -1,5 +1,5 @@
#include "ftxui/dom/node.hpp"
#include "ftxui/dom/elements.hpp"
#include "ftxui/dom/node.hpp"
namespace ftxui {
@ -15,8 +15,10 @@ class DBox : public Node {
requirement_.flex.y = 0;
for (auto& child : children) {
child->ComputeRequirement();
requirement_.min.x = std::max(requirement_.min.x, child->requirement().min.x);
requirement_.min.y = std::max(requirement_.min.y, child->requirement().min.y);
requirement_.min.x =
std::max(requirement_.min.x, child->requirement().min.x);
requirement_.min.y =
std::max(requirement_.min.y, child->requirement().min.y);
if (requirement_.selection < child->requirement().selection) {
requirement_.selection = child->requirement().selection;

View File

@ -1,5 +1,5 @@
#include "ftxui/dom/node_decorator.hpp"
#include "ftxui/dom/elements.hpp"
#include "ftxui/dom/node_decorator.hpp"
namespace ftxui {

View File

@ -1,5 +1,5 @@
#include "ftxui/dom/node.hpp"
#include "ftxui/dom/elements.hpp"
#include "ftxui/dom/node.hpp"
namespace ftxui {

View File

@ -1,3 +1,5 @@
#include <algorithm>
#include "ftxui/dom/elements.hpp"
#include "ftxui/dom/node.hpp"
#include "ftxui/util/autoreset.hpp"

View File

@ -1,5 +1,5 @@
#include "ftxui/dom/node.hpp"
#include "ftxui/dom/elements.hpp"
#include "ftxui/dom/node.hpp"
namespace ftxui {
@ -28,6 +28,7 @@ class Gauge : public Node {
while (x <= box_.x_max)
screen.at(x++, y) = charset[0];
}
private:
float progress_;
};

View File

@ -1,5 +1,7 @@
#include "ftxui/dom/node.hpp"
#include <algorithm>
#include "ftxui/dom/elements.hpp"
#include "ftxui/dom/node.hpp"
namespace ftxui {

View File

@ -1,5 +1,5 @@
#include "ftxui/dom/node.hpp"
#include "ftxui/dom/elements.hpp"
#include "ftxui/dom/node.hpp"
namespace ftxui {

View File

@ -1,5 +1,5 @@
#include "ftxui/dom/node_decorator.hpp"
#include "ftxui/dom/elements.hpp"
#include "ftxui/dom/node_decorator.hpp"
namespace ftxui {

View File

@ -1,8 +1,8 @@
#ifndef FTXUI_DOM_NODE_DECORATOR_H_
#define FTXUI_DOM_NODE_DECORATOR_H_
#include "ftxui/dom/node.hpp"
#include "ftxui/dom/elements.hpp"
#include "ftxui/dom/node.hpp"
namespace ftxui {

View File

@ -1,4 +1,5 @@
#include <sstream>
#include "ftxui/dom/elements.hpp"
namespace ftxui {

View File

@ -1,3 +1,5 @@
#include <algorithm>
#include "ftxui/dom/elements.hpp"
#include "ftxui/dom/node.hpp"

View File

@ -1,5 +1,5 @@
#include "ftxui/dom/node.hpp"
#include "ftxui/dom/elements.hpp"
#include "ftxui/dom/node.hpp"
namespace ftxui {
@ -127,26 +127,13 @@ static const std::vector<std::vector<std::vector<std::wstring>>> elements = {
{L""},
},
{
{L"(*----------)"},
{L"(-*---------)"},
{L"(--*--------)"},
{L"(---*-------)"},
{L"(----*------)"},
{L"(-----*-----)"},
{L"(------*----)"},
{L"(-------*---)"},
{L"(--------*--)"},
{L"(---------*-)"},
{L"(----------*)"},
{L"(---------*-)"},
{L"(--------*--)"},
{L"(-------*---)"},
{L"(------*----)"},
{L"(-----*-----)"},
{L"(----*------)"},
{L"(---*-------)"},
{L"(--*--------)"},
{L"(-*---------)"},
{L"(*----------)"}, {L"(-*---------)"}, {L"(--*--------)"},
{L"(---*-------)"}, {L"(----*------)"}, {L"(-----*-----)"},
{L"(------*----)"}, {L"(-------*---)"}, {L"(--------*--)"},
{L"(---------*-)"}, {L"(----------*)"}, {L"(---------*-)"},
{L"(--------*--)"}, {L"(-------*---)"}, {L"(------*----)"},
{L"(-----*-----)"}, {L"(----*------)"}, {L"(---*-------)"},
{L"(--*--------)"}, {L"(-*---------)"},
},
{
{L"[ ]"},
@ -194,8 +181,7 @@ static const std::vector<std::vector<std::vector<std::wstring>>> elements = {
{L"[ == ]"},
{L"[ == ]"},
},
{
{
{{
L" ─╮",
L"",
L" ",
@ -234,10 +220,8 @@ static const std::vector<std::vector<std::vector<std::wstring>>> elements = {
L"╭─╮",
L" ",
L" ",
}
},
{
{
}},
{{
L" /\\O ",
L" /\\/ ",
L" /\\ ",
@ -257,9 +241,7 @@ static const std::vector<std::vector<std::vector<std::wstring>>> elements = {
L" |\\ ",
L" / | ",
L" LOLLOL ",
}
}
};
}}};
std::unique_ptr<Node> spinner(int c, size_t index) {
if (c == 0) {

View File

@ -1,5 +1,5 @@
#include "ftxui/dom/node_decorator.hpp"
#include "ftxui/dom/elements.hpp"
#include "ftxui/dom/node_decorator.hpp"
namespace ftxui {

View File

@ -7,10 +7,7 @@ Element nothing(Element element) {
}
Decorator compose(Decorator a, Decorator b) {
return [
a = std::move(a),
b = std::move(b)
](Element element) {
return [a = std::move(a), b = std::move(b)](Element element) {
return b(a(std::move(element)));
};
}

View File

@ -1,3 +1,5 @@
#include <algorithm>
#include "ftxui/dom/elements.hpp"
#include "ftxui/dom/node.hpp"

View File

@ -1,4 +1,5 @@
#include "ftxui/screen/box.hpp"
#include <algorithm>
namespace ftxui {

View File

@ -1,10 +1,12 @@
#include "ftxui/screen/screen.hpp"
#include <algorithm>
#include <sstream>
#include "ftxui/dom/node.hpp"
#include "ftxui/screen/string.hpp"
#include "ftxui/screen/terminal.hpp"
#include <sstream>
namespace ftxui {
namespace {

View File

@ -1,9 +1,10 @@
#include "ftxui/screen/terminal.hpp"
#include <stdio.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <iostream>
#include "ftxui/screen/terminal.hpp"
#include <iostream>
namespace ftxui {