diff --git a/examples/index.html b/examples/index.html index fde820a..461adf2 100644 --- a/examples/index.html +++ b/examples/index.html @@ -10,7 +10,7 @@
- FTXUI is a single + FTXUI is a simple C++ library for terminal user interface.
@@ -69,10 +69,8 @@
];
const url_search_params = new URLSearchParams(window.location.search);
- const example_index = url_search_params.get("id") || 16;
- const example = example_list[example_index];
-
- var select = document.getElementById("selectExample");
+ const example = url_search_params.get("file") || "./dom/color_gallery.js"
+ const select = document.getElementById("selectExample");
for(var i = 0; i < example_list.length; i++) {
var opt = example_list[i];
@@ -81,9 +79,10 @@
el.value = opt;
select.appendChild(el);
}
- select.selectedIndex = example_index;
+ select.selectedIndex = example_list.findIndex(path => path == example) || 0;
select.addEventListener("change", () => {
- location.href = (location.href).split('?')[0] + "?id=" + select.selectedIndex;
+ location.href = (location.href).split('?')[0] + "?file=" +
+ example_list[select.selectedIndex];
});
let stdin_buffer = [];
@@ -94,6 +93,7 @@
stdout_buffer = [];
let stdout = code => {
if (code == 0) {
+ console.log(code);
term.write(new Uint8Array(stdout_buffer));
stdout_buffer = [];
} else {
diff --git a/include/ftxui/component/input.hpp b/include/ftxui/component/input.hpp
index 9b92b83..a55bd30 100644
--- a/include/ftxui/component/input.hpp
+++ b/include/ftxui/component/input.hpp
@@ -27,6 +27,11 @@ class Input : public Component {
// Component implementation.
Element Render() override;
bool OnEvent(Event) override;
+
+ private:
+ bool OnMouseEvent(Event);
+ Box input_box_;
+ Box cursor_box_;
};
} // namespace ftxui
diff --git a/src/ftxui/component/input.cpp b/src/ftxui/component/input.cpp
index 7a76055..9ca7bcd 100644
--- a/src/ftxui/component/input.cpp
+++ b/src/ftxui/component/input.cpp
@@ -15,14 +15,15 @@ Element Input::Render() {
// Placeholder.
if (content.size() == 0) {
if (is_focused)
- return text(placeholder) | focus | dim | inverted | main_decorator;
+ return text(placeholder) | focus | dim | inverted | main_decorator |
+ reflect(input_box_);
else
- return text(placeholder) | dim | main_decorator;
+ return text(placeholder) | dim | main_decorator | reflect(input_box_);
}
// Not focused.
if (!is_focused)
- return text(content) | main_decorator;
+ return text(content) | main_decorator | reflect(input_box_);
std::wstring part_before_cursor = content.substr(0, cursor_position);
std::wstring part_at_cursor = cursor_position < (int)content.size()
@@ -37,13 +38,18 @@ Element Input::Render() {
return
hbox(
text(part_before_cursor),
- text(part_at_cursor) | underlined | focused,
+ text(part_at_cursor) | underlined | focused | reflect(cursor_box_),
text(part_after_cursor)
- ) | flex | inverted | frame | main_decorator;
- // clang-format off
+ ) | flex | inverted | frame | main_decorator | reflect(input_box_);
+ // clang-format on
}
+
bool Input::OnEvent(Event event) {
cursor_position = std::max(0, std::min