mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-29 22:55:51 +08:00
Run clang-format.
This commit is contained in:
parent
1703552235
commit
fce29a03b3
@ -10,7 +10,6 @@
|
|||||||
#include "ftxui/component/toggle.hpp"
|
#include "ftxui/component/toggle.hpp"
|
||||||
#include "ftxui/screen/string.hpp"
|
#include "ftxui/screen/string.hpp"
|
||||||
|
|
||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int shift = 0;
|
int shift = 0;
|
||||||
|
@ -22,11 +22,7 @@ class MyComponent : public Component {
|
|||||||
|
|
||||||
container_.Add(&tab_container_);
|
container_.Add(&tab_container_);
|
||||||
|
|
||||||
menu_1_.entries = {
|
menu_1_.entries = {L"Forest", L"Water", L"I don't know"};
|
||||||
L"Forest",
|
|
||||||
L"Water",
|
|
||||||
L"I don't know"
|
|
||||||
};
|
|
||||||
tab_container_.Add(&menu_1_);
|
tab_container_.Add(&menu_1_);
|
||||||
|
|
||||||
menu_2_.entries = {
|
menu_2_.entries = {
|
||||||
@ -45,7 +41,8 @@ class MyComponent : public Component {
|
|||||||
tab_container_.Add(&menu_3_);
|
tab_container_.Add(&menu_3_);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::function<void()> on_enter = [](){};
|
std::function<void()> on_enter = []() {};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Menu menu_;
|
Menu menu_;
|
||||||
Container container_ = Container::Horizontal();
|
Container container_ = Container::Horizontal();
|
||||||
@ -55,9 +52,7 @@ class MyComponent : public Component {
|
|||||||
Menu menu_3_;
|
Menu menu_3_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int main(int argc, const char* argv[]) {
|
||||||
int main(int argc, const char *argv[])
|
|
||||||
{
|
|
||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
MyComponent component;
|
MyComponent component;
|
||||||
component.on_enter = screen.ExitLoopClosure();
|
component.on_enter = screen.ExitLoopClosure();
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include "ftxui/dom/elements.hpp"
|
#include "ftxui/dom/elements.hpp"
|
||||||
#include "ftxui/screen/screen.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 ftxui;
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#include "ftxui/screen/screen.hpp"
|
#include "ftxui/screen/screen.hpp"
|
||||||
#include "ftxui/screen/string.hpp"
|
#include "ftxui/screen/string.hpp"
|
||||||
|
|
||||||
|
|
||||||
class Graph {
|
class Graph {
|
||||||
public:
|
public:
|
||||||
std::vector<int> operator()(int width, int height) {
|
std::vector<int> operator()(int width, int height) {
|
||||||
|
@ -2,19 +2,18 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include "ftxui/screen/screen.hpp"
|
|
||||||
#include "ftxui/dom/elements.hpp"
|
#include "ftxui/dom/elements.hpp"
|
||||||
|
#include "ftxui/screen/screen.hpp"
|
||||||
#include "ftxui/screen/string.hpp"
|
#include "ftxui/screen/string.hpp"
|
||||||
|
|
||||||
int main(int argc, const char *argv[])
|
int main(int argc, const char* argv[]) {
|
||||||
{
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
std::string reset_position;
|
std::string reset_position;
|
||||||
for(int index = 0; index < 200; ++index) {
|
for (int index = 0; index < 200; ++index) {
|
||||||
std::vector<Element> entries;
|
std::vector<Element> entries;
|
||||||
for(int i = 0; i<22; ++i) {
|
for (int i = 0; i < 22; ++i) {
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
entries.push_back(separator());
|
entries.push_back(separator());
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#include "ftxui/dom/elements.hpp"
|
|
||||||
#include "ftxui/screen/screen.hpp"
|
|
||||||
#include <iostream>
|
#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;
|
using namespace ftxui;
|
||||||
// clang-format off
|
// clang-format off
|
||||||
auto document =
|
auto document =
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#include "ftxui/screen/screen.hpp"
|
|
||||||
#include "ftxui/dom/elements.hpp"
|
|
||||||
#include <iostream>
|
#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;
|
using namespace ftxui;
|
||||||
// clang-format off
|
// clang-format off
|
||||||
auto document =
|
auto document =
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#include "ftxui/screen/screen.hpp"
|
|
||||||
#include "ftxui/dom/elements.hpp"
|
|
||||||
#include <iostream>
|
#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;
|
using namespace ftxui;
|
||||||
// clang-format off
|
// clang-format off
|
||||||
auto document =
|
auto document =
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#include "ftxui/screen/screen.hpp"
|
|
||||||
#include "ftxui/dom/elements.hpp"
|
|
||||||
#include <iostream>
|
#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;
|
using namespace ftxui;
|
||||||
// clang-format off
|
// clang-format off
|
||||||
auto document =
|
auto document =
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#include "ftxui/screen/screen.hpp"
|
|
||||||
#include "ftxui/dom/elements.hpp"
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#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 ftxui;
|
||||||
// clang-format off
|
// clang-format off
|
||||||
auto document =
|
auto document =
|
||||||
|
@ -16,7 +16,7 @@ class DrawKey : public Component {
|
|||||||
Elements children;
|
Elements children;
|
||||||
for (size_t i = std::max(0, (int)keys.size() - 10); i < keys.size(); ++i) {
|
for (size_t i = std::max(0, (int)keys.size() - 10); i < keys.size(); ++i) {
|
||||||
std::wstring code;
|
std::wstring code;
|
||||||
for(auto& it : keys[i].input())
|
for (auto& it : keys[i].input())
|
||||||
code += L" " + std::to_wstring((unsigned int)it);
|
code += L" " + std::to_wstring((unsigned int)it);
|
||||||
|
|
||||||
code = L"(" + code + L" ) -> ";
|
code = L"(" + code + L" ) -> ";
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
#ifndef FTXUI_COMPONENT_RECEIVER_HPP_
|
#ifndef FTXUI_COMPONENT_RECEIVER_HPP_
|
||||||
#define FTXUI_COMPONENT_RECEIVER_HPP_
|
#define FTXUI_COMPONENT_RECEIVER_HPP_
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
@ -50,7 +49,7 @@ template <class T>
|
|||||||
class SenderImpl {
|
class SenderImpl {
|
||||||
public:
|
public:
|
||||||
void Send(T t) { receiver_->Receive(std::move(t)); }
|
void Send(T t) { receiver_->Receive(std::move(t)); }
|
||||||
~SenderImpl() { receiver_->ReleaseSender();}
|
~SenderImpl() { receiver_->ReleaseSender(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class ReceiverImpl<T>;
|
friend class ReceiverImpl<T>;
|
||||||
|
@ -75,5 +75,4 @@ TEST(RadioboxTest, Navigation) {
|
|||||||
radiobox.OnEvent(Event::TabReverse);
|
radiobox.OnEvent(Event::TabReverse);
|
||||||
EXPECT_EQ(radiobox.focused, 1);
|
EXPECT_EQ(radiobox.focused, 1);
|
||||||
radiobox.OnEvent(Event::TabReverse);
|
radiobox.OnEvent(Event::TabReverse);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -58,10 +58,14 @@ TEST(Receiver, BasicWithThread) {
|
|||||||
s1_bis.reset();
|
s1_bis.reset();
|
||||||
|
|
||||||
char c;
|
char c;
|
||||||
EXPECT_TRUE(r3->Receive(&c));EXPECT_EQ(c, '1');
|
EXPECT_TRUE(r3->Receive(&c));
|
||||||
EXPECT_TRUE(r3->Receive(&c)); EXPECT_EQ(c, '2');
|
EXPECT_EQ(c, '1');
|
||||||
EXPECT_TRUE(r3->Receive(&c)); EXPECT_EQ(c, '3');
|
EXPECT_TRUE(r3->Receive(&c));
|
||||||
EXPECT_TRUE(r3->Receive(&c)); EXPECT_EQ(c, '4');
|
EXPECT_EQ(c, '2');
|
||||||
|
EXPECT_TRUE(r3->Receive(&c));
|
||||||
|
EXPECT_EQ(c, '3');
|
||||||
|
EXPECT_TRUE(r3->Receive(&c));
|
||||||
|
EXPECT_EQ(c, '4');
|
||||||
EXPECT_FALSE(r3->Receive(&c));
|
EXPECT_FALSE(r3->Receive(&c));
|
||||||
|
|
||||||
// Thread will end at the end of the stream.
|
// Thread will end at the end of the stream.
|
||||||
|
@ -70,5 +70,4 @@ TEST(ToggleTest, Tab) {
|
|||||||
toggle.OnEvent(Event::TabReverse);
|
toggle.OnEvent(Event::TabReverse);
|
||||||
EXPECT_EQ(toggle.selected, 1);
|
EXPECT_EQ(toggle.selected, 1);
|
||||||
toggle.OnEvent(Event::TabReverse);
|
toggle.OnEvent(Event::TabReverse);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,114 +6,79 @@ using namespace ftxui;
|
|||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
TEST(HBoxTest, ScreenSmaller1) {
|
TEST(HBoxTest, ScreenSmaller1) {
|
||||||
auto root = hbox(
|
auto root = hbox(text(L"text_1"), text(L"text_2"));
|
||||||
text(L"text_1"),
|
Screen screen(11, 1);
|
||||||
text(L"text_2")
|
|
||||||
);
|
|
||||||
Screen screen(11,1);
|
|
||||||
Render(screen, root.get());
|
Render(screen, root.get());
|
||||||
|
|
||||||
EXPECT_EQ("text_1text_", screen.ToString());
|
EXPECT_EQ("text_1text_", screen.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(HBoxTest, ScreenSmaller2) {
|
TEST(HBoxTest, ScreenSmaller2) {
|
||||||
auto root = hbox(
|
auto root = hbox(text(L"text_1"), text(L"text_2"));
|
||||||
text(L"text_1"),
|
Screen screen(10, 1);
|
||||||
text(L"text_2")
|
|
||||||
);
|
|
||||||
Screen screen(10,1);
|
|
||||||
Render(screen, root.get());
|
Render(screen, root.get());
|
||||||
|
|
||||||
EXPECT_EQ("text_1text", screen.ToString());
|
EXPECT_EQ("text_1text", screen.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(HBoxTest, ScreenFit) {
|
TEST(HBoxTest, ScreenFit) {
|
||||||
auto root = hbox(
|
auto root = hbox(text(L"text_1"), text(L"text_2"));
|
||||||
text(L"text_1"),
|
Screen screen(12, 1);
|
||||||
text(L"text_2")
|
|
||||||
);
|
|
||||||
Screen screen(12,1);
|
|
||||||
Render(screen, root.get());
|
Render(screen, root.get());
|
||||||
|
|
||||||
EXPECT_EQ("text_1text_2", screen.ToString());
|
EXPECT_EQ("text_1text_2", screen.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(HBoxTest, ScreenBigger1) {
|
TEST(HBoxTest, ScreenBigger1) {
|
||||||
auto root = hbox(
|
auto root = hbox(text(L"text_1"), text(L"text_2"));
|
||||||
text(L"text_1"),
|
Screen screen(13, 1);
|
||||||
text(L"text_2")
|
|
||||||
);
|
|
||||||
Screen screen(13,1);
|
|
||||||
Render(screen, root.get());
|
Render(screen, root.get());
|
||||||
|
|
||||||
EXPECT_EQ("text_1text_2 ", screen.ToString());
|
EXPECT_EQ("text_1text_2 ", screen.ToString());
|
||||||
}
|
}
|
||||||
TEST(HBoxTest, ScreenBigger2) {
|
TEST(HBoxTest, ScreenBigger2) {
|
||||||
auto root = hbox(
|
auto root = hbox(text(L"text_1"), text(L"text_2"));
|
||||||
text(L"text_1"),
|
Screen screen(14, 1);
|
||||||
text(L"text_2")
|
|
||||||
);
|
|
||||||
Screen screen(14,1);
|
|
||||||
Render(screen, root.get());
|
Render(screen, root.get());
|
||||||
|
|
||||||
EXPECT_EQ("text_1text_2 ", screen.ToString());
|
EXPECT_EQ("text_1text_2 ", screen.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(HBoxTest, ScreenSmaller1Flex) {
|
TEST(HBoxTest, ScreenSmaller1Flex) {
|
||||||
auto root = hbox(
|
auto root = hbox(text(L"text_1"), filler(), text(L"text_2"));
|
||||||
text(L"text_1"),
|
Screen screen(11, 1);
|
||||||
filler(),
|
|
||||||
text(L"text_2")
|
|
||||||
);
|
|
||||||
Screen screen(11,1);
|
|
||||||
Render(screen, root.get());
|
Render(screen, root.get());
|
||||||
|
|
||||||
EXPECT_EQ("text_1text_", screen.ToString());
|
EXPECT_EQ("text_1text_", screen.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(HBoxTest, ScreenSmaller2Flex) {
|
TEST(HBoxTest, ScreenSmaller2Flex) {
|
||||||
auto root = hbox(
|
auto root = hbox(text(L"text_1"), filler(), text(L"text_2"));
|
||||||
text(L"text_1"),
|
Screen screen(10, 1);
|
||||||
filler(),
|
|
||||||
text(L"text_2")
|
|
||||||
);
|
|
||||||
Screen screen(10,1);
|
|
||||||
Render(screen, root.get());
|
Render(screen, root.get());
|
||||||
|
|
||||||
EXPECT_EQ("text_1text", screen.ToString());
|
EXPECT_EQ("text_1text", screen.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(HBoxTest, ScreenFitFlex) {
|
TEST(HBoxTest, ScreenFitFlex) {
|
||||||
auto root = hbox(
|
auto root = hbox(text(L"text_1"), filler(), text(L"text_2"));
|
||||||
text(L"text_1"),
|
Screen screen(12, 1);
|
||||||
filler(),
|
|
||||||
text(L"text_2")
|
|
||||||
);
|
|
||||||
Screen screen(12,1);
|
|
||||||
Render(screen, root.get());
|
Render(screen, root.get());
|
||||||
|
|
||||||
EXPECT_EQ("text_1text_2", screen.ToString());
|
EXPECT_EQ("text_1text_2", screen.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(HBoxTest, ScreenBigger1Flex) {
|
TEST(HBoxTest, ScreenBigger1Flex) {
|
||||||
auto root = hbox(
|
auto root = hbox(text(L"text_1"), filler(), text(L"text_2"));
|
||||||
text(L"text_1"),
|
Screen screen(13, 1);
|
||||||
filler(),
|
|
||||||
text(L"text_2")
|
|
||||||
);
|
|
||||||
Screen screen(13,1);
|
|
||||||
Render(screen, root.get());
|
Render(screen, root.get());
|
||||||
|
|
||||||
EXPECT_EQ("text_1 text_2", screen.ToString());
|
EXPECT_EQ("text_1 text_2", screen.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(HBoxTest, ScreenBigger2Flex) {
|
TEST(HBoxTest, ScreenBigger2Flex) {
|
||||||
auto root = hbox(
|
auto root = hbox(text(L"text_1"), filler(), text(L"text_2"));
|
||||||
text(L"text_1"),
|
Screen screen(14, 1);
|
||||||
filler(),
|
|
||||||
text(L"text_2")
|
|
||||||
);
|
|
||||||
Screen screen(14,1);
|
|
||||||
Render(screen, root.get());
|
Render(screen, root.get());
|
||||||
|
|
||||||
EXPECT_EQ("text_1 text_2", screen.ToString());
|
EXPECT_EQ("text_1 text_2", screen.ToString());
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include <iostream>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "ftxui/dom/elements.hpp"
|
#include "ftxui/dom/elements.hpp"
|
||||||
#include "ftxui/dom/node.hpp"
|
#include "ftxui/dom/node.hpp"
|
||||||
|
@ -54,8 +54,8 @@ TEST(VBoxTest, ScreenFitFlex) {
|
|||||||
" \n"
|
" \n"
|
||||||
" \n"
|
" \n"
|
||||||
" \n"
|
" \n"
|
||||||
"text_2 "
|
"text_2 ",
|
||||||
,screen.ToString());
|
screen.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(VBoxTest, ScreenBigger1Flex) {
|
TEST(VBoxTest, ScreenBigger1Flex) {
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#include "ftxui/screen/string.hpp"
|
#include "ftxui/screen/string.hpp"
|
||||||
#include "ftxui/screen/terminal.hpp"
|
#include "ftxui/screen/terminal.hpp"
|
||||||
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
|
@ -3,10 +3,9 @@
|
|||||||
#include <codecvt>
|
#include <codecvt>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable : 4996) // codecvt_utf8_utf16 is deprecated
|
#pragma warning(disable : 4996) // codecvt_utf8_utf16 is deprecated
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string to_string(const std::wstring& s) {
|
std::string to_string(const std::wstring& s) {
|
||||||
@ -20,5 +19,5 @@ std::wstring to_wstring(const std::string& s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
|
Loading…
Reference in New Issue
Block a user