mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-12-16 01:48:56 +08:00
First version of supporting extraction of the terminal id.
This commit is contained in:
@@ -46,6 +46,7 @@ example(slider_direction)
|
||||
example(slider_rgb)
|
||||
example(tab_horizontal)
|
||||
example(tab_vertical)
|
||||
example(terminal_id)
|
||||
example(textarea)
|
||||
example(toggle)
|
||||
example(window)
|
||||
|
||||
33
examples/component/terminal_id.cpp
Normal file
33
examples/component/terminal_id.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright 2025 Arthur Sonzogni. All rights reserved.
|
||||
// Use of this source code is governed by the MIT license that can be found in
|
||||
// the LICENSE file.
|
||||
|
||||
#include "ftxui/component/component.hpp" // for Renderer
|
||||
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
||||
#include "ftxui/dom/elements.hpp" // for text, hbox, separator, Element, operator|, vbox, border
|
||||
|
||||
int main() {
|
||||
using namespace ftxui;
|
||||
|
||||
std::string terminal_id = "UNKNOWN";
|
||||
|
||||
auto screen =
|
||||
ScreenInteractive::TerminalOutput();
|
||||
|
||||
screen.OnTerminalIDUpdate([&terminal_id] (
|
||||
TerminalID const& terminal_id_update)
|
||||
{
|
||||
std::stringstream stream;
|
||||
stream << terminal_id_update;
|
||||
terminal_id = stream.str();
|
||||
});
|
||||
|
||||
auto renderer = Renderer([&]
|
||||
{
|
||||
return vbox({
|
||||
text("Terminal id " + terminal_id),
|
||||
}) | border;
|
||||
});
|
||||
|
||||
screen.Loop(renderer);
|
||||
}
|
||||
Reference in New Issue
Block a user