Run clang-format.

This commit is contained in:
ArthurSonzogni 2020-03-27 01:42:46 +01:00
parent 1703552235
commit fce29a03b3
21 changed files with 104 additions and 151 deletions

View File

@ -10,7 +10,6 @@
#include "ftxui/component/toggle.hpp"
#include "ftxui/screen/string.hpp"
using namespace ftxui;
int shift = 0;

View File

@ -9,55 +9,50 @@
using namespace ftxui;
class MyComponent : public Component {
public:
MyComponent() {
Add(&container_);
container_.Add(&menu_);
public:
MyComponent() {
Add(&container_);
container_.Add(&menu_);
menu_.entries = {
L"menu_1",
L"menu_2",
L"menu_3",
};
menu_.entries = {
L"menu_1",
L"menu_2",
L"menu_3",
};
container_.Add(&tab_container_);
menu_1_.entries = {
L"Forest",
L"Water",
L"I don't know"
};
tab_container_.Add(&menu_1_);
container_.Add(&tab_container_);
menu_2_.entries = {
L"Hello",
L"Hi",
L"Hay",
};
tab_container_.Add(&menu_2_);
menu_1_.entries = {L"Forest", L"Water", L"I don't know"};
tab_container_.Add(&menu_1_);
menu_3_.entries = {
L"Table",
L"Nothing",
L"Is",
L"Empty",
};
tab_container_.Add(&menu_3_);
}
menu_2_.entries = {
L"Hello",
L"Hi",
L"Hay",
};
tab_container_.Add(&menu_2_);
std::function<void()> on_enter = [](){};
private:
Menu menu_;
Container container_ = Container::Horizontal();
Container tab_container_ = Container::Tab(&(menu_.selected));
Menu menu_1_;
Menu menu_2_;
Menu menu_3_;
menu_3_.entries = {
L"Table",
L"Nothing",
L"Is",
L"Empty",
};
tab_container_.Add(&menu_3_);
}
std::function<void()> on_enter = []() {};
private:
Menu menu_;
Container container_ = Container::Horizontal();
Container tab_container_ = Container::Tab(&(menu_.selected));
Menu menu_1_;
Menu menu_2_;
Menu menu_3_;
};
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

@ -5,7 +5,6 @@
#include "ftxui/dom/elements.hpp"
#include "ftxui/screen/screen.hpp"
int main(int argc, const char* argv[]) {
using namespace ftxui;
using namespace std::chrono_literals;

View File

@ -7,7 +7,6 @@
#include "ftxui/screen/screen.hpp"
#include "ftxui/screen/string.hpp"
class Graph {
public:
std::vector<int> operator()(int width, int height) {

View File

@ -2,21 +2,20 @@
#include <iostream>
#include <thread>
#include "ftxui/screen/screen.hpp"
#include "ftxui/dom/elements.hpp"
#include "ftxui/screen/screen.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 std::chrono_literals;
std::string reset_position;
for(int index = 0; index < 200; ++index) {
for (int index = 0; index < 200; ++index) {
std::vector<Element> entries;
for(int i = 0; i<22; ++i) {
for (int i = 0; i < 22; ++i) {
if (i != 0)
entries.push_back(separator());
entries.push_back(separator());
// clang-format off
entries.push_back(
hbox(

View File

@ -1,9 +1,9 @@
#include "ftxui/dom/elements.hpp"
#include "ftxui/screen/screen.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 =

View File

@ -1,9 +1,9 @@
#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 =

View File

@ -1,9 +1,9 @@
#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 =

View File

@ -1,9 +1,9 @@
#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 =

View File

@ -1,10 +1,9 @@
#include "ftxui/screen/screen.hpp"
#include "ftxui/dom/elements.hpp"
#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;
// clang-format off
auto document =

View File

@ -16,14 +16,14 @@ class DrawKey : public Component {
Elements children;
for (size_t i = std::max(0, (int)keys.size() - 10); i < keys.size(); ++i) {
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"(" + code + L" ) -> ";
if (keys[i].is_character())
code += keys[i].character();
code += keys[i].character();
else
code += L"(special)";
code += L"(special)";
children.push_back(text(code));
}
return vbox(std::move(children));

View File

@ -1,11 +1,10 @@
#ifndef FTXUI_COMPONENT_RECEIVER_HPP_
#define FTXUI_COMPONENT_RECEIVER_HPP_
#include <iostream>
#include <atomic>
#include <condition_variable>
#include <functional>
#include <iostream>
#include <memory>
#include <mutex>
#include <queue>
@ -50,7 +49,7 @@ template <class T>
class SenderImpl {
public:
void Send(T t) { receiver_->Receive(std::move(t)); }
~SenderImpl() { receiver_->ReleaseSender();}
~SenderImpl() { receiver_->ReleaseSender(); }
private:
friend class ReceiverImpl<T>;

View File

@ -75,5 +75,4 @@ TEST(RadioboxTest, Navigation) {
radiobox.OnEvent(Event::TabReverse);
EXPECT_EQ(radiobox.focused, 1);
radiobox.OnEvent(Event::TabReverse);
}

View File

@ -58,10 +58,14 @@ TEST(Receiver, BasicWithThread) {
s1_bis.reset();
char c;
EXPECT_TRUE(r3->Receive(&c));EXPECT_EQ(c, '1');
EXPECT_TRUE(r3->Receive(&c)); EXPECT_EQ(c, '2');
EXPECT_TRUE(r3->Receive(&c)); EXPECT_EQ(c, '3');
EXPECT_TRUE(r3->Receive(&c)); EXPECT_EQ(c, '4');
EXPECT_TRUE(r3->Receive(&c));
EXPECT_EQ(c, '1');
EXPECT_TRUE(r3->Receive(&c));
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));
// Thread will end at the end of the stream.

View File

@ -70,5 +70,4 @@ TEST(ToggleTest, Tab) {
toggle.OnEvent(Event::TabReverse);
EXPECT_EQ(toggle.selected, 1);
toggle.OnEvent(Event::TabReverse);
}

View File

@ -6,114 +6,79 @@ using namespace ftxui;
using namespace ftxui;
TEST(HBoxTest, ScreenSmaller1) {
auto root = hbox(
text(L"text_1"),
text(L"text_2")
);
Screen screen(11,1);
auto root = hbox(text(L"text_1"), text(L"text_2"));
Screen screen(11, 1);
Render(screen, root.get());
EXPECT_EQ("text_1text_", screen.ToString());
}
TEST(HBoxTest, ScreenSmaller2) {
auto root = hbox(
text(L"text_1"),
text(L"text_2")
);
Screen screen(10,1);
auto root = hbox(text(L"text_1"), text(L"text_2"));
Screen screen(10, 1);
Render(screen, root.get());
EXPECT_EQ("text_1text", screen.ToString());
}
TEST(HBoxTest, ScreenFit) {
auto root = hbox(
text(L"text_1"),
text(L"text_2")
);
Screen screen(12,1);
auto root = hbox(text(L"text_1"), text(L"text_2"));
Screen screen(12, 1);
Render(screen, root.get());
EXPECT_EQ("text_1text_2", screen.ToString());
}
TEST(HBoxTest, ScreenBigger1) {
auto root = hbox(
text(L"text_1"),
text(L"text_2")
);
Screen screen(13,1);
auto root = hbox(text(L"text_1"), text(L"text_2"));
Screen screen(13, 1);
Render(screen, root.get());
EXPECT_EQ("text_1text_2 ", screen.ToString());
}
TEST(HBoxTest, ScreenBigger2) {
auto root = hbox(
text(L"text_1"),
text(L"text_2")
);
Screen screen(14,1);
auto root = hbox(text(L"text_1"), text(L"text_2"));
Screen screen(14, 1);
Render(screen, root.get());
EXPECT_EQ("text_1text_2 ", screen.ToString());
}
TEST(HBoxTest, ScreenSmaller1Flex) {
auto root = hbox(
text(L"text_1"),
filler(),
text(L"text_2")
);
Screen screen(11,1);
auto root = hbox(text(L"text_1"), filler(), text(L"text_2"));
Screen screen(11, 1);
Render(screen, root.get());
EXPECT_EQ("text_1text_", screen.ToString());
}
TEST(HBoxTest, ScreenSmaller2Flex) {
auto root = hbox(
text(L"text_1"),
filler(),
text(L"text_2")
);
Screen screen(10,1);
auto root = hbox(text(L"text_1"), filler(), text(L"text_2"));
Screen screen(10, 1);
Render(screen, root.get());
EXPECT_EQ("text_1text", screen.ToString());
}
TEST(HBoxTest, ScreenFitFlex) {
auto root = hbox(
text(L"text_1"),
filler(),
text(L"text_2")
);
Screen screen(12,1);
auto root = hbox(text(L"text_1"), filler(), text(L"text_2"));
Screen screen(12, 1);
Render(screen, root.get());
EXPECT_EQ("text_1text_2", screen.ToString());
}
TEST(HBoxTest, ScreenBigger1Flex) {
auto root = hbox(
text(L"text_1"),
filler(),
text(L"text_2")
);
Screen screen(13,1);
auto root = hbox(text(L"text_1"), filler(), text(L"text_2"));
Screen screen(13, 1);
Render(screen, root.get());
EXPECT_EQ("text_1 text_2", screen.ToString());
}
TEST(HBoxTest, ScreenBigger2Flex) {
auto root = hbox(
text(L"text_1"),
filler(),
text(L"text_2")
);
Screen screen(14,1);
auto root = hbox(text(L"text_1"), filler(), text(L"text_2"));
Screen screen(14, 1);
Render(screen, root.get());
EXPECT_EQ("text_1 text_2", screen.ToString());

View File

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

View File

@ -50,12 +50,12 @@ TEST(VBoxTest, ScreenFitFlex) {
Render(screen, root.get());
EXPECT_EQ(
"text_1 \n"
" \n"
" \n"
" \n"
"text_2 "
,screen.ToString());
"text_1 \n"
" \n"
" \n"
" \n"
"text_2 ",
screen.ToString());
}
TEST(VBoxTest, ScreenBigger1Flex) {

View File

@ -7,7 +7,6 @@
#include "ftxui/screen/string.hpp"
#include "ftxui/screen/terminal.hpp"
#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX

View File

@ -3,10 +3,9 @@
#include <codecvt>
#include <locale>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4996) // codecvt_utf8_utf16 is deprecated
#pragma warning(push)
#pragma warning(disable : 4996) // codecvt_utf8_utf16 is deprecated
#endif
std::string to_string(const std::wstring& s) {
@ -20,5 +19,5 @@ std::wstring to_wstring(const std::string& s) {
}
#ifdef _MSC_VER
#pragma warning(pop)
#pragma warning(pop)
#endif

View File

@ -2,7 +2,6 @@
#include <stdio.h>
#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX