mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-16 08:04:21 +08:00
Clean source code. Add to_wstring<T> T={int, float, double, ...}
This commit is contained in:
@@ -23,7 +23,7 @@ class Input : public Component {
|
||||
|
||||
// Component implementation.
|
||||
dom::Element Render() override;
|
||||
bool OnEvent(Event) override;
|
||||
bool OnEvent(Event) override;
|
||||
|
||||
private:
|
||||
int cursor_position = 0;
|
||||
|
@@ -27,7 +27,7 @@ class Menu : public Component {
|
||||
|
||||
// Component implementation.
|
||||
dom::Element Render() override;
|
||||
bool OnEvent(Event) override;
|
||||
bool OnEvent(Event) override;
|
||||
};
|
||||
|
||||
} // namespace component
|
||||
|
@@ -52,20 +52,8 @@ Element nothing(Element element);
|
||||
Element operator|(Element, Decorator);
|
||||
Decorator operator|(Decorator, Decorator);
|
||||
|
||||
// Make container able to take several children.
|
||||
template <class... Args>
|
||||
Children unpack(Args... args) {
|
||||
Children vec;
|
||||
(vec.push_back(std::forward<Args>(args)), ...);
|
||||
return vec;
|
||||
}
|
||||
|
||||
#define TAKE_ANY_ARGS(container) \
|
||||
template <class... Args> \
|
||||
Element container(Args... children) { \
|
||||
return container(unpack(std::forward<Args>(children)...)); \
|
||||
} \
|
||||
|
||||
// Make container able to take any number of children as input.
|
||||
#include "take_any_args.hpp"
|
||||
TAKE_ANY_ARGS(vbox)
|
||||
TAKE_ANY_ARGS(hbox)
|
||||
TAKE_ANY_ARGS(dbox)
|
||||
|
@@ -4,23 +4,11 @@
|
||||
namespace ftxui {
|
||||
|
||||
struct Requirement {
|
||||
// Minimal dimensions.
|
||||
struct {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
} min;
|
||||
// The required size to fully draw the element.
|
||||
struct { int x = 0; int y = 0; } min;
|
||||
|
||||
// Maximal dimensions.
|
||||
struct {
|
||||
int x = -1;
|
||||
int y = -1;
|
||||
} max;
|
||||
|
||||
// Flex.
|
||||
struct {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
} flex;
|
||||
// How much flexibility is given to the component.
|
||||
struct { int x = 0; int y = 0; } flex;
|
||||
};
|
||||
|
||||
}; // namespace ftxui
|
||||
|
@@ -2,3 +2,8 @@
|
||||
|
||||
std::string to_string(const std::wstring& s);
|
||||
std::wstring to_wstring(const std::string& s);
|
||||
|
||||
template<typename T>
|
||||
std::wstring to_wstring(T s) {
|
||||
return to_wstring(std::to_string(s));
|
||||
}
|
||||
|
@@ -18,8 +18,8 @@ TEST(GaugeTest, half) {
|
||||
Screen screen(11,1);
|
||||
Render(screen, root.get());
|
||||
|
||||
EXPECT_EQ("█████▏▋ ", screen.ToString());
|
||||
//" ▏▎▍▌▊▉█";
|
||||
EXPECT_EQ("█████▍ ", screen.ToString());
|
||||
//" ▏▎▍▌▊▉█";
|
||||
}
|
||||
|
||||
TEST(GaugeTest, one) {
|
||||
|
@@ -10,7 +10,7 @@ TEST(VBoxTest, ScreenSmaller1) {
|
||||
Screen screen(6, 1);
|
||||
Render(screen, root.get());
|
||||
|
||||
EXPECT_EQ("text_1", screen.ToString());
|
||||
EXPECT_EQ("text_2", screen.ToString());
|
||||
}
|
||||
|
||||
TEST(VBoxTest, ScreenFit) {
|
||||
|
Reference in New Issue
Block a user