Compare commits

...

370 Commits
v0.10 ... main

Author SHA1 Message Date
Jacob Shing
4604adb502
Adds example project using FTXUI (#1044)
Some checks failed
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (cl, windows-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, macos-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, ubuntu-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, macos-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, ubuntu-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (cl, Windows MSVC, windows-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, Linux GCC, ubuntu-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, Linux Clang, ubuntu-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, MacOS clang, macos-latest) (push) Has been cancelled
Documentation / documentation (push) Has been cancelled
2025-05-05 17:44:13 +02:00
ArthurSonzogni
add5f40d31
Restore dbox behavior from ftxui5.0.0
Some checks failed
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (cl, windows-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, macos-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, ubuntu-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, macos-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, ubuntu-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (cl, Windows MSVC, windows-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, Linux GCC, ubuntu-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, Linux Clang, ubuntu-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, MacOS clang, macos-latest) (push) Has been cancelled
Documentation / documentation (push) Has been cancelled
Bug:https://github.com/eclipse-ecal/ecal/pull/2095
2025-05-02 16:48:00 +02:00
ArthurSonzogni
805db9bdea
Set Bazel compatibility level
Some checks failed
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (cl, windows-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, macos-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, ubuntu-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, macos-latest) (push) Has been cancelled
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, ubuntu-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (cl, Windows MSVC, windows-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, Linux GCC, ubuntu-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, Linux Clang, ubuntu-latest) (push) Has been cancelled
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, MacOS clang, macos-latest) (push) Has been cancelled
Documentation / documentation (push) Has been cancelled
2025-05-01 11:53:18 +02:00
ArthurSonzogni
784f53fd7e
Remove attestion for Bazel 2025-05-01 11:30:12 +02:00
ArthurSonzogni
799d8a267e
Fix release workflow 2025-05-01 10:52:54 +02:00
ArthurSonzogni
f4513702b0
Fix release workflow 2025-05-01 10:40:53 +02:00
ArthurSonzogni
ba6716c6e1
Fix publish workflow 2025-05-01 10:33:19 +02:00
ArthurSonzogni
694fa6bf5c
Fix publish workflow 2025-05-01 10:09:18 +02:00
Arthur Sonzogni
625915b52c
Fix publish workflow (#1041) 2025-05-01 10:06:49 +02:00
Arthur Sonzogni
2d4c114008
v6.1.2 (#1040) 2025-05-01 10:01:05 +02:00
Arthur Sonzogni
aa80d8bac9
Generate attestation + refactor workflows (#1039) 2025-05-01 09:59:08 +02:00
Arthur Sonzogni
bcdcf70348
Fix Bazel Central Repository Workflow (#1038)
Some checks are pending
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (cl, windows-latest) (push) Waiting to run
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, macos-latest) (push) Waiting to run
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, ubuntu-latest) (push) Waiting to run
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, macos-latest) (push) Waiting to run
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, ubuntu-latest) (push) Waiting to run
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (cl, Windows MSVC, windows-latest) (push) Waiting to run
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, Linux GCC, ubuntu-latest) (push) Waiting to run
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, Linux Clang, ubuntu-latest) (push) Waiting to run
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, MacOS clang, macos-latest) (push) Waiting to run
Build / Create release (push) Blocked by required conditions
Build / Build packages (build/ftxui*Darwin*, macos-latest) (push) Blocked by required conditions
Build / Build packages (build/ftxui*Linux*, ubuntu-latest) (push) Blocked by required conditions
Build / Build packages (build/ftxui*Win64*, windows-latest) (push) Blocked by required conditions
Build / Build source package (push) Blocked by required conditions
Build / documentation (push) Waiting to run
2025-04-30 12:04:32 +02:00
Arthur Sonzogni
4231c4903b
Release version 6.1.0. (#1037)
Some checks are pending
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (cl, windows-latest) (push) Waiting to run
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, macos-latest) (push) Waiting to run
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, ubuntu-latest) (push) Waiting to run
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, macos-latest) (push) Waiting to run
Build / Bazel, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, ubuntu-latest) (push) Waiting to run
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (cl, Windows MSVC, windows-latest) (push) Waiting to run
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (gcc, Linux GCC, ubuntu-latest) (push) Waiting to run
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, Linux Clang, ubuntu-latest) (push) Waiting to run
Build / CMake, ${{ matrix.compiler }}, ${{ matrix.os }} (llvm, llvm-cov gcov, MacOS clang, macos-latest) (push) Waiting to run
Build / Create release (push) Blocked by required conditions
Build / Build packages (build/ftxui*Darwin*, macos-latest) (push) Blocked by required conditions
Build / Build packages (build/ftxui*Linux*, ubuntu-latest) (push) Blocked by required conditions
Build / Build packages (build/ftxui*Win64*, windows-latest) (push) Blocked by required conditions
Build / Build source package (push) Blocked by required conditions
Build / documentation (push) Waiting to run
This highlight support for the Bazel build system.
2025-04-29 16:05:11 +02:00
Arthur Sonzogni
10d73d365f
Support Bazel build system (#1033)
Bug:https://github.com/ArthurSonzogni/FTXUI/issues/1032
Fixed:https://github.com/ArthurSonzogni/FTXUI/issues/1032
2025-04-29 15:11:10 +02:00
Arthur Sonzogni
07fd3e685a
Bugfix: Avoid crash with ResizeableSplit. (#1025)
Component
---------
- Bugfix: Fix a crash with ResizeableSplit. See #1023.
  - Clamp screen size to terminal size.
  - Disallow `ResizeableSplit` with negative size.

Dom
---
- Bugfix: Disallow specifying a negative size constraint. See #1023.

Bug: https://github.com/ArthurSonzogni/FTXUI/issues/1023
2025-03-31 18:19:48 +02:00
ArthurSonzogni
09eb2f7fb0
v6.0.2 2025-03-30 01:27:57 +01:00
Arthur Sonzogni
1144e13125
Apply @forworldm code review. (#1022)
See: https://github.com/ArthurSonzogni/FTXUI/pull/1021?notification_referrer_id=NT_kwDOAEieQrMxNTU3OTg4MDA1MDo0NzU5MTA2#discussion_r2019827970
2025-03-30 01:22:17 +01:00
Arthur Sonzogni
4ba7dd2c5e
Window: Major crash fix. (#1021)
A patch handling focus was recently merged, but a special condition on
Windows was inverted, causing a segfault.

Bug:https://github.com/ArthurSonzogni/FTXUI/issues/1020
2025-03-29 12:51:08 +01:00
ArthurSonzogni
ee24bec3ba
v6.0.1
Same as v6.0.0.

Due to a problem tag v6.0.0 was replaced. This isn't a good practice and affect
developers that started using it in the short timeframe. Submitting a new
release with the same content is the best way to fix this.

Bug:https://github.com/ArthurSonzogni/FTXUI/issues/1017
Bug:https://github.com/ArthurSonzogni/FTXUI/issues/1019
2025-03-28 12:08:59 +01:00
ArthurSonzogni
327f43b175
v6.0.0 2025-03-27 19:19:44 +01:00
Arthur Sonzogni
5bf8ee819b
Update README.md 2025-03-23 23:55:31 +01:00
Arthur Sonzogni
d5b741b2be
Update README.md 2025-03-23 19:26:36 +01:00
ArthurSonzogni
b69e0f8b91
v6.0.0 2025-03-23 18:19:57 +01:00
Arthur Sonzogni
67163c2571
Fix errors. (#1010) 2025-03-23 15:29:01 +01:00
KenReneris
2c9a828402
Add support for italics (#1009)
Co-authored-by: Ken Reneris <ms/devops kreneris@microsoft.com>
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2025-03-22 18:03:43 +01:00
ArthurSonzogni
bc682d25a6
Fix compiler nits. 2025-03-22 17:31:27 +01:00
Arthur Sonzogni
96e8b8d92e
Implement Node::Select for flexbox. (#977) 2025-03-21 16:15:25 +01:00
ArthurSonzogni
f2fb434e31
Quickfix 2025-03-20 19:59:59 +01:00
Ayaan
b0e087ecef
Merge dom and component focus (#978)
Instead of two levels of focus with `focus` and `selected`, use a recursive
level. The components set the one "active" and hbox/vbox/dbox 

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2025-03-19 15:33:05 +01:00
Emmanuel Ogie
8519e9b0f3
Add terminal-rain and keywords to README.md (#1003)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2025-03-13 12:24:57 +01:00
Frames
36c669c194
Add a new example in README.md (#1005)
Add project to README.

Add https://github.com/Cyxuan0311/FTB.git
2025-03-13 12:17:48 +01:00
Arthur Sonzogni
d75108e960
Fix linear_gradient float precision bug.
This was reported by:
https://github.com/ArthurSonzogni/FTXUI/issues/998

Indeed, the `t` interpolation factor, which is itself interpolated might become
slightly larger than 1.0. This is due to the float precision.
This was supposedly handled, but there was an off-by-one error in the check.

Along the way, fix a bug found by a fuzzer.

Bug: https://github.com/ArthurSonzogni/FTXUI/issues/998
Fixed: https://github.com/ArthurSonzogni/FTXUI/issues/998
2025-02-10 23:10:27 +01:00
Yazid
15587dad01
Adding BestEdrOfTheMarket in examples (#995) 2025-01-27 18:21:59 +01:00
s1dd
c58a234f05
[DOCS] Add inLimbo as example project (#988) 2025-01-20 15:29:54 +01:00
Jan Stranik
c89569f5a7
Update menu.cpp - remove unused variable (#982) 2025-01-03 18:20:11 +01:00
Arthur Sonzogni
f6a690a942
Fix dev warning. (#980) 2024-12-29 10:24:17 +01:00
Clément Roblot
6fafa2dfed
Feature: Selection
Add support for selection content in the dom.
2024-12-27 09:45:13 +01:00
Arthur Sonzogni
751c8fab26
Force reload in examples. (#974)
After installing the service worker to use the COOP/COEP header, ensure
the document is reloaded.

Bug:https://github.com/ArthurSonzogni/FTXUI/issues/973
Fixed:https://github.com/ArthurSonzogni/FTXUI/issues/973
2024-12-25 13:32:35 +01:00
Sumit Patel
daa421fa6a
add tuisic example project (#967) 2024-12-15 18:58:08 +01:00
Yongqi Zhu
e213cfda37
add Lazylist example project (#964) 2024-12-06 15:20:17 +01:00
Vemy
58ff448e76
Fix: Properly changing window title text color #940 (#961) 2024-12-01 09:38:09 +01:00
Dmitry Nefedov
dfa461b46b
Clear terminal output of interactive screen on resize if alternate screen not in use (#952) 2024-11-27 21:52:20 +01:00
Dmitry Atamanov
0683285f01
Remove non-existent Just-Fast from README.md (#957) 2024-11-27 21:47:09 +01:00
glebundiy
7f74917887
Add yafth as an example project using FTXUI (#958) 2024-11-27 21:44:32 +01:00
Brian
ad0392ec39
Fixed typo on border (#956)
Fixed minor issue in function name
2024-11-20 22:37:02 +01:00
Boris Jaulmes
70bc44d28b
Allow a Dimension::Fit to extend beyond the terminal maximum height (#950)
For long tables (and other DOM elements), one may want the screen to render on dimensions higher than the terminal.  
Hence, this PR proposes a way to do so, with an optional parameter in the `Dimension::Fit` util function.

Discussions / Issues :  
- https://github.com/ArthurSonzogni/FTXUI/issues/572
- https://github.com/ArthurSonzogni/FTXUI/discussions/949

Bug:https://github.com/ArthurSonzogni/FTXUI/issues/572
Fixed:Bug:https://github.com/ArthurSonzogni/FTXUI/issues/572
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2024-11-07 21:07:09 +01:00
Petr Vyazovik
55af678fb9
Added pciex as an example project using FTXUI (#948) 2024-11-02 12:08:43 +01:00
Mikołaj Lubiak
edaa7a24e7
Add memory game and terminal animation to project list (#946) 2024-10-31 21:09:42 +01:00
Vemy
8922e6d55e
Add 2048-cpp to projects using FTXUI (#944) 2024-10-29 09:15:07 +01:00
Mikołaj Lubiak
99df1ac8ba
Add SliderWithCallback component (#938)
Add SliderOption::on_change.

Useful to observe a change to the value.

Signed-off-by: Mikołaj Lubiak <lubiak@proton.me>
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2024-10-29 08:03:59 +01:00
Herring
1d40687a40
Add index to EntryState (#933)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2024-09-30 23:18:59 +02:00
ljrrjl
dfb9558eaf
add ftxui-image-view (#924) 2024-08-27 14:35:15 +02:00
ArthurSonzogni
c5357acbaa
Add scrollbar example. 2024-08-18 10:46:41 +02:00
ArthurSonzogni
fbd56cdf43
Fix CQ failures. 2024-08-17 12:01:43 +02:00
ArthurSonzogni
66d1c1f61f
Quickfix 2024-08-16 11:47:01 +02:00
Arthur Sonzogni
f5d8c7deb5
Apply Clang-tidy (#918) 2024-08-16 11:19:51 +02:00
Sergey Latu
535290bb3b
My project added to readme (#916) 2024-08-15 16:08:32 +02:00
Arthur Sonzogni
fcd050c017
Table: support initializer list constructor. (#915)
To avoid burdening the user with explicit type construction when using
the library, we can use a constructor that accepts an initializer list
(std::initializer_list). This allows users to pass initializer lists
directly without having to wrap them in
std::vector<std::vector<std::string>>. This resolves the ambiguous case
when the inner list contains only two elements.

Bug:https://github.com/ArthurSonzogni/FTXUI/issues/912
2024-08-13 15:55:09 +02:00
Paolo Bosetti
d7de24cd9e
Added -fPIC compile option (#913)
Added -fPIC compile option.
2024-08-11 19:17:57 +02:00
Charney Kaye
547d9278d8
Add XJ music to FTXUI example projects (#909)
We use FTXUI as the frontend for the example C++ application for our adaptive music runtime engine.

https://github.com/xjmusic/xjmusic/tree/main/engine/example
2024-08-04 11:05:59 +02:00
Brian
5a9ef876a1
Update README.md (#905)
added step writer
2024-07-25 11:07:38 +02:00
LiAuTraver
307e4eb4b3
add missing include guard for screen/pixel.hpp (#890) 2024-06-27 13:07:10 +02:00
sAkuraOfficial
b28d57086a
fix a small bug in button example (#868) 2024-06-13 18:43:49 +02:00
Arthur Sonzogni
ff305147ca
Color alpha support. (#884) 2024-06-13 18:43:14 +02:00
Timon Ensel
d6a2049483
Add ostree-tui to README (#874) 2024-06-09 15:50:01 +02:00
Dr Power
b5e11ba1f6
Added Caravan to README.md (#871) 2024-06-09 15:44:12 +02:00
ArthurSonzogni
a715a767b5
Fix Color::HSV(h,0,v)
There was a problem when v==0
2024-06-02 12:03:41 +02:00
Felix
7b1f4d435b
Solve issues with atomic copy (#867) 2024-05-26 15:28:05 +02:00
Arthur Sonzogni
ecacb22d37
Dropdown: Fix title not updated. (#851)
A bug was introduced by:
https://github.com/ArthurSonzogni/FTXUI/pull/826

The checkbox label wasn't updated.

Bug:https://github.com/ArthurSonzogni/FTXUI/issues/861
2024-05-15 18:23:59 +02:00
ArthurSonzogni
af49b57e60
Dropdown: Fix title not updated.
A bug was introduced by:
https://github.com/ArthurSonzogni/FTXUI/pull/826

The checkbox label wasn't updated.

Bug:https://github.com/ArthurSonzogni/FTXUI/issues/861
2024-05-13 10:53:11 +02:00
ccn
4913379625
Update index.html (#858)
correct spelling
2024-05-06 12:54:17 +02:00
ccn
d40cafde5c
Update homescreen.cpp (#859)
fix typo
2024-05-06 12:53:56 +02:00
ccn
65296b9aa3
Update flex.cpp (#860)
fix typo
2024-05-06 12:53:37 +02:00
ccn
a58e6e6bcf
Update README.md (#857)
minor typo
2024-05-05 18:11:07 +02:00
Arthur Sonzogni
8a2a9b0799
Generate compile commands for clangd. (#855)
Fix all the diagnostics reported.

Bug: https://github.com/ArthurSonzogni/FTXUI/issues/828
2024-05-01 14:32:22 +02:00
Arthur Sonzogni
6a755f3760
Fix Menu focus. (#850)
Bug:https://github.com/ArthurSonzogni/FTXUI/issues/841
2024-04-28 16:03:00 +02:00
Jørn Gustav Larsen
d386df6f94
Enable raw keyboard input (#832)
In order for applications to receive all keyboard inputs, including the
Ctrl-C and Ctrl-Z, the raw input mode has been enabled. As result the
SIGINT will no longer be used, instead the keyboard Ctrl-C event is used
for exiting the framework, but only if no components has made use of it.

Co-authored-by: Jørn Gustav Larsen <jgl@fasttracksoftware.com>
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2024-04-28 15:17:54 +02:00
Mark Antabi
d38b14ffb6
Allow user to specify window element border. (#849) 2024-04-28 14:48:02 +02:00
ArthurSonzogni
7e3e1d4bca
Apply clang-tidy. 2024-04-28 10:40:57 +02:00
Clancy Walters
affa787244
Prefer Exit() over OnExit() (#847)
This is a no-op patch, but prefered, because this centralize the exit path below `Exit()`.
2024-04-27 11:32:46 +02:00
Arthur Sonzogni
014bdb4a05
Flush before applying a new configuration. (#848)
This avoids an ordering problem with whatever the user printed and
interacting with termios/WinAPI.

Bug:https://github.com/ArthurSonzogni/FTXUI/issues/846
2024-04-27 11:18:35 +02:00
Dimo Markov
293ff179f6
Separate a reusable Image class from Screen (#834)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2024-04-27 11:03:44 +02:00
cole-io
1f6e1101e8
clarified README and added tip on linking (#845)
Clarified some sentences, changed "external package" section to "utilization", added a tip on linking
2024-04-22 08:48:32 +02:00
na-trium-144
0dfd59bd09
Fix ResizableSplit handling keyboard navigation incorrectly (#842)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2024-04-18 17:28:28 +02:00
ArthurSonzogni
e03a0797be
Fix minor compile error. 2024-04-07 18:10:52 +02:00
James
3c9fa60d28
Feature: Dropdown options with callback (#826)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2024-04-06 17:45:10 +02:00
Jørn Gustav Larsen
2216f3a5da
Problem with setting the cursor position on the right screen edge when drawing. (#831)
When moving the cursor back to its original location, a problem arises when cursor placed in the right edge column, where an off by one error occur. This pull request will resolve this problem.

Co-authored-by: Jørn Gustav Larsen <jgl@fasttracksoftware.com>
Co-authored-by: Jørn Gustav Larsen <jgl@adminbyrequest.com>
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2024-04-03 21:32:19 +02:00
Arthur Sonzogni
f609c12846
Revert change to button example. (#835)
It was introduced mistakenly by:
f495ce029c
2024-03-30 11:01:28 +01:00
faizan171997
ce5ac6b12f
- Added exit button to homescreen example (#819) 2024-02-22 12:12:51 +01:00
ArthurSonzogni
f495ce029c
Add example to use system ftxui
Fixed: https://github.com/ArthurSonzogni/FTXUI/issues/814
2024-01-26 18:32:44 +01:00
Arthur Sonzogni
810657dab8
Update mainpage.md
Fixed: https://github.com/ArthurSonzogni/FTXUI/issues/812
2024-01-25 11:56:25 +01:00
rio
65bbb4f0eb
Make Checkbox take focus when clicked (#810) 2024-01-17 18:21:32 +01:00
Arthur Sonzogni
5112d9139d
Button: invoke on_click at the end. (#807)
Some users might destroy `this`, which would result in UAF.

In the future, we should consider alternatives like posting a task to
the main loop, or rely on users for this.

Fixed:https://github.com/ArthurSonzogni/FTXUI/issues/804
2024-01-10 22:08:57 +01:00
Mohammad Rahimi
91a162a30e
Add FTowerX to README (#805)
FTowerX is Tower of Hanoi game developed using FTXUI
2024-01-08 16:48:42 +01:00
Nikola Dućak
4d5cc41c65
Add Captain's log to README (#803) 2024-01-08 07:25:38 +01:00
nyako
cc3bcbf069
ftxui_set_options: properly check the current compiler. (#802)
This solve the issue encountered when using clang under MSVC.
2024-01-08 07:05:41 +01:00
Particle_G
d0634e1ca0
Add missing Checkbox() implementation (#796)
Fix: #795
2023-12-23 08:35:20 +01:00
Arthur Sonzogni
a7b6785420
Restore cursor shape on exit. (#793) (#794)
Fixed: https://github.com/ArthurSonzogni/FTXUI/issues/792
2023-12-17 10:35:21 +01:00
Arthur Sonzogni
348c3853d4
Restore cursor shape on exit. (#793)
Fixed: https://github.com/ArthurSonzogni/FTXUI/issues/792
2023-12-17 10:24:33 +01:00
ArthurSonzogni
bfadcb7165
Fix default for ScreenInteractive::Fullscreen()
It was intended to open gthe alternate screen.
2023-11-19 14:09:42 +01:00
Arthur Sonzogni
6c2b43a2aa
Improve the example page. (#780) 2023-11-19 12:09:52 +01:00
Arthur Sonzogni
b970cb6ea8
feature: allow fullscreen without alternative screen (#777)
This should solve #766

The original PR was:
#767

Co-authored-by: rbrugo <brugo.riccardo@gmail.com>
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-11-11 17:57:07 +01:00
Clément Roblot
c31aecf2ed
Checkbox button debounce (#774)
This fixes: https://github.com/ArthurSonzogni/FTXUI/issues/773

Dragging the mouse with the left button pressed now avoids activating multiple
checkboxes.

Add support for detecting mouse press transition. Added:
```cpp
// The previous mouse event.
Mouse Mouse::previous;

// Return whether the mouse transitionned from:
// released to pressed => IsPressed()
// pressed to pressed => IsHeld()
// pressed to released => IsReleased()
bool Mouse::IsPressed(Button button) const;
bool Mouse::IsHeld(Button button) const;
bool Mouse::IsReleased(Button button) const;
```
A couple of components are now activated when the mouse is pressed,
as opposed to released.

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-11-11 17:33:50 +01:00
chrysante
e8589dd533
Fix Input onchange not called (#776) 2023-11-11 17:29:19 +01:00
Clément Roblot
0631c3ab3f
Add example to filter characters inputted in an input field (#763)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-11-05 10:26:12 +01:00
Ali Caglayan
d548a18658
update nix and add dev shell (#769)
We update the lock on the nix flake and also add a dev shell. This means
you can do `nix build` to build the project and `nix develop` to drop
into a development environment with cmake and clang.

Signed-off-by: Ali Caglayan <alizter@gmail.com>
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-10-23 08:48:50 +02:00
benoitdudu
f499d34f7e
fix the doxygen documentation by moving comments at the right place (#768) 2023-10-19 16:58:02 -04:00
Ruebled
d4c9c5e226
Update README.md (#761)
Version FetchContent Update
2023-10-12 17:27:18 +02:00
Clément Roblot
62c0b43caf
Scrollbar coloring (#755)
This a proposed MR to fix #754. While building the scroll bar the pixels were completely reseted thus canceling any style previously applied to said pixels. This MR removes this resetting of the pixels and leaves only the drawing of the shape of the scroll bar.
2023-10-02 10:29:23 +02:00
Arthur Sonzogni
c24a274292
Feature: hscroll_indicator (#753)
This is the symetrical of `vscroll_indicator`.

Requested by @ibrahimnasson.

Fixed:https://github.com/ArthurSonzogni/FTXUI/issues/752
2023-09-26 23:08:42 +02:00
Contexploit
20d4be286b
Example: fix small flaw in example/button.cpp (#751) 2023-09-20 18:23:05 +02:00
Arthur Sonzogni
550a59f0a5
Add catalincd/resource-monitor (#745) 2023-09-18 20:10:48 +02:00
Arthur Sonzogni
5db2be0f4d
List J0sephDavis/ftxuiFileReader (#746) 2023-09-18 20:09:45 +02:00
Arthur Sonzogni
8d1665022a
List ftxui_CPUMeter (#744) 2023-09-03 16:21:13 +02:00
Arthur Sonzogni
e5978a8e76
Update README.md 2023-09-03 11:45:23 +02:00
MingSheng
0f1588e3d1
Add grid container library (#742) 2023-09-02 11:00:45 +02:00
Claus Klein
dd6a5d371f
Fix CMAKE_UNITY_BUILD usage (#738)
Add missing include guard.
This fix https://github.com/cpp-best-practices/cmake_template/issues/64

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-08-28 21:38:51 +02:00
MingSheng
05c7bee6dd
Feature: input can now use overwrite mode when toggled with insert key (#735)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-08-28 21:07:26 +02:00
ArthurSonzogni
cdf28903a7
Release v5.0.0 2023-08-19 15:46:36 +02:00
ArthurSonzogni
49a48820dd
Add documentations to every public functions. 2023-08-19 14:56:28 +02:00
ArthurSonzogni
5724f8483b
Move copyright to the top of files. 2023-08-19 13:57:01 +02:00
ArthurSonzogni
7e6b7386ce
Fix linear_gradient_gallery example slider increment. 2023-08-19 13:35:56 +02:00
mingsheng13
20baaef5b8
Dropdown now closes when using return key to select (#731)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-08-19 12:02:04 +02:00
Stefan Ravn van Overeem
eb9a701fd7
Add -Wuseless-cast to FTXUI_DEV_WARNINGS (#728)
Add the -Wuseless-cast to the FTXUI_DEV_WARNINGS and
fix the compiler complaints about useless casts
2023-08-19 11:20:04 +02:00
mr-mocap
1e6df78ec2
Tidy up some ConstRef<T> and Ref<T> constructor cases (#730)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-08-19 11:10:29 +02:00
Stefan Ravn van Overeem
b3f1edc385
Add a TrackMouse(false) on ScreenInteractive to disable mouse events (#726)
When mouse events are enabled, it is not possible to select text in the
terminal and copy it somewhere else. This could be usefull for some
applications if they don't need to handle mouse events.

Add a function on the ScreenInteractive class to disable grabbing of
mouse events so that it is e.g. possible to select text in the user
interface. The function needs to be called on the screen object before
starting the application loop if such a behaviour is desired.
2023-08-19 10:57:50 +02:00
Stefan Ravn van Overeem
f7304c28c3
Fix Wshadow warning in Color::Interpolate (#727)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-08-17 22:18:33 +02:00
lexika979
acbdb50747
Fix typo in link (#724) 2023-08-15 18:47:14 +02:00
Arthur Sonzogni
8ae1c95d18
Update CHANGELOG.md 2023-08-13 17:36:41 +02:00
ArthurSonzogni
8058e1af6c
Cleanup. (IWYU, clang-tidy, etc...) 2023-08-13 08:20:16 +02:00
mr-mocap
06ba1c10b9
Possible clarification and reimplementation of Ref<T> classes (#719)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-08-12 21:18:33 +02:00
ArthurSonzogni
461d557674
Apply clang-tidy 2023-08-08 02:17:40 +02:00
Clément Roblot
e2a205ed0d
Performance improvement by refactoring pixel styles (#704)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-08-08 00:46:51 +02:00
ArthurSonzogni
00e63993ce
Run IWYU and clang-format 2023-08-06 13:25:42 +02:00
Stefan Ravn van Overeem
b0a7f88f07
Change WordBreakProperty underlying type to int8_t (#715)
This yields a ~1% performance improvements, likely
because the smaller types causes less load on memory
when bisearching the WordBreakProperty interval table

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-08-03 17:41:54 +02:00
Clément Roblot
cebe49dd23
Added some true colors in the benchmark (#717) 2023-08-01 15:13:04 +02:00
Stefan Ravn van Overeem
4debd4f3de
Extract extend codepoints out in seperate array (#713)
IsCombining() is a hotpath when rendering the screen.
Most of the time is spent doing bisearch on the word break interval list
to check it characters has the extend property.

Create a seperate table for intervals with the extend property,
so they can just be searched in isCombining().

Also some of the intervals in the word break interval list
were consecutive and could be combined to reduce the
size of the list.

This gives a ~25% performance improvement when running the benchmark
2023-08-01 09:39:14 +02:00
KyuHyuk Lee
bb43ce1875
Added rw-tui to the list of projects that are using FTXUI (#712) 2023-07-31 18:26:45 +02:00
Clément Roblot
0930142597
Added the print stage to the benchmarks (#708) 2023-07-29 11:04:24 +02:00
Clément Roblot
21fe59dee8
Upgrade the version of google benchmark (#709)
This upgrades the version of google benchmark used. The main reason for this upgrade is that the old version doesn't display the OVERALL_GEOMEAN when comparing two benchmarks.

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-07-29 11:00:48 +02:00
ArthurSonzogni
5094b5f3fb
Add style targetted benchmark. 2023-07-28 20:54:30 +02:00
ArthurSonzogni
e5eb822d44
Start using c++20 in examples. 2023-07-26 01:02:37 +02:00
Igor Bogoslavskyi
b50f1fffc8
Improve const correctness in the Screen class (#701)
- Add a const variant to the accessor functions
- Make Print and ToString functions const

This fixes: https://github.com/ArthurSonzogni/FTXUI/issues/700
2023-07-26 00:41:16 +02:00
ArthurSonzogni
43240a5fd4
Add missing includes for gcc
Bug:https://github.com/ArthurSonzogni/FTXUI/issues/695
2023-07-15 16:40:20 +02:00
Arthur Sonzogni
e19550ae69
Feature: Windows. (#690)
Into ftxui/component/, add:
```
Container::Stacked(...)
Window(...);
```

Together, they can be used to display draggable/resizable windows.

Bug:https://github.com/ArthurSonzogni/FTXUI/issues/682

* Fix typo.
2023-07-15 16:29:48 +02:00
ArthurSonzogni
79f8293a0d
Fix Canvas documentation.
The braille characters can fit 2x4 dots per cells, not 2x8.

Bug:https://github.com/ArthurSonzogni/FTXUI/issues/694
2023-07-03 21:10:47 +02:00
cblack-dev
c2fef9d377
Resolve unused varaible warning in _WIN32 builds of screen_interactive.cpp (#693)
Marks constexpr int timeout_microseconds on line 73 as [[maybe_unused]] to resolve unused variable warning on _WIN32 builds.
2023-07-02 17:50:31 +02:00
Stefan Ravn van Overeem
b2f66c7386
Improve unicode codepoint Bisearch performance (#691)
Improve the performance of the functions for searching for codepoints
in a table by passing the table array in as a reference instead of copying
it.

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-06-27 22:32:57 +02:00
Arthur Sonzogni
455998d759
Remove Ref<XxxOption> and add new interfaces. (#686)
1. Stop taking Ref<XxxOption> in Component constructors. Instead, use
   the XxxOption directly. Passing by copy avoid problems developers had
   where one was shared in between multiple component, causing issues.

2. Add variants of most component constructors taking a struct only.

This replaces:
https://github.com/ArthurSonzogni/FTXUI/pull/670

This fixes:
https://github.com/ArthurSonzogni/FTXUI/issues/426
2023-06-25 17:22:05 +02:00
Stefan Ravn van Overeem
e73e7f0d68
Support Fn keys for every terminal standards (#689)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-06-25 17:11:59 +02:00
ArthurSonzogni
5b5c6e1402
Fix .gitignore 2023-06-24 17:54:04 +02:00
Arthur Sonzogni
e9e1451f3c
Fix the .gitignore file. (#688) 2023-06-24 17:52:44 +02:00
Arthur Sonzogni
34688fdd8c
Support F1-F5 from OS terminal (#687)
Bug:https://github.com/ArthurSonzogni/FTXUI/issues/685
2023-06-24 17:15:23 +02:00
Arthur Sonzogni
da32a8ba0a
Add .gitignore (#679)
Bug:https://github.com/ArthurSonzogni/FTXUI/issues/669
2023-06-16 21:29:28 +02:00
Arthur Sonzogni
d9712cf1e8
Improve the README GIF 2023-06-11 14:04:30 +02:00
ArthurSonzogni
98b31ff1fe
Remove ButtonOption::Arthur()
It was added by mistacke previously.
2023-06-11 13:39:33 +02:00
Ruebled
67717ab923
Path Finder to README (#674) 2023-06-10 11:35:19 +02:00
Arthur Sonzogni
d587737633
Update README.md
The link was broken.

This fixes: https://github.com/ArthurSonzogni/FTXUI/issues/673
2023-06-09 13:48:11 +02:00
Avighna
c3c3a2b11f
Fixed small typo in screen.hpp (#668) 2023-06-06 00:13:36 +02:00
Arthur Sonzogni
ff5817b8a6
Fix on_enter bug in ftxui::Input (#667)
Fixed:https://github.com/ArthurSonzogni/FTXUI/issues/666
2023-06-04 21:34:16 +02:00
Arthur Sonzogni
7b7177b59c
Feature: hyperlink support. (#665)
See the [OSC 8 page](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda).
FTXUI support proposed by @aaleino in [#662](https://github.com/ArthurSonzogni/FTXUI/issues/662).

API:
```cpp
auto link = text("Click here") | hyperlink("https://github.com/FTXUI")
```

Fixed:https://github.com/ArthurSonzogni/FTXUI/issues/662
2023-06-04 21:06:19 +02:00
Arthur Sonzogni
d4c6cebea3
Update README.md 2023-06-04 18:05:32 +02:00
Arthur Sonzogni
c6f0dd60ee
Update README.md 2023-06-04 18:04:50 +02:00
Arthur Sonzogni
7d7be0e9da
build: Display options and turn DOC/EXAMPLE OFF (#661)
- Add `FTXUI_QUIET` to stop displaying FTXUI configuration messages.
- Turn `FTXUI_BUILD_DOC` and `FTXUI_BUILD_EXAMPLE` OFF by default
- Display the list of options.
2023-06-04 14:35:08 +02:00
Prokop Randáček
59bbe3ed5e
fix some warnings (#660)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-06-03 13:59:39 +02:00
Herman Semenov
d464a071da
Optimize inserts in vector and refactor const reference objects (#659)
Signed-off-by: German Semenov <GermanAizek@yandex.ru>
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-05-31 19:24:08 +02:00
Henrik S. Gaßmann
8bea9261bc build: Properly escape paths which may contain spaces 2023-05-29 16:27:31 +02:00
Henrik S. Gaßmann
3e5322944d build: Remove redundant cmake version check
The main `CMakelists.txt` already asserts a minimum version of `3.12`
which renders the condition `cmake <= 3.11.4` to be always false.
2023-05-29 16:27:31 +02:00
Henrik S. Gaßmann
332f229e49 build(install): Remove redundant install settings 2023-05-29 16:27:31 +02:00
Henrik S. Gaßmann
806bacf15a build(install): Fix pkgconfig install directory
`pkg-config` finds configs within `$prefix/lib/pkgconfig`, but not in
`$prefix/lib`.

See-Also: https://linux.die.net/man/1/pkg-config
2023-05-29 16:27:31 +02:00
Arthur Sonzogni
d00d946282
Update CHANGELOG.md (#651) 2023-05-29 11:52:39 +02:00
SpaceIm
d93b687bde
CMake: use compile_features to set min C++ standard (#647) 2023-05-25 19:34:34 +02:00
SpaceIm
69557d4623
add FTXUI_DEV_WARNINGS option in CMakeLists (#648)
This option allows to enable warnings as errors, and add more compiler warnings
2023-05-23 14:38:49 +02:00
Robin Lindén
f1303626f5
Fix MSVC possible loss of data warning (#645) 2023-05-20 00:35:26 +02:00
Henrik Gaßmann
b1c53bcd15
build: Check package version in find_package (#643)
Modify the `ftxui-config.cmake.in` file so that it includes
`ftxui-targets.cmake`. This causes cmake to check the version is
compatible with what the user requested.

This patch also includes additional minor changes.

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-05-19 17:50:23 +02:00
ArthurSonzogni
5e1af6bb69
Parallelize github build workflow 2023-05-19 12:11:12 +02:00
ArthurSonzogni
4b9b0635c4
Update the CHANGELOG 2023-05-19 11:59:23 +02:00
ArthurSonzogni
8dbda8551f
Update CHANGELOG to reflect the v4.1.0 support branch. 2023-05-18 11:21:34 +02:00
Henner Zeller
38827dda5b
Fix types used in Hash() function used in tests. (#640)
Using `auto` seems to create a different output on different platforms.
Notably it was observed that aarch64 compiles return a different
value.

Fix the type of the characters iterated through the string.

Fixes #639

Signed-off-by: Henner Zeller <h.zeller@acm.org>
2023-05-17 11:59:41 +02:00
Henner Zeller
6e059dadd5
Add pkg-config file. (#642)
This file describes the include and lib location and makes
it possible to use the library in build systems other than
CMake, e.g. in basic Makefiles.

Signed-off-by: Henner Zeller <h.zeller@acm.org>
2023-05-17 10:50:47 +02:00
Nick Fistere
9bfa241627
Delete copy constructor and copy operator (#638)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-05-16 18:33:41 +02:00
Arthur Sonzogni
4d77353852
Create codeql.yml (#631) 2023-05-03 21:56:58 +02:00
Arthur Sonzogni
7de4f8683d
Feature: Add multi-line input. (#630) 2023-05-02 13:32:37 +02:00
Arthur Sonzogni
6215240b37
Support arrow keys in application mode. (#627)
Depending on the Cursor Key Mode (DECCKM), the terminal sends different
escape sequences:

Key     Normal    Application
-----   --------  -----------
Up      ESC [ A   ESC O A
Down    ESC [ B   ESC O B
Right   ESC [ C   ESC O C
Left    ESC [ D   ESC O D
Home    ESC [ H   ESC O H
End     ESC [ F   ESC O F

I decided not to update the current mode to fit what FTXUI parse, but
instead support parsing both. We convert the sequences from the
"application mode" into the "normal mode".

Bug:https://github.com/ArthurSonzogni/FTXUI/issues/626
Fixed:https://github.com/ArthurSonzogni/FTXUI/issues/626
2023-04-25 08:52:16 +02:00
Arthur Sonzogni
a602013179
Check graph area is positive. (#625)
Bug:https://github.com/ArthurSonzogni/FTXUI/issues/624
2023-04-23 16:14:50 +02:00
Jason Turner
e23dbc7473
Use globally set CMAKE_CXX_STANDARD if it is set (#620) 2023-04-17 22:17:48 +02:00
Arthur Sonzogni
1397c10234
Remove string combining character list. (#616)
It was possible to access it from the WordBreakProperty list
2023-04-10 17:00:02 +02:00
Arthur Sonzogni
4bdbf6352d
Update workflow to main branch. (#614)
This fixes:
https://github.com/ArthurSonzogni/FTXUI/issues/599
2023-04-09 11:40:54 +02:00
Michael Vetter
2d6ea25682
Add repology badge (#613)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-04-03 23:07:56 +02:00
Michael Vetter
900a1e060f
Add link to openSUSE package (#611) 2023-04-03 13:49:46 +02:00
Arthur Sonzogni
898b8d672e
Fix useless new line when using the alternative screen. (#610)
Fix:https://github.com/ArthurSonzogni/FTXUI/issues/609
2023-03-31 17:44:01 +02:00
Marc
896c0f2f6e
Casting and documentation fixes (#608)
Add `-wDocumentation` option. Fix the documentation.
Fix c++20/c++17 confusion in tests.

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-03-31 17:13:48 +02:00
Marc
eed7e2ea70
Multiple fixes: signed/unsigned, etc... (#600)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-03-26 20:20:02 +02:00
Arthur Sonzogni
e177409bd3
Update float style in animation.cpp (#607)
Partially taken out of:
https://github.com/ArthurSonzogni/FTXUI/pull/600

Co-authored-by: LostInCompilation <12819635+LostInCompilation@users.noreply.github.com>
2023-03-26 16:42:08 +02:00
Arthur Sonzogni
422c30cd34
nit: Remove useless ';' and ',' (#606)
Taken out of:
https://github.com/ArthurSonzogni/FTXUI/pull/600

Co-authored-by: LostInCompilation <12819635+LostInCompilation@users.noreply.github.com>
2023-03-26 16:14:43 +02:00
Arthur Sonzogni
0b57be9c49
Doc: Fix @params vs @param (#605)
Fixed wrong parameter documentation name.

Taken out of:
https://github.com/ArthurSonzogni/FTXUI/pull/600

Co-authored-by: LostInCompilation <12819635+LostInCompilation@users.noreply.github.com>
2023-03-26 15:56:28 +02:00
dev-null-undefined
a366c5a423
Feature: Added nix build support (#603)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-03-26 12:17:22 +02:00
Vinicius Moura Longaray
e83e90ced2
Feature: LinearGradient color decorator. (#592)
Based on the existing color decorators, create new ones to apply a gradient effect on the DOM.

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-03-22 13:59:02 +01:00
Arthur Sonzogni
2991b0389e
Add colored border. (#595)
This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/564
2023-03-16 13:15:14 +01:00
Arthur Sonzogni
9efa0f7874
Feature: Add the dashed style. (#594) 2023-03-15 22:50:27 +01:00
ArthurSonzogni
2dc95d6a5d
Tweak ftxui/example wasm configuration. 2023-03-12 17:38:09 +01:00
Arthur Sonzogni
9b074d1e27
Feature resizable spilt with custom separator (#583)
* Feature: ResizableSplit with custom separator

This resolves:
    https://github.com/ArthurSonzogni/FTXUI/issues/580

Co-authored-by: Pin Loon Lee <pinloon_0428@hotmail.com>
2023-03-09 20:21:23 +01:00
Evgeny Gorodetskiy
436c237213
Fix Apple Clang 14 build errors (issue #588) (#589) 2023-02-26 21:49:52 +01:00
Peter V
90d18a2d20
Reword description of ftxui/component in #modules (#585)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2023-02-16 22:33:16 +01:00
ArthurSonzogni
d301fab1f4
Release v4.0.0 2023-02-12 18:02:40 +01:00
Arthur Sonzogni
3e35f45830
Execute clang-tidy and IWYU. (#576) 2023-02-12 14:07:28 +01:00
Arthur Sonzogni
a4e70dfb93
Fix vscroll hidding the last character. (#575)
This resolve:
https://github.com/ArthurSonzogni/FTXUI/issues/574
2023-02-12 13:51:51 +01:00
Arthur Sonzogni
b2853c8f14
Fix: cursor position offset. (#562)
This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/559
2023-01-22 11:51:37 +01:00
Arthur Sonzogni
6fe8310321
Feature: strikethrough and underlinedDouble decorator. (#561)
This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/560
2023-01-22 11:02:27 +01:00
Arthur Sonzogni
350dcac032
Fix build about fuzzer. (#557)
Previous patch introduced a regression. The condition needs to be
inverted.

Fixed:https://github.com/ArthurSonzogni/FTXUI/issues/556
2023-01-17 17:36:59 +01:00
Arthur Sonzogni
65848d1e5f
cmake: support gtest from the package manager (#552)
Some developers would be happier with the gtest version provided from
their package manager. Use it if it is installed the package provide
cmake support.

Fixed: https://github.com/ArthurSonzogni/FTXUI/issues/551
2023-01-14 20:37:42 +01:00
Alex
1561293140
change vcpk.info to vcpkgx.com (#553)
The vcpkg.info site is now defunct.
[vcpkgx.com](https://vcpkgx.com/) provides a similar if not identical service to what vcpkg.info used to provide.
2023-01-12 10:16:00 +01:00
Arthur Sonzogni
90dfceefcb
Fix slider focus. (#549)
This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/547

From discussion:
https://github.com/ArthurSonzogni/FTXUI/discussions/546
2023-01-07 18:13:59 +01:00
Arthur Sonzogni
5410329ac6
Adding heartbeat to spinner (#548)
Co-authored-by: cyrus <cyruswang2017@gmail.com>
2023-01-06 11:05:56 +01:00
Matthias Vallentin
9f9571190a
Fix crash on empty tab container. (#540) 2022-12-30 16:31:47 +01:00
Arthur Sonzogni
b56afce48c
Fix blinking cursor shape. (#539) 2022-12-28 13:17:56 +01:00
Arthur Sonzogni
abd5b2a503
Fix Windows UTF16 char. (#538)
Windows output UTF16 unicode char, but FTXUI works using UTF8. Do the
conversion.

This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/495
2022-12-28 11:47:11 +01:00
Arthur Sonzogni
60b9e491db
Add all the Slider implementations. (#532)
This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/524
2022-12-22 21:15:54 +01:00
重装小杰
6cea410eaa
Remove punctuation that affects compilation (#531) 2022-12-22 18:00:27 +01:00
Arthur Sonzogni
a52b959f66
Fix compile with gcc. (#529)
This resolves:
- https://github.com/ArthurSonzogni/FTXUI/issues/526
- https://github.com/ArthurSonzogni/FTXUI/issues/520
2022-12-19 20:00:03 +01:00
Arthur Sonzogni
0542227ba7
Execute clang tidy and IWYU (#528) 2022-12-19 19:44:43 +01:00
Arthur Sonzogni
4dc1a9fff9
Fix mouse on support over PuTTY (#525)
This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/523
2022-12-14 22:09:25 +01:00
ArthurSonzogni
b9f51844c3
Add documentation about the hoverable component. 2022-12-04 11:59:56 +01:00
Arthur Sonzogni (slow/sick)
0d54285e19
Add the Hoverable wrapper. (#522)
This will make it easier for developers. For instance:
https://github.com/ArthurSonzogni/FTXUI/issues/521
2022-12-04 11:54:49 +01:00
mr-mocap
f21ca3aa14
Improve UNIX signal handling (#518)
There was a dead lock caused by the reentrancy of the post method.

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2022-12-01 22:56:35 +01:00
Arthur Sonzogni (slow/sick)
05f29ff3b3
Remove codecvt dependency. (#516)
This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/514
2022-11-26 20:43:09 +01:00
Fredrik Hallenberg
55b9706cfd
Fix automerge at border (#515) 2022-11-25 00:39:17 +01:00
wflohry
121bd0d046
Ignoring wstring_convert deprecation warnings (#498) 2022-11-19 14:22:44 +01:00
Arthur Sonzogni (slow/sick)
2c5681ee20
Interpret 8 as 127 (#510)
This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/508

Apparently, this is a common issue:
https://www.cs.colostate.edu/~mcrob/toolbox/unix/keyboard.html
2022-11-17 22:16:25 +01:00
Arthur Sonzogni (slow/sick)
1689802349
Support multiple kind of cursor shapes. (#505)
https://github.com/ArthurSonzogni/FTXUI/issues/424
2022-11-11 14:09:53 +01:00
Arthur Sonzogni (slow/sick)
9babfea36b
Fix example demo. (#506) 2022-11-11 14:07:27 +01:00
Tim Ebbeke
dfdbe1eecf
Fix std::ignore is in <tuple>. (#502) 2022-10-25 15:26:12 -04:00
Arthur Sonzogni
aeaf39b8ea
Fix F1-F4 keymapping. (#501)
It was just wrong, even on Linux.

Bug:https://github.com/ArthurSonzogni/FTXUI/issues/492
2022-10-18 22:58:22 +02:00
Arthur Sonzogni
0acfd8f255
Introduce Loop. (#476)
It can be used to give developers a better control on the loop. Users
can use it not to take full control of the thread, and poll FTXUI from
time to time as part of an external loop.

This resolves: https://github.com/ArthurSonzogni/FTXUI/issues/474
2022-10-18 21:29:27 +02:00
Arthur Sonzogni
26d63bc56f
Fix pedantic compile issue. (#500) 2022-10-16 10:45:11 +02:00
Aleksandar Brakmić
f692a50195
Added eCAL monitor to the list of projects that are using FTXUI (#497) 2022-10-10 00:10:38 +02:00
Rosen Penev
e04ea27dcd
fix cross compiling with MinGW (#499)
MinGW on Linux is case sensitive. Windows is case insensitive.

Signed-off-by: Rosen Penev <rosenp@gmail.com>

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2022-10-10 00:08:28 +02:00
Arthur Sonzogni
f4b47333be
Featre: Support ctrl+arrow in input. (#494)
CTRL+LEFT: Move the cursor to the beginning of the word.
CTRL+RIGHT: Move the cursor to the beginning of the word.

This was requested by:
https://github.com/ArthurSonzogni/FTXUI/issues/490
2022-10-06 21:16:55 +02:00
Arthur Sonzogni
ccfe22bc24
Test Page{Up,Down} for Radiobox. (#493)
See: https://github.com/ArthurSonzogni/FTXUI/pull/491#issuecomment-1264335576
2022-10-01 20:24:16 +02:00
jdfa
5ba29a9539
#487 Handled Space and Enter events for Radiobox (#491)
Return true when an event a RadioBox is state change due to pressing Return or space.

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2022-10-01 13:34:15 +02:00
Arthur Sonzogni
c61fadd8ec
Update to unicode 13 standard. (#484)
It contains additional full width character and combining characters.

This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/483
2022-09-29 10:50:27 +02:00
Lobanova Valeriia
b3aad183da
FIX: minor mistake (#482) 2022-09-25 22:00:12 +02:00
Arthur Sonzogni
fab74f745d
Execute clang tidy. (#477) 2022-09-05 20:56:41 +02:00
Arthur Sonzogni
c8ec151154
Bring back C++17 minimal requirement. (#475) 2022-09-03 13:03:04 +02:00
Arthur Sonzogni
1d76a2321c
Update codecov.yml (#473)
This avoids being spammed by codecov.
2022-08-30 21:19:32 +02:00
Arthur Sonzogni
1661a5e83d
Implement ButtonOption::Border() (#472)
It was missing. See:
https://github.com/ArthurSonzogni/FTXUI/issues/471
2022-08-30 19:03:14 +02:00
Arthur Sonzogni
b3ba747d82
Feature: Slider in any directions. (#468)
Add the `SliderOption` option supporting:
```cpp
{
  Ref<T> value;
  ConstRef<T> min = T(0);
  ConstRef<T> max = T(100);
  ConstRef<T> increment = (max() - min()) / 20;
  GaugeDirection direction = GaugeDirection::Right;
  Color color_active = Color::White;
  Color color_inactive = Color::GrayDark;
};
```

In particular, this supports multiple direction. This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/467

This one do not support adding a label. The old constructors can still
be used to have a label.
2022-08-30 18:52:33 +02:00
Arthur Sonzogni
8226c5aea7
Fix clang-tidy. (#469) 2022-08-28 21:30:01 +02:00
Arthur Sonzogni
1e381fcad6
Add codecov.yml (#470) 2022-08-28 21:29:48 +02:00
Jan Sende
d04e04adc6
Fixed typo (#465) 2022-08-24 12:00:54 +02:00
Arthur Sonzogni
ec994a4e65
Add support for emscripten screen resize. (#463)
This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/432
2022-08-21 23:04:32 +02:00
Arthur Sonzogni
3ec765e1f0
Menu: keep the previously focused element with mouse. (#462)
This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/453
2022-08-21 17:23:13 +02:00
Ian J
251306a4bb
Fixed divide by zero segault (#461)
Check if inner_size is less than 1 to prevent divide by 0 segfault.

Co-authored-by: Arthur Sonzogni <sonzogniarthur@gmail.com>
2022-08-19 19:43:55 +02:00
Jan Sende
7cc68cfbd0
Fixed dim and bold not mixing well (#460)
One single reset code controls both the dim and bold properties. Mixing both led to one of the properties being wrongly reset.

Co-authored-by: Arthur Sonzogni <sonzogniarthur@gmail.com>
2022-08-19 19:03:56 +02:00
Arthur Sonzogni
36460fea2a
Switch to codecov v3 (#458) 2022-08-15 15:00:28 +02:00
Arthur Sonzogni
d755356481
Add ref for sliders. (#457)
This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/456
2022-08-13 16:26:53 +02:00
Arthur Sonzogni
f461050759
Run IWYU (#450) 2022-08-07 14:44:33 +02:00
Julien Marrec
e42ab7b2e6
Typo in iwyu.cmake (#447) 2022-08-07 12:15:52 +02:00
Arthur Sonzogni
d9241435ce
Fix link to TermBreaker. 2022-07-15 17:59:13 +02:00
badlydrawnrod
d5044bdaaf
Fix #441 Canvas::DrawText() (#442)
Fix for Canvas::DrawText() draws nothing if the start coordinate is out
of bounds.
2022-07-10 22:14:32 +02:00
ArthurSonzogni
f91677e79f
Update links toward examples. 2022-07-09 20:47:18 +02:00
ArthurSonzogni
d6da30a518
Add COOP/COEP for worker.js file. 2022-07-09 19:58:11 +02:00
ArthurSonzogni
d5b1899290
Fix workflow for documentation. 2022-07-09 19:15:17 +02:00
Hunter Zolomon
d545fb6f19
Fix README link reference. (#440) 2022-07-09 18:57:30 +02:00
ArthurSonzogni
f80e20c4aa
Build documents and examples on master. 2022-07-09 18:51:35 +02:00
Hunter Zolomon
d805eb0648
Improved Introductory Tutorial Page (#433)
This PR solves #434 by improving on the existing introductory tutorial through adjustment of the grammar and vocabulary of the sentences, rewriting of sentences, writing new descriptions for sub-headings, and adding new link references for the corresponding discussion elements.

I have not replaced the inline script ascii calls yet, and there might be a few other things that might require some adjustment. However, this version looks much cleaner, consistent, and descriptive that the previous iteration.

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2022-07-09 17:53:36 +02:00
倔强的贝吉塔
940f805b8f
Add StartUp into the project list (#439) 2022-07-09 16:16:05 +02:00
Arthur Sonzogni
57da24dfdb
Fix homescreen example thread safety. (#431)
This addresses and fix:
https://github.com/ArthurSonzogni/FTXUI/issues/430

This patchs makes |shift| to be read and written on the same thread. We
request the update to be made via a task posted on the main thread.

This patch has no real consequence, the previous behavior was fine.
I hope it will help users not to have thread safety issue and better
understand they can post tasks this way.
2022-07-04 23:34:37 +02:00
Jason Turner
0abaab6268
Update tag from v2.0.0 to v3.0.0 for cmake fetch (#429) 2022-07-01 09:15:58 +02:00
Levon
ef0f1da147
README: game_jam DisarmSelfDestruct link fixed (#425) 2022-06-26 22:52:32 +02:00
DanArmor
137f1fbf67
Add turing_cmd into the project list (#422) 2022-06-14 21:47:39 +02:00
AMS21
094d8d9d0a
Fix border charset array being to large (#421)
This for some reason caused the clang compiler to crash, while also
being incorrect as the tables are actually only 5x6.

See the LLVM issue here:
https://github.com/llvm/llvm-project/issues/56016
2022-06-14 21:03:03 +02:00
Arthur Sonzogni
81e086788d
Avoid making new allocation to clear the screen. (#420)
Previously, a new 2D vector was allocated for every new frame. This
caused a lot of temporary allocation to be made.

This patch modify "Screen::Clear" so that it do make a new allocation,
but clear the existing one instead.

Bug:https://github.com/ArthurSonzogni/FTXUI/issues/290#issuecomment-1153327251
2022-06-13 21:49:36 +02:00
Arthur Sonzogni
925a7578d4
Feature: the Modal component. (#418) 2022-06-12 17:08:22 +02:00
Vebjørn Johansen Rognli
bb3231695f
Set includes as system interface to suppress warnings for other users (#415)
Set includes as system interface to suppress warnings for other users

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2022-06-11 18:39:07 +02:00
Jian De
0a522488a7
Add beagle-config into the project list (#412) 2022-06-05 18:07:20 +02:00
Jhon Adams
b63aa9e375
Swap incorrect width/height mapping (#409)
width and height were being set using the incorrect axes resulting in incorrect canvas dimensions

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2022-06-01 21:13:39 +02:00
Arthur Sonzogni
ed5b4cec49
Fix: Forward gridbox selected box. (#408)
This was discovered in:
https://github.com/ArthurSonzogni/FTXUI/issues/407
2022-05-28 22:35:52 +02:00
Amin Yahyaabadi
219daf46ff
ci: use gcovr 5.0 temporarily (#406) 2022-05-23 17:34:07 +02:00
Arthur Sonzogni
11519ef1c6
Fix focus vs flexbox interaction. (#405)
- Fix focus in flexbox. This required resetting the focus state at the
  beginning of the ComputeRequirement(), because it can now run several
  times.

  This resolves:https://github.com/ArthurSonzogni/FTXUI/issues/399

- Add Box::Union.

- Add a preliminary implementation of forwarding selected_box from
  within the flexbox.
2022-05-22 21:41:29 +02:00
Conner
f9256fa132
Fix PostEvent() segfault (#403)
Fix segfault when PostEvent() called on inactive screen.

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2022-05-22 15:37:27 +02:00
Arthur Sonzogni
c033ca61ae
Remove NXXM. Execute IWYU. (#397) 2022-05-08 08:44:38 +02:00
Arthur Sonzogni
a6e04b4346
Table: reset dimensions. (#396)
The table is not meant to be used to render more than once. Reset the
dimensions so that, even if it is used wrongly, this is not memory
unsafe.

This was raised by:
https://github.com/ArthurSonzogni/FTXUI/issues/381
2022-05-08 08:34:51 +02:00
SColibri
09a2c077eb
windows.h defines DrawText and shadows the function Canvas.DrawText, fix based on the solution #70 (#394)
Co-authored-by: Sebastian Carrion Ständer <sebastian.carrion@tum.de>
2022-05-04 23:39:03 +02:00
ArthurSonzogni
bc206f85da
Fix compilation error on Windows for Color::Print 2022-05-02 20:50:15 +02:00
ArthurSonzogni
e9772a0116 Update gcov options. 2022-04-28 11:32:30 +02:00
ArthurSonzogni
e4c5c7b43b Fix ButtonTest.Animate 2022-04-28 11:03:39 +02:00
ArthurSonzogni
c2e1920449 Execute IWYU. 2022-04-28 10:43:31 +02:00
ArthurSonzogni
3d56146447 Add test coverage for button, collapsible and menu. 2022-04-28 10:08:33 +02:00
ArthurSonzogni
c33e805a76 Add coverage for menu and resizable_split. 2022-04-27 23:00:29 +02:00
ArthurSonzogni
d0890f94d1 execute IWYU and add some coverage tests. 2022-04-27 18:57:48 +02:00
ArthurSonzogni
84d6e6b3dd Add additional coverage tests. 2022-04-27 14:00:46 +02:00
ArthurSonzogni
001dd0a8c3 Exclude tests from coverage. 2022-04-27 13:25:43 +02:00
ArthurSonzogni
114cbfcffd Add coverage and remove deprecated WideInput. 2022-04-27 11:33:42 +02:00
ArthurSonzogni
5ba301d316 Add coverage for terminal_input_parser. 2022-04-27 11:11:32 +02:00
Arthur Sonzogni
06ed8567b8 Add coverage for colors (extended) (#385) 2022-04-27 09:28:48 +02:00
Arthur Sonzogni
04b36df567
Coverage decorator (#384)
Add code coverage for colors and decorators.
2022-04-26 17:04:34 +02:00
Arthur Sonzogni
764c24ef40
Add code coverage support. (#378) 2022-04-17 15:47:20 +02:00
Arthur Sonzogni
b2896aba49
Add games from the gamejam 2022-04-12 23:52:35 +02:00
Arthur Sonzogni
9f610a0110
Make the focused button to take the focus inside frame. (#371)
This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/370
2022-04-03 15:04:33 +02:00
Arthur Sonzogni
aebde94352
Add clang-tidy. (#368) 2022-03-31 02:17:43 +02:00
Arthur Sonzogni
62fb6298be
Bug fixes. (#367)
- Do not draw more frames than what is needed.
- Fix MenuEntry transform state.
- Fix Canvas animated example.
2022-03-26 07:55:52 +01:00
Arthur Sonzogni
548fa51b71
Upgrade version (#363) 2022-03-20 21:14:17 +01:00
Arthur Sonzogni
1a3fcc1bd8
Improvement documentation. (#361) 2022-03-20 18:13:11 +01:00
Kefu Chai
0137d2a9ac
component/collapsible: drop unused member variable (#360)
Signed-off-by: Kefu Chai <tchaikov@gmail.com>
2022-03-20 16:04:42 +01:00
Arthur Sonzogni
c76612a3c8
Fix error with invalid float in the gauge component. (#356) 2022-03-13 22:30:05 +01:00
Arthur Sonzogni
4da63b9260
Animation (#355) 2022-03-13 18:51:46 +01:00
Kefu Chai
95c766e9e4
Component decorators (#354)
Add decorator variants for decorator components

Add the "pipe" operator for components, similar to what was done for Elements.
We are able to put something like:
```
Button(...) | Maybe(&show_button)
```

Add decorators for:
- `Maybe`
- `CatchEvent`
- `Renderer`

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2022-03-12 15:18:36 +01:00
Arthur Sonzogni
3e28fd6520
Convert \r into \n (#350)
This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/337
2022-03-04 13:23:45 +01:00
Kefu Chai
a254e36632
component/catch_event: improve the example for CatchEvent() (#351)
before this change, the example in the doxygen document for CatchEvent()
does not use the documented function. hence the example is not that
useful for developers interested in a typical usage of this function.

after this change, the example is improved to added the call to
CatchEvent(), which allows the application to the Loop() function at
user input.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
2022-03-04 13:23:31 +01:00
IsakTheHacker
9dbc23a7d4
Fix typos in README (#349) 2022-03-01 19:07:50 +01:00
Vladislav Nepogodin
3fe12b8a2f
Add cachyos-cli-installer in README (#347) 2022-02-24 14:38:28 +01:00
Arthur Sonzogni
43dd70979d
Update README.md 2022-02-21 10:27:53 +01:00
Elazar Leibovich
779c2d5b1a
Add conan as a possible packaging system. (#342) 2022-02-21 10:25:05 +01:00
Arthur Sonzogni
20f16b3984
Improve ComponentBase and Container::Tab Focusable implementations (#341)
- Provide better defaults for ComponentBase `Focusable()` and
  `ActiveChild()` methods. This resolves:
  https://github.com/ArthurSonzogni/FTXUI/issues/335

- Implement `Container::Tab` 's  `Focusable()` methods. This prevents
  the users to navigate into a tab with no interactivity.
2022-02-19 11:49:12 +01:00
ericLemanissier
f95ed885bb
Don't override PREFIX target property (#340)
PREFIX is by default "lib", which most of the libraries use.
this changes makes the library files libftxui-foo.a
as ArthurSonzogni/FTXUI#140 intended originally
2022-02-19 10:48:07 +01:00
Kefu Chai
63e8dadad9
allow passing move-only parameter to Make() (#338)
ftxui::Ref<> is used for passing Options, for instance, MenuOption,
to the corresponding component which is supposed to hold a strong
reference of it. and we can observe the events sent to the component
by setting callback(s) in the option instance passed to the owner
component.

but the callback function is not always copyable, despite that it
might be moveable.

in this change,

* Make<>() is updated to use the perfect forwarding to avoid
  enforcing its parameters to be copyable.
* Ref<> is also updated to take a rvalue reference, so we can
  move away from the contructor parameter when creating an
  instance of Ref<>() from it.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
2022-02-16 14:09:08 +01:00
Arthur Sonzogni
9b83205b3e
Fix vscroll-indicator size and offset. (#334) 2022-02-14 02:44:57 +01:00
Arthur Sonzogni
5da7b8a59a
Fix automerge in tables. (#333) 2022-02-13 11:41:31 +01:00
Arthur Sonzogni
9c4218c2a8
Support SIGTSTP and task posting. (#331)
- Add support for SIGTSTP:
https://github.com/ArthurSonzogni/FTXUI/issues/330
This

- Add support for task posting.
This allows folks to defer function execution, and execute it directly
below the main loop. The task are executed in a FIFO order.
2022-02-13 11:11:34 +01:00
Arthur Sonzogni
62747a49b6
Fix windows warning. (#332) 2022-02-13 10:51:47 +01:00
Arthur Sonzogni
8ba3698437
Gauge direction (#326)
Add `gauge` with all the different directions.

Co-authored-by: Aleksandar Brakmic <13668697+brakmic-aleksandar@users.noreply.github.com>
2022-02-06 19:17:21 +01:00
Arthur Sonzogni
7c3ca1beb5
Update README.md 2022-02-05 15:06:23 +01:00
Nikola Dućak
689d5dd299
Replace std::clamp with util::clamp and reformat the code (#321)
* Replace std::clamp with util::clamp
* Apply clang-format
* Execute ./tools/iwyu.sh

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2022-02-05 15:03:45 +01:00
Tushar Maheshwari
372d0ace4a
Add tusharpm/tiles in README (#324) 2022-02-04 13:18:34 +01:00
Arthur Sonzogni
81b7207121
Move to v2.0.0 (#315) 2022-01-22 17:58:33 +01:00
Arthur Sonzogni
6039474a26
Automerge feature. (#313)
Add the `automerge` attribute to the Pixel bit field. It controls
whether two pixels must be automerged. Defining this allows two
mergeable characters not to be merged.

This was requested by:
https://github.com/ArthurSonzogni/FTXUI/issues/285
2022-01-22 15:38:01 +01:00
Arthur Sonzogni
4267b40a68
Add collapsible into fuzzer. (#312) 2022-01-22 11:44:52 +01:00
Arthur Sonzogni
3829734fa9
Fix table separator (#311) 2022-01-21 23:02:29 +01:00
Vladislav Nepogodin
b4a655ec65
Introduce WithRestoredIO (#307)
This function allow running a callback with the terminal hooks
temporarily uninstalled.

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2022-01-19 13:38:39 +01:00
Vladislav Nepogodin
cd82fccde7
Add missing const. (#297)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2022-01-18 19:48:58 +01:00
Arthur Sonzogni
382205c057
Add Table constructor from Elements. (#310) 2022-01-16 16:46:32 +01:00
pezy
feb24b9498
Fix Clamp crash when entries_ size is zero (#306)
Run ftxui_example_homescreen on Windows, then select compiler tab, crash on origin code.

Co-authored-by: chenpeizhe <peizhe.chen@horizon.ai>
2022-01-13 01:46:09 +01:00
pezy
3dc215e6c0
Fix README link (#308)
- [Build using nxxm] is same with [Build using CMake], just remove
- fix [Build using CMake] link

Co-authored-by: chenpeizhe <peizhe.chen@horizon.ai>
2022-01-12 15:31:44 +01:00
Arthur Sonzogni
1888631bec
Main (#303)
* Refresh cursor reporting on resize.

* Fix invalid size write.

This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/302
2022-01-11 23:06:36 +01:00
Arthur Sonzogni
84299de2e1
Add json-tui as using FTXUI. 2022-01-09 22:00:45 +01:00
Arthur Sonzogni
cdd6339849
Execute IWYU (#299) 2022-01-07 11:03:54 +01:00
Andrey Zimin
358f886fab
Clamp selected_ on list resize for Radiobox/Menu/Toggle (#298)
fix: https://github.com/ArthurSonzogni/FTXUI/issues/296#issue-1092343846

When the list in Radiobox/Menu/Toggle is resized, clamp the |selected_| values so that it stays within bounds.
Clamping is executed in Render() and in OnEvent()

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2022-01-06 22:38:32 +01:00
Arthur Sonzogni
728976bdeb
Fix vscroll indicator (#295)
* Clear vscroll_indicator content before drawing it.
2022-01-05 12:04:03 +01:00
Arthur Sonzogni
fc92f52b4c
The collapsible element. (#294) 2022-01-02 15:48:56 +01:00
Man, Jianting (Meco)
071d2bc92b
improve the window size handle method (#292)
1. the default window size should be 80x24 rather than 80x25 in VT100.
2. the ioctl return value result should be checked. Some operating systems don't support TIOCGWINSZ this command.
2022-01-01 19:24:37 +01:00
Vladislav Nepogodin
d549cdabb0
Reduce amount of warnings with pedantic compiler (#291) 2022-01-01 11:40:18 +01:00
Arthur Sonzogni
aea67743d4
Canvas bug fix and documentation. (#289) 2021-12-29 16:31:27 +01:00
Arthur Sonzogni
7614bf04a6
Address felixjulianheitmann suggestions. (#288)
- Remove unused examples/dom/flexbox.cpp
- Add canvas(width, height, void(Canvas&)) method
2021-12-24 17:29:39 +01:00
Arthur Sonzogni
188cffc5f6
Add example in the README.md 2021-12-23 15:12:22 +01:00
Arthur Sonzogni
0d47dd19ab
Feature: Canvas (#287)
Draw using braille and block characters on a grid.
2021-12-23 14:17:33 +01:00
Arthur Sonzogni
7e5cd23b4c
Add focusPosition[relative](x,y) (#280)
It allows when using inside a frame, to scroll the view toward a
particular position.

This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/125
2021-12-13 11:38:31 +01:00
Arthur Sonzogni
52276c8a2b
Bugfix Input use std::string (#279)
Use std::string by default for the implementation of FTXUI's input
component.

Along the way:
- Give a correct implementation for fullwidth characters.
- Add tests
- Modify the way the cursor is drawn.
2021-12-12 21:31:54 +01:00
Arthur Sonzogni
602392c43d
Implement flexbox (#277)
This implement the flexbox elements, following the HTML one.

Built from them, there is also the following elements:
- `paragraph`
- `paragraphAlignLeft`
- `paragraphAlignRight`
- `paragraphAlignCenter`
- `paragraphAlignJustify`

This is a breaking change.
2021-12-11 17:58:25 +01:00
Hassan Farooq
f7c6bf91a7
adding to projects using FTXUI list (#274)
Co-authored-by: hfarooq <hfarooq@tenstorrent.com>
2021-12-06 20:18:09 +01:00
Nikola Dućak
cecd54df42
Fix gridbox segfault (#260)
The problem was about
2021-11-17 10:16:09 +01:00
Gokulakrishnan D P
0186f8a463
added vantage in project section (#258) 2021-11-10 13:06:15 +01:00
Arthur Sonzogni
ebfb5ef3a1
Input shouldn't take focus. (#257)
This fixes:
https://github.com/ArthurSonzogni/FTXUI/issues/252
2021-11-09 20:30:27 +01:00
bogdasar1985
8f405f5054
Fix a typo (#256) 2021-11-09 12:11:45 +01:00
Arthur Sonzogni
8652280c85
Input shouldn't take focus. (#253)
This fixes:
https://github.com/ArthurSonzogni/FTXUI/issues/252
2021-11-07 12:01:17 +01:00
Arthur Sonzogni
aa6b78b8ad
Upgrade version to 0.11.1 (#246)
A minor new version. Mostly for packaging the library in Release mode.
2021-10-23 21:13:23 +02:00
Arthur Sonzogni
c0e47aecb2
Remove unused file. (#244)
It was added mistakenly in:
https://github.com/ArthurSonzogni/FTXUI/pull/214#pullrequestreview-786773967
but @robinlinden found it.
2021-10-22 18:10:11 +02:00
Kevin Brennan
cba11151b5
Fix Windows builds not being in Release mode (#245) 2021-10-22 18:06:19 +02:00
Arthur Sonzogni
f80d9b5cfd
Fix dropdown fuzzer. (#243) 2021-10-22 14:04:07 +02:00
Arthur Sonzogni
313ce9c35f
Add support for PageUp/PageDown/Home/End buttons. (#242)
See:
https://github.com/ArthurSonzogni/FTXUI/issues/241
2021-10-20 21:15:40 +02:00
Arthur Sonzogni
4188ee2c04
Merge workflows. (#234)
- Merge all the workflows into one file.
- Produce Windows and MacOS artifact.
2021-10-17 20:10:07 +02:00
Arthur Sonzogni
026a005753
Table (#229)
This class allows rendering stylized table.
2021-10-15 23:04:11 +02:00
Jarosław Pelczar
7298636e7c
Add API to set terminal fallback size (#230)
In case of embedded systems, the terminal size may not
always be detectable (e.g. in case of serial output).
Allow application to set up the default size in case
autodetection fails. On platform such as Emscripten,
there is only "fallback" size.

Signed-off-by: Jarosław Pelczar <jarek@jpelczar.com>
2021-10-13 13:44:30 +02:00
tomvg
5e199fcd85
Include <algorithm> for std::max for msvc 2017, (#226)
Msvc defined its own (lowercase) macros for min/max. Because of this, the std::min and std::max functions need to be explicitly included or otherwise are not availible.
In the msvc 2019 compiler this issue seems fixed. However, on msvc 2017 not including <algorithm> causes compilation errors. Adding the include is a simple fix that does not hurt the other platforms and enables compilation on msvc 2017.
2021-10-12 11:36:19 +02:00
Arthur Sonzogni
57a5512a22
Support dynamic library. (#225)
- Let the global `BUILD_SHARED_LIBS` dictates whether the library should
  be built statically or dynamically. The cmake's default is statically.
- Add library version and symlink.

This lead to the following install tree.
.
├── include
│   └── ftxui
│       ├── component [...]
│       ├── dom [...]
│       ├── screen [...]
│       └── util [...]
└── lib
    ├── cmake
    │   └── ftxui
    │       ├── ftxui-config.cmake
    │       ├── ftxui-config-version.cmake
    │       └── ftxui-config-version-noconfig.cmake
    ├── ftxui-component.so -> ftxui-component.so.0.10.369
    ├── ftxui-component.so.0.10.369
    ├── ftxui-dom.so -> ftxui-dom.so.0.10.369
    ├── ftxui-dom.so.0.10.369
    ├── ftxui-screen.so -> ftxui-screen.so.0.10.369
    └── ftxui-screen.so.0.10.369

Fixed: https://github.com/ArthurSonzogni/FTXUI/issues/223
2021-10-10 12:52:34 +02:00
Jarosław Pelczar
75482d82d4
Use sensible defaults in case TIOCGWINSZ fails (#224)
This can happen for example in embedded linux, in case
the application is started via serial terminal.

Signed-off-by: Jarosław Pelczar <jarek@jpelczar.com>
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2021-10-09 11:51:00 +02:00
Arthur Sonzogni
31c26c6956
Update README.md 2021-10-08 14:12:27 +02:00
ArthurSonzogni
6dd626a79a Fix: Add separator(Pixel) back.
It was removed by mistacke previously.
Take the opportunity to create new documentation.
2021-10-03 10:45:47 +02:00
ArthurSonzogni
05fc866d74 Do not trigger the CQ twice on pull request. 2021-09-30 21:44:29 +02:00
ArthurSonzogni
46f481ded7 Submit release as draft.
This will let me time to add a description.
2021-09-30 21:42:52 +02:00
308 changed files with 27205 additions and 5198 deletions

9
.bcr/README.md Normal file
View File

@ -0,0 +1,9 @@
# Bazel Central Registry
When the ruleset is released, we want it to be published to the
Bazel Central Registry automatically:
<https://registry.bazel.build>
This folder contains configuration files to automate the publish step.
See <https://github.com/bazel-contrib/publish-to-bcr/blob/main/templates/README.md>
for authoritative documentation about these files.

View File

@ -0,0 +1,16 @@
{
"homepage": "https://github.com/ArthurSonzogni/FTXUI",
"maintainers": [
{
"name": "Arthur Sonzogni",
"email": "sonzogniarthur@gmail.com",
"github": "ArthurSonzogni",
"github_user_id": 4759106
}
],
"repository": [
"github:ArthurSonzogni/FTXUI"
],
"versions": [],
"yanked_versions": {}
}

21
.bcr/presubmit.yml Normal file
View File

@ -0,0 +1,21 @@
matrix:
platform:
- centos7
- debian10
- ubuntu2004
- macos
- windows
bazel: [6.x, 7.x, 8.x]
tasks:
verify_targets:
name: Build and test.
platform: ${{ platform }}
bazel: ${{ bazel }}
build_targets:
- '@ftxui//:ftxui'
- '@ftxui//:screen'
- '@ftxui//:dom'
- '@ftxui//:component'
test_targets:
- '@ftxui//:tests'

View File

@ -0,0 +1,5 @@
{
"integrity": "",
"strip_prefix": "",
"url": "https://github.com/ArthurSonzogni/FTXUI/releases/download/{TAG}/source.tar.gz"
}

35
.clang-tidy Normal file
View File

@ -0,0 +1,35 @@
---
Checks: "*,
-*-macro-usage,
-*-magic-numbers,
-*-narrowing-conversions
-*-unnecessary-value-param,
-*-uppercase-literal-suffix,
-abseil-*,
-altera-*,
-android-*,
-bugprone-easily-swappable-parameters,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-pro-type-union-access,
-fuchsia-*,
-google-*,
-hicpp-signed-bitwise,
-llvm*,
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-readability-avoid-const-params-in-decls,
-readability-else-after-return,
-readability-identifier-length,
-readability-implicit-bool-conversion,
-readability-non-const-parameter,
-readability-simplify-boolean-expr,
-readability-static-accessed-through-instance,
-readability-use-anyofallof,
-readability-avoid-nested-conditional-operator,
-zircon-*,
"
WarningsAsErrors: ''
HeaderFilterRegex: ''
FormatStyle: none

156
.github/workflows/build.yaml vendored Normal file
View File

@ -0,0 +1,156 @@
name: Build
on:
# On new commits to main:
push:
branches:
- main
# On pull requests:
pull_request:
branches:
- main
jobs:
test_bazel:
name: "Bazel, ${{ matrix.compiler }}, ${{ matrix.os }}"
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
compiler: gcc
- os: ubuntu-latest
compiler: llvm
- os: macos-latest
compiler: llvm
- os: macos-latest
compiler: gcc
- os: windows-latest
compiler: cl
runs-on: ${{ matrix.os }}
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
- name: "Build with Bazel"
run: bazel build ...
- name: "Tests with Bazel"
run: bazel run tests
test_cmake:
name: "CMake, ${{ matrix.compiler }}, ${{ matrix.os }}"
strategy:
fail-fast: false
matrix:
include:
- name: Linux GCC
os: ubuntu-latest
compiler: gcc
- name: Linux Clang
os: ubuntu-latest
compiler: llvm
gcov_executable: "llvm-cov gcov"
- name: MacOS clang
os: macos-latest
compiler: llvm
gcov_executable: "llvm-cov gcov"
- name: Windows MSVC
os: windows-latest
compiler: cl
runs-on: ${{ matrix.os }}
steps:
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
id: cpu-cores
- name: "Checkout repository"
uses: actions/checkout@v3
- name: "Setup Cpp"
uses: aminya/setup-cpp@v1
with:
compiler: ${{ matrix.compiler }}
vcvarsall: ${{ contains(matrix.os, 'windows' )}}
cmake: true
ninja: true
clangtidy: false
cppcheck: false
gcovr: "5.0"
opencppcoverage: true
# make sure coverage is only enabled for Debug builds, since it sets -O0
# to make sure coverage has meaningful results
- name: "Configure CMake"
run: >
cmake -S .
-B ./build
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_BUILD_PARALLEL_LEVEL=${{ steps.cpu-cores.outputs.count }}
-DFTXUI_ENABLE_COVERAGE:BOOL=ON
-DFTXUI_BUILD_DOCS:BOOL=OFF
-DFTXUI_BUILD_EXAMPLES:BOOL=ON
-DFTXUI_BUILD_TESTS:BOOL=ON
-DFTXUI_BUILD_TESTS_FUZZER:BOOL=OFF
-DFTXUI_ENABLE_INSTALL:BOOL=ON
-DFTXUI_DEV_WARNINGS:BOOL=ON ;
- name: "Build"
run: >
cmake
--build ./build
- name: Unix - Test
if: runner.os != 'Windows'
working-directory: ./build
run: >
ctest -C Debug --rerun-failed --output-on-failure;
- name: Unix - coverage
if: matrix.gcov_executable != ''
working-directory: ./build
run: >
gcovr
-j ${{env.nproc}}
--delete
--root ../
--exclude "../examples"
--exclude ".*google.*"
--exclude ".*test.*"
--exclude-unreachable-branches
--exclude-throw-branches
--sort-uncovered
--print-summary
--xml-pretty
--xml
coverage.xml
.
--gcov-executable '${{ matrix.gcov_executable }}';
- name: Windows - Test and coverage
if: runner.os == 'Windows'
working-directory: ./build
run: >
OpenCppCoverage.exe
--export_type cobertura:coverage.xml
--cover_children
--
ctest -C Debug --rerun-failed --output-on-failure;
- name: Publish to codecov
uses: codecov/codecov-action@v3
with:
flags: ${{ runner.os }}
name: ${{ runner.os }}-coverage
files: ./build/coverage.xml

View File

@ -1,71 +0,0 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '38 7 * * 4'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

60
.github/workflows/documentation.yaml vendored Normal file
View File

@ -0,0 +1,60 @@
name: Documentation
on:
# On new commits to main:
push:
branches:
- main
jobs:
documentation:
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
- name: "Install cmake"
uses: lukka/get-cmake@latest
- name: "Install emsdk"
uses: mymindstorm/setup-emsdk@v7
- name: "Install Doxygen/Graphviz"
run: >
sudo apt-get update;
sudo apt-get install doxygen graphviz;
- name: "Build documentation"
run: >
mkdir build;
cd build;
emcmake cmake ..
-DCMAKE_BUILD_TYPE=Release
-DFTXUI_BUILD_DOCS=ON
-DFTXUI_BUILD_EXAMPLES=ON
-DFTXUI_BUILD_TESTS=OFF
-DFTXUI_BUILD_TESTS_FUZZER=OFF
-DFTXUI_ENABLE_INSTALL=OFF
-DFTXUI_DEV_WARNINGS=ON ;
cmake --build . --target doc;
cmake --build . ;
rsync -amv
--include='*/'
--include='*.html'
--include='*.css'
--include='*.mjs'
--include='*.js'
--include='*.wasm'
--exclude='*'
examples
doc/doxygen/html;
- name: "Deploy"
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: build/doc/doxygen/html/
enable_jekyll: false
allow_empty_commit: false
force_orphan: true
publish_branch: gh-pages

View File

@ -1,27 +0,0 @@
name: Linux Clang
on:
- pull_request
- push
jobs:
build:
name: Linux Clang
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: seanmiddleditch/gha-setup-ninja@master
- name: Build
run: >
mkdir build;
cd build;
cmake ..
-DCMAKE_CXX_COMPILER=clang++
-DFTXUI_BUILD_TESTS=ON;
cmake --build . --config Release;
- name: Tests
if: ${{ matrix.config.test }}
run: >
cd build;
./tests

View File

@ -1,47 +0,0 @@
name: Linux Emscripten
on:
- pull_request
- push
jobs:
build:
name: Linux Emscripten
runs-on: ubuntu-latest
env:
DOCUMENTATION: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
steps:
- uses: actions/checkout@v2
- uses: seanmiddleditch/gha-setup-ninja@master
- uses: mymindstorm/setup-emsdk@v7
- name: Install Doxygen/Graphviz
if: fromJSON(env.DOCUMENTATION)
run: |
sudo apt-get update
sudo apt-get install doxygen graphviz
- name: Build
run: |
emcmake cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -S . -B build
cmake --build build
- name: Build documentation
if: fromJSON(env.DOCUMENTATION)
run: |
cd build
cmake --build . --target doc
# Copy emscripten built examples to the doxygen output directory for deployment
rsync -amv --include='*/' --include='*.html' --include='*.js' --include='*.wasm' --exclude='*' examples doc/doxygen/html
# Deploy the HTML documentation to GitHub Pages
- name: GH Pages Deployment
if: fromJSON(env.DOCUMENTATION)
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: build/doc/doxygen/html/
enable_jekyll: false
allow_empty_commit: false
force_orphan: true
publish_branch: gh-pages

View File

@ -1,26 +0,0 @@
name: Linux GCC
on:
- pull_request
- push
jobs:
build:
name: Linux GCC
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: seanmiddleditch/gha-setup-ninja@master
- name: Build
run: >
mkdir build;
cd build;
cmake ..
-DCMAKE_CXX_COMPILER=g++-9
-DFTXUI_BUILD_TESTS=ON;
cmake --build . --config Release;
- name: Tests
run: >
cd build;
./tests

View File

@ -1,27 +0,0 @@
name: MacOS Clang
on:
- pull_request
- push
jobs:
build:
name: MacOS Clang
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: seanmiddleditch/gha-setup-ninja@master
- name: Build
run: >
mkdir build;
cd build;
cmake ..
-DCMAKE_CXX_COMPILER=clang++
-DFTXUI_BUILD_TESTS=ON;
cmake --build . --config Release;
- name: Tests
if: ${{ matrix.config.test }}
run: >
cd build;
./tests

24
.github/workflows/publish.yaml vendored Normal file
View File

@ -0,0 +1,24 @@
name: "Publish to Bazel Central Registry"
on:
# Manual kick-off (you type the tag)
workflow_dispatch:
inputs:
tag_name:
description: "Tag to publish"
required: true
type: string
permissions:
contents: write
jobs:
publish:
uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v0.0.4
with:
tag_name: ${{ github.event.inputs.tag_name }}
registry_fork: ArthurSonzogni/bazel-central-registry
attest: false
secrets:
publish_token: ${{ secrets.PUBLISH_TOKEN }}

View File

@ -1,39 +1,100 @@
name: Release
on:
create:
# On push to a tag:
push:
tags:
-v*
- 'v*'
# On manual trigger:
workflow_dispatch:
permissions:
# Needed to mint attestations
id-token: write
attestations: write
# Needed to upload release assets
contents: write
jobs:
build:
name: Release
release:
name: "Create release"
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v2
- name: "Create release"
uses: softprops/action-gh-release@v1
id: create_release
with:
fetch-depth: 0
draft: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: seanmiddleditch/gha-setup-ninja@master
# Build artifact for the release
package_compiled:
name: "Build packages"
needs: release
strategy:
matrix:
include:
- os: ubuntu-latest
asset_path: build/ftxui*Linux*
- os: macos-latest
asset_path: build/ftxui*Darwin*
- os: windows-latest
asset_path: build/ftxui*Win64*
runs-on: ${{ matrix.os }}
steps:
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
id: cpu-cores
- name: Build
- name: "Checkout repository"
uses: actions/checkout@v3
- name: "Install cmake"
uses: lukka/get-cmake@latest
- name: "Build packages"
run: >
mkdir build;
cd build;
cmake ..
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_BUILD_PARALLEL_LEVEL=${{ steps.cpu-cores.outputs.count }}
-DFTXUI_BUILD_DOCS=OFF
-DFTXUI_BUILD_EXAMPLES=OFF
-DFTXUI_BUILD_TESTS=OFF
-DFTXUI_BUILD_TESTS_FUZZER=OFF
-DFTXUI_ENABLE_INSTALL=ON;
cmake --build . --config Release;
make package;
-DFTXUI_ENABLE_INSTALL=ON
-DFTXUI_DEV_WARNINGS=ON ;
cmake --build . --target package;
- name: Upload
uses: softprops/action-gh-release@v1
- uses: shogo82148/actions-upload-release-asset@v1
with:
files: build/ftxui-*
draft: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ${{ matrix.asset_path }}
overwrite: true
# Build "source" artifact for the release. This is the same as the github
# "source" archive, but with a stable URL. This is useful for the Bazel
# Central Repository.
package_source:
name: "Build source package"
needs: release
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
- name: "Create source package"
run: >
git archive --format=tar.gz -o source.tar.gz HEAD
- name: "Upload source package"
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: source.tar.gz
overwrite: true

View File

@ -1,28 +0,0 @@
name: Windows MSVC
on:
- pull_request
- push
jobs:
build:
name: Windows MSVC
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: seanmiddleditch/gha-setup-ninja@master
- uses: ilammy/msvc-dev-cmd@v1
- name: Build
run: >
mkdir build;
cd build;
cmake ..
-DCMAKE_CXX_COMPILER="cl"
-DFTXUI_BUILD_TESTS=ON;
cmake --build . --config Release;
- name: Tests
if: ${{ matrix.config.test }}
run: >
cd build;
./tests.exe

70
.gitignore vendored Normal file
View File

@ -0,0 +1,70 @@
# Ignore all the files, except the ones we expect.
# See https://jasonstitt.com/gitignore-whitelisting-patterns
*
!*/
# Ignore build directories generated by default MSVC CMake integration
# (otherwise causes terribly slow indexing)
out/
# Allowed top-level files:
!.clang-format
!.clang-tidy
!.gitignore
!CHANGELOG.md
!CMakeLists.txt
!LICENSE
!README.md
!codecov.yml
!flake.lock
!flake.nix
!ftxui.pc.in
!iwyu.imp
!WORKSPACE.bazel
!BUILD.bazel
!MODULE.bazel
!.bazelrc
# .github directory:
!.github/**/*.yaml
!.github/**/*.yml
# cmake directory:
!cmake/**/*.in
!cmake/**/*.cmake
# bazel directory:
!bazel/**/*.bzl
!.bcr/*
# doc directory:
!doc/**/Doxyfile.in
!doc/**/*.txt
!doc/**/*.css
!doc/**/*.html
!doc/**/*.xml
!doc/**/*.md
# examples directory:
!examples/**/*.cpp
!examples/**/*.css
!examples/**/*.hpp
!examples/**/*.html
!examples/**/*.html.disabled
!examples/**/*.ipp
!examples/**/*.js
!examples/**/*.mjs
!examples/**/*.py
!examples/**/*.txt
# include directory:
!include/ftxui/**/*.hpp
!include/ftxui/**/*.cpp
# src directory:
!src/ftxui/**/*.hpp
!src/ftxui/**/*.cpp
# tools directory:
!tools/**/*.sh
!tools/**/*.cpp

View File

@ -1,5 +0,0 @@
{
"platform": [
"GTest::+gtest"
]
}

251
BUILD.bazel Normal file
View File

@ -0,0 +1,251 @@
# 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.
# TODO:
# - Build benchmark.
# - Build fuzzers.
# - Build documentation.
# - Enable the two tests timing out.
# - Support WebAssembly
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load(":bazel/ftxui.bzl", "ftxui_cc_library")
load(":bazel/ftxui.bzl", "generate_examples")
load(":bazel/ftxui.bzl", "cpp20")
load(":bazel/ftxui.bzl", "windows_copts")
load(":bazel/ftxui.bzl", "pthread_linkopts")
package(default_visibility = ["//visibility:public"])
# A meta target that depends on all the ftxui sub modules.
alias(
name = "ftxui",
# Note that :component depends on :dom, which depends on :screen. Bazel
# doesn't really support "public" and "private" dependencies. They are all
# public. This is equivalent to depending on all the submodules.
actual = ":component",
visibility = ["//visibility:public"],
)
# ftxui:screen is a module that provides a screen buffer and color management
# for terminal applications. A screen is a 2D array of cells, each cell can
# contain a glyph, a color, and other attributes. The library also provides
# functions to manipulate the screen.
ftxui_cc_library(
name = "screen",
srcs = [
"src/ftxui/screen/box.cpp",
"src/ftxui/screen/color.cpp",
"src/ftxui/screen/color_info.cpp",
"src/ftxui/screen/image.cpp",
"src/ftxui/screen/screen.cpp",
"src/ftxui/screen/string.cpp",
"src/ftxui/screen/string_internal.hpp",
"src/ftxui/screen/terminal.cpp",
"src/ftxui/screen/util.hpp",
],
hdrs = [
"include/ftxui/screen/box.hpp",
"include/ftxui/screen/color.hpp",
"include/ftxui/screen/color_info.hpp",
"include/ftxui/screen/deprecated.hpp",
"include/ftxui/screen/image.hpp",
"include/ftxui/screen/pixel.hpp",
"include/ftxui/screen/screen.hpp",
"include/ftxui/screen/string.hpp",
"include/ftxui/screen/terminal.hpp",
"include/ftxui/util/autoreset.hpp",
"include/ftxui/util/ref.hpp",
],
)
# ftxui:dom is a library that provides a way to create and manipulate a
# "document" that can be rendered to a screen. The document is a tree of nodes.
# Nodes can be text, layouts, or various decorators. Users needs to compose
# nodes to create a document. A document is responsive to the size of the
# screen.
ftxui_cc_library(
name = "dom",
srcs = [
"src/ftxui/dom/automerge.cpp",
"src/ftxui/dom/blink.cpp",
"src/ftxui/dom/bold.cpp",
"src/ftxui/dom/border.cpp",
"src/ftxui/dom/box_helper.cpp",
"src/ftxui/dom/box_helper.hpp",
"src/ftxui/dom/canvas.cpp",
"src/ftxui/dom/clear_under.cpp",
"src/ftxui/dom/color.cpp",
"src/ftxui/dom/composite_decorator.cpp",
"src/ftxui/dom/dbox.cpp",
"src/ftxui/dom/dim.cpp",
"src/ftxui/dom/flex.cpp",
"src/ftxui/dom/flexbox.cpp",
"src/ftxui/dom/flexbox_config.cpp",
"src/ftxui/dom/flexbox_helper.cpp",
"src/ftxui/dom/flexbox_helper.hpp",
"src/ftxui/dom/focus.cpp",
"src/ftxui/dom/frame.cpp",
"src/ftxui/dom/gauge.cpp",
"src/ftxui/dom/graph.cpp",
"src/ftxui/dom/gridbox.cpp",
"src/ftxui/dom/hbox.cpp",
"src/ftxui/dom/hyperlink.cpp",
"src/ftxui/dom/inverted.cpp",
"src/ftxui/dom/italic.cpp",
"src/ftxui/dom/linear_gradient.cpp",
"src/ftxui/dom/node.cpp",
"src/ftxui/dom/node_decorator.cpp",
"src/ftxui/dom/node_decorator.hpp",
"src/ftxui/dom/paragraph.cpp",
"src/ftxui/dom/reflect.cpp",
"src/ftxui/dom/scroll_indicator.cpp",
"src/ftxui/dom/selection.cpp",
"src/ftxui/dom/selection_style.cpp",
"src/ftxui/dom/separator.cpp",
"src/ftxui/dom/size.cpp",
"src/ftxui/dom/spinner.cpp",
"src/ftxui/dom/strikethrough.cpp",
"src/ftxui/dom/table.cpp",
"src/ftxui/dom/text.cpp",
"src/ftxui/dom/underlined.cpp",
"src/ftxui/dom/underlined_double.cpp",
"src/ftxui/dom/util.cpp",
"src/ftxui/dom/vbox.cpp",
],
hdrs = [
"include/ftxui/dom/canvas.hpp",
"include/ftxui/dom/deprecated.hpp",
"include/ftxui/dom/direction.hpp",
"include/ftxui/dom/elements.hpp",
"include/ftxui/dom/flexbox_config.hpp",
"include/ftxui/dom/linear_gradient.hpp",
"include/ftxui/dom/node.hpp",
"include/ftxui/dom/requirement.hpp",
"include/ftxui/dom/selection.hpp",
"include/ftxui/dom/table.hpp",
"include/ftxui/dom/take_any_args.hpp",
],
deps = [":screen"],
)
# ftxui:component is a library to create "dynamic" component renderering and
# updating a ftxui::dom document on the screen. It is a higher level API than
# ftxui:dom.
#
# The module is required if your program needs to respond to user input. It
# defines a set of ftxui::Component. These components can be utilized to
# navigate using the arrow keys and/or cursor. There are several builtin widgets
# like checkbox/inputbox/etc to interact with. You can combine them, or even
# define your own custom components.
ftxui_cc_library(
name = "component",
srcs = [
"src/ftxui/component/animation.cpp",
"src/ftxui/component/button.cpp",
"src/ftxui/component/catch_event.cpp",
"src/ftxui/component/checkbox.cpp",
"src/ftxui/component/collapsible.cpp",
"src/ftxui/component/component.cpp",
"src/ftxui/component/component_options.cpp",
"src/ftxui/component/container.cpp",
"src/ftxui/component/dropdown.cpp",
"src/ftxui/component/event.cpp",
"src/ftxui/component/hoverable.cpp",
"src/ftxui/component/input.cpp",
"src/ftxui/component/loop.cpp",
"src/ftxui/component/maybe.cpp",
"src/ftxui/component/menu.cpp",
"src/ftxui/component/modal.cpp",
"src/ftxui/component/radiobox.cpp",
"src/ftxui/component/renderer.cpp",
"src/ftxui/component/resizable_split.cpp",
"src/ftxui/component/screen_interactive.cpp",
"src/ftxui/component/slider.cpp",
"src/ftxui/component/terminal_input_parser.cpp",
"src/ftxui/component/terminal_input_parser.hpp",
"src/ftxui/component/util.cpp",
"src/ftxui/component/window.cpp",
],
hdrs = [
"include/ftxui/component/animation.hpp",
"include/ftxui/component/captured_mouse.hpp",
"include/ftxui/component/component.hpp",
"include/ftxui/component/component_base.hpp",
"include/ftxui/component/component_options.hpp",
"include/ftxui/component/event.hpp",
"include/ftxui/component/loop.hpp",
"include/ftxui/component/mouse.hpp",
"include/ftxui/component/receiver.hpp",
"include/ftxui/component/screen_interactive.hpp",
"include/ftxui/component/task.hpp",
],
linkopts = pthread_linkopts(),
deps = [":dom"],
)
# FTXUI's tests
cc_test(
name = "tests",
testonly = True,
srcs = [
"src/ftxui/component/animation_test.cpp",
"src/ftxui/component/button_test.cpp",
"src/ftxui/component/collapsible_test.cpp",
"src/ftxui/component/component_test.cpp",
"src/ftxui/component/container_test.cpp",
"src/ftxui/component/dropdown_test.cpp",
"src/ftxui/component/hoverable_test.cpp",
"src/ftxui/component/input_test.cpp",
"src/ftxui/component/menu_test.cpp",
"src/ftxui/component/modal_test.cpp",
"src/ftxui/component/radiobox_test.cpp",
"src/ftxui/component/receiver_test.cpp",
"src/ftxui/component/resizable_split_test.cpp",
"src/ftxui/component/slider_test.cpp",
"src/ftxui/component/terminal_input_parser_test.cpp",
"src/ftxui/component/terminal_input_parser_test_fuzzer.cpp",
"src/ftxui/component/toggle_test.cpp",
"src/ftxui/dom/blink_test.cpp",
"src/ftxui/dom/bold_test.cpp",
"src/ftxui/dom/border_test.cpp",
"src/ftxui/dom/canvas_test.cpp",
"src/ftxui/dom/color_test.cpp",
"src/ftxui/dom/dbox_test.cpp",
"src/ftxui/dom/dim_test.cpp",
"src/ftxui/dom/flexbox_helper_test.cpp",
"src/ftxui/dom/flexbox_test.cpp",
"src/ftxui/dom/gauge_test.cpp",
"src/ftxui/dom/gridbox_test.cpp",
"src/ftxui/dom/hbox_test.cpp",
"src/ftxui/dom/hyperlink_test.cpp",
"src/ftxui/dom/italic_test.cpp",
"src/ftxui/dom/linear_gradient_test.cpp",
"src/ftxui/dom/scroll_indicator_test.cpp",
"src/ftxui/dom/separator_test.cpp",
"src/ftxui/dom/spinner_test.cpp",
"src/ftxui/dom/table_test.cpp",
"src/ftxui/dom/text_test.cpp",
"src/ftxui/dom/underlined_test.cpp",
"src/ftxui/dom/vbox_test.cpp",
"src/ftxui/screen/color_test.cpp",
"src/ftxui/screen/string_test.cpp",
"src/ftxui/util/ref_test.cpp",
# TODO: Enable the two tests timing out with Bazel:
# - "src/ftxui/component/screen_interactive_test.cpp",
# - "src/ftxui/dom/selection_test.cpp",
],
includes = [
"include",
"src",
],
copts = cpp20() + windows_copts(),
deps = [
"//:ftxui",
"@googletest//:gtest_main",
],
)
generate_examples()

View File

@ -1,20 +1,428 @@
# Changelog
Changelog
=========
## Current
Future release
------------
## 0.10 (2021-09-30)
### dom
- Bugfix: Restore the `dbox` behavior from ftxui 5.0.0. To apply bgcolor
blending between the two layers, a new `dboxBlend` will be added.
6.1.8 (2025-05-01)
------------------
### Build
- Feature: Support `bazel` build system. See #1032.
Proposed by Kostya Serebryany @kcc
If all goes well (pending), it should appear in the Bazel central repository.
It can be imported into your project using the following lines:
**MODULE.bazel**
```bazel
bazel_dep(name = "ftxui", version = "6.1.8")
```
**BUILD.bazel**
```bazel
deps = [
// Depend on the whole library:
"@ftxui//:ftxui",
// Choose a specific submodule:
"@ftxui//:component",
"@ftxui//:dom",
"@ftxui//:screen",
]
```
### Component
- Bugfix: Fix a crash with ResizeableSplit. See #1023.
- Clamp screen size to terminal size.
- Disallow `ResizeableSplit` with negative size.
### Dom
- Bugfix: Disallow specifying a negative size constraint. See #1023.
6.0.2 (2025-03-30)
-----
### Component
- BugFix: Fix major crash on Windows affecting all components. See #1020
- BugFix: Fix focusRelative.
6.0.1 (2025-03-28)
-----
Same as v6.0.0.
Due to a problem tag v6.0.0 was replaced. This isn't a good practice and affect
developers that started using it in the short timeframe. Submitting a new
release with the same content is the best way to fix this.
See #1017 and #1019.
6.0.0 (2025-03-23)
-----
### Component
- Feature: Add support for raw input. Allowing more keys to be detected.
- Feature: Add `ScreenInteractive::ForceHandleCtrlC(false)` to allow component
to fully override the default `Ctrl+C` handler.
- Feature: Add `ScreenInteractive::ForceHandleCtrlZ(false)` to allow component
to fully override the default `Ctrl+Z` handler.
- Feature: Add `Mouse::WeelLeft` and `Mouse::WeelRight` events on supported
terminals.
- Feature: Add `Event::DebugString()`.
- Feature: Add support for `Input`'s insert mode. Add `InputOption::insert`
option. Added by @mingsheng13.
- Feature: Add `DropdownOption` to configure the dropdown. See #826.
- Feature: Add support for Selection. Thanks @clement-roblot. See #926.
- See `ScreenInteractive::GetSelection()`.
- See `ScreenInteractive::SelectionChange(...)` listener.
- Bugfix/Breaking change: `Mouse transition`:
- Detect when the mouse move, as opposed to being pressed.
The Mouse::Moved motion was added.
- Dragging the mouse with the left button pressed now avoids activating
multiple checkboxes.
- A couple of components are now activated when the mouse is pressed,
as opposed to being released.
This fixes: https://github.com/ArthurSonzogni/FTXUI/issues/773
This fixes: https://github.com/ArthurSonzogni/FTXUI/issues/792
- Bugfix: mouse.control is now reported correctly.
- Feature: Add `ScreenInteractive::FullscreenPrimaryScreen()`. This allows
displaying a fullscreen component on the primary screen, as opposed to the
alternate screen.
- Bugfix: `Input` `onchange` was not called on backspace or delete key.
Fixed by @chrysante in chrysante in PR #776.
- Bugfix: Propertly restore cursor shape on exit. See #792.
- Bugfix: Fix cursor position in when in the last column. See #831.
- Bugfix: Fix `ResizeableSplit` keyboard navigation. Fixed by #842.
- Bugfix: Fix `Menu` focus. See #841
- Feature: Add `ComponentBase::Index()`. This allows to get the index of a
component in its parent. See #932
- Feature: Add `EntryState::index`. This allows to get the index of a menu entry.
See #932
- Feature: Add `SliderOption::on_change`. This allows to set a callback when the
slider value changes. See #938.
- Bugfix: Handle `Dropdown` with no entries.
- Bugfix: Fix crash in `LinearGradient` due to float precision and an off-by-one
mistake. See #998.
### Dom
- Feature: Add `italic` decorator. For instance:
```cpp
auto italic_text = text("Italic text") | italic;
```
```cpp
auto italic_text = italic(text("Italic text"));
```
Proposed by @kenReneris in #1009.
- Feature: Add `hscroll_indicator`. It display an horizontal indicator
reflecting the current scroll position. Proposed by @ibrahimnasson in
[issue 752](https://github.com/ArthurSonzogni/FTXUI/issues/752)
- Feature: Add `extend_beyond_screen` option to `Dimension::Fit(..)`, allowing
the element to be larger than the screen. Proposed by @LordWhiro. See #572 and
#949.
- Feature: Add support for Selection. Thanks @clement-roblot. See #926.
- See `selectionColor` decorator.
- See `selectionBackgroundColor` decorator.
- See `selectionForegroundColor` decorator.
- See `selectionStyle(style)` decorator.
- See `selectionStyleReset` decorator.
- Breaking change: Change how "focus"/"select" are handled. This fixes the
behavior.
- Breaking change: `Component::OnRender()` becomes the method to override to
render a component. This replaces `Component::Render()` that is still in use
to call the rendering method on the children. This change allows to fix a
couple of issues around focus handling.
### Screen
- Feature: Add `Box::IsEmpty()`.
- Feature: Color transparency
- Add `Color::RGBA(r,g,b,a)`.
- Add `Color::HSVA(r,g,b,a)`.
- Add `Color::Blend(Color)`.
- Add `Color::IsOpaque()`
### Util
- Feature: Support arbitrary `Adapter` for `ConstStringListRef`. See #843.
### Build
- Support for cmake's "unity/jumbo" builds. Fixed by @ClausKlein.
5.0.0
-----
### Component
- Breaking: MenuDirection enum is renamed Direction
- Breaking: GaugeDirection enum is renamed Direction
- Breaking: Direction enum is renamed WidthOrHeight
- Breaking: Remove `ComponentBase` copy constructor/assignment.
- Breaking: MenuOption::entries is renamed MenuOption::entries_option.
- Breaking: `Ref<{Component}Option>` becomes `{Component}Option` in component constructors.
- Feature: `ResizeableSplit` now support arbitrary element as a separator.
- Feature: `input` is now supporting multiple lines.
- Feature: `input` style is now customizeable.
- Bugfix: Support F1-F5 from OS terminal.
- Feature: Add struct based constructor:
```cpp
Component Button(ButtonOption options);
Component Checkbox(CheckboxOption options);
Component Input(InputOption options);
Component Menu(MenuOption options);
Component MenuEntry(MenuEntryOption options);
Component Radiobox(RadioboxOption options);
Component Slider(SliderOption<T> options);
Component ResizableSplit(ResizableSplitOption options);
```
- Feature: Add `ScreenInteractive::TrackMouse(false)` disable mouse support.
### Dom
- Feature: Add `hyperlink` decorator. For instance:
```cpp
auto link = text("Click here") | hyperlink("https://github.com/FTXUI")
```
See the [OSC 8 page](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda).
FTXUI support proposed by @aaleino in [#662](https://github.com/ArthurSonzogni/FTXUI/issues/662).
### Screen
- Breaking: `WordBreakProperty` becomes a uint8_t enum. This yields a 0.8%
performance improvement.
- Breaking: Remove user defined Pixel constructor and equality operator.
- Performance: 19% faster on benchmarks.
### Build
- Check version compatibility when using cmake find_package()
- Add `FTXUI_DEV_WARNING` options to turn on warnings when building FTXUI
- Turn OFF by default `FTXUI_BUILD_DOCS`
- Turn OFF by default `FTXUI_BUILD_EXAMPLE`
4.1.1
-----
### Component
- Fix: Support arrow keys in application mode
- Fix: Remove useless new line when using an alternative screen.
### Dom
- Feature: Add the dashed style for border and separator:
- See `DASHED` enum, and `separatorDashed()`, `borderDashed()` functions.
- Feature: Add colored borders.
- See functions: `borderStyled(BorderStyle, Color)` and `borderStyled(Color)`.
- Feature: Add `LinearGradient`. It can be used in `color` and `bgColor`.
- Improvement: Color::Interpolate() uses gamma correction.
- Fix: Check the `graph` area is positive.
### Build/Install
- Use globally set CMAKE_CXX_STANDARD if it is set.
- Expose the pkg-config file
- Check version compatibility when using cmake find_package()
4.1.0 (Abandonned)
-----
This version is abandonned and must not be used. It introduced a breaking change in the API.
4.0.0
-----
### DOM
- Feature: more styles:
- `strikethrough`
- `underlinedDouble`
- Feature: Customize the cursor. Add the following decorators:
- `focusCursorBlock`
- `focusCursorBlockBlinking`
- `focusCursorBar`
- `focusCursorBarBlinking`
- `focusCursorUnderline`
- `focusCursorUnderlineBlinking`
- Bugfix: Fix `focus`/`select` when the `vbox`/`hbox`/`dbox` contains a
`flexbox`
- Bugfix: Fix the selected/focused area. It used to be 1 cell larger/longer than
requested
- Bugfix: Forward the selected/focused area from the child in gridbox.
- Bugfix: Fix incorrect Canvas computed dimensions.
- Bugfix: Support `vscroll_indicator` with a zero inner size.
- Bugfix: Fix `vscroll_indicator` hidding the last column.
### Component:
- Feature: Add the `Modal` component.
- Feature: `Slider` supports taking references for all its arguments.
- Feature: `Slider` supports `SliderOption`. It supports:
- multiple directions.
- multiple colors.
- various values (value, min, max, increment).
- Feature: Define `ScreenInteractive::Exit()`.
- Feature: Add `Loop` to give developers a better control on the main loop. This
can be used to integrate FTXUI into another main loop, without taking the full
control.
- Feature: `Input` supports CTRL+Left and CTRL+Right
- Feature: Use a blinking bar in the `Input` component.
- Improvement: The `Menu` keeps the focus when an entry is selected with the
mouse.
- Bugfix: Add implementation of `ButtonOption::Border()`. It was missing.
- Bugfix: Provide the correct key for F1-F4 and F11.
- Feature: Add the `Hoverable` component decorators.
### Screen
- Feature: add `Box::Union(a,b) -> Box`
- Bugfix: Fix resetting `dim` clashing with resetting of `bold`.
- Feature: Add emscripten screen resize support.
- Bugfix: Add unicode 13 support for full width characters.
- Bugfix: Fix MSVC treating codecvt C++17 deprecated function as an error.
### Build
- Support using the google test version provided by the package manager.
3.0.0
-----
### Build
- **breaking**: The library prefix is now back to "lib" (the default). This
means non-cmake users should not link against "libftxui-dom" for instance.
### Component
- **Animations** module! Components can implement the `OnAnimation` method and
the animation::Animator to define some animated properties.
- `Menu` now support animations.
- `Button` now supports animations.
- Support SIGTSTP. (ctrl+z).
- Support task posting. `ScreenInteractive::Post(Task)`.
- `Menu` can now be used in the 4 directions, using `MenuOption.direction`.
- `Menu` can display an animated underline, using
`MenuOption.underline.enabled`.
- `Button` is now taking the focus in frame.
- **breaking** All the options are now using a transform function.
- **breaking** The `Toggle` component is now implemented using `Menu`.
- **bugfix** Container::Tab implements `Focusable()`.
- **bugfix** Improved default implementations of ComponentBase `Focusable()` and
`ActiveChild()` methods.
- **bugfix** Automatically convert '\r' keys into '\n' for Linux programs that
do not send the correct code for the return key, like the 'bind'.
https://github.com/ArthurSonzogni/FTXUI/issues/337
- Add decorator for components:
- `operator|(Component, ComponentDecorator)`
- `operator|(Component, ElementDecorator)`
- `operator|=(Component, ComponentDecorator)`
- `operator|=(Component, ElementDecorator)`
- Add the `Maybe` decorator.
- Add the `CatchEvent` decorator.
- Add the `Renderer` decorator.
- **breaking** remove the "deprectated.hpp" header and Input support for wide
string.
### DOM:
- **breaking**: The `inverted` decorator now toggle in the inverted attribute.
- Add `gauge` for the 4 directions. Expose the following API:
```cpp
Element gauge(float ratio);
Element gaugeLeft(float ratio);
Element gaugeRight(float ratio);
Element gaugeUp(float ratio);
Element gaugeDown(float ratio);
Element gaugeDirection(float ratio, GaugeDirection);
```
- Add `separatorHSelector` and `separatorVSelector` elements. This can be used
to highlight an area.
- Add the `automerge` decorator. This makes separator characters to be merged
with others nearby.
- Fix the `Table` rendering function, to allow automerging characters.
- **Bugfix**: The `vscroll_indicator` now computes its offset and size
correctly.
- Add the `operator|=(Element, Decorator)`
### Screen:
- Add: `Color::Interpolate(lambda, color_a, color_b)`.
2.0.0
-----
### Features:
#### Screen
- Add the `automerge` to the Pixel bit field. This now controls which pixels are
automatically merged.
#### DOM:
- Add the `Canvas` class and `ElementFrom('canvas')` function. Together users of
the library can draw using braille and block characters.
- Support `flexbox` dom elements. This is build symmetrically to the HTML one.
All the following attributes are supported: direction, wrap, justify-content,
align-items, align-content, gap
- Add the dom elements helper based on `flexbox`:
- `paragraph`
- `paragraphAlignLeft`
- `paragraphAlignCenter`
- `paragraphAlignRight`
- `paragraphAlignJustify`
- Add the helper elements based on `flexbox`: `hflow()`, `vflow()`.
- Add: `focusPositionRelative` and `focusPosition`
- Add `Table` constructor from 2D vector of Element, instead of string.
#### Component
- Add the `collapsible` component.
- Add the `ScreenInteractive::WithRestoredIO`. This decorates a callback. This
runs it with the terminal hooks temporarilly uninstalled. This is useful if
you want to execute command using directly stdin/stdout/sterr.
### Bug
#### Table
- The `table` horizontal and vertical separator are now correctly expanded.
#### Component
- `Input` shouldn't take focus when hovered by the mouse.
- Modifying `Input`'s during on_enter/on_change event is now working correctly.
### Breaking changes:
- The behavior of `paragraph` has been modified. It now returns en Element,
instead of a list of elements.
0.11.1
------
# Component
- Feature: Support for PageUp/PageDown/Home/End buttons.
- Bugfix: Check the selected element are within bounds for Dropdown.
# Build
- Bugfix: Package library using the "Release config". Not debug.
0.11
----
## github workflow
- Add Windows ad MacOS artefacts.
- Merge all the workflows.
## Bug
- On Unix system, fallback to {80,25} screen dimension on failure.
## CMake
- Support for shared library, via `BUILD_SHARED_LIBS` option.
- Add library version and symlinks.
0.10 (2021-09-30)
--------------------
## Bug
- Fix the automated merge of borders.
### Dom
- `vscroll_indicator`. Show a scrollbar indicator on the right.
- `Table()` class to build stylised table.
See https://github.com/ArthurSonzogni/FTXUI/discussions/228
- `vscroll_indicator`. Show a scrollbar indicator on the right.
- `separatorEmpty`. A separator drawing nothing.
- `separatorFixed`. A separator drawing the provided character.
### Component
- `Maybe`: Display an component conditionnally based on a boolean.
- `Dropdown`: A dropdown select list.
- `Maybe`: Display an component conditionnally based on a boolean.
- `Dropdown`: A dropdown select list.
## 0.9 (2021-09-26)
0.9 (2021-09-26)
----------------
The initial release where changelog where written.

View File

@ -1,17 +1,20 @@
cmake_minimum_required(VERSION 3.11)
include(cmake/ftxui_git_version.cmake)
cmake_minimum_required(VERSION 3.12)
project(ftxui
LANGUAGES CXX
VERSION 0.10.${git_version}
VERSION 6.1.8
DESCRIPTION "C++ Functional Terminal User Interface."
)
option(FTXUI_BUILD_DOCS "Set to ON to build tests" ON)
option(FTXUI_BUILD_EXAMPLES "Set to ON to build examples" ON)
option(FTXUI_QUIET "Set to ON for FTXUI to be quiet" OFF)
option(FTXUI_BUILD_EXAMPLES "Set to ON to build examples" OFF)
option(FTXUI_BUILD_DOCS "Set to ON to build docs" OFF)
option(FTXUI_BUILD_TESTS "Set to ON to build tests" OFF)
option(FTXUI_BUILD_TESTS_FUZZER "Set to ON to enable fuzzing" OFF)
option(FTXUI_ENABLE_INSTALL "Generate the install target" ON)
option(FTXUI_CLANG_TIDY "Execute clang-tidy" OFF)
option(FTXUI_ENABLE_COVERAGE "Execute code coverage" OFF)
option(FTXUI_DEV_WARNINGS "Enable more compiler warnings and warnings as errors" OFF)
set(FTXUI_MICROSOFT_TERMINAL_FALLBACK_HELP_TEXT "On windows, assume the \
terminal used will be one of Microsoft and use a set of reasonnable fallback \
@ -24,75 +27,111 @@ else()
${FTXUI_MICROSOFT_TERMINAL_FALLBACK_HELP_TEXT} OFF)
endif()
add_library(screen STATIC
src/ftxui/screen/box.cpp
src/ftxui/screen/color.cpp
src/ftxui/screen/color_info.cpp
src/ftxui/screen/screen.cpp
src/ftxui/screen/string.cpp
src/ftxui/screen/terminal.cpp
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(cmake/ftxui_message.cmake)
add_library(screen
include/ftxui/screen/box.hpp
include/ftxui/screen/color.hpp
include/ftxui/screen/color_info.hpp
include/ftxui/screen/image.hpp
include/ftxui/screen/pixel.hpp
include/ftxui/screen/screen.hpp
include/ftxui/screen/string.hpp
src/ftxui/screen/box.cpp
src/ftxui/screen/color.cpp
src/ftxui/screen/color_info.cpp
src/ftxui/screen/image.cpp
src/ftxui/screen/screen.cpp
src/ftxui/screen/string.cpp
src/ftxui/screen/terminal.cpp
src/ftxui/screen/util.hpp
)
add_library(dom STATIC
add_library(dom
include/ftxui/dom/canvas.hpp
include/ftxui/dom/direction.hpp
include/ftxui/dom/elements.hpp
include/ftxui/dom/flexbox_config.hpp
include/ftxui/dom/node.hpp
include/ftxui/dom/requirement.hpp
include/ftxui/dom/selection.hpp
include/ftxui/dom/take_any_args.hpp
src/ftxui/dom/automerge.cpp
src/ftxui/dom/selection_style.cpp
src/ftxui/dom/blink.cpp
src/ftxui/dom/bold.cpp
src/ftxui/dom/border.cpp
src/ftxui/dom/box_helper.cpp
src/ftxui/dom/box_helper.hpp
src/ftxui/dom/canvas.cpp
src/ftxui/dom/clear_under.cpp
src/ftxui/dom/color.cpp
src/ftxui/dom/composite_decorator.cpp
src/ftxui/dom/dbox.cpp
src/ftxui/dom/dim.cpp
src/ftxui/dom/flex.cpp
src/ftxui/dom/flexbox.cpp
src/ftxui/dom/flexbox_config.cpp
src/ftxui/dom/flexbox_helper.cpp
src/ftxui/dom/flexbox_helper.hpp
src/ftxui/dom/focus.cpp
src/ftxui/dom/frame.cpp
src/ftxui/dom/gauge.cpp
src/ftxui/dom/graph.cpp
src/ftxui/dom/gridbox.cpp
src/ftxui/dom/hbox.cpp
src/ftxui/dom/hflow.cpp
src/ftxui/dom/hyperlink.cpp
src/ftxui/dom/inverted.cpp
src/ftxui/dom/italic.cpp
src/ftxui/dom/linear_gradient.cpp
src/ftxui/dom/node.cpp
src/ftxui/dom/node_decorator.cpp
src/ftxui/dom/paragraph.cpp
src/ftxui/dom/reflect.cpp
src/ftxui/dom/scroll_indicator.cpp
src/ftxui/dom/selection.cpp
src/ftxui/dom/separator.cpp
src/ftxui/dom/size.cpp
src/ftxui/dom/spinner.cpp
src/ftxui/dom/strikethrough.cpp
src/ftxui/dom/table.cpp
src/ftxui/dom/text.cpp
src/ftxui/dom/underlined.cpp
src/ftxui/dom/underlined_double.cpp
src/ftxui/dom/util.cpp
src/ftxui/dom/vbox.cpp
)
add_library(component STATIC
add_library(component
include/ftxui/component/animation.hpp
include/ftxui/component/captured_mouse.hpp
include/ftxui/component/component.hpp
include/ftxui/component/component_base.hpp
include/ftxui/component/component_options.hpp
include/ftxui/component/event.hpp
include/ftxui/component/loop.hpp
include/ftxui/component/mouse.hpp
include/ftxui/component/receiver.hpp
include/ftxui/component/screen_interactive.hpp
include/ftxui/component/task.hpp
src/ftxui/component/animation.cpp
src/ftxui/component/button.cpp
src/ftxui/component/catch_event.cpp
src/ftxui/component/checkbox.cpp
src/ftxui/component/collapsible.cpp
src/ftxui/component/component.cpp
src/ftxui/component/component_options.cpp
src/ftxui/component/container.cpp
src/ftxui/component/dropdown.cpp
src/ftxui/component/event.cpp
src/ftxui/component/hoverable.cpp
src/ftxui/component/input.cpp
src/ftxui/component/loop.cpp
src/ftxui/component/maybe.cpp
src/ftxui/component/menu.cpp
src/ftxui/component/modal.cpp
src/ftxui/component/radiobox.cpp
src/ftxui/component/radiobox.cpp
src/ftxui/component/renderer.cpp
@ -101,41 +140,42 @@ add_library(component STATIC
src/ftxui/component/slider.cpp
src/ftxui/component/terminal_input_parser.cpp
src/ftxui/component/terminal_input_parser.hpp
src/ftxui/component/toggle.cpp
src/ftxui/component/util.cpp
src/ftxui/component/window.cpp
)
target_link_libraries(dom
PUBLIC screen
)
find_package(Threads)
target_link_libraries(component
PUBLIC dom
PRIVATE Threads::Threads
)
if (NOT EMSCRIPTEN)
find_package(Threads)
target_link_libraries(component
PUBLIC Threads::Threads
)
endif()
include(cmake/ftxui_set_options.cmake)
ftxui_set_options(screen)
ftxui_set_options(dom)
ftxui_set_options(component)
if (FTXUI_BUILD_TESTS AND ${CMAKE_VERSION} VERSION_GREATER "3.11.4")
include(cmake/ftxui_test.cmake)
endif()
if(FTXUI_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if(FTXUI_BUILD_DOCS)
add_subdirectory(doc)
endif()
include(cmake/ftxui_coverage.cmake)
ftxui_check_coverage(screen)
ftxui_check_coverage(dom)
ftxui_check_coverage(component)
include(cmake/ftxui_test.cmake)
include(cmake/ftxui_benchmark.cmake)
include(cmake/ftxui_fuzzer.cmake)
include(cmake/iwyu.cmake)
include(cmake/ftxui_export.cmake)
include(cmake/ftxui_install.cmake)
include(cmake/ftxui_package.cmake)
if(FTXUI_ENABLE_INSTALL)
include(cmake/ftxui_install.cmake)
include(cmake/ftxui_package.cmake)
endif()
add_subdirectory(examples)
add_subdirectory(doc)

9
MODULE.bazel Normal file
View File

@ -0,0 +1,9 @@
# FTXUI Module.
module(name = "ftxui", version = "6.1.8", compatibility_level = 6)
# Build deps.
bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "platforms", version = "0.0.11")
# Test deps.
bazel_dep(name = "googletest", version = "1.16.0.bcr.1")

419
README.md
View File

@ -1,113 +1,404 @@
<p align="center">
<img src="./examples/component/homescreen.gif" alt="Demo image"></img>
<img src="https://github.com/ArthurSonzogni/FTXUI/assets/4759106/6925b6da-0a7e-49d9-883c-c890e1f36007" alt="Demo image"></img>
<br/>
<a href="#"><img src="https://img.shields.io/badge/c++-%2300599C.svg?style=flat&logo=c%2B%2B&logoColor=white"></img></a>
<a href="http://opensource.org/licenses/MIT"><img src="https://img.shields.io/github/license/arthursonzogni/FTXUI?color=black"></img></a>
<a href="#"><img src="https://img.shields.io/github/stars/ArthurSonzogni/FTXUI"></img></a>
<a href="#"><img src="https://img.shields.io/github/forks/ArthurSonzogni/FTXUI"></img></a>
<a href="#"><img src="https://img.shields.io/github/repo-size/ArthurSonzogni/FTXUI"></img></a>
<a href="https://github.com/ArthurSonzogni/FTXUI/issues"><img src="https://img.shields.io/github/issues/ArthurSonzogni/FTXUI"></img></a>
<a href="https://github.com/ArthurSonzogni/FTXUI/graphs/contributors"><img src="https://img.shields.io/github/contributors/arthursonzogni/FTXUI?color=blue"></img></a>
<br/>
<a href="https://github.com/ArthurSonzogni/FTXUI/issues"><img src="https://img.shields.io/github/issues/ArthurSonzogni/FTXUI"></img></a>
<a href="https://repology.org/project/ftxui/versions"><img src="https://repology.org/badge/latest-versions/ftxui.svg" alt="latest packaged version(s)"></a>
<a href="https://codecov.io/gh/ArthurSonzogni/FTXUI">
<img src="https://codecov.io/gh/ArthurSonzogni/FTXUI/branch/master/graph/badge.svg?token=C41FdRpNVA"/>
</a>
<br/>
<a href="https://github.com/ArthurSonzogni/FTXUI/wiki">Documentation</a> ·
<a href="https://github.com/ArthurSonzogni/FTXUI/issues">Report Bug</a> ·
<a href="https://arthursonzogni.github.io/FTXUI/">Documentation</a> ·
<a href="https://github.com/ArthurSonzogni/FTXUI/issues">Report a Bug</a> ·
<a href="https://arthursonzogni.github.io/FTXUI/examples.html">Examples</a> .
<a href="https://github.com/ArthurSonzogni/FTXUI/issues">Request Feature</a> ·
<a href="https://github.com/ArthurSonzogni/FTXUI/pulls">Send a Pull Request</a>
</p>
## FTXUI
# FTXUI
<i>Functional Terminal (X) User interface</i>
A simple C++ library for terminal based user interface.
A simple cross-platform C++ library for terminal based user interfaces!
## Feature
* Functional style. Inspired by
[[1]](https://hackernoon.com/building-reactive-terminal-interfaces-in-c-d392ce34e649?gi=d9fb9ce35901)
[1](https://hackernoon.com/building-reactive-terminal-interfaces-in-c-d392ce34e649?gi=d9fb9ce35901)
and [React](https://reactjs.org/)
* Simple and elegant syntax (in my opinion).
* Support for [UTF8](https://en.wikipedia.org/wiki/UTF-8) and [fullwidth chars](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) (→ 测试).
* No dependencies.
* Cross platform. Linux/mac (main target), Windows (experimental thanks to contributors), WebAssembly.
* Simple and elegant syntax (in my opinion)
* Keyboard & mouse navigation.
* Support for [UTF8](https://en.wikipedia.org/wiki/UTF-8) and [fullwidth chars](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) (→ 测试)
* Support for animations. [Demo 1](https://arthursonzogni.github.io/FTXUI/examples/?file=component/menu_underline_animated_gallery), [Demo 2](https://arthursonzogni.github.io/FTXUI/examples/?file=component/button_style)
* Support for drawing. [Demo](https://arthursonzogni.github.io/FTXUI/examples/?file=component/canvas_animated)
* No dependencies
* **Cross platform**: Linux/MacOS (main target), WebAssembly, Windows (Thanks to contributors!).
* Learn by [examples](#documentation), and [tutorials](#documentation)
* Multiple packages: CMake [FetchContent]([https://bewagner.net/programming/2020/05/02/cmake-fetchcontent/](https://cmake.org/cmake/help/latest/module/FetchContent.html)) (preferred),Bazel, vcpkg, pkgbuild, conan.
* Good practices: documentation, tests, fuzzers, performance tests, automated CI, automated packaging, etc...
## Operating systems
- [![linux-emscripten][badge.linux-emscripten]][link.linux-emscripten]
- [![linux-gcc][badge.linux-gcc]][link.linux-gcc]
[![linux-clang][badge.linux-clang]][link.linux-clang]
- [![windows-msvc][badge.windows-msvc]][link.windows-msvc]
- [![mac-clang][badge.mac-clang]][link.mac-clang]
[badge.linux-gcc]: https://github.com/ArthurSonzogni/FTXUI/actions/workflows/linux-gcc.yaml/badge.svg?branch=master
[badge.linux-clang]: https://github.com/ArthurSonzogni/FTXUI/actions/workflows/linux-clang.yaml/badge.svg?branch=master
[badge.linux-emscripten]: https://github.com/ArthurSonzogni/FTXUI/actions/workflows/linux-emscripten.yaml/badge.svg?branch=master
[badge.windows-msvc]: https://github.com/ArthurSonzogni/FTXUI/actions/workflows/windows-msvc.yaml/badge.svg?branch=master
[badge.mac-clang]: https://github.com/ArthurSonzogni/FTXUI/actions/workflows/mac-clang.yaml/badge.svg?branch=master
[link.linux-gcc]: https://github.com/ArthurSonzogni/FTXUI/actions/workflows/linux-gcc.yaml
[link.linux-clang]: https://github.com/ArthurSonzogni/FTXUI/actions/workflows/linux-clang.yaml
[link.linux-emscripten]: https://github.com/ArthurSonzogni/FTXUI/actions/workflows/linux-emscripten.yaml
[link.windows-msvc]: https://github.com/ArthurSonzogni/FTXUI/actions/workflows/windows-msvc.yaml
[link.mac-clang]: https://github.com/ArthurSonzogni/FTXUI/actions/workflows/mac-clang.yaml
## Example
~~~cpp
vbox({
hbox({
text("left") | border,
text("middle") | border | flex,
text("right") | border,
}),
gauge(0.5) | border,
});
~~~
~~~bash
┌────┐┌───────────────────────────────────────────────────────────────┐┌─────┐
│left││middle ││right│
└────┘└───────────────────────────────────────────────────────────────┘└─────┘
┌────────────────────────────────────────────────────────────────────────────┐
│██████████████████████████████████████ │
└────────────────────────────────────────────────────────────────────────────┘
~~~
# Documentation
## Documentation
- [Starter example project](https://github.com/ArthurSonzogni/ftxui-starter)
- [Documentation](https://arthursonzogni.github.io/FTXUI/)
- [Examples (WebAssembly)](https://arthursonzogni.com/FTXUI/examples/)
- [Build using CMake](https://arthursonzogni.com/FTXUI/doc/#build-using-cmake)
- [Build using nxxm](https://arthursonzogni.com/FTXUI/doc/#build-using-cmake)
- [Examples (WebAssembly)](https://arthursonzogni.github.io/FTXUI/examples/)
- [Build using CMake](https://arthursonzogni.github.io/FTXUI/#build-cmake)
## Example
~~~cpp
vbox({
hbox({
text("one") | border,
text("two") | border | flex,
text("three") | border | flex,
}),
gauge(0.25) | color(Color::Red),
gauge(0.50) | color(Color::White),
gauge(0.75) | color(Color::Blue),
});
~~~
![image](https://github.com/ArthurSonzogni/FTXUI/assets/4759106/569bf043-4e85-4245-aad5-2324572135c4)
## Short gallery
#### DOM
This module defines a hierarchical set of Element. An Element manages layout and can be responsive to the terminal dimensions.
They are declared in [<ftxui/dom/elements.hpp>](https://arthursonzogni.github.io/FTXUI/elements_8hpp_source.html
)
<details><summary>Layout</summary>
Element can be arranged together:
- horizontally with `hbox`
- vertically with `vbox`
- inside a grid with `gridbox`
- wrap along one direction using the `flexbox`.
Element can become flexible using the the `flex` decorator.
[Example](https://arthursonzogni.github.io/FTXUI/examples_2dom_2vbox_hbox_8cpp-example.html) using `hbox`, `vbox` and `filler`.
![image](https://user-images.githubusercontent.com/4759106/147242524-7103b5d9-1a92-4e2d-ac70-b3d6740061e3.png)
[Example](https://arthursonzogni.github.io/FTXUI/examples_2dom_2gridbox_8cpp-example.html) using gridbox:
![image](https://user-images.githubusercontent.com/4759106/147242972-0db1f2e9-0790-496f-86e6-ed2c604f7a73.png)
[Example](https://github.com/ArthurSonzogni/FTXUI/blob/master/examples/dom/hflow.cpp) using flexbox:
![image](https://user-images.githubusercontent.com/4759106/147243064-780ac7cc-605b-475f-94b8-cf7c4aed03a5.png)
[See](https://arthursonzogni.github.io/FTXUI/examples_2dom_2hflow_8cpp-example.html) also this [demo](https://arthursonzogni.github.io/FTXUI/examples/?file=component/flexbox).
</details>
<details><summary>Style</summary>
An element can be decorated using the functions:
- `bold`
- `italic`
- `dim`
- `inverted`
- `underlined`
- `underlinedDouble`
- `blink`
- `strikethrough`
- `color`
- `bgcolor`
- `hyperlink`
[Example](https://arthursonzogni.github.io/FTXUI/examples_2dom_2style_gallery_8cpp-example.html)
![image](https://user-images.githubusercontent.com/4759106/147244118-380bf834-9e33-40df-9ff0-07c10f2598ef.png)
FTXUI supports the pipe operator. It means: `decorator1(decorator2(element))` and `element | decorator1 | decorator2` can be used.
</details>
<details><summary>Colors</summary>
FTXUI support every color palette:
Color [gallery](https://arthursonzogni.github.io/FTXUI/examples_2dom_2color_gallery_8cpp-example.html):
![image](https://user-images.githubusercontent.com/4759106/147248595-04c7245a-5b85-4544-809d-a5984fc6f9e7.png)
</details>
<details><summary>Border and separator</summary>
Use decorator border and element separator() to subdivide your UI:
```cpp
auto document = vbox({
text("top"),
separator(),
text("bottom"),
}) | border;
```
[Demo](https://arthursonzogni.github.io/FTXUI/examples_2dom_2separator_8cpp-example.html):
![image](https://user-images.githubusercontent.com/4759106/147244514-4135f24b-fb8e-4067-8896-bc53545583f7.png)
</details>
<details><summary>Text and paragraph</summary>
A simple piece of text is represented using `text("content")`.
To support text wrapping following spaces the following functions are provided:
```cpp
Element paragraph(std::string text);
Element paragraphAlignLeft(std::string text);
Element paragraphAlignRight(std::string text);
Element paragraphAlignCenter(std::string text);
Element paragraphAlignJustify(std::string text);
```
[Paragraph example](https://arthursonzogni.github.io/FTXUI/examples_2dom_2paragraph_8cpp-example.html)
![ezgif com-gif-maker (4)](https://user-images.githubusercontent.com/4759106/147251370-983a06e7-6f41-4113-92b8-942f43d34d06.gif)
</details>
<details><summary>Table</summary>
A class to easily style a table of data.
[Example](https://arthursonzogni.github.io/FTXUI/examples_2dom_2table_8cpp-example.html):
![image](https://user-images.githubusercontent.com/4759106/147250766-77d8ec9e-cf2b-486d-9866-1fd9f1bd2e6b.png)
</details>
<details><summary>Canvas</summary>
Drawing can be made on a Canvas, using braille, block, or simple characters:
Simple [example](https://github.com/ArthurSonzogni/FTXUI/blob/master/examples/dom/canvas.cpp):
![image](https://user-images.githubusercontent.com/4759106/147245843-76cc62fb-ccb4-421b-aacf-939f9afb42fe.png)
Complex [examples](https://github.com/ArthurSonzogni/FTXUI/blob/master/examples/component/canvas_animated.cpp):
![ezgif com-gif-maker (3)](https://user-images.githubusercontent.com/4759106/147250538-783a8246-98e0-4a25-b032-3bd3710549d1.gif)
</details>
#### Component
ftxui/component produces dynamic UI, reactive to the user's input. It defines a set of ftxui::Component. A component reacts to Events (keyboard, mouse, resize, ...) and Renders as an Element (see previous section).
Prebuilt components are declared in [<ftxui/component/component.hpp>](https://arthursonzogni.github.io/FTXUI/component_8hpp_source.html)
<details><summary>Gallery</summary>
[Gallery](https://arthursonzogni.github.io/FTXUI/examples_2component_2gallery_8cpp-example.html) of multiple components. ([demo](https://arthursonzogni.github.io/FTXUI/examples/?file=component/gallery))
![image](https://user-images.githubusercontent.com/4759106/147247330-b60beb9f-e665-48b4-81c0-4b01ee95bc66.png)
</details>
<details><summary>Radiobox</summary>
[Example](https://arthursonzogni.github.io/FTXUI/examples_2component_2radiobox_8cpp-example.html):
![image](https://user-images.githubusercontent.com/4759106/147246401-809d14a5-6621-4e36-8dd9-a2d75ef2a94e.png)
</details>
<details><summary>Checkbox</summary>
[Example](https://arthursonzogni.github.io/FTXUI/examples_2component_2checkbox_8cpp-example.html):
![image](https://user-images.githubusercontent.com/4759106/147246646-b86926a9-1ef9-4efb-af98-48a9b62acd81.png)
</details>
<details><summary>Input</summary>
[Example](https://arthursonzogni.github.io/FTXUI/examples_2component_2input_8cpp-example.html):
![image](https://user-images.githubusercontent.com/4759106/147247671-f1d6f606-1845-4e94-a4a0-d4273e9ae6bd.png)
</details>
<details><summary>Toggle</summary>
[Example](https://arthursonzogni.github.io/FTXUI/examples_2component_2toggle_8cpp-example.html):
![image](https://user-images.githubusercontent.com/4759106/147249383-e2201cf1-b7b8-4a5a-916f-d761e3e7ae40.png)
</details>
<details><summary>Slider</summary>
[Example](https://arthursonzogni.github.io/FTXUI/examples_2component_2slider_8cpp-example.html):
![image](https://user-images.githubusercontent.com/4759106/147249265-7e2cad75-082c-436e-affe-44a550c480ab.png)
</details>
<details><summary>Menu</summary>
[Example](https://arthursonzogni.github.io/FTXUI/examples_2component_2menu_8cpp-example.html):
![image](https://user-images.githubusercontent.com/4759106/147247822-0035fd6f-bb13-4b3a-b057-77eb9291582f.png)
</details>
<details><summary>ResizableSplit</summary>
[Example](https://arthursonzogni.github.io/FTXUI/examples_2component_2resizable_split_8cpp-example.html):
![ezgif com-gif-maker](https://user-images.githubusercontent.com/4759106/147248372-c55512fe-9b96-4b08-a1df-d05cf2cae431.gif)
</details>
<details><summary>Dropdown</summary>
[Example](https://arthursonzogni.github.io/FTXUI/examples_2component_2dropdown_8cpp-example.html):
![youtube-video-gif (3)](https://user-images.githubusercontent.com/4759106/147246982-1e821751-531c-4e1f-bc37-2fa290e143cd.gif)
</details>
<details><summary>Tab</summary>
[Vertical](https://arthursonzogni.github.io/FTXUI/examples_2component_2tab_vertical_8cpp-example.html):
![ezgif com-gif-maker (1)](https://user-images.githubusercontent.com/4759106/147250144-22ff044a-4773-4ff7-a49c-12ba4034acb4.gif)
[Horizontal](https://arthursonzogni.github.io/FTXUI/examples_2component_2tab_horizontal_8cpp-example.html):
![ezgif com-gif-maker (2)](https://user-images.githubusercontent.com/4759106/147250217-fe447e0f-7a99-4e08-948a-995087d9b40e.gif)
</details>
## Libraries for FTXUI
- *Want to share a useful Component for FTXUI? Feel free to add yours here*
- [ftxui-grid-container](https://github.com/mingsheng13/grid-container-ftxui)
- [ftxui-ip-input](https://github.com/mingsheng13/ip-input-ftxui)
- [ftxui-image-view](https://github.com/ljrrjl/ftxui-image-view.git): For Image Display.
## Project using FTXUI
Feel free to add your projects here:
- [json-tui](https://github.com/ArthurSonzogni/json-tui)
- [git-tui](https://github.com/ArthurSonzogni/git-tui)
- [ostree-tui](https://github.com/AP-Sensing/ostree-tui)
- [rgb-tui](https://github.com/ArthurSonzogni/rgb-tui)
- [chrome-log-beautifier](https://github.com/ArthurSonzogni/chrome-log-beautifier)
- [x86-64 CPU Architecture Simulation](https://github.com/AnisBdz/CPU)
- [ltuiny](https://github.com/adrianoviana87/ltuiny)
- [i3-termdialogs](https://github.com/mibli/i3-termdialogs)
- [Just-Fast](https://github.com/GiuseppeCesarano/just-fast)
- [simpPRU](https://github.com/VedantParanjape/simpPRU)
- [Pigeon ROS TUI](https://github.com/PigeonSensei/Pigeon_ros_tui)
- [hastur](https://github.com/robinlinden/hastur)
- [CryptoCalculator](https://github.com/brevis/CryptoCalculator)
- [todoman](https://github.com/aaleino/todoman)
- [TimeAccumulator](https://github.com/asari555/TimeAccumulator)
- [vantage](https://github.com/gokulmaxi/vantage)
- [tabdeeli](https://github.com/typon/tabdeeli)
- [tiles](https://github.com/tusharpm/tiles)
- [cachyos-cli-installer](https://github.com/cachyos/new-cli-installer)
- [beagle-config](https://github.com/SAtacker/beagle-config)
- [turing_cmd](https://github.com/DanArmor/turing_cmd)
- [StartUp](https://github.com/StubbornVegeta/StartUp)
- [eCAL monitor](https://github.com/eclipse-ecal/ecal)
- [Path Finder](https://github.com/Ruebled/Path_Finder)
- [rw-tui](https://github.com/LeeKyuHyuk/rw-tui)
- [resource-monitor](https://github.com/catalincd/resource-monitor)
- [ftxuiFileReader](https://github.com/J0sephDavis/ftxuiFileReader)
- [ftxui_CPUMeter](https://github.com/tzzzzzzzx/ftxui_CPUMeter)
- [Captain's log](https://github.com/nikoladucak/caps-log)
- [FTowerX](https://github.com/MhmRhm/FTowerX)
- [Caravan](https://github.com/r3w0p/caravan)
- [Step-Writer](https://github.com/BrianAnakPintar/step-writer)
- [XJ music](https://github.com/xjmusic/xjmusic)
- [UDP chat](https://github.com/Sergeydigl3/udp-chat-tui)
- [2048-cpp](https://github.com/Chessom/2048-cpp)
- [Memory game](https://github.com/mikolajlubiak/memory)
- [Terminal Animation](https://github.com/mikolajlubiak/terminal_animation)
- [pciex](https://github.com/s0nx/pciex)
- [Fallout terminal hacking](https://github.com/gshigin/yet-another-fallout-terminal-hacking-game)
- [Lazylist](https://github.com/zhuyongqi9/lazylist)
- [TUISIC](https://github.com/Dark-Kernel/tuisic)
- [inLimbo](https://github.com/nots1dd/inLimbo)
- [BestEdrOfTheMarket](https://github.com/Xacone/BestEdrOfTheMarket)
- [terminal-rain](https://github.com/Oakamoore/terminal-rain)
- [keywords](https://github.com/Oakamoore/keywords) ([Play web version :heart:](https://oakamoore.itch.io/keywords))
- [FTB - tertminal file browser](https://github.com/Cyxuan0311/FTB)
- [SHOOT!](https://github.com/ShingZhanho/ENGG1340-Project-25Spring)
## Hosted on
* [github](https://github.com/ArthurSonzogni/ftxui)
* [gitlab](https://gitlab.com/ArthurSonzogni/ftxui)
### [cpp-best-practices/game_jam](https://github.com/cpp-best-practices/game_jam)
## External package
Several games using the FTXUI have been made during the Game Jam:
- [TermBreaker](https://github.com/ArthurSonzogni/termBreaker) [**[Play web version]**](https://arthursonzogni.com/TermBreaker/)
- [Minesweeper Marathon](https://github.com/cpp-best-practices/game_jam/blob/main/Jam1_April_2022/minesweeper_marathon.md) [**[Play web version]**](https://barlasgarden.com/minesweeper/index.html)
- [Grand Rounds](https://github.com/cpp-best-practices/game_jam/blob/main/Jam1_April_2022/grandrounds.md)
- [LightsRound](https://github.com/cpp-best-practices/game_jam/blob/main/Jam1_April_2022/LightsRound.v.0.1.0.md)
- [DanteO](https://github.com/cpp-best-practices/game_jam/blob/main/Jam1_April_2022/danteo.md)
- [Sumo](https://github.com/cpp-best-practices/game_jam/blob/main/Jam1_April_2022/sumo.md)
- [Drag Me aROUND](https://github.com/cpp-best-practices/game_jam/blob/main/Jam1_April_2022/drag_me_around.md)
- [DisarmSelfDestruct](https://github.com/cpp-best-practices/game_jam/blob/main/Jam1_April_2022/DisarmSelfDestruct.md)
- [TheWorld](https://github.com/cpp-best-practices/game_jam/blob/main/Jam1_April_2022/TheWorld.md)
- [smoothlife](https://github.com/cpp-best-practices/game_jam/blob/main/Jam1_April_2022/smoothlife.md)
- [Consu](https://github.com/cpp-best-practices/game_jam/blob/main/Jam1_April_2022/consu.md)
It is **highly** recommanded to use cmake FetchContent to depends on FTXUI. This
way you can specify which commit you would like to depends on.
## Utilization
If you don't, the following packages have been created:
- vcpkg ([soon](https://github.com/ArthurSonzogni/FTXUI/issues/112))
It is **highly** recommended to use CMake FetchContent to depend on FTXUI so you may specify which commit you would like to depend on.
```cmake
include(FetchContent)
FetchContent_Declare(ftxui
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
GIT_TAG v6.1.8
)
FetchContent_GetProperties(ftxui)
if(NOT ftxui_POPULATED)
FetchContent_Populate(ftxui)
add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
```
If you don't, FTXUI may be used from the following packages:
- [bazel](...)
- [vcpkg](https://vcpkgx.com/details.html?package=ftxui)
- [Arch Linux PKGBUILD](https://aur.archlinux.org/packages/ftxui-git/).
- [conan.io](https://conan.io/center/ftxui)
- [openSUSE](https://build.opensuse.org/package/show/devel:libraries:c_c++/ftxui)
-
[![Packaging status](https://repology.org/badge/vertical-allrepos/libftxui.svg)](https://repology.org/project/libftxui/versions)
If you choose to build and link FTXUI yourself, `ftxui-component` must be first in the linking order relative to the other FTXUI libraries, i.e.
```bash
g++ . . . -lftxui-component -lftxui-dom -lftxui-screen . . .
```
## Contributors
<a href="https://github.com/ArthurSonzogni/FTXUI/graphs/contributors">
<img src="https://contrib.rocks/image?repo=ArthurSonzogni/FTXUI" />
</a>

4
WORKSPACE.bazel Normal file
View File

@ -0,0 +1,4 @@
# 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.
workspace(name = "ftxui")

115
bazel/ftxui.bzl Normal file
View File

@ -0,0 +1,115 @@
# ftxui_common.bzl
load("@rules_cc//cc:defs.bzl", "cc_library")
def cpp17():
return select({
"@rules_cc//cc/compiler:msvc-cl": ["/std:c++17"],
"@rules_cc//cc/compiler:clang-cl": ["/std:c++17"],
"@rules_cc//cc/compiler:clang": ["-std=c++17"],
"@rules_cc//cc/compiler:gcc": ["-std=c++17"],
"//conditions:default": ["-std=c++17"],
})
def cpp20():
return select({
"@rules_cc//cc/compiler:msvc-cl": ["/std:c++20"],
"@rules_cc//cc/compiler:clang-cl": ["/std:c++20"],
"@rules_cc//cc/compiler:clang": ["-std=c++20"],
"@rules_cc//cc/compiler:gcc": ["-std=c++20"],
"//conditions:default": ["-std=c++20"],
})
# Microsoft terminal is a bit buggy ¯\_(ツ)_/¯ and MSVC uses bad defaults.
def windows_copts():
MSVC_COPTS = [
# Microsoft Visual Studio must decode sources files as UTF-8.
"/utf-8",
# Microsoft Visual Studio must interpret the codepoint using unicode.
"/DUNICODE",
"/D_UNICODE",
# Fallback for Microsoft Terminal.
# This
# - Replace missing font symbols by others.
# - Reduce screen position pooling frequency to deals against a Microsoft
# race condition. This was fixed in 2020, but clients never not updated.
# - https://github.com/microsoft/terminal/pull/7583
# - https://github.com/ArthurSonzogni/FTXUI/issues/136
"/DFTXUI_MICROSOFT_TERMINAL_FALLBACK",
]
WINDOWS_COPTS = [
# Fallback for Microsoft Terminal.
# This
# - Replace missing font symbols by others.
# - Reduce screen position pooling frequency to deals against a Microsoft
# race condition. This was fixed in 2020, but clients never not updated.
# - https://github.com/microsoft/terminal/pull/7583
# - https://github.com/ArthurSonzogni/FTXUI/issues/136
"-DFTXUI_MICROSOFT_TERMINAL_FALLBACK",
];
return select({
# MSVC:
"@rules_cc//cc/compiler:msvc-cl": MSVC_COPTS,
"@rules_cc//cc/compiler:clang-cl": MSVC_COPTS,
"@platforms//os:windows": WINDOWS_COPTS,
"//conditions:default": [],
})
def pthread_linkopts():
return select({
# With MSVC, threading is already built-in (you don't need -pthread.
"@rules_cc//cc/compiler:msvc-cl": [],
"@rules_cc//cc/compiler:clang-cl": [],
"@rules_cc//cc/compiler:clang": ["-pthread"],
"@rules_cc//cc/compiler:gcc": ["-pthread"],
"//conditions:default": ["-pthread"],
})
def ftxui_cc_library(
name,
srcs,
hdrs,
linkopts = [],
deps = []):
cc_library(
name = name,
srcs = srcs,
hdrs = hdrs,
linkopts = linkopts,
deps = deps,
strip_include_prefix = "",
include_prefix = "",
includes = [
"include",
"src",
],
copts = cpp17() + windows_copts(),
visibility = ["//visibility:public"],
)
# Compile all the examples in the examples/ directory.
# This is useful to check the Bazel is synchronized with CMake definitions.
def generate_examples():
cpp_files = native.glob(["examples/**/*.cpp"])
for src in cpp_files:
# Skip failing examples due to the color_info_sorted_2d.ipp dependency.
if src == "examples/component/homescreen.cpp" or \
src == "examples/dom/color_info_palette256.cpp" or \
src == "examples/dom/color_gallery.cpp":
continue
# Turn "examples/component/button.cpp" → "example_component_button"
name = src.replace("/", "_").replace(".cpp", "")
native.cc_binary(
name = name,
srcs = [src],
deps = ["//:component"],
copts = cpp20() + windows_copts(),
)

View File

@ -2,3 +2,5 @@
include(CMakeFindDependencyMacro)
find_dependency(Threads)
include("${CMAKE_CURRENT_LIST_DIR}/ftxui-targets.cmake")

View File

@ -1,19 +1,21 @@
if (NOT WIN32)
FetchContent_Declare(googlebenchmark
GIT_REPOSITORY "https://github.com/google/benchmark"
GIT_TAG 62937f91b5c763a8e119d0c20c67b87bde8eff1c
)
FetchContent_MakeAvailable(googlebenchmark)
add_executable(ftxui_benchmark
src/ftxui/dom/benchmark_test.cpp
)
target_link_libraries(ftxui_benchmark
PRIVATE dom
PRIVATE benchmark::benchmark
PRIVATE benchmark::benchmark_main
)
target_include_directories(ftxui_benchmark
PRIVATE src
)
if (NOT FTXUI_BUILD_TESTS OR
NOT ${CMAKE_VERSION} VERSION_GREATER "3.11.4" OR
WIN32
)
return()
endif()
include(cmake/ftxui_find_google_benchmark.cmake)
add_executable(ftxui-benchmark
src/ftxui/dom/benchmark_test.cpp
)
ftxui_set_options(ftxui-benchmark)
target_link_libraries(ftxui-benchmark
PRIVATE dom
PRIVATE benchmark::benchmark
PRIVATE benchmark::benchmark_main
)
target_include_directories(ftxui-benchmark
PRIVATE src
)

View File

@ -0,0 +1,8 @@
function(ftxui_check_coverage library)
if (FTXUI_ENABLE_COVERAGE)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
target_compile_options(${library} INTERFACE --coverage -O0 -g)
target_link_libraries(${library} INTERFACE --coverage)
endif()
endif()
endfunction()

View File

@ -4,5 +4,5 @@ add_library(ftxui::component ALIAS component)
export(
TARGETS screen dom component
NAMESPACE ftxui::
FILE ${PROJECT_BINARY_DIR}/ftxui-targets.cmake
FILE "${PROJECT_BINARY_DIR}/ftxui-targets.cmake"
)

View File

@ -0,0 +1,32 @@
# Some developers would be happier with the google benchmark version provided
# from their package manager. Use it if it is installed the package provide
# cmake support.
# https://github.com/ArthurSonzogni/FTXUI/issues/551
find_package(benchmark QUIET)
if (benchmark_FOUND)
return()
endif()
option(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
option(FETCHCONTENT_QUIET FALSE)
include(FetchContent)
FetchContent_Declare(googlebenchmark
GIT_REPOSITORY "https://github.com/google/benchmark"
GIT_TAG "015d1a091af6937488242b70121858bce8fd40e9" # v1.8.2
GIT_PROGRESS TRUE
)
FetchContent_GetProperties(googlebenchmark)
set (BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE INTERNAL "")
set (BENCHMARK_ENABLE_TESTING OFF CACHE INTERNAL "")
if(googlebenchmark_POPULATED)
return()
endif()
FetchContent_Populate(googlebenchmark)
add_subdirectory(
${googlebenchmark_SOURCE_DIR}
${googlebenchmark_BINARY_DIR}
EXCLUDE_FROM_ALL
)

View File

@ -0,0 +1,33 @@
# Some developers would be happier with the gtest version provided from their
# package manager. Use it if it is installed the package provide cmake support.
# https://github.com/ArthurSonzogni/FTXUI/issues/551
find_package(GTest QUIET)
if (GTest_FOUND)
return()
endif()
option(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
option(FETCHCONTENT_QUIET FALSE)
include(FetchContent)
FetchContent_Declare(googletest
GIT_REPOSITORY "https://github.com/google/googletest"
GIT_TAG 23ef29555ef4789f555f1ba8c51b4c52975f0907
GIT_PROGRESS TRUE
)
FetchContent_GetProperties(googletest)
if(googletest_POPULATED)
return()
endif()
FetchContent_Populate(googletest)
set(BUILD_GMOCK OFF CACHE INTERNAL "")
set(INSTALL_GTEST OFF CACHE INTERNAL "")
set(gtest_force_shared_crt ON CACHE INTERNAL "")
add_subdirectory(
"${googletest_SOURCE_DIR}"
"${googletest_BINARY_DIR}"
EXCLUDE_FROM_ALL
)

View File

@ -1,22 +1,20 @@
if (NOT FTXUI_BUILD_TESTS_FUZZER)
return()
endif()
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
function(fuzz name)
function(fuzz source)
set(name "ftxui-${source}")
add_executable(${name}
src/ftxui/component/${name}.cpp
)
target_include_directories(${name}
PRIVATE src
)
target_link_libraries(${name}
PRIVATE component
)
target_compile_options(${name}
PRIVATE -fsanitize=fuzzer,address
)
target_link_libraries(${name}
PRIVATE -fsanitize=fuzzer,address
src/ftxui/component/${source}.cpp
)
target_include_directories(${name} PRIVATE src)
target_link_libraries(${name} PRIVATE component)
target_compile_options(${name} PRIVATE -fsanitize=fuzzer,address)
target_link_libraries(${name} PRIVATE -fsanitize=fuzzer,address)
target_compile_features(${name} PRIVATE cxx_std_17)
endfunction(fuzz)
fuzz(terminal_input_parser_test_fuzzer)

View File

@ -1,13 +0,0 @@
find_package(Git QUIET)
if (Git_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
message("git found")
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE git_version
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else()
set(git_version 0)
endif()

View File

@ -1,29 +1,60 @@
if(NOT FTXUI_ENABLE_INSTALL)
return()
endif()
include(GNUInstallDirs)
install(TARGETS screen dom component
EXPORT ftxui-export
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(DIRECTORY include/ftxui DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
include(CMakePackageConfigHelpers)
configure_package_config_file(ftxui-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/ftxui-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/ftxui/cmake
PATH_VARS CMAKE_INSTALL_INCLUDEDIR
)
write_basic_package_version_file(
ftxui-config-version.cmake
VERSION ${PACKAGE_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ftxui-config.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ftxui
)
install(EXPORT ftxui-export
FILE ftxui-config-version.cmake
# ------------------------------------------------------------------------------
# Install the library and its public headers into the standard subdirectories
# ------------------------------------------------------------------------------
install(
TARGETS screen dom component
EXPORT ftxui-targets
)
install(
DIRECTORY include/ftxui
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
# ------------------------------------------------------------------------------
# Install the exported cmake targets for use in other CMake projects.
# ------------------------------------------------------------------------------
install(
EXPORT ftxui-targets
NAMESPACE ftxui::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ftxui
)
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ftxui"
)
# ------------------------------------------------------------------------------
# Create and install the ftuxi-config.cmake and ftuxi-config-version.cmake files
# needed to support users of find_package()
# ------------------------------------------------------------------------------
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/ftxui-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/ftxui-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/ftxui/cmake"
PATH_VARS CMAKE_INSTALL_INCLUDEDIR
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/cmake/ftxui-config-version.cmake"
VERSION ${PACKAGE_VERSION}
COMPATIBILITY SameMajorVersion
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/cmake/ftxui-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/ftxui-config-version.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ftxui"
)
# ------------------------------------------------------------------------------
# Create and install pkg-config file for easy use of library in build systems
# other than CMake:
# ------------------------------------------------------------------------------
configure_file(ftxui.pc.in ${CMAKE_CURRENT_BINARY_DIR}/ftxui.pc @ONLY)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/ftxui.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
)

17
cmake/ftxui_message.cmake Normal file
View File

@ -0,0 +1,17 @@
function(ftxui_message msg)
if (NOT FTXUI_QUIET)
message(STATUS "${msg}")
endif()
endfunction()
ftxui_message("┌─ FTXUI options ─────────────────────")
ftxui_message("│ FTXUI_ENABLE_INSTALL : ${FTXUI_ENABLE_INSTALL}")
ftxui_message("│ FTXUI_BUILD_EXAMPLES : ${FTXUI_BUILD_EXAMPLES}")
ftxui_message("│ FTXUI_QUIET : ${FTXUI_QUIET}")
ftxui_message("│ FTXUI_BUILD_DOCS : ${FTXUI_BUILD_DOCS}")
ftxui_message("│ FTXUI_BUILD_TESTS : ${FTXUI_BUILD_TESTS}")
ftxui_message("│ FTXUI_BUILD_TESTS_FUZZER : ${FTXUI_BUILD_TESTS_FUZZER}")
ftxui_message("│ FTXUI_ENABLE_COVERAGE : ${FTXUI_ENABLE_COVERAGE}")
ftxui_message("│ FTXUI_DEV_WARNINGS : ${FTXUI_DEV_WARNINGS}")
ftxui_message("│ FTXUI_CLANG_TIDY : ${FTXUI_CLANG_TIDY}")
ftxui_message("└─────────────────────────────────────")

View File

@ -1,4 +1,16 @@
set(CPACK_GENERATOR "DEB;External;RPM;STGZ;TBZ2;TGZ;TXZ;TZ;TZST;ZIP")
if(NOT FTXUI_ENABLE_INSTALL)
return()
endif()
if (UNIX AND NOT APPLE)
set(CPACK_GENERATOR "DEB;External;RPM;STGZ;TBZ2;TGZ;TXZ;TZ;TZST;ZIP")
elseif (UNIX AND APPLE)
set(CPACK_GENERATOR "DragNDrop;NuGet;TGZ;ZIP")
elseif (WIN32)
set(CPACK_GENERATOR "DEB;NuGet;TGZ;ZIP")
else()
set(CPACK_GENERATOR "ZIP")
endif()
set(CPACK_DEBIAN_PACKAGE_DEPENDS " ")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE_URL "https://github.com/ArthurSonzogni/FTXUI/")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Arthur Sonzogni")

View File

@ -1,29 +1,67 @@
find_program(CLANG_TIDY_EXE NAMES "clang-tidy" DOC "Path to clang-tidy executable" )
function(ftxui_set_options library)
set_target_properties(${library} PROPERTIES PREFIX "ftxui-")
set_target_properties(${library} PROPERTIES VERSION ${PROJECT_VERSION})
if (NOT ${library} MATCHES "ftxui-*")
set_target_properties(${library} PROPERTIES OUTPUT_NAME "ftxui-${library}")
endif()
if (FTXUI_CLANG_TIDY)
if (NOT CLANG_TIDY_EXE)
message(FATAL_ERROR "clang-tidy requested but executable not found")
endif()
target_include_directories(${library}
PUBLIC
set_target_properties(${library}
PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-warnings-as-errors=*"
)
# By using "PUBLIC" as opposed to "SYSTEM INTERFACE", the compiler warning
# are enforced on the headers. This is behind "FTXUI_CLANG_TIDY", so that it
# applies only when developing FTXUI and on the CI. User's of the library
# get only the SYSTEM INTERFACE instead.
target_include_directories(${library}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
else()
target_include_directories(${library} SYSTEM
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
endif()
target_include_directories(${library} SYSTEM
INTERFACE
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
src
)
# C++17 is used. We require fold expression at least.
target_include_directories(${library}
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
target_compile_features(${library} PUBLIC cxx_std_17)
# Force Microsoft Visual Studio to decode sources files in UTF-8. This applies
# to the library and the library users.
if (MSVC)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(${library} PUBLIC "/utf-8")
endif()
# CMake does automatically add -fPIC when linking a shared library, but it
# does not add it when linking a static library. This is a problem when the
# static library is later linked into a shared library.
# Doing it helps some users.
set_property(TARGET ${library} PROPERTY POSITION_INDEPENDENT_CODE ON)
# Add as many warning as possible:
if (WIN32)
if (MSVC)
target_compile_options(${library} PRIVATE "/W3")
target_compile_options(${library} PRIVATE "/WX")
if(FTXUI_DEV_WARNINGS)
target_compile_options(${library} PRIVATE "/W3")
target_compile_options(${library} PRIVATE "/WX")
endif()
target_compile_options(${library} PRIVATE "/wd4244")
target_compile_options(${library} PRIVATE "/wd4267")
target_compile_options(${library} PRIVATE "/D_CRT_SECURE_NO_WARNINGS")
@ -31,15 +69,30 @@ function(ftxui_set_options library)
# Force Win32 to UNICODE
target_compile_definitions(${library} PRIVATE UNICODE _UNICODE)
else()
target_compile_options(${library} PRIVATE "-Wall")
target_compile_options(${library} PRIVATE "-Wextra")
target_compile_options(${library} PRIVATE "-pedantic")
target_compile_options(${library} PRIVATE "-Werror")
target_compile_options(${library} PRIVATE "-Wmissing-declarations")
target_compile_options(${library} PRIVATE "-Wdeprecated")
target_compile_options(${library} PRIVATE "-Wshadow")
if(FTXUI_DEV_WARNINGS)
target_compile_options(${library} PRIVATE "-Wall")
target_compile_options(${library} PRIVATE "-Werror")
target_compile_options(${library} PRIVATE "-Wextra")
target_compile_options(${library} PRIVATE "-Wcast-align")
target_compile_options(${library} PRIVATE "-Wdeprecated")
target_compile_options(${library} PRIVATE "-Wmissing-declarations")
target_compile_options(${library} PRIVATE "-Wnon-virtual-dtor")
target_compile_options(${library} PRIVATE "-Wnull-dereference")
target_compile_options(${library} PRIVATE "-Woverloaded-virtual")
target_compile_options(${library} PRIVATE "-Wpedantic")
target_compile_options(${library} PRIVATE "-Wshadow")
target_compile_options(${library} PRIVATE "-Wunused")
endif()
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(FTXUI_DEV_WARNINGS)
target_compile_options(${library} PRIVATE "-Wdocumentation")
endif()
endif()
if (FTXUI_MICROSOFT_TERMINAL_FALLBACK)
target_compile_definitions(${library}
PRIVATE "FTXUI_MICROSOFT_TERMINAL_FALLBACK")
@ -47,9 +100,7 @@ function(ftxui_set_options library)
endfunction()
if (EMSCRIPTEN)
#string(APPEND CMAKE_CXX_FLAGS " -s ASSERTIONS=1")
string(APPEND CMAKE_CXX_FLAGS " -s USE_PTHREADS")
string(APPEND CMAKE_EXE_LINKER_FLAGS " -s ASYNCIFY")
string(APPEND CMAKE_EXE_LINKER_FLAGS " -s PROXY_TO_PTHREAD")
endif()

View File

@ -1,48 +1,83 @@
if (NOT FTXUI_BUILD_TESTS)
return()
endif()
enable_testing()
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
include(FetchContent)
include(cmake/ftxui_find_google_test.cmake)
FetchContent_Declare( googletest
GIT_REPOSITORY "https://github.com/google/googletest"
GIT_TAG 23ef29555ef4789f555f1ba8c51b4c52975f0907
)
FetchContent_MakeAvailable(googletest)
add_executable(tests
add_executable(ftxui-tests
src/ftxui/component/animation_test.cpp
src/ftxui/component/button_test.cpp
src/ftxui/component/collapsible_test.cpp
src/ftxui/component/component_test.cpp
src/ftxui/component/component_test.cpp
src/ftxui/component/container_test.cpp
src/ftxui/component/dropdown_test.cpp
src/ftxui/component/hoverable_test.cpp
src/ftxui/component/input_test.cpp
src/ftxui/component/menu_test.cpp
src/ftxui/component/modal_test.cpp
src/ftxui/component/radiobox_test.cpp
src/ftxui/util/ref_test.cpp
src/ftxui/component/receiver_test.cpp
src/ftxui/component/resizable_split_test.cpp
src/ftxui/component/screen_interactive_test.cpp
src/ftxui/component/slider_test.cpp
src/ftxui/component/terminal_input_parser_test.cpp
src/ftxui/component/toggle_test.cpp
src/ftxui/dom/blink_test.cpp
src/ftxui/dom/bold_test.cpp
src/ftxui/dom/border_test.cpp
src/ftxui/dom/canvas_test.cpp
src/ftxui/dom/color_test.cpp
src/ftxui/dom/dbox_test.cpp
src/ftxui/dom/dim_test.cpp
src/ftxui/dom/flexbox_helper_test.cpp
src/ftxui/dom/flexbox_test.cpp
src/ftxui/dom/gauge_test.cpp
src/ftxui/dom/gridbox_test.cpp
src/ftxui/dom/hbox_test.cpp
src/ftxui/dom/hyperlink_test.cpp
src/ftxui/dom/italic_test.cpp
src/ftxui/dom/linear_gradient_test.cpp
src/ftxui/dom/scroll_indicator_test.cpp
src/ftxui/dom/selection_test.cpp
src/ftxui/dom/separator_test.cpp
src/ftxui/dom/spinner_test.cpp
src/ftxui/dom/table_test.cpp
src/ftxui/dom/text_test.cpp
src/ftxui/dom/underlined_test.cpp
src/ftxui/dom/vbox_test.cpp
src/ftxui/screen/color_test.cpp
src/ftxui/screen/string_test.cpp
)
target_link_libraries(tests
target_link_libraries(ftxui-tests
PRIVATE component
PRIVATE gtest
PRIVATE gmock
PRIVATE gtest_main
PRIVATE GTest::gtest
PRIVATE GTest::gtest_main
)
target_include_directories(tests
target_include_directories(ftxui-tests
PRIVATE src
)
target_compile_options(tests PRIVATE -fsanitize=address)
target_link_libraries(tests PRIVATE -fsanitize=address)
target_compile_features(ftxui-tests PRIVATE cxx_std_20)
if (NOT MSVC)
include(cmake/ftxui_benchmark.cmake)
# Disable unity build for tests. There are several files defining the same
# function in different anonymous namespaces. This is not allowed in unity
# builds, as it would result in multiple definitions of the same function.
set_target_properties(ftxui-tests PROPERTIES UNITY_BUILD OFF)
if (FTXUI_MICROSOFT_TERMINAL_FALLBACK)
target_compile_definitions(ftxui-tests
PRIVATE "FTXUI_MICROSOFT_TERMINAL_FALLBACK")
endif()
if (FTXUI_BUILD_TESTS_FUZZER)
include(cmake/ftxui_fuzzer.cmake)
endif()
include(GoogleTest)
gtest_discover_tests(ftxui-tests
DISCOVERY_TIMEOUT 600
)
#set(CMAKE_CTEST_ARGUMENTS "--rerun-failed --output-on-failure")
#set_tests_properties(gen_init_queries PROPERTIES FIXTURES_SETUP f_init_queries)
#set_tests_properties(test PROPERTIES FIXTURES_REQUIRED f_init_queries)

View File

@ -1,7 +1,7 @@
find_program(iwyu_path NAMES include-what-you-use iwyu)
if(iwyu_path)
set_property(TARGET ${lib}
PROPERTY ${iwyu_path} -Xiwyu
--mapping_file ${CMAKE_CURRENT_SOURCE_DIR}/iwyu.impl
PROPERTY "${iwyu_path}" -Xiwyu
--mapping_file "${CMAKE_CURRENT_SOURCE_DIR}/iwyu.imp"
)
endif()

12
codecov.yml Normal file
View File

@ -0,0 +1,12 @@
codecov:
require_ci_to_pass: no
notify:
after_n_builds: 4
wait_for_ci: yes
coverage:
precision: 2
round: down
range: "50...100"
comment: false

View File

@ -1,22 +1,27 @@
if(NOT FTXUI_BUILD_DOCS)
return()
endif()
find_package(Doxygen)
if (DOXYGEN_FOUND)
# Generate example list for documentation
set(EXAMPLE_LIST "${CMAKE_CURRENT_BINARY_DIR}/example_list.md")
file(WRITE ${EXAMPLE_LIST} "# Examples")
get_property(EXAMPLES GLOBAL PROPERTY FTXUI::EXAMPLES)
foreach(EXAMPLE IN LISTS EXAMPLES)
file(APPEND ${EXAMPLE_LIST} "\n@example examples/${EXAMPLE}.cpp")
endforeach(EXAMPLE IN LISTS EXAMPLES)
configure_file(Doxyfile.in Doxyfile @ONLY)
# note the option ALL which allows to build the docs together with the application
add_custom_target(doc
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM
)
else (DOXYGEN_FOUND)
if (NOT DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
return()
endif()
# Generate example list for documentation
set(EXAMPLE_LIST "${CMAKE_CURRENT_BINARY_DIR}/example_list.md")
file(WRITE ${EXAMPLE_LIST} "# Examples")
get_property(EXAMPLES GLOBAL PROPERTY FTXUI::EXAMPLES)
foreach(EXAMPLE IN LISTS EXAMPLES)
file(APPEND ${EXAMPLE_LIST} "\n@example examples/${EXAMPLE}.cpp")
endforeach(EXAMPLE IN LISTS EXAMPLES)
configure_file(Doxyfile.in Doxyfile @ONLY)
# note the option ALL which allows to build the docs together with the application
add_custom_target(doc
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM
)

View File

@ -178,11 +178,12 @@ div.headertitle {
}
div.fragment {
padding: 16px;
background-color: #f3f3f3;
border: 0 solid;
transition: all 0.5s ease-in-out;
border-radius:5px;
border: 0 solid;
border: none;
padding:16px;
transition: all 0.5s ease-in-out;
}
div.fragment:hover {
@ -192,8 +193,9 @@ div.fragment:hover {
div.line {
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
font-size: 85%;
line-height: 1.45;
font-size: 90%;
font-variant-numeric: tabular-nums lining-nums;
font-kerning: none;
-webkit-transition-duration: 0;
-moz-transition-duration: 0;
-ms-transition-duration: 0;
@ -206,15 +208,6 @@ div.line.glow {
box-shadow: none;
}
pre.fragment {
border: 0 solid #C4CFE5;
padding: 16px;
background-color: #f3f3f3;
font-size: 85%;
line-height: 1.45;
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
}
/* @group Code Colorization */
span.keyword {
color: #808000

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,29 @@
if(NOT FTXUI_BUILD_EXAMPLES)
return()
endif()
set(EXAMPLES_DIR ${CMAKE_CURRENT_SOURCE_DIR})
function(example name)
add_executable(${name} ${name}.cpp)
target_link_libraries(${name} PUBLIC ${DIRECTORY_LIB})
add_executable(ftxui_example_${name} ${name}.cpp)
target_link_libraries(ftxui_example_${name} PUBLIC ${DIRECTORY_LIB})
file(RELATIVE_PATH dir ${EXAMPLES_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
set_property(GLOBAL APPEND PROPERTY FTXUI::EXAMPLES ${dir}/${name})
target_compile_features(ftxui_example_${name} PRIVATE cxx_std_20)
endfunction(example)
add_subdirectory(component)
add_subdirectory(dom)
if (EMSCRIPTEN)
string(APPEND CMAKE_EXE_LINKER_FLAGS " -s ALLOW_MEMORY_GROWTH=1")
target_link_options(component PUBLIC "SHELL: -s ALLOW_MEMORY_GROWTH=1")
get_property(EXAMPLES GLOBAL PROPERTY FTXUI::EXAMPLES)
foreach(file
"index.html"
"index.mjs"
"index.css"
"sw.js"
"run_webassembly.py")
configure_file(${file} ${file})
endforeach(file)

View File

@ -1,29 +1,52 @@
set(DIRECTORY_LIB component)
example(button)
example(button_animated)
example(button_in_frame)
example(button_style)
example(canvas_animated)
example(checkbox)
example(checkbox_in_frame)
example(collapsible)
example(composition)
example(custom_loop)
example(dropdown)
example(dropdown_custom)
example(flexbox_gallery)
example(focus)
example(focus_cursor)
example(gallery)
example(homescreen)
example(input)
example(input_in_frame)
example(input_style)
example(linear_gradient_gallery)
example(maybe)
example(menu)
example(menu2)
example(menu_entries)
example(menu_entries_animated)
example(menu_in_frame)
example(menu_in_frame_horizontal)
example(menu_multiple)
example(menu_style)
example(menu_underline_animated_gallery)
example(modal_dialog)
example(modal_dialog_custom)
example(nested_screen)
example(print_key_press)
example(radiobox)
example(radiobox_in_frame)
example(renderer)
example(resizable_split)
example(scrollbar)
example(selection)
example(slider)
example(slider_direction)
example(slider_rgb)
example(tab_horizontal)
example(tab_vertical)
example(textarea)
example(toggle)
example(window)
example(with_restored_io)

View File

@ -1,45 +1,9 @@
#include <memory> // for shared_ptr, __shared_ptr_access
#include <string> // for operator+, to_wstring
#include "ftxui/component/component.hpp"
#include "ftxui/component/screen_interactive.hpp"
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Button, Horizontal, Renderer
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/component_options.hpp" // for ButtonOption
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for separator, gauge, Element, operator|, vbox, border
using namespace ftxui;
int main(int argc, const char* argv[]) {
int value = 50;
// The tree of components. This defines how to navigate using the keyboard.
auto button_option = ButtonOption();
button_option.border = false;
auto buttons = Container::Horizontal({
Button(
"[Decrease]", [&] { value--; }, &button_option),
Button(
"[Increase]", [&] { value++; }, &button_option),
});
// Modify the way to render them on screen:
auto component = Renderer(buttons, [&] {
return vbox({
text("value = " + std::to_string(value)),
separator(),
gauge(value * 0.01f),
separator(),
buttons->Render(),
}) |
border;
});
auto screen = ScreenInteractive::FitComponent();
screen.Loop(component);
return 0;
int main(){
auto screen = ftxui::ScreenInteractive::Fullscreen();
auto testComponent = ftxui::Renderer([](){return ftxui::text("test Component");});
screen.Loop(testComponent);
return 0;
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -0,0 +1,45 @@
// Copyright 2020 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 <memory> // for shared_ptr, __shared_ptr_access
#include <string> // for operator+, to_string
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Button, Horizontal, Renderer
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/component_options.hpp" // for ButtonOption
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for gauge, separator, text, vbox, operator|, Element, border
#include "ftxui/screen/color.hpp" // for Color, Color::Blue, Color::Green, Color::Red
using namespace ftxui;
int main() {
int value = 50;
// The tree of components. This defines how to navigate using the keyboard.
auto buttons = Container::Horizontal({
Button(
"Decrease", [&] { value--; }, ButtonOption::Animated(Color::Red)),
Button(
"Reset", [&] { value = 50; }, ButtonOption::Animated(Color::Green)),
Button(
"Increase", [&] { value++; }, ButtonOption::Animated(Color::Blue)),
});
// Modify the way to render them on screen:
auto component = Renderer(buttons, [&] {
return vbox({
vbox({
text("value = " + std::to_string(value)),
separator(),
gauge(value * 0.01f),
}) | border,
buttons->Render(),
});
});
auto screen = ScreenInteractive::FitComponent();
screen.Loop(component);
return 0;
}

View File

@ -0,0 +1,47 @@
// Copyright 2022 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 <memory> // for allocator, __shared_ptr_access, shared_ptr
#include <string> // for to_string, operator+
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Button, Renderer, Vertical
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/component_options.hpp" // for ButtonOption
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for operator|, text, Element, hbox, separator, size, vbox, border, frame, vscroll_indicator, HEIGHT, LESS_THAN
#include "ftxui/screen/color.hpp" // for Color, Color::Default, Color::GrayDark, Color::White
using namespace ftxui;
int main() {
int counter = 0;
auto on_click = [&] { counter++; };
auto style = ButtonOption::Animated(Color::Default, Color::GrayDark,
Color::Default, Color::White);
auto container = Container::Vertical({});
for (int i = 0; i < 30; ++i) {
auto button = Button("Button " + std::to_string(i), on_click, style);
container->Add(button);
}
auto renderer = Renderer(container, [&] {
return vbox({
hbox({
text("Counter:"),
text(std::to_string(counter)),
}),
separator(),
container->Render() | vscroll_indicator | frame |
size(HEIGHT, LESS_THAN, 20),
}) |
border;
});
auto screen = ScreenInteractive::FitComponent();
screen.Loop(renderer);
return 0;
}

View File

@ -0,0 +1,60 @@
// Copyright 2020 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 <string> // for operator+, to_string
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Button, Vertical, Renderer, Horizontal, operator|
#include "ftxui/component/component_base.hpp" // for Component
#include "ftxui/component/component_options.hpp" // for ButtonOption
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for Element, separator, text, border
#include "ftxui/screen/color.hpp" // for Color, Color::Blue, Color::Green, Color::Red
using namespace ftxui;
int main() {
int value = 0;
auto action = [&] { value++; };
auto action_renderer =
Renderer([&] { return text("count = " + std::to_string(value)); });
auto buttons =
Container::Vertical({
action_renderer,
Renderer([] { return separator(); }),
Container::Horizontal({
Container::Vertical({
Button("Ascii 1", action, ButtonOption::Ascii()),
Button("Ascii 2", action, ButtonOption::Ascii()),
Button("Ascii 3", action, ButtonOption::Ascii()),
}),
Renderer([] { return separator(); }),
Container::Vertical({
Button("Simple 1", action, ButtonOption::Simple()),
Button("Simple 2", action, ButtonOption::Simple()),
Button("Simple 3", action, ButtonOption::Simple()),
}),
Renderer([] { return separator(); }),
Container::Vertical({
Button("Animated 1", action, ButtonOption::Animated()),
Button("Animated 2", action, ButtonOption::Animated()),
Button("Animated 3", action, ButtonOption::Animated()),
}),
Renderer([] { return separator(); }),
Container::Vertical({
Button("Animated 4", action,
ButtonOption::Animated(Color::Red)),
Button("Animated 5", action,
ButtonOption::Animated(Color::Green)),
Button("Animated 6", action,
ButtonOption::Animated(Color::Blue)),
}),
}),
}) |
border;
auto screen = ScreenInteractive::FitComponent();
screen.Loop(buttons);
return 0;
}

View File

@ -0,0 +1,262 @@
// Copyright 2021 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSED file.
#include <cmath> // for sin, cos
#include <ftxui/dom/elements.hpp> // for canvas, Element, separator, hbox, operator|, border
#include <ftxui/screen/screen.hpp> // for Pixel
#include <memory> // for allocator, shared_ptr, __shared_ptr_access
#include <string> // for string, basic_string
#include <utility> // for move
#include <vector> // for vector, __alloc_traits<>::value_type
#include "ftxui/component/component.hpp" // for Renderer, CatchEvent, Horizontal, Menu, Tab
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/event.hpp" // for Event
#include "ftxui/component/mouse.hpp" // for Mouse
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/canvas.hpp" // for Canvas
#include "ftxui/screen/color.hpp" // for Color, Color::Red, Color::Blue, Color::Green, ftxui
int main() {
using namespace ftxui;
int mouse_x = 0;
int mouse_y = 0;
// A triangle following the mouse, using braille characters.
auto renderer_line_braille = Renderer([&] {
auto c = Canvas(100, 100);
c.DrawText(0, 0, "Several lines (braille)");
c.DrawPointLine(mouse_x, mouse_y, 80, 10, Color::Red);
c.DrawPointLine(80, 10, 80, 40, Color::Blue);
c.DrawPointLine(80, 40, mouse_x, mouse_y, Color::Green);
return canvas(std::move(c));
});
// A triangle following the mouse, using block characters.
auto renderer_line_block = Renderer([&] {
auto c = Canvas(100, 100);
c.DrawText(0, 0, "Several lines (block)");
c.DrawBlockLine(mouse_x, mouse_y, 80, 10, Color::Red);
c.DrawBlockLine(80, 10, 80, 40, Color::Blue);
c.DrawBlockLine(80, 40, mouse_x, mouse_y, Color::Green);
return canvas(std::move(c));
});
// A circle following the mouse, using braille characters.
auto renderer_circle_braille = Renderer([&] {
auto c = Canvas(100, 100);
c.DrawText(0, 0, "A circle (braille)");
c.DrawPointCircle(mouse_x, mouse_y, 30);
return canvas(std::move(c));
});
// A circle following the mouse, using block characters.
auto renderer_circle_block = Renderer([&] {
auto c = Canvas(100, 100);
c.DrawText(0, 0, "A circle (block)");
c.DrawBlockCircle(mouse_x, mouse_y, 30);
return canvas(std::move(c));
});
// A filled circle following the mouse, using braille characters.
auto renderer_circle_filled_braille = Renderer([&] {
auto c = Canvas(100, 100);
c.DrawText(0, 0, "A circle filled (braille)");
c.DrawPointCircleFilled(mouse_x, mouse_y, 30);
return canvas(std::move(c));
});
// A filled circle following the mouse, using block characters.
auto renderer_circle_filled_block = Renderer([&] {
auto c = Canvas(100, 100);
c.DrawText(0, 0, "A circle filled (block)");
c.DrawBlockCircleFilled(mouse_x, mouse_y, 30);
return canvas(std::move(c));
});
// An ellipse following the mouse, using braille characters.
auto renderer_ellipse_braille = Renderer([&] {
auto c = Canvas(100, 100);
c.DrawText(0, 0, "An ellipse (braille)");
c.DrawPointEllipse(mouse_x / 2, mouse_y / 2, mouse_x / 2, mouse_y / 2);
return canvas(std::move(c));
});
// An ellipse following the mouse, using block characters.
auto renderer_ellipse_block = Renderer([&] {
auto c = Canvas(100, 100);
c.DrawText(0, 0, "An ellipse (block)");
c.DrawBlockEllipse(mouse_x / 2, mouse_y / 2, mouse_x / 2, mouse_y / 2);
return canvas(std::move(c));
});
// An ellipse following the mouse filled, using braille characters.
auto renderer_ellipse_filled_braille = Renderer([&] {
auto c = Canvas(100, 100);
c.DrawText(0, 0, "A filled ellipse (braille)");
c.DrawPointEllipseFilled(mouse_x / 2, mouse_y / 2, mouse_x / 2,
mouse_y / 2);
return canvas(std::move(c));
});
// An ellipse following the mouse filled, using block characters.
auto renderer_ellipse_filled_block = Renderer([&] {
auto c = Canvas(100, 100);
c.DrawText(0, 0, "A filled ellipse (block)");
c.DrawBlockEllipseFilled(mouse_x / 2, mouse_y / 2, mouse_x / 2,
mouse_y / 2);
c.DrawBlockEllipse(mouse_x / 2, mouse_y / 2, mouse_x / 2, mouse_y / 2);
return canvas(std::move(c));
});
// A text following the mouse
auto renderer_text = Renderer([&] {
auto c = Canvas(100, 100);
c.DrawText(0, 0, "A piece of text");
c.DrawText(mouse_x, mouse_y, "This is a piece of text with effects",
[](Pixel& p) {
p.foreground_color = Color::Red;
p.underlined = true;
p.bold = true;
});
return canvas(std::move(c));
});
auto renderer_plot_1 = Renderer([&] {
auto c = Canvas(100, 100);
c.DrawText(0, 0, "A graph");
std::vector<int> ys(100);
for (int x = 0; x < 100; x++) {
float dx = float(x - mouse_x);
float dy = 50.f;
ys[x] = int(dy + 20 * cos(dx * 0.14) + 10 * sin(dx * 0.42));
}
for (int x = 1; x < 99; x++)
c.DrawPointLine(x, ys[x], x + 1, ys[x + 1]);
return canvas(std::move(c));
});
auto renderer_plot_2 = Renderer([&] {
auto c = Canvas(100, 100);
c.DrawText(0, 0, "A symmetrical graph filled");
std::vector<int> ys(100);
for (int x = 0; x < 100; x++) {
ys[x] = int(30 + //
10 * cos(x * 0.2 - mouse_x * 0.05) + //
5 * sin(x * 0.4) + //
5 * sin(x * 0.3 - mouse_y * 0.05)); //
}
for (int x = 0; x < 100; x++) {
c.DrawPointLine(x, 50 + ys[x], x, 50 - ys[x], Color::Red);
}
return canvas(std::move(c));
});
auto renderer_plot_3 = Renderer([&] {
auto c = Canvas(100, 100);
c.DrawText(0, 0, "A 2D gaussian plot");
int size = 15;
// mouse_x = 5mx + 3*my
// mouse_y = 0mx + -5my + 90
float my = (mouse_y - 90) / -5.f;
float mx = (mouse_x - 3 * my) / 5.f;
std::vector<std::vector<float>> ys(size, std::vector<float>(size));
for (int y = 0; y < size; y++) {
for (int x = 0; x < size; x++) {
float dx = x - mx;
float dy = y - my;
ys[y][x] = -1.5 + 3.0 * std::exp(-0.2f * (dx * dx + dy * dy));
}
}
for (int y = 0; y < size; y++) {
for (int x = 0; x < size; x++) {
if (x != 0) {
c.DrawPointLine(
5 * (x - 1) + 3 * (y - 0), 90 - 5 * (y - 0) - 5 * ys[y][x - 1],
5 * (x - 0) + 3 * (y - 0), 90 - 5 * (y - 0) - 5 * ys[y][x]);
}
if (y != 0) {
c.DrawPointLine(
5 * (x - 0) + 3 * (y - 1), 90 - 5 * (y - 1) - 5 * ys[y - 1][x],
5 * (x - 0) + 3 * (y - 0), 90 - 5 * (y - 0) - 5 * ys[y][x]);
}
}
}
return canvas(std::move(c));
});
int selected_tab = 12;
auto tab = Container::Tab(
{
renderer_line_braille,
renderer_line_block,
renderer_circle_braille,
renderer_circle_block,
renderer_circle_filled_braille,
renderer_circle_filled_block,
renderer_ellipse_braille,
renderer_ellipse_block,
renderer_ellipse_filled_braille,
renderer_ellipse_filled_block,
renderer_plot_1,
renderer_plot_2,
renderer_plot_3,
renderer_text,
},
&selected_tab);
// This capture the last mouse position.
auto tab_with_mouse = CatchEvent(tab, [&](Event e) {
if (e.is_mouse()) {
mouse_x = (e.mouse().x - 1) * 2;
mouse_y = (e.mouse().y - 1) * 4;
}
return false;
});
std::vector<std::string> tab_titles = {
"line (braille)",
"line (block)",
"circle (braille)",
"circle (block)",
"circle filled (braille)",
"circle filled (block)",
"ellipse (braille)",
"ellipse (block)",
"ellipse filled (braille)",
"ellipse filled (block)",
"plot_1 simple",
"plot_2 filled",
"plot_3 3D",
"text",
};
auto tab_toggle = Menu(&tab_titles, &selected_tab);
auto component = Container::Horizontal({
tab_with_mouse,
tab_toggle,
});
// Add some separator to decorate the whole component:
auto component_renderer = Renderer(component, [&] {
return hbox({
tab_with_mouse->Render(),
separator(),
tab_toggle->Render(),
}) |
border;
});
auto screen = ScreenInteractive::FitComponent();
screen.Loop(component_renderer);
return 0;
}

View File

@ -1,25 +1,38 @@
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Checkbox, Vertical
// Copyright 2021 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 <array> // for array
#include <iostream>
#include <memory> // for shared_ptr, __shared_ptr_access
#include <string> // for operator+, to_string
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Checkbox, Renderer, Vertical
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for operator|, Element, size, border, frame, vscroll_indicator, HEIGHT, LESS_THAN
using namespace ftxui;
int main(int argc, const char* argv[]) {
bool build_examples_state = false;
bool build_tests_state = false;
bool use_webassembly_state = true;
int main() {
bool download = false;
bool upload = false;
bool ping = false;
auto component = Container::Vertical({
Checkbox("Build examples", &build_examples_state),
Checkbox("Build tests", &build_tests_state),
Checkbox("Use WebAssembly", &use_webassembly_state),
auto container = Container::Vertical({
Checkbox("Download", &download),
Checkbox("Upload", &upload),
Checkbox("Ping", &ping),
});
auto screen = ScreenInteractive::TerminalOutput();
screen.Loop(component);
auto screen = ScreenInteractive::FitComponent();
screen.Loop(container);
std::cout << "---" << std::endl;
std::cout << "Download: " << download << std::endl;
std::cout << "Upload: " << upload << std::endl;
std::cout << "Ping: " << ping << std::endl;
std::cout << "---" << std::endl;
return 0;
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -1,26 +1,25 @@
#include <memory> // for shared_ptr, __shared_ptr_access, allocator_traits<>::value_type
// Copyright 2020 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 <array> // for array
#include <memory> // for shared_ptr, __shared_ptr_access
#include <string> // for operator+, to_string
#include <vector> // for vector
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Checkbox, Renderer, Vertical
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for operator|, Element, size, border, frame, HEIGHT, LESS_THAN
#include "ftxui/dom/elements.hpp" // for operator|, Element, size, border, frame, vscroll_indicator, HEIGHT, LESS_THAN
using namespace ftxui;
struct CheckboxState {
bool checked;
};
int main() {
std::array<bool, 30> states;
int main(int argc, const char* argv[]) {
std::vector<CheckboxState> states(30);
auto container = Container::Vertical({});
for (int i = 0; i < 30; ++i) {
states[i].checked = false;
container->Add(
Checkbox("Checkbox" + std::to_string(i), &states[i].checked));
states[i] = false;
container->Add(Checkbox("Checkbox" + std::to_string(i), &states[i]));
}
auto renderer = Renderer(container, [&] {
@ -33,7 +32,3 @@ int main(int argc, const char* argv[]) {
return 0;
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -0,0 +1,57 @@
// Copyright 2020 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 <memory> // for allocator, make_shared, __shared_ptr_access
#include <utility> // for move
#include <vector> // for vector
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Collapsible, Renderer, Vertical
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
#include "ftxui/dom/elements.hpp" // for text, hbox, Element
using namespace ftxui;
// Take a list of component, display them vertically, one column shifted to the
// right.
Component Inner(std::vector<Component> children) {
Component vlist = Container::Vertical(std::move(children));
return Renderer(vlist, [vlist] {
return hbox({
text(" "),
vlist->Render(),
});
});
}
Component Empty() {
return std::make_shared<ComponentBase>();
}
int main() {
auto component =
Collapsible("Collapsible 1",
Inner({
Collapsible("Collapsible 1.1",
Inner({
Collapsible("Collapsible 1.1.1", Empty()),
Collapsible("Collapsible 1.1.2", Empty()),
Collapsible("Collapsible 1.1.3", Empty()),
})),
Collapsible("Collapsible 1.2",
Inner({
Collapsible("Collapsible 1.2.1", Empty()),
Collapsible("Collapsible 1.2.2", Empty()),
Collapsible("Collapsible 1.2.3", Empty()),
})),
Collapsible("Collapsible 1.3",
Inner({
Collapsible("Collapsible 1.3.1", Empty()),
Collapsible("Collapsible 1.3.2", Empty()),
Collapsible("Collapsible 1.3.3", Empty()),
})),
}));
ScreenInteractive::FitComponent().Loop(component);
}

View File

@ -1,10 +1,12 @@
// Copyright 2021 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 <memory> // for allocator, shared_ptr, __shared_ptr_access
#include <string> // for operator+, to_string
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Button, Horizontal, Renderer
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/component_options.hpp" // for ButtonOption
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for text, separator, Element, operator|, vbox, border
@ -12,25 +14,18 @@ using namespace ftxui;
// An example of how to compose multiple components into one and maintain their
// interactiveness.
int main(int argc, const char* argv[]) {
auto button_option = ButtonOption();
button_option.border = false;
int main() {
auto left_count = 0;
auto right_count = 0;
auto left_buttons = Container::Horizontal({
Button(
"[Decrease]", [&] { left_count--; }, &button_option),
Button(
"[Increase]", [&] { left_count++; }, &button_option),
Button("Decrease", [&] { left_count--; }),
Button("Increase", [&] { left_count++; }),
});
auto right_buttons = Container::Horizontal({
Button(
"[Decrease]", [&] { right_count--; }, &button_option),
Button(
"[Increase]", [&] { right_count++; }, &button_option),
Button("Decrease", [&] { right_count--; }),
Button("Increase", [&] { right_count++; }),
});
// Renderer decorates its child with a new rendering function. The way the
@ -66,7 +61,3 @@ int main(int argc, const char* argv[]) {
}
// Thanks to Chris Morgan for this example!
// Copyright 2021 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -0,0 +1,54 @@
// Copyright 2020 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 <stdlib.h> // for EXIT_SUCCESS
#include <chrono> // for milliseconds
#include <ftxui/component/event.hpp> // for Event
#include <ftxui/component/mouse.hpp> // for ftxui
#include <ftxui/dom/elements.hpp> // for text, separator, Element, operator|, vbox, border
#include <memory> // for allocator, shared_ptr
#include <string> // for operator+, to_string
#include <thread> // for sleep_for
#include "ftxui/component/component.hpp" // for CatchEvent, Renderer, operator|=
#include "ftxui/component/loop.hpp" // for Loop
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
int main() {
using namespace ftxui;
auto screen = ScreenInteractive::FitComponent();
// Create a component counting the number of frames drawn and event handled.
int custom_loop_count = 0;
int frame_count = 0;
int event_count = 0;
auto component = Renderer([&] {
frame_count++;
return vbox({
text("This demonstrates using a custom ftxui::Loop. It "),
text("runs at 100 iterations per seconds. The FTXUI events "),
text("are all processed once per iteration and a new frame "),
text("is rendered as needed"),
separator(),
text("ftxui event count: " + std::to_string(event_count)),
text("ftxui frame count: " + std::to_string(frame_count)),
text("Custom loop count: " + std::to_string(custom_loop_count)),
}) |
border;
});
component |= CatchEvent([&](Event) -> bool {
event_count++;
return false;
});
Loop loop(&screen, component);
while (!loop.HasQuitted()) {
custom_loop_count++;
loop.RunOnce();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
return EXIT_SUCCESS;
}

View File

@ -1,26 +1,26 @@
#include <functional> // for function
#include <iostream> // for basic_ostream::operator<<, operator<<, endl, basic_ostream, basic_ostream<>::__ostream_type, cout, ostream
#include <string> // for string, basic_string, allocator
#include <vector> // for vector
// Copyright 2020 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 <string> // for basic_string, string, allocator
#include <vector> // for vector
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Menu
#include "ftxui/component/component_options.hpp" // for MenuOption
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Dropdown, Horizontal, Vertical
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
std::vector<std::string> entries = {
"tribute", "clearance", "ally", "bend", "electronics",
"module", "era", "cultural", "sniff", "nationalism",
"negotiation", "deliver", "figure", "east",
"tribute", "clearance", "ally", "bend", "electronics",
"module", "era", "cultural", "sniff", "nationalism",
"negotiation", "deliver", "figure", "east",
"tribute", "clearance", "ally", "bend", "electronics",
"module", "era", "cultural", "sniff", "nationalism",
"negotiation", "deliver", "figure", "east",
"tribute", "clearance", "ally", "bend", "electronics",
"module", "era", "cultural", "sniff", "nationalism",
"negotiation", "deliver", "figure", "east", "tribute",
"clearance", "ally", "bend", "electronics", "module",
"era", "cultural", "sniff", "nationalism", "negotiation",
"deliver", "figure", "east", "tribute", "clearance",
"ally", "bend", "electronics", "module", "era",
"cultural", "sniff", "nationalism", "negotiation", "deliver",
"figure", "east",
};
int selected_1 = 0;
@ -42,7 +42,3 @@ int main(int argc, const char* argv[]) {
auto screen = ScreenInteractive::FitComponent();
screen.Loop(layout);
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -0,0 +1,104 @@
// Copyright 2020 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 <string> // for basic_string, string, allocator
#include <vector> // for vector
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Dropdown, Horizontal, Vertical
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
int main() {
using namespace ftxui;
std::vector<std::string> entries = {
"tribute", "clearance", "ally", "bend", "electronics",
"module", "era", "cultural", "sniff", "nationalism",
"negotiation", "deliver", "figure", "east", "tribute",
"clearance", "ally", "bend", "electronics", "module",
"era", "cultural", "sniff", "nationalism", "negotiation",
"deliver", "figure", "east", "tribute", "clearance",
"ally", "bend", "electronics", "module", "era",
"cultural", "sniff", "nationalism", "negotiation", "deliver",
"figure", "east",
};
auto dropdown_1 = Dropdown({
.radiobox = {.entries = &entries},
.transform =
[](bool open, Element checkbox, Element radiobox) {
if (open) {
return vbox({
checkbox | inverted,
radiobox | vscroll_indicator | frame |
size(HEIGHT, LESS_THAN, 10),
filler(),
});
}
return vbox({
checkbox,
filler(),
});
},
});
auto dropdown_2 = Dropdown({
.radiobox = {.entries = &entries},
.transform =
[](bool open, Element checkbox, Element radiobox) {
if (open) {
return vbox({
checkbox | inverted,
radiobox | vscroll_indicator | frame |
size(HEIGHT, LESS_THAN, 10) | bgcolor(Color::Blue),
filler(),
});
}
return vbox({
checkbox | bgcolor(Color::Blue),
filler(),
});
},
});
auto dropdown_3 = Dropdown({
.radiobox =
{
.entries = &entries,
.transform =
[](const EntryState& s) {
auto t = text(s.label) | borderEmpty;
if (s.active) {
t |= bold;
}
if (s.focused) {
t |= inverted;
}
return t;
},
},
.transform =
[](bool open, Element checkbox, Element radiobox) {
checkbox |= borderEmpty;
if (open) {
return vbox({
checkbox | inverted,
radiobox | vscroll_indicator | frame |
size(HEIGHT, LESS_THAN, 20) | bgcolor(Color::Red),
filler(),
});
}
return vbox({
checkbox | bgcolor(Color::Red),
filler(),
});
},
});
auto screen = ScreenInteractive::FitComponent();
screen.Loop(Container::Horizontal({
dropdown_1,
dropdown_2,
dropdown_3,
}));
}

View File

@ -0,0 +1,191 @@
// Copyright 2020 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 <stddef.h> // for size_t
#include <memory> // for shared_ptr, __shared_ptr_access, allocator
#include <string> // for string, basic_string, to_string, operator+, char_traits
#include <vector> // for vector
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Radiobox, Vertical, Checkbox, Horizontal, Renderer, ResizableSplitBottom, ResizableSplitRight
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for text, window, operator|, vbox, hbox, Element, flexbox, bgcolor, filler, flex, size, border, hcenter, color, EQUAL, bold, dim, notflex, xflex_grow, yflex_grow, HEIGHT, WIDTH
#include "ftxui/dom/flexbox_config.hpp" // for FlexboxConfig, FlexboxConfig::AlignContent, FlexboxConfig::JustifyContent, FlexboxConfig::AlignContent::Center, FlexboxConfig::AlignItems, FlexboxConfig::Direction, FlexboxConfig::JustifyContent::Center, FlexboxConfig::Wrap
#include "ftxui/screen/color.hpp" // for Color, Color::Black
using namespace ftxui;
int main() {
auto screen = ScreenInteractive::Fullscreen();
int direction_index = 0;
int wrap_index = 0;
int justify_content_index = 0;
int align_items_index = 0;
int align_content_index = 0;
std::vector<std::string> directions = {
"Row",
"RowInversed",
"Column",
"ColumnInversed",
};
std::vector<std::string> wraps = {
"NoWrap",
"Wrap",
"WrapInversed",
};
std::vector<std::string> justify_content = {
"FlexStart", "FlexEnd", "Center", "Stretch",
"SpaceBetween", "SpaceAround", "SpaceEvenly",
};
std::vector<std::string> align_items = {
"FlexStart",
"FlexEnd",
"Center",
"Stretch",
};
std::vector<std::string> align_content = {
"FlexStart", "FlexEnd", "Center", "Stretch",
"SpaceBetween", "SpaceAround", "SpaceEvenly",
};
auto radiobox_direction = Radiobox(&directions, &direction_index);
auto radiobox_wrap = Radiobox(&wraps, &wrap_index);
auto radiobox_justify_content =
Radiobox(&justify_content, &justify_content_index);
auto radiobox_align_items = Radiobox(&align_items, &align_items_index);
auto radiobox_align_content = Radiobox(&align_content, &align_content_index);
bool element_xflex_grow = false;
bool element_yflex_grow = false;
bool group_xflex_grow = true;
bool group_yflex_grow = true;
auto checkbox_element_xflex_grow =
Checkbox("element |= xflex_grow", &element_xflex_grow);
auto checkbox_element_yflex_grow =
Checkbox("element |= yflex_grow", &element_yflex_grow);
auto checkbox_group_xflex_grow =
Checkbox("group |= xflex_grow", &group_xflex_grow);
auto checkbox_group_yflex_grow =
Checkbox("group |= yflex_grow", &group_yflex_grow);
auto make_box = [&](size_t dimx, size_t dimy, size_t index) {
std::string title = std::to_string(dimx) + "x" + std::to_string(dimy);
auto element = window(text(title) | hcenter | bold,
text(std::to_string(index)) | hcenter | dim) |
size(WIDTH, EQUAL, dimx) | size(HEIGHT, EQUAL, dimy) |
bgcolor(Color::HSV(index * 25, 255, 255)) |
color(Color::Black);
if (element_xflex_grow)
element = element | xflex_grow;
if (element_yflex_grow)
element = element | yflex_grow;
return element;
};
auto content_renderer = Renderer([&] {
FlexboxConfig config;
config.direction = static_cast<FlexboxConfig::Direction>(direction_index);
config.wrap = static_cast<FlexboxConfig::Wrap>(wrap_index);
config.justify_content =
static_cast<FlexboxConfig::JustifyContent>(justify_content_index);
config.align_items =
static_cast<FlexboxConfig::AlignItems>(align_items_index);
config.align_content =
static_cast<FlexboxConfig::AlignContent>(align_content_index);
auto group = flexbox(
{
make_box(8, 4, 0),
make_box(9, 6, 1),
make_box(11, 6, 2),
make_box(10, 4, 3),
make_box(13, 7, 4),
make_box(12, 4, 5),
make_box(12, 5, 6),
make_box(10, 4, 7),
make_box(12, 4, 8),
make_box(10, 5, 9),
},
config);
group = group | bgcolor(Color::Black);
group = group | notflex;
if (!group_xflex_grow)
group = hbox(group, filler());
if (!group_yflex_grow)
group = vbox(group, filler());
group = group | flex;
return group;
});
auto center = FlexboxConfig()
.Set(FlexboxConfig::JustifyContent::Center)
.Set(FlexboxConfig::AlignContent::Center);
int space_right = 10;
int space_bottom = 1;
content_renderer = ResizableSplitRight(
Renderer([&] { return flexbox({text("resizable")}, center); }),
content_renderer, &space_right);
content_renderer = ResizableSplitBottom(
Renderer([&] { return flexbox({text("resizable")}, center); }),
content_renderer, &space_bottom);
auto main_container = Container::Vertical({
Container::Horizontal({
radiobox_direction,
radiobox_wrap,
Container::Vertical({
checkbox_element_xflex_grow,
checkbox_element_yflex_grow,
checkbox_group_xflex_grow,
checkbox_group_yflex_grow,
}),
}),
Container::Horizontal({
radiobox_justify_content,
radiobox_align_items,
radiobox_align_content,
}),
content_renderer,
});
auto main_renderer = Renderer(main_container, [&] {
return vbox({
vbox({hbox({
window(text("FlexboxConfig::Direction"),
radiobox_direction->Render()),
window(text("FlexboxConfig::Wrap"), radiobox_wrap->Render()),
window(text("Misc:"),
vbox({
checkbox_element_xflex_grow->Render(),
checkbox_element_yflex_grow->Render(),
checkbox_group_xflex_grow->Render(),
checkbox_group_yflex_grow->Render(),
})),
}),
hbox({
window(text("FlexboxConfig::JustifyContent"),
radiobox_justify_content->Render()),
window(text("FlexboxConfig::AlignItems"),
radiobox_align_items->Render()),
window(text("FlexboxConfig::AlignContent"),
radiobox_align_content->Render()),
})}),
content_renderer->Render() | flex | border,
});
});
screen.Loop(main_renderer);
return 0;
}

View File

@ -0,0 +1,69 @@
// Copyright 2020 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 <memory> // for allocator, shared_ptr, __shared_ptr_access
#include <string> // for operator+, char_traits, to_string, string
#include <vector> // for vector
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Slider, Renderer, Vertical
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for Elements, Element, operator|, separator, text, focusPositionRelative, size, border, flex, frame, bgcolor, gridbox, vbox, EQUAL, center, HEIGHT, WIDTH
#include "ftxui/screen/color.hpp" // for Color
using namespace ftxui;
Element make_box(int x, int y) {
std::string title = "(" + std::to_string(x) + ", " + std::to_string(y) + ")";
return text(title) | center | size(WIDTH, EQUAL, 18) |
size(HEIGHT, EQUAL, 9) | border |
bgcolor(Color::HSV(x * 255 / 15, 255, y * 255 / 15));
};
Element make_grid() {
std::vector<Elements> rows;
for (int i = 0; i < 15; i++) {
std::vector<Element> cols;
for (int j = 0; j < 15; j++) {
cols.push_back(make_box(i, j));
}
rows.push_back(cols);
}
return gridbox(rows);
};
int main() {
float focus_x = 0.5f;
float focus_y = 0.5f;
auto slider_x = Slider("x", &focus_x, 0.f, 1.f, 0.01f);
auto slider_y = Slider("y", &focus_y, 0.f, 1.f, 0.01f);
auto renderer = Renderer(
Container::Vertical({
slider_x,
slider_y,
}),
[&] {
auto title = "focusPositionRelative(" + //
std::to_string(focus_x) + ", " + //
std::to_string(focus_y) + ")"; //
return vbox({
text(title),
separator(),
slider_x->Render(),
slider_y->Render(),
separator(),
make_grid() | focusPositionRelative(focus_x, focus_y) |
frame | flex,
}) |
border;
});
auto screen = ScreenInteractive::Fullscreen();
screen.Loop(renderer);
return 0;
}

View File

@ -0,0 +1,37 @@
// Copyright 2020 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/captured_mouse.hpp> // for ftxui
#include <string> // for allocator, operator+, char_traits, string
#include "ftxui/component/component.hpp" // for Renderer, Vertical
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive, Component
#include "ftxui/dom/elements.hpp" // for text, Decorator, focus, focusCursorBar, focusCursorBarBlinking, focusCursorBlock, focusCursorBlockBlinking, focusCursorUnderline, focusCursorUnderlineBlinking, hbox, Element
using namespace ftxui;
Component Instance(std::string label, Decorator focusCursor) {
return Renderer([=](bool focused) {
if (focused) {
return hbox({
text("> " + label + " "),
focusCursor(text(" ")),
});
}
return text(" " + label + " ");
});
};
int main() {
auto screen = ScreenInteractive::Fullscreen();
screen.Loop(Container::Vertical({
Instance("focus", focus),
Instance("focusCursorBlock", focusCursorBlock),
Instance("focusCursorBlockBlinking", focusCursorBlockBlinking),
Instance("focusCursorBar", focusCursorBar),
Instance("focusCursorBarBlinking", focusCursorBarBlinking),
Instance("focusCursorUnderline", focusCursorUnderline),
Instance("focusCursorUnderlineBlinking", focusCursorUnderlineBlinking),
}));
return 0;
}

View File

@ -1,3 +1,6 @@
// Copyright 2020 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 <functional> // for function
#include <memory> // for shared_ptr, allocator, __shared_ptr_access
#include <string> // for string, basic_string
@ -23,7 +26,7 @@ Component Wrap(std::string name, Component component) {
});
}
int main(int argc, const char* argv[]) {
int main() {
auto screen = ScreenInteractive::FitComponent();
// -- Menu
@ -94,7 +97,25 @@ int main(int argc, const char* argv[]) {
});
sliders = Wrap("Slider", sliders);
// -- Layout -----------------------------------------------------------------
// A large text:
auto lorel_ipsum = Renderer([] {
return vbox({
text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. "),
text("Sed do eiusmod tempor incididunt ut labore et dolore magna "
"aliqua. "),
text("Ut enim ad minim veniam, quis nostrud exercitation ullamco "
"laboris nisi ut aliquip ex ea commodo consequat. "),
text("Duis aute irure dolor in reprehenderit in voluptate velit esse "
"cillum dolore eu fugiat nulla pariatur. "),
text("Excepteur sint occaecat cupidatat non proident, sunt in culpa "
"qui officia deserunt mollit anim id est laborum. "),
});
});
lorel_ipsum = Wrap("Lorel Ipsum", lorel_ipsum);
// -- Layout
// -----------------------------------------------------------------
auto layout = Container::Vertical({
menu,
toggle,
@ -103,6 +124,7 @@ int main(int argc, const char* argv[]) {
input,
sliders,
button,
lorel_ipsum,
});
auto component = Renderer(layout, [&] {
@ -120,6 +142,8 @@ int main(int argc, const char* argv[]) {
sliders->Render(),
separator(),
button->Render(),
separator(),
lorel_ipsum->Render(),
}) |
xflex | size(WIDTH, GREATER_THAN, 40) | border;
});
@ -128,7 +152,3 @@ int main(int argc, const char* argv[]) {
return 0;
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -1,27 +1,38 @@
// Copyright 2020 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 <stddef.h> // for size_t
#include <array> // for array
#include <atomic> // for atomic
#include <chrono> // for operator""s, chrono_literals
#include <cmath> // for sin
#include <functional> // for ref, reference_wrapper, function
#include <memory> // for allocator, shared_ptr, __shared_ptr_access
#include <string> // for string, basic_string, operator+, char_traits, to_string
#include <string> // for string, basic_string, char_traits, operator+, to_string
#include <thread> // for sleep_for, thread
#include <utility> // for move
#include <vector> // for vector
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Checkbox, Renderer, Horizontal, Vertical, Menu, Radiobox, Tab, Toggle
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/component_options.hpp" // for InputOption
#include "../dom/color_info_sorted_2d.ipp" // for ColorInfoSorted2D
#include "ftxui/component/component.hpp" // for Checkbox, Renderer, Horizontal, Vertical, Input, Menu, Radiobox, ResizableSplitLeft, Tab
#include "ftxui/component/component_base.hpp" // for ComponentBase, Component
#include "ftxui/component/component_options.hpp" // for MenuOption, InputOption
#include "ftxui/component/event.hpp" // for Event, Event::Custom
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
#include "ftxui/dom/elements.hpp" // for operator|, color, bgcolor, filler, Element, size, vbox, flex, hbox, graph, separator, EQUAL, WIDTH, hcenter, bold, border, window, HEIGHT, Elements, hflow, flex_grow, frame, gauge, LESS_THAN, spinner, dim, GREATER_THAN
#include "ftxui/screen/color.hpp" // for Color, Color::BlueLight, Color::RedLight, Color::Black, Color::Blue, Color::Cyan, Color::CyanLight, Color::GrayDark, Color::GrayLight, Color::Green, Color::GreenLight, Color::Magenta, Color::MagentaLight, Color::Red, Color::White, Color::Yellow, Color::YellowLight, Color::Default
#include "ftxui/dom/elements.hpp" // for text, color, operator|, bgcolor, filler, Element, vbox, size, hbox, separator, flex, window, graph, EQUAL, paragraph, WIDTH, hcenter, Elements, bold, vscroll_indicator, HEIGHT, flexbox, hflow, border, frame, flex_grow, gauge, paragraphAlignCenter, paragraphAlignJustify, paragraphAlignLeft, paragraphAlignRight, dim, spinner, LESS_THAN, center, yframe, GREATER_THAN
#include "ftxui/dom/flexbox_config.hpp" // for FlexboxConfig
#include "ftxui/screen/color.hpp" // for Color, Color::BlueLight, Color::RedLight, Color::Black, Color::Blue, Color::Cyan, Color::CyanLight, Color::GrayDark, Color::GrayLight, Color::Green, Color::GreenLight, Color::Magenta, Color::MagentaLight, Color::Red, Color::White, Color::Yellow, Color::YellowLight, Color::Default, Color::Palette256, ftxui
#include "ftxui/screen/color_info.hpp" // for ColorInfo
#include "ftxui/screen/terminal.hpp" // for Size, Dimensions
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
auto screen = ScreenInteractive::Fullscreen();
// ---------------------------------------------------------------------------
// HTOP
// ---------------------------------------------------------------------------
int shift = 0;
auto my_graph = [&shift](int width, int height) {
@ -89,9 +100,13 @@ int main(int argc, const char* argv[]) {
separator(),
ram | flex,
}) |
flex | border;
flex;
});
// ---------------------------------------------------------------------------
// Compiler
// ---------------------------------------------------------------------------
const std::vector<std::string> compiler_entries = {
"gcc",
"clang",
@ -245,64 +260,128 @@ int main(int argc, const char* argv[]) {
}) | size(HEIGHT, LESS_THAN, 8),
hflow(render_command()) | flex_grow,
}) |
flex_grow | border;
flex_grow;
});
// ---------------------------------------------------------------------------
// Spinner
// ---------------------------------------------------------------------------
auto spinner_tab_renderer = Renderer([&] {
Elements entries;
for (int i = 0; i < 22; ++i) {
entries.push_back(spinner(i, shift / 2) | bold |
size(WIDTH, GREATER_THAN, 2) | border);
}
return hflow(std::move(entries)) | border;
return hflow(std::move(entries));
});
// ---------------------------------------------------------------------------
// Colors
// ---------------------------------------------------------------------------
auto color_tab_renderer = Renderer([] {
return hbox({
vbox({
color(Color::Default, text("Default")),
color(Color::Black, text("Black")),
color(Color::GrayDark, text("GrayDark")),
color(Color::GrayLight, text("GrayLight")),
color(Color::White, text("White")),
color(Color::Blue, text("Blue")),
color(Color::BlueLight, text("BlueLight")),
color(Color::Cyan, text("Cyan")),
color(Color::CyanLight, text("CyanLight")),
color(Color::Green, text("Green")),
color(Color::GreenLight, text("GreenLight")),
color(Color::Magenta, text("Magenta")),
color(Color::MagentaLight, text("MagentaLight")),
color(Color::Red, text("Red")),
color(Color::RedLight, text("RedLight")),
color(Color::Yellow, text("Yellow")),
color(Color::YellowLight, text("YellowLight")),
}),
vbox({
bgcolor(Color::Default, text("Default")),
bgcolor(Color::Black, text("Black")),
bgcolor(Color::GrayDark, text("GrayDark")),
bgcolor(Color::GrayLight, text("GrayLight")),
bgcolor(Color::White, text("White")),
bgcolor(Color::Blue, text("Blue")),
bgcolor(Color::BlueLight, text("BlueLight")),
bgcolor(Color::Cyan, text("Cyan")),
bgcolor(Color::CyanLight, text("CyanLight")),
bgcolor(Color::Green, text("Green")),
bgcolor(Color::GreenLight, text("GreenLight")),
bgcolor(Color::Magenta, text("Magenta")),
bgcolor(Color::MagentaLight, text("MagentaLight")),
bgcolor(Color::Red, text("Red")),
bgcolor(Color::RedLight, text("RedLight")),
bgcolor(Color::Yellow, text("Yellow")),
bgcolor(Color::YellowLight, text("YellowLight")),
}),
}) |
hcenter | border;
auto basic_color_display =
vbox({
text("16 color palette:"),
separator(),
hbox({
vbox({
color(Color::Default, text("Default")),
color(Color::Black, text("Black")),
color(Color::GrayDark, text("GrayDark")),
color(Color::GrayLight, text("GrayLight")),
color(Color::White, text("White")),
color(Color::Blue, text("Blue")),
color(Color::BlueLight, text("BlueLight")),
color(Color::Cyan, text("Cyan")),
color(Color::CyanLight, text("CyanLight")),
color(Color::Green, text("Green")),
color(Color::GreenLight, text("GreenLight")),
color(Color::Magenta, text("Magenta")),
color(Color::MagentaLight, text("MagentaLight")),
color(Color::Red, text("Red")),
color(Color::RedLight, text("RedLight")),
color(Color::Yellow, text("Yellow")),
color(Color::YellowLight, text("YellowLight")),
}),
vbox({
bgcolor(Color::Default, text("Default")),
bgcolor(Color::Black, text("Black")),
bgcolor(Color::GrayDark, text("GrayDark")),
bgcolor(Color::GrayLight, text("GrayLight")),
bgcolor(Color::White, text("White")),
bgcolor(Color::Blue, text("Blue")),
bgcolor(Color::BlueLight, text("BlueLight")),
bgcolor(Color::Cyan, text("Cyan")),
bgcolor(Color::CyanLight, text("CyanLight")),
bgcolor(Color::Green, text("Green")),
bgcolor(Color::GreenLight, text("GreenLight")),
bgcolor(Color::Magenta, text("Magenta")),
bgcolor(Color::MagentaLight, text("MagentaLight")),
bgcolor(Color::Red, text("Red")),
bgcolor(Color::RedLight, text("RedLight")),
bgcolor(Color::Yellow, text("Yellow")),
bgcolor(Color::YellowLight, text("YellowLight")),
}),
}),
}) |
border;
auto palette_256_color_display = text("256 colors palette:");
{
std::vector<std::vector<ColorInfo>> info_columns = ColorInfoSorted2D();
Elements columns;
for (auto& column : info_columns) {
Elements column_elements;
for (auto& it : column) {
column_elements.push_back(
text(" ") | bgcolor(Color(Color::Palette256(it.index_256))));
}
columns.push_back(hbox(std::move(column_elements)));
}
palette_256_color_display = vbox({
palette_256_color_display,
separator(),
vbox(columns),
}) |
border;
}
// True color display.
auto true_color_display = text("TrueColors: 24bits:");
{
int saturation = 255;
Elements array;
for (int value = 0; value < 255; value += 16) {
Elements line;
for (int hue = 0; hue < 255; hue += 6) {
line.push_back(text("") //
| color(Color::HSV(hue, saturation, value)) //
| bgcolor(Color::HSV(hue, saturation, value + 8)));
}
array.push_back(hbox(std::move(line)));
}
true_color_display = vbox({
true_color_display,
separator(),
vbox(std::move(array)),
}) |
border;
}
return flexbox(
{
basic_color_display,
palette_256_color_display,
true_color_display,
},
FlexboxConfig().SetGap(1, 1));
});
// ---------------------------------------------------------------------------
// Gauges
// ---------------------------------------------------------------------------
auto render_gauge = [&shift](int delta) {
float progress = (shift + delta) % 1000 / 1000.f;
float progress = (shift + delta) % 500 / 500.f;
return hbox({
text(std::to_string(int(progress * 100)) + "% ") |
size(WIDTH, EQUAL, 5),
@ -312,32 +391,94 @@ int main(int argc, const char* argv[]) {
auto gauge_component = Renderer([render_gauge] {
return vbox({
render_gauge(0) | color(Color::Black),
render_gauge(100) | color(Color::GrayDark),
render_gauge(50) | color(Color::GrayLight),
render_gauge(6894) | color(Color::White),
separator(),
render_gauge(6841) | color(Color::Blue),
render_gauge(9813) | color(Color::BlueLight),
render_gauge(98765) | color(Color::Cyan),
render_gauge(98) | color(Color::CyanLight),
render_gauge(9846) | color(Color::Green),
render_gauge(1122) | color(Color::GreenLight),
render_gauge(84) | color(Color::Magenta),
render_gauge(645) | color(Color::MagentaLight),
render_gauge(568) | color(Color::Red),
render_gauge(2222) | color(Color::RedLight),
render_gauge(220) | color(Color::Yellow),
render_gauge(348) | color(Color::YellowLight),
}) |
border;
render_gauge(0) | color(Color::Black),
render_gauge(100) | color(Color::GrayDark),
render_gauge(50) | color(Color::GrayLight),
render_gauge(6894) | color(Color::White),
separator(),
render_gauge(6841) | color(Color::Blue),
render_gauge(9813) | color(Color::BlueLight),
render_gauge(98765) | color(Color::Cyan),
render_gauge(98) | color(Color::CyanLight),
render_gauge(9846) | color(Color::Green),
render_gauge(1122) | color(Color::GreenLight),
render_gauge(84) | color(Color::Magenta),
render_gauge(645) | color(Color::MagentaLight),
render_gauge(568) | color(Color::Red),
render_gauge(2222) | color(Color::RedLight),
render_gauge(220) | color(Color::Yellow),
render_gauge(348) | color(Color::YellowLight),
});
});
// ---------------------------------------------------------------------------
// Paragraph
// ---------------------------------------------------------------------------
auto make_box = [](size_t dimx, size_t dimy) {
std::string title = std::to_string(dimx) + "x" + std::to_string(dimy);
return window(text(title) | hcenter | bold,
text("content") | hcenter | dim) |
size(WIDTH, EQUAL, dimx) | size(HEIGHT, EQUAL, dimy);
};
auto paragraph_renderer_left = Renderer([&] {
std::string str =
"Lorem Ipsum is simply dummy text of the printing and typesetting "
"industry.\nLorem Ipsum has been the industry's standard dummy text "
"ever since the 1500s, when an unknown printer took a galley of type "
"and scrambled it to make a type specimen book.";
return vbox({
window(text("Align left:"), paragraphAlignLeft(str)),
window(text("Align center:"), paragraphAlignCenter(str)),
window(text("Align right:"), paragraphAlignRight(str)),
window(text("Align justify:"), paragraphAlignJustify(str)),
window(text("Side by side"), hbox({
paragraph(str),
separator(),
paragraph(str),
})),
window(text("Elements with different size:"),
flexbox({
make_box(10, 5),
make_box(9, 4),
make_box(8, 4),
make_box(6, 3),
make_box(10, 5),
make_box(9, 4),
make_box(8, 4),
make_box(6, 3),
make_box(10, 5),
make_box(9, 4),
make_box(8, 4),
make_box(6, 3),
})),
}) |
vscroll_indicator | yframe | flex;
});
auto paragraph_renderer_right = Renderer([] {
return paragraph("<--- This vertical bar is resizable using the mouse") |
center;
});
int paragraph_renderer_split_position = Terminal::Size().dimx / 2;
auto paragraph_renderer_group =
ResizableSplitLeft(paragraph_renderer_left, paragraph_renderer_right,
&paragraph_renderer_split_position);
auto paragraph_renderer_group_renderer =
Renderer(paragraph_renderer_group,
[&] { return paragraph_renderer_group->Render(); });
// ---------------------------------------------------------------------------
// Tabs
// ---------------------------------------------------------------------------
int tab_index = 0;
std::vector<std::string> tab_entries = {
"htop", "color", "spinner", "gauge", "compiler",
"htop", "color", "spinner", "gauge", "compiler", "paragraph",
};
auto tab_selection = Toggle(&tab_entries, &tab_index);
auto tab_selection =
Menu(&tab_entries, &tab_index, MenuOption::HorizontalAnimated());
auto tab_content = Container::Tab(
{
htop,
@ -345,29 +486,44 @@ int main(int argc, const char* argv[]) {
spinner_tab_renderer,
gauge_component,
compiler_renderer,
paragraph_renderer_group_renderer,
},
&tab_index);
auto exit_button =
Button("Exit", [&] { screen.Exit(); }, ButtonOption::Animated());
auto main_container = Container::Vertical({
tab_selection,
Container::Horizontal({
tab_selection,
exit_button,
}),
tab_content,
});
auto main_renderer = Renderer(main_container, [&] {
return vbox({
text("FTXUI Demo") | bold | hcenter,
tab_selection->Render() | hcenter,
hbox({
tab_selection->Render() | flex,
exit_button->Render(),
}),
tab_content->Render() | flex,
});
});
bool refresh_ui_continue = true;
std::atomic<bool> refresh_ui_continue = true;
std::thread refresh_ui([&] {
while (refresh_ui_continue) {
using namespace std::chrono_literals;
std::this_thread::sleep_for(0.05s);
shift++;
screen.PostEvent(Event::Custom);
// The |shift| variable belong to the main thread. `screen.Post(task)`
// will execute the update on the thread where |screen| lives (e.g. the
// main thread). Using `screen.Post(task)` is threadsafe.
screen.Post([&] { shift++; });
// After updating the state, request a new frame to be drawn. This is done
// by simulating a new "custom" event to be handled.
screen.Post(Event::Custom);
}
});
@ -377,7 +533,3 @@ int main(int argc, const char* argv[]) {
return 0;
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 966 KiB

View File

@ -1,3 +1,6 @@
// Copyright 2020 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 <memory> // for allocator, __shared_ptr_access
#include <string> // for char_traits, operator+, string, basic_string
@ -9,33 +12,53 @@
#include "ftxui/dom/elements.hpp" // for text, hbox, separator, Element, operator|, vbox, border
#include "ftxui/util/ref.hpp" // for Ref
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
// The data:
std::string first_name;
std::string last_name;
std::string password;
std::string phoneNumber;
// The basic input components:
Component input_first_name = Input(&first_name, "first name");
Component input_last_name = Input(&last_name, "last name");
// The password input component:
InputOption password_option;
password_option.password = true;
Component input_password = Input(&password, "password", password_option);
// The phone number input component:
// We are using `CatchEvent` to filter out non-digit characters.
Component input_phone_number = Input(&phoneNumber, "phone number");
input_phone_number |= CatchEvent([&](Event event) {
return event.is_character() && !std::isdigit(event.character()[0]);
});
input_phone_number |= CatchEvent([&](Event event) {
return event.is_character() && phoneNumber.size() > 10;
});
// The component tree:
auto component = Container::Vertical({
input_first_name,
input_last_name,
input_password,
input_phone_number,
});
// Tweak how the component tree is rendered:
auto renderer = Renderer(component, [&] {
return vbox({
text("Hello " + first_name + " " + last_name),
separator(),
hbox(text(" First name : "), input_first_name->Render()),
hbox(text(" Last name : "), input_last_name->Render()),
hbox(text(" Password : "), input_password->Render()),
hbox(text(" Phone num : "), input_phone_number->Render()),
separator(),
text("Hello " + first_name + " " + last_name),
text("Your password is " + password),
text("Your phone number is " + phoneNumber),
}) |
border;
});
@ -43,7 +66,3 @@ int main(int argc, const char* argv[]) {
auto screen = ScreenInteractive::TerminalOutput();
screen.Loop(renderer);
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -0,0 +1,30 @@
// Copyright 2021 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 <memory> // for allocator, __shared_ptr_access
#include <string> // for string, basic_string, operator+, to_string
#include <vector> // for vector
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Input, Renderer, Vertical
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
#include "ftxui/dom/elements.hpp" // for operator|, Element, size, border, frame, vscroll_indicator, HEIGHT, LESS_THAN
int main() {
using namespace ftxui;
Component input_list = Container::Vertical({});
std::vector<std::string> items(100, "");
for (size_t i = 0; i < items.size(); ++i) {
input_list->Add(Input(&(items[i]), "placeholder " + std::to_string(i)));
}
auto renderer = Renderer(input_list, [&] {
return input_list->Render() | vscroll_indicator | frame | border |
size(HEIGHT, LESS_THAN, 10);
});
auto screen = ScreenInteractive::TerminalOutput();
screen.Loop(renderer);
}

View File

@ -0,0 +1,97 @@
// Copyright 2020 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/dom/linear_gradient.hpp> // for LinearGradient
#include <ftxui/screen/color.hpp> // for Color, Color::White, Color::Red, Color::Blue, Color::Black, Color::GrayDark, ftxui
#include <functional> // for function
#include <string> // for allocator, string
#include <utility> // for move
#include "ftxui/component/component.hpp" // for Input, Horizontal, Vertical, operator|
#include "ftxui/component/component_base.hpp" // for Component
#include "ftxui/component/component_options.hpp" // for InputState, InputOption
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for operator|=, Element, bgcolor, operator|, separatorEmpty, color, borderEmpty, separator, text, center, dim, hbox, vbox, border, borderDouble, borderRounded
int main() {
using namespace ftxui;
InputOption style_1 = InputOption::Default();
InputOption style_2 = InputOption::Spacious();
InputOption style_3 = InputOption::Spacious();
style_3.transform = [](InputState state) {
state.element |= borderEmpty;
if (state.is_placeholder) {
state.element |= dim;
}
if (state.focused) {
state.element |= borderDouble;
state.element |= bgcolor(Color::White);
state.element |= color(Color::Black);
} else if (state.hovered) {
state.element |= borderRounded;
state.element |= bgcolor(LinearGradient(90, Color::Blue, Color::Red));
state.element |= color(Color::White);
} else {
state.element |= border;
state.element |= bgcolor(LinearGradient(0, Color::Blue, Color::Red));
state.element |= color(Color::White);
}
return state.element;
};
InputOption style_4 = InputOption::Spacious();
style_4.transform = [](InputState state) {
state.element = hbox({
text("Theorem") | center | borderEmpty | bgcolor(Color::Red),
separatorEmpty(),
separator() | color(Color::White),
separatorEmpty(),
std::move(state.element),
});
state.element |= borderEmpty;
if (state.is_placeholder) {
state.element |= dim;
}
if (state.focused) {
state.element |= bgcolor(Color::Black);
} else {
state.element |= bgcolor(Color::Blue);
}
if (state.hovered) {
state.element |= bgcolor(Color::GrayDark);
}
return vbox({state.element, separatorEmpty()});
};
auto generateUiFromStyle = [&](InputOption style) {
auto first_name = new std::string(); // Leaked
auto middle_name = new std::string(); // Leaked
auto last_name = new std::string(); // Leaked
return Container::Vertical({
Input(first_name, "first name", style),
Input(middle_name, "middle name", style),
Input(last_name, "last name", style),
}) |
borderEmpty;
};
auto ui = Container::Horizontal({
generateUiFromStyle(style_1),
generateUiFromStyle(style_2),
generateUiFromStyle(style_3),
generateUiFromStyle(style_4),
});
auto screen = ScreenInteractive::TerminalOutput();
screen.Loop(ui);
}

View File

@ -0,0 +1,55 @@
// Copyright 2023 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_base.hpp> // for ComponentBase, Component
#include <ftxui/dom/elements.hpp> // for operator|, Element, flex, bgcolor, text, vbox, center
#include <ftxui/dom/linear_gradient.hpp> // for LinearGradient
#include <ftxui/screen/color.hpp> // for Color, Color::Blue, Color::Red
#include <memory> // for __shared_ptr_access, shared_ptr
#include <string> // for allocator, operator+, char_traits, string, to_string
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Slider, Renderer, Vertical
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
int main() {
using namespace ftxui;
auto screen = ScreenInteractive::Fullscreen();
int angle = 180.f;
float start = 0.f;
float end = 1.f;
std::string slider_angle_text;
std::string slider_start_text;
std::string slider_end_text;
auto slider_angle = Slider(&slider_angle_text, &angle, 0, 360);
auto slider_start = Slider(&slider_start_text, &start, 0.f, 1.f, 0.05f);
auto slider_end = Slider(&slider_end_text, &end, 0.f, 1.f, 0.05f);
auto layout = Container::Vertical({
slider_angle,
slider_start,
slider_end,
});
auto renderer = Renderer(layout, [&] {
slider_angle_text = "angle = " + std::to_string(angle) + "°";
slider_start_text = "start = " + std::to_string(int(start * 100)) + "%";
slider_end_text = "end = " + std::to_string(int(end * 100)) + "%";
auto background = text("Gradient") | center |
bgcolor(LinearGradient()
.Angle(angle)
.Stop(Color::Blue, start)
.Stop(Color::Red, end));
return vbox({
background | flex,
layout->Render(),
}) |
flex;
});
screen.Loop(renderer);
}

View File

@ -1,20 +1,19 @@
#include <functional> // for function
#include <iostream> // for basic_ostream::operator<<, operator<<, endl, basic_ostream, basic_ostream<>::__ostream_type, cout, ostream
#include <string> // for string, basic_string, allocator
#include <vector> // for vector
// Copyright 2020 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 <string> // for string, allocator, basic_string
#include <vector> // for vector
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Menu
#include "ftxui/component/component_options.hpp" // for MenuOption
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for operator|, Maybe, Checkbox, Radiobox, Renderer, Vertical
#include "ftxui/component/component_base.hpp" // for Component
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for Element, border, color, operator|, text
#include "ftxui/screen/color.hpp" // for Color, Color::Red
using namespace ftxui;
Component Border(Component child) {
return Renderer(child, [child] { return child->Render() | border; });
}
int main(int argc, const char* argv[]) {
int main() {
std::vector<std::string> entries = {
"entry 1",
"entry 2",
@ -22,26 +21,21 @@ int main(int argc, const char* argv[]) {
};
int menu_1_selected = 0;
int menu_2_selected = 0;
auto menu_1 = Radiobox(&entries, &menu_1_selected);
auto menu_2 = Radiobox(&entries, &menu_2_selected);
menu_1 = Border(menu_1);
menu_2 = Border(menu_2);
bool menu_1_show = false;
bool menu_2_show = false;
auto layout = Container::Vertical({
Checkbox("Show menu_1", &menu_1_show),
Maybe(menu_1, &menu_1_show),
Radiobox(&entries, &menu_1_selected) | border | Maybe(&menu_1_show),
Checkbox("Show menu_2", &menu_2_show),
Maybe(menu_2, &menu_2_show),
Radiobox(&entries, &menu_2_selected) | border | Maybe(&menu_2_show),
Renderer([] {
return text("You found the secret combinaison!") | color(Color::Red);
}) | Maybe([&] { return menu_1_selected == 1 && menu_2_selected == 2; }),
});
auto screen = ScreenInteractive::TerminalOutput();
screen.Loop(layout);
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -1,3 +1,6 @@
// Copyright 2020 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 <functional> // for function
#include <iostream> // for basic_ostream::operator<<, operator<<, endl, basic_ostream, basic_ostream<>::__ostream_type, cout, ostream
#include <string> // for string, basic_string, allocator
@ -8,7 +11,7 @@
#include "ftxui/component/component_options.hpp" // for MenuOption
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto screen = ScreenInteractive::TerminalOutput();
@ -21,13 +24,9 @@ int main(int argc, const char* argv[]) {
MenuOption option;
option.on_enter = screen.ExitLoopClosure();
auto menu = Menu(&entries, &selected, &option);
auto menu = Menu(&entries, &selected, option);
screen.Loop(menu);
std::cout << "Selected element = " << selected << std::endl;
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -1,3 +1,6 @@
// Copyright 2020 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 <functional> // for function
#include <memory> // for allocator, __shared_ptr_access
#include <string> // for string, basic_string, operator+, to_string
@ -10,7 +13,7 @@
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
#include "ftxui/dom/elements.hpp" // for text, separator, bold, hcenter, vbox, hbox, gauge, Element, operator|, border
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto screen = ScreenInteractive::TerminalOutput();
@ -27,9 +30,9 @@ int main(int argc, const char* argv[]) {
int left_menu_selected = 0;
int right_menu_selected = 0;
Component left_menu_ =
Menu(&left_menu_entries, &left_menu_selected, &menu_option);
Menu(&left_menu_entries, &left_menu_selected, menu_option);
Component right_menu_ =
Menu(&right_menu_entries, &right_menu_selected, &menu_option);
Menu(&right_menu_entries, &right_menu_selected, menu_option);
Component container = Container::Horizontal({
left_menu_,
@ -74,7 +77,3 @@ int main(int argc, const char* argv[]) {
screen.Loop(renderer);
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -1,28 +1,37 @@
// Copyright 2020 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 <functional> // for function
#include <iostream> // for basic_ostream::operator<<, operator<<, endl, basic_ostream, basic_ostream<>::__ostream_type, cout, ostream
#include <memory> // for shared_ptr, __shared_ptr_access
#include <string> // for to_string, allocator
#include <memory> // for allocator, shared_ptr, __shared_ptr_access
#include <string> // for char_traits, to_string, operator+, string, basic_string
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for MenuEntry, Renderer, Vertical
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/component_options.hpp" // for MenuEntryOption
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for operator|, separator, Element, Decorator, color, text, hbox, size, bold, frame, inverted, vbox, HEIGHT, LESS_THAN, border
#include "ftxui/dom/elements.hpp" // for operator|, Element, separator, text, hbox, size, frame, color, vbox, HEIGHT, LESS_THAN, bold, border, inverted
#include "ftxui/screen/color.hpp" // for Color, Color::Blue, Color::Cyan, Color::Green, Color::Red, Color::Yellow
using namespace ftxui;
// Define a special style for some menu entry.
MenuEntryOption Colored(ftxui::Color c) {
MenuEntryOption special_style;
special_style.style_normal = Decorator(color(c));
special_style.style_focused = Decorator(color(c)) | inverted;
special_style.style_selected = Decorator(color(c)) | bold;
special_style.style_selected_focused = Decorator(color(c)) | inverted | bold;
return special_style;
MenuEntryOption option;
option.transform = [c](EntryState state) {
state.label = (state.active ? "> " : " ") + state.label;
Element e = text(state.label) | color(c);
if (state.focused)
e = e | inverted;
if (state.active)
e = e | bold;
return e;
};
return option;
}
int main(int argc, const char* argv[]) {
int main() {
auto screen = ScreenInteractive::TerminalOutput();
int selected = 0;
@ -70,7 +79,3 @@ int main(int argc, const char* argv[]) {
std::cout << "Selected element = " << selected << std::endl;
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -0,0 +1,65 @@
// Copyright 2020 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 <iostream> // for basic_ostream::operator<<, operator<<, endl, basic_ostream, basic_ostream<>::__ostream_type, cout, ostream
#include <memory> // for shared_ptr, __shared_ptr_access
#include <string> // for to_string, allocator
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for MenuEntryAnimated, Renderer, Vertical
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/component_options.hpp" // for MenuEntryAnimated
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for operator|, separator, Element, Decorator, color, text, hbox, size, bold, frame, inverted, vbox, HEIGHT, LESS_THAN, border
#include "ftxui/screen/color.hpp" // for Color, Color::Blue, Color::Cyan, Color::Green, Color::Red, Color::Yellow
using namespace ftxui;
// Define a special style for some menu entry.
MenuEntryOption Colored(ftxui::Color c) {
MenuEntryOption option;
option.animated_colors.foreground.enabled = true;
option.animated_colors.background.enabled = true;
option.animated_colors.background.active = c;
option.animated_colors.background.inactive = Color::Black;
option.animated_colors.foreground.active = Color::White;
option.animated_colors.foreground.inactive = c;
return option;
}
int main() {
auto screen = ScreenInteractive::TerminalOutput();
int selected = 0;
auto menu = Container::Vertical(
{
MenuEntry(" 1. rear", Colored(Color::Red)),
MenuEntry(" 2. drown", Colored(Color::Yellow)),
MenuEntry(" 3. nail", Colored(Color::Green)),
MenuEntry(" 4. quit", Colored(Color::Cyan)),
MenuEntry(" 5. decorative", Colored(Color::Blue)),
MenuEntry(" 7. costume"),
MenuEntry(" 8. pick"),
MenuEntry(" 9. oral"),
MenuEntry("11. minister"),
MenuEntry("12. football"),
MenuEntry("13. welcome"),
MenuEntry("14. copper"),
MenuEntry("15. inhabitant"),
},
&selected);
// Display together the menu with a border
auto renderer = Renderer(menu, [&] {
return vbox({
hbox(text("selected = "), text(std::to_string(selected))),
separator(),
menu->Render() | frame,
}) |
border | bgcolor(Color::Black);
});
screen.Loop(renderer);
std::cout << "Selected element = " << selected << std::endl;
}

View File

@ -1,3 +1,6 @@
// Copyright 2020 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 <memory> // for shared_ptr, __shared_ptr_access
#include <string> // for string, basic_string, operator+, to_string
#include <vector> // for vector
@ -10,7 +13,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
std::vector<std::string> entries;
int selected = 0;
@ -27,7 +30,3 @@ int main(int argc, const char* argv[]) {
return 0;
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -0,0 +1,30 @@
// Copyright 2020 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 <memory> // for shared_ptr, __shared_ptr_access
#include <string> // for string, basic_string, operator+, to_string
#include <vector> // for vector
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Radiobox, Renderer
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for operator|, Element, size, border, frame, HEIGHT, LESS_THAN
using namespace ftxui;
int main() {
std::vector<std::string> entries;
int selected = 0;
for (int i = 0; i < 100; ++i)
entries.push_back(std::to_string(i));
auto radiobox = Menu(&entries, &selected, MenuOption::Horizontal());
auto renderer = Renderer(
radiobox, [&] { return radiobox->Render() | hscroll_indicator | frame; });
auto screen = ScreenInteractive::FitComponent();
screen.Loop(renderer);
return 0;
}

View File

@ -1,3 +1,6 @@
// Copyright 2020 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 <stdlib.h> // for EXIT_SUCCESS
#include <memory> // for allocator, __shared_ptr_access
#include <string> // for string, operator+, basic_string, to_string, char_traits
@ -17,7 +20,7 @@ Component Window(std::string title, Component component) {
});
}
int main(int argc, const char* argv[]) {
int main() {
int menu_selected[] = {0, 0, 0};
std::vector<std::vector<std::string>> menu_entries = {
{
@ -72,7 +75,3 @@ int main(int argc, const char* argv[]) {
screen.Loop(global);
return EXIT_SUCCESS;
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -1,100 +1,257 @@
// Copyright 2020 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 <array> // for array
#include <chrono> // for milliseconds
#include <functional> // for function
#include <memory> // for shared_ptr, __shared_ptr_access, allocator
#include <string> // for string, basic_string
#include <memory> // for __shared_ptr_access, shared_ptr, allocator
#include <string> // for string, char_traits, operator+, basic_string
#include <vector> // for vector
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Menu, Horizontal, Renderer
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/component_options.hpp" // for MenuOption
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for operator|, color, separator, Decorator, bgcolor, flex, Element, bold, hbox, border, dim
#include "ftxui/screen/color.hpp" // for Color, Color::Blue, Color::BlueLight, Color::Red, Color::Yellow
#include "ftxui/component/animation.hpp" // for ElasticOut, Linear
#include "ftxui/component/component.hpp" // for Menu, Horizontal, Renderer, Vertical
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/component_options.hpp" // for MenuOption, EntryState, MenuEntryOption, AnimatedColorOption, AnimatedColorsOption, UnderlineOption
#include "ftxui/component/mouse.hpp" // for ftxui
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
#include "ftxui/dom/elements.hpp" // for separator, operator|, Element, text, bgcolor, hbox, bold, color, filler, border, vbox, borderDouble, dim, flex, hcenter
#include "ftxui/screen/color.hpp" // for Color, Color::Red, Color::Black, Color::Yellow, Color::Blue, Color::Default, Color::White
int main(int argc, const char* argv[]) {
using namespace ftxui;
using namespace ftxui;
Component VMenu1(std::vector<std::string>* entries, int* selected);
Component VMenu2(std::vector<std::string>* entries, int* selected);
Component VMenu3(std::vector<std::string>* entries, int* selected);
Component VMenu4(std::vector<std::string>* entries, int* selected);
Component VMenu5(std::vector<std::string>* entries, int* selected);
Component VMenu6(std::vector<std::string>* entries, int* selected);
Component VMenu7(std::vector<std::string>* entries, int* selected);
Component VMenu8(std::vector<std::string>* entries, int* selected);
Component HMenu1(std::vector<std::string>* entries, int* selected);
Component HMenu2(std::vector<std::string>* entries, int* selected);
Component HMenu3(std::vector<std::string>* entries, int* selected);
Component HMenu4(std::vector<std::string>* entries, int* selected);
Component HMenu5(std::vector<std::string>* entries, int* selected);
int main() {
auto screen = ScreenInteractive::TerminalOutput();
std::vector<std::string> entries = {
"Monkey", "Dog", "Cat", "Bird", "Elephant",
std::vector<std::string> entries{
"Monkey", "Dog", "Cat", "Bird", "Elephant", "Cat",
};
int menu_1_selected_ = 0;
int menu_2_selected_ = 0;
int menu_3_selected_ = 0;
int menu_4_selected_ = 0;
int menu_5_selected_ = 0;
int menu_6_selected_ = 0;
std::array<int, 12> selected = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
MenuOption option_1;
option_1.style_focused = bold | color(Color::Blue);
option_1.style_selected = color(Color::Blue);
option_1.style_selected_focused = bold | color(Color::Blue);
option_1.on_enter = screen.ExitLoopClosure();
auto menu_1_ = Menu(&entries, &menu_1_selected_, &option_1);
auto vmenu_1_ = VMenu1(&entries, &selected[0]);
auto vmenu_2_ = VMenu2(&entries, &selected[1]);
auto vmenu_3_ = VMenu3(&entries, &selected[2]);
auto vmenu_4_ = VMenu4(&entries, &selected[3]);
auto vmenu_5_ = VMenu5(&entries, &selected[4]);
auto vmenu_6_ = VMenu6(&entries, &selected[5]);
auto vmenu_7_ = VMenu7(&entries, &selected[6]);
auto vmenu_8_ = VMenu8(&entries, &selected[7]);
MenuOption option_2;
option_2.style_focused = bold | color(Color::Blue);
option_2.style_selected = color(Color::Blue);
option_2.style_selected_focused = bold | color(Color::Blue);
option_2.on_enter = screen.ExitLoopClosure();
auto menu_2_ = Menu(&entries, &menu_2_selected_, &option_2);
auto hmenu_1_ = HMenu1(&entries, &selected[8]);
auto hmenu_2_ = HMenu2(&entries, &selected[9]);
auto hmenu_3_ = HMenu3(&entries, &selected[10]);
auto hmenu_4_ = HMenu4(&entries, &selected[11]);
auto hmenu_5_ = HMenu5(&entries, &selected[12]);
MenuOption option_3;
option_3.style_selected = color(Color::Blue);
option_3.style_focused = bgcolor(Color::Blue);
option_3.style_selected_focused = bgcolor(Color::Blue);
option_3.on_enter = screen.ExitLoopClosure();
auto menu_3_ = Menu(&entries, &menu_3_selected_, &option_3);
MenuOption option_4;
option_4.style_selected = bgcolor(Color::Blue);
option_4.style_focused = bgcolor(Color::BlueLight);
option_4.style_selected_focused = bgcolor(Color::BlueLight);
option_4.on_enter = screen.ExitLoopClosure();
auto menu_4_ = Menu(&entries, &menu_4_selected_, &option_4);
MenuOption option_5;
option_5.style_normal = bgcolor(Color::Blue);
option_5.style_selected = bgcolor(Color::Yellow);
option_5.style_focused = bgcolor(Color::Red);
option_5.style_selected_focused = bgcolor(Color::Red);
option_5.on_enter = screen.ExitLoopClosure();
auto menu_5_ = Menu(&entries, &menu_5_selected_, &option_5);
MenuOption option_6;
option_6.style_normal = dim | color(Color::Blue);
option_6.style_selected = color(Color::Blue);
option_6.style_focused = bold | color(Color::Blue);
option_6.style_selected_focused = bold | color(Color::Blue);
option_6.on_enter = screen.ExitLoopClosure();
auto menu_6_ = Menu(&entries, &menu_6_selected_, &option_6);
auto container = Container::Horizontal({
menu_1_,
menu_2_,
menu_3_,
menu_4_,
menu_5_,
menu_6_,
auto container = Container::Vertical({
Container::Horizontal({
vmenu_1_,
vmenu_2_,
vmenu_3_,
vmenu_4_,
vmenu_5_,
vmenu_6_,
vmenu_7_,
vmenu_8_,
}),
hmenu_1_,
hmenu_2_,
hmenu_3_,
hmenu_4_,
hmenu_5_,
});
// clang-format off
auto renderer = Renderer(container, [&] {
return
hbox({
menu_1_->Render() | flex, separator(),
menu_2_->Render() | flex, separator(),
menu_3_->Render() | flex, separator(),
menu_4_->Render() | flex, separator(),
menu_5_->Render() | flex, separator(),
menu_6_->Render() | flex,
}) | border;
return //
hbox({
vbox({
hbox({
vmenu_1_->Render(),
separator(),
vmenu_2_->Render(),
separator(),
vmenu_3_->Render(),
separator(),
vmenu_4_->Render(),
separator(),
vmenu_5_->Render(),
vmenu_6_->Render(),
separator(),
vmenu_7_->Render(),
separator(),
vmenu_8_->Render(),
}),
separator(),
hmenu_1_->Render(),
separator(),
hmenu_2_->Render(),
separator(),
hmenu_3_->Render(),
separator(),
hmenu_4_->Render(),
hmenu_5_->Render(),
}) | border,
filler(),
});
});
// clang-format on
screen.Loop(renderer);
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
Component VMenu1(std::vector<std::string>* entries, int* selected) {
auto option = MenuOption::Vertical();
option.entries_option.transform = [](EntryState state) {
state.label = (state.active ? "> " : " ") + state.label;
Element e = text(state.label);
if (state.focused)
e = e | bgcolor(Color::Blue);
if (state.active)
e = e | bold;
return e;
};
return Menu(entries, selected, option);
}
Component VMenu2(std::vector<std::string>* entries, int* selected) {
auto option = MenuOption::Vertical();
option.entries_option.transform = [](EntryState state) {
state.label += (state.active ? " <" : " ");
Element e = hbox(filler(), text(state.label));
if (state.focused)
e = e | bgcolor(Color::Red);
if (state.active)
e = e | bold;
return e;
};
return Menu(entries, selected, option);
}
Component VMenu3(std::vector<std::string>* entries, int* selected) {
auto option = MenuOption::Vertical();
option.entries_option.transform = [](EntryState state) {
Element e = state.active ? text("[" + state.label + "]")
: text(" " + state.label + " ");
if (state.focused)
e = e | bold;
if (state.focused)
e = e | color(Color::Blue);
if (state.active)
e = e | bold;
return e;
};
return Menu(entries, selected, option);
}
Component VMenu4(std::vector<std::string>* entries, int* selected) {
auto option = MenuOption::Vertical();
option.entries_option.transform = [](EntryState state) {
if (state.active && state.focused) {
return text(state.label) | color(Color::Yellow) | bgcolor(Color::Black) |
bold;
}
if (state.active) {
return text(state.label) | color(Color::Yellow) | bgcolor(Color::Black);
}
if (state.focused) {
return text(state.label) | color(Color::Black) | bgcolor(Color::Yellow) |
bold;
}
return text(state.label) | color(Color::Black) | bgcolor(Color::Yellow);
};
return Menu(entries, selected, option);
}
Component VMenu5(std::vector<std::string>* entries, int* selected) {
auto option = MenuOption::Vertical();
option.entries_option.transform = [](EntryState state) {
auto element = text(state.label);
if (state.active && state.focused) {
return element | borderDouble;
}
if (state.active) {
return element | border;
}
if (state.focused) {
return element | bold;
}
return element;
};
return Menu(entries, selected, option);
}
Component VMenu6(std::vector<std::string>* entries, int* selected) {
auto option = MenuOption::VerticalAnimated();
option.underline.color_inactive = Color::Default;
option.underline.color_active = Color::Red;
option.underline.SetAnimationFunction(animation::easing::Linear);
return Menu(entries, selected, option);
}
Component VMenu7(std::vector<std::string>* entries, int* selected) {
auto option = MenuOption::Vertical();
option.entries_option.animated_colors.foreground.enabled = true;
option.entries_option.animated_colors.background.enabled = true;
option.entries_option.animated_colors.background.active = Color::Red;
option.entries_option.animated_colors.background.inactive = Color::Black;
option.entries_option.animated_colors.foreground.active = Color::White;
option.entries_option.animated_colors.foreground.inactive = Color::Red;
return Menu(entries, selected, option);
}
Component VMenu8(std::vector<std::string>* entries, int* selected) {
auto option = MenuOption::Vertical();
option.entries_option.animated_colors.foreground.Set(
Color::Red, Color::White, std::chrono::milliseconds(500));
return Menu(entries, selected, option);
}
Component HMenu1(std::vector<std::string>* entries, int* selected) {
return Menu(entries, selected, MenuOption::Horizontal());
}
Component HMenu2(std::vector<std::string>* entries, int* selected) {
return Menu(entries, selected, MenuOption::Toggle());
}
Component HMenu3(std::vector<std::string>* entries, int* selected) {
auto option = MenuOption::Toggle();
option.elements_infix = [] { return text(" 🮣🮠 "); };
return Menu(entries, selected, option);
}
Component HMenu4(std::vector<std::string>* entries, int* selected) {
return Menu(entries, selected, MenuOption::HorizontalAnimated());
}
Component HMenu5(std::vector<std::string>* entries, int* selected) {
auto option = MenuOption::HorizontalAnimated();
option.underline.SetAnimation(std::chrono::milliseconds(1500),
animation::easing::ElasticOut);
option.entries_option.transform = [](EntryState state) {
Element e = text(state.label) | hcenter | flex;
if (state.active && state.focused)
e = e | bold;
if (!state.focused && !state.active)
e = e | dim;
return e;
};
option.underline.color_inactive = Color::Default;
option.underline.color_active = Color::Red;
return Menu(entries, selected, option);
}

View File

@ -0,0 +1,93 @@
// Copyright 2020 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 <chrono> // for operator""ms, literals
#include <memory> // for allocator, shared_ptr, __shared_ptr_access
#include <string> // for string, operator+, to_string, basic_string
#include <vector> // for vector
#include "ftxui/component/animation.hpp" // for BackOut, Duration
#include "ftxui/component/component.hpp" // for Menu, Renderer, Vertical
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/component_options.hpp" // for MenuOption, UnderlineOption
#include "ftxui/component/mouse.hpp" // for ftxui
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
#include "ftxui/dom/elements.hpp" // for text, Element, operator|, borderEmpty, inverted
#include "ftxui/screen/color.hpp" // for Color, Color::Blue, Color::Red
using namespace ftxui;
Component DummyComponent(int id) {
return Renderer([id](bool focused) {
auto t = text("component " + std::to_string(id));
if (focused)
t = t | inverted;
return t;
});
}
Component Text(const std::string& t) {
return Renderer([t] { return text(t) | borderEmpty; });
}
int main() {
using namespace std::literals;
std::vector<std::string> tab_values{
"Tab 1", "Tab 2", "Tab 3", "A very very long tab", "",
};
int tab_selected = 0;
auto container = Container::Vertical({});
int frame_count = 0;
container->Add(Renderer(
[&] { return text("Frame count: " + std::to_string(frame_count++)); }));
{
auto option = MenuOption::HorizontalAnimated();
container->Add(Text("This demonstrate the Menu component"));
container->Add(Menu(&tab_values, &tab_selected, option));
}
{
container->Add(Text("Set underline color to blue"));
auto option = MenuOption::HorizontalAnimated();
option.underline.color_inactive = Color::Blue;
container->Add(Menu(&tab_values, &tab_selected, option));
}
{
container->Add(Text("Set underline active color to red"));
auto option = MenuOption::HorizontalAnimated();
option.underline.color_active = Color::Red;
container->Add(Menu(&tab_values, &tab_selected, option));
}
{
container->Add(Text("Set animation duration to 0ms"));
auto option = MenuOption::HorizontalAnimated();
option.underline.SetAnimationDuration(0ms);
container->Add(Menu(&tab_values, &tab_selected, option));
}
{
container->Add(Text("Set animation easing function to back-out"));
auto option = MenuOption::HorizontalAnimated();
option.underline.SetAnimationFunction(animation::easing::BackOut);
option.underline.SetAnimationDuration(350ms);
container->Add(Menu(&tab_values, &tab_selected, option));
}
// option.underline_animation_follower_delay = 250ms
{
container->Add(Text("Add delay to desynchronize animation"));
auto option = MenuOption::HorizontalAnimated();
option.underline.follower_delay = 250ms;
container->Add(Menu(&tab_values, &tab_selected, option));
}
container->SetActiveChild(container->ChildAt(2));
auto screen = ScreenInteractive::TerminalOutput();
screen.Loop(container);
}

View File

@ -1,94 +1,82 @@
#include <memory> // for allocator, shared_ptr, __shared_ptr_access
#include <string> // for string, basic_string, char_traits, operator+
#include <vector> // for vector
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Button, Renderer, Horizontal, Tab
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for operator|, Element, filler, text, hbox, separator, center, vbox, bold, border, clear_under, dbox, size, GREATER_THAN, HEIGHT
int main(int argc, const char* argv[]) {
using namespace ftxui;
auto screen = ScreenInteractive::TerminalOutput();
// There are two layers. One at depth = 0 and the modal window at depth = 1;
int depth = 0;
// The current rating of FTXUI.
std::string rating = "3/5 stars";
// At depth=0, two buttons. One for rating FTXUI and one for quitting.
auto button_rate_ftxui = Button("Rate FTXUI", [&] { depth = 1; });
auto button_quit = Button("Quit", screen.ExitLoopClosure());
auto depth_0_container = Container::Horizontal({
button_rate_ftxui,
button_quit,
});
auto depth_0_renderer = Renderer(depth_0_container, [&] {
return vbox({
text("Modal dialog example"),
separator(),
text("☆☆☆ FTXUI:" + rating + " ☆☆☆") | bold,
filler(),
hbox({
button_rate_ftxui->Render(),
filler(),
button_quit->Render(),
}),
}) |
border | size(HEIGHT, GREATER_THAN, 18) | center;
});
// At depth=1, The "modal" window.
std::vector<std::string> rating_labels = {
"1/5 stars", "2/5 stars", "3/5 stars", "4/5 stars", "5/5 stars",
};
auto on_rating = [&](std::string new_rating) {
rating = new_rating;
depth = 0;
};
auto depth_1_container = Container::Horizontal({
Button(&rating_labels[0], [&] { on_rating(rating_labels[0]); }),
Button(&rating_labels[1], [&] { on_rating(rating_labels[1]); }),
Button(&rating_labels[2], [&] { on_rating(rating_labels[2]); }),
Button(&rating_labels[3], [&] { on_rating(rating_labels[3]); }),
Button(&rating_labels[4], [&] { on_rating(rating_labels[4]); }),
});
auto depth_1_renderer = Renderer(depth_1_container, [&] {
return vbox({
text("Do you like FTXUI?"),
separator(),
hbox(depth_1_container->Render()),
}) |
border;
});
auto main_container = Container::Tab(
{
depth_0_renderer,
depth_1_renderer,
},
&depth);
auto main_renderer = Renderer(main_container, [&] {
Element document = depth_0_renderer->Render();
if (depth == 1) {
document = dbox({
document,
depth_1_renderer->Render() | clear_under | center,
});
}
return document;
});
screen.Loop(main_renderer);
return 0;
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Copyright 2022 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_options.hpp> // for ButtonOption
#include <ftxui/component/mouse.hpp> // for ftxui
#include <functional> // for function
#include <memory> // for allocator, shared_ptr
#include "ftxui/component/component.hpp" // for Button, operator|=, Renderer, Vertical, Modal
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive, Component
#include "ftxui/dom/elements.hpp" // for operator|, separator, text, size, Element, vbox, border, GREATER_THAN, WIDTH, center, HEIGHT
using namespace ftxui;
auto button_style = ButtonOption::Animated();
// Definition of the main component. The details are not important.
Component MainComponent(std::function<void()> show_modal,
std::function<void()> exit) {
auto component = Container::Vertical({
Button("Show modal", show_modal, button_style),
Button("Quit", exit, button_style),
});
// Polish how the two buttons are rendered:
component |= Renderer([&](Element inner) {
return vbox({
text("Main component"),
separator(),
inner,
}) //
| size(WIDTH, GREATER_THAN, 15) //
| size(HEIGHT, GREATER_THAN, 15) //
| border //
| center; //
});
return component;
}
// Definition of the modal component. The details are not important.
Component ModalComponent(std::function<void()> do_nothing,
std::function<void()> hide_modal) {
auto component = Container::Vertical({
Button("Do nothing", do_nothing, button_style),
Button("Quit modal", hide_modal, button_style),
});
// Polish how the two buttons are rendered:
component |= Renderer([&](Element inner) {
return vbox({
text("Modal component "),
separator(),
inner,
}) //
| size(WIDTH, GREATER_THAN, 30) //
| border; //
});
return component;
}
int main(int argc, const char* argv[]) {
auto screen = ScreenInteractive::TerminalOutput();
// State of the application:
bool modal_shown = false;
// Some actions modifying the state:
auto show_modal = [&] { modal_shown = true; };
auto hide_modal = [&] { modal_shown = false; };
auto exit = screen.ExitLoopClosure();
auto do_nothing = [&] {};
// Instanciate the main and modal components:
auto main_component = MainComponent(show_modal, exit);
auto modal_component = ModalComponent(do_nothing, hide_modal);
// Use the `Modal` function to use together the main component and its modal
// window. The |modal_shown| boolean controls whether the modal is shown or
// not.
main_component |= Modal(modal_component, &modal_shown);
screen.Loop(main_component);
return 0;
}

View File

@ -0,0 +1,93 @@
// Copyright 2020 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 <memory> // for allocator, shared_ptr, __shared_ptr_access
#include <string> // for string, basic_string, char_traits, operator+
#include <vector> // for vector
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Button, Renderer, Horizontal, Tab
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for operator|, Element, filler, text, hbox, separator, center, vbox, bold, border, clear_under, dbox, size, GREATER_THAN, HEIGHT
int main() {
using namespace ftxui;
auto screen = ScreenInteractive::TerminalOutput();
// There are two layers. One at depth = 0 and the modal window at depth = 1;
int depth = 0;
// The current rating of FTXUI.
std::string rating = "3/5 stars";
// At depth=0, two buttons. One for rating FTXUI and one for quitting.
auto button_rate_ftxui = Button("Rate FTXUI", [&] { depth = 1; });
auto button_quit = Button("Quit", screen.ExitLoopClosure());
auto depth_0_container = Container::Horizontal({
button_rate_ftxui,
button_quit,
});
auto depth_0_renderer = Renderer(depth_0_container, [&] {
return vbox({
text("Modal dialog example"),
separator(),
text("☆☆☆ FTXUI:" + rating + " ☆☆☆") | bold,
filler(),
hbox({
button_rate_ftxui->Render(),
filler(),
button_quit->Render(),
}),
}) |
border | size(HEIGHT, GREATER_THAN, 18) | center;
});
// At depth=1, The "modal" window.
std::vector<std::string> rating_labels = {
"1/5 stars", "2/5 stars", "3/5 stars", "4/5 stars", "5/5 stars",
};
auto on_rating = [&](std::string new_rating) {
rating = new_rating;
depth = 0;
};
auto depth_1_container = Container::Horizontal({
Button(&rating_labels[0], [&] { on_rating(rating_labels[0]); }),
Button(&rating_labels[1], [&] { on_rating(rating_labels[1]); }),
Button(&rating_labels[2], [&] { on_rating(rating_labels[2]); }),
Button(&rating_labels[3], [&] { on_rating(rating_labels[3]); }),
Button(&rating_labels[4], [&] { on_rating(rating_labels[4]); }),
});
auto depth_1_renderer = Renderer(depth_1_container, [&] {
return vbox({
text("Do you like FTXUI?"),
separator(),
hbox(depth_1_container->Render()),
}) |
border;
});
auto main_container = Container::Tab(
{
depth_0_renderer,
depth_1_renderer,
},
&depth);
auto main_renderer = Renderer(main_container, [&] {
Element document = depth_0_renderer->Render();
if (depth == 1) {
document = dbox({
document,
depth_1_renderer->Render() | clear_under | center,
});
}
return document;
});
screen.Loop(main_renderer);
return 0;
}

View File

@ -1,3 +1,6 @@
// Copyright 2020 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 <memory> // for allocator, shared_ptr, __shared_ptr_access
#include <string> // for operator+, string, char_traits, basic_string
@ -35,7 +38,7 @@ void Nested(std::string path) {
screen.Loop(renderer);
}
int main(int argc, const char* argv[]) {
int main() {
auto screen = ScreenInteractive::FitComponent();
auto button_quit = Button("Quit", screen.ExitLoopClosure());
auto button_nested = Button("Nested", [] { Nested(""); });
@ -45,7 +48,3 @@ int main(int argc, const char* argv[]) {
}));
return 0;
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -18,75 +18,48 @@
using namespace ftxui;
std::string Stringify(Event event) {
std::string out;
for (auto& it : event.input())
out += " " + std::to_string((unsigned int)it);
out = "(" + out + " ) -> ";
if (event.is_character()) {
out += "character(" + event.character() + ")";
} else if (event.is_mouse()) {
out += "mouse";
switch (event.mouse().button) {
case Mouse::Left:
out += "_left";
break;
case Mouse::Middle:
out += "_middle";
break;
case Mouse::Right:
out += "_right";
break;
case Mouse::None:
out += "_none";
break;
case Mouse::WheelUp:
out += "_wheel_up";
break;
case Mouse::WheelDown:
out += "_wheel_down";
break;
}
switch (event.mouse().motion) {
case Mouse::Pressed:
out += "_pressed";
break;
case Mouse::Released:
out += "_released";
break;
}
if (event.mouse().control)
out += "_control";
if (event.mouse().shift)
out += "_shift";
if (event.mouse().meta)
out += "_meta";
out += "(" + //
std::to_string(event.mouse().x) + "," +
std::to_string(event.mouse().y) + ")";
} else {
out += "(special)";
std::string Code(Event event) {
std::string codes;
for (auto& it : event.input()) {
codes += " " + std::to_string((unsigned int)it);
}
return out;
return codes;
}
int main(int argc, const char* argv[]) {
int main() {
auto screen = ScreenInteractive::TerminalOutput();
std::vector<Event> keys;
auto component = Renderer([&] {
Elements children;
for (size_t i = std::max(0, (int)keys.size() - 20); i < keys.size(); ++i)
children.push_back(text(Stringify(keys[i])));
return window(text("keys"), vbox(std::move(children)));
auto left_column = Renderer([&] {
Elements children = {
text("Codes"),
separator(),
};
for (size_t i = std::max(0, (int)keys.size() - 20); i < keys.size(); ++i) {
children.push_back(text(Code(keys[i])));
}
return vbox(children);
});
component = CatchEvent(component, [&](Event event) {
auto right_column = Renderer([&] {
Elements children = {
text("Event"),
separator(),
};
for (size_t i = std::max(0, (int)keys.size() - 20); i < keys.size(); ++i) {
children.push_back(text(keys[i].DebugString()));
}
return vbox(children);
});
int split_size = 40;
auto component = ResizableSplitLeft(left_column, right_column, &split_size);
component |= border;
component |= CatchEvent([&](Event event) {
keys.push_back(event);
return true;
return false;
});
screen.Loop(component);

View File

@ -1,3 +1,6 @@
// Copyright 2020 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 <string> // for string, allocator, basic_string
#include <vector> // for vector
@ -7,7 +10,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
std::vector<std::string> radiobox_list = {
"Use gcc",
"Use clang",
@ -20,7 +23,3 @@ int main(int argc, const char* argv[]) {
screen.Loop(Radiobox(&radiobox_list, &selected));
return 0;
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -1,3 +1,6 @@
// Copyright 2020 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 <memory> // for shared_ptr, __shared_ptr_access
#include <string> // for string, basic_string, operator+, to_string
#include <vector> // for vector
@ -10,7 +13,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
std::vector<std::string> entries;
int selected = 0;
@ -27,7 +30,3 @@ int main(int argc, const char* argv[]) {
return 0;
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -1,3 +1,6 @@
// Copyright 2020 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 <memory> // for shared_ptr, allocator, __shared_ptr_access
#include "ftxui/component/captured_mouse.hpp" // for ftxui
@ -7,7 +10,7 @@
#include "ftxui/dom/elements.hpp" // for operator|, Element, text, bold, border, center, color
#include "ftxui/screen/color.hpp" // for Color, Color::Red
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto screen = ScreenInteractive::FitComponent();
@ -43,7 +46,3 @@ int main(int argc, const char* argv[]) {
renderer_wrap,
}));
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -1,3 +1,6 @@
// Copyright 2020 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 <memory> // for shared_ptr, allocator, __shared_ptr_access
#include "ftxui/component/captured_mouse.hpp" // for ftxui
@ -8,7 +11,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
auto screen = ScreenInteractive::Fullscreen();
auto middle = Renderer([] { return text("middle") | center; });
@ -33,7 +36,3 @@ int main(int argc, const char* argv[]) {
screen.Loop(renderer);
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -0,0 +1,112 @@
// Copyright 2023 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>
#include <ftxui/component/screen_interactive.hpp>
using namespace ftxui;
Component DummyWindowContent() {
class Impl : public ComponentBase {
private:
float scroll_x = 0.1;
float scroll_y = 0.1;
public:
Impl() {
auto content = Renderer([=] {
const std::string lorem =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed "
"do eiusmod tempor incididunt ut labore et dolore magna "
"aliqua. Ut enim ad minim veniam, quis nostrud exercitation "
"ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis "
"aute irure dolor in reprehenderit in voluptate velit esse "
"cillum dolore eu fugiat nulla pariatur. Excepteur sint "
"occaecat cupidatat non proident, sunt in culpa qui officia "
"deserunt mollit anim id est laborum.";
return vbox({
text(lorem.substr(0, -1)), text(lorem.substr(5, -1)), text(""),
text(lorem.substr(10, -1)), text(lorem.substr(15, -1)), text(""),
text(lorem.substr(20, -1)), text(lorem.substr(25, -1)), text(""),
text(lorem.substr(30, -1)), text(lorem.substr(35, -1)), text(""),
text(lorem.substr(40, -1)), text(lorem.substr(45, -1)), text(""),
text(lorem.substr(50, -1)), text(lorem.substr(55, -1)), text(""),
text(lorem.substr(60, -1)), text(lorem.substr(65, -1)), text(""),
text(lorem.substr(70, -1)), text(lorem.substr(75, -1)), text(""),
text(lorem.substr(80, -1)), text(lorem.substr(85, -1)), text(""),
text(lorem.substr(90, -1)), text(lorem.substr(95, -1)), text(""),
text(lorem.substr(100, -1)), text(lorem.substr(105, -1)), text(""),
text(lorem.substr(110, -1)), text(lorem.substr(115, -1)), text(""),
text(lorem.substr(120, -1)), text(lorem.substr(125, -1)), text(""),
text(lorem.substr(130, -1)), text(lorem.substr(135, -1)), text(""),
text(lorem.substr(140, -1)),
});
});
auto scrollable_content = Renderer(content, [&, content] {
return content->Render() | focusPositionRelative(scroll_x, scroll_y) |
frame | flex;
});
SliderOption<float> option_x;
option_x.value = &scroll_x;
option_x.min = 0.f;
option_x.max = 1.f;
option_x.increment = 0.1f;
option_x.direction = Direction::Right;
option_x.color_active = Color::Blue;
option_x.color_inactive = Color::BlueLight;
auto scrollbar_x = Slider(option_x);
SliderOption<float> option_y;
option_y.value = &scroll_y;
option_y.min = 0.f;
option_y.max = 1.f;
option_y.increment = 0.1f;
option_y.direction = Direction::Down;
option_y.color_active = Color::Yellow;
option_y.color_inactive = Color::YellowLight;
auto scrollbar_y = Slider(option_y);
Add(Container::Vertical({
Container::Horizontal({
scrollable_content,
scrollbar_y,
}) | flex,
Container::Horizontal({
scrollbar_x,
Renderer([] { return text(L"x"); }),
}),
}));
}
};
return Make<Impl>();
}
int main() {
auto window_1 = Window({
.inner = DummyWindowContent(),
.title = "First window",
.width = 80,
.height = 30,
});
auto window_2 = Window({
.inner = DummyWindowContent(),
.title = "My window",
.left = 40,
.top = 20,
.width = 80,
.height = 30,
});
auto window_container = Container::Stacked({
window_1,
window_2,
});
auto screen = ScreenInteractive::Fullscreen();
screen.Loop(window_container);
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,87 @@
// Copyright 2020 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 <string> // for char_traits, operator+, string, basic_string
#include "ftxui/component/component.hpp" // for Input, Renderer, Vertical
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/component_options.hpp" // for InputOption
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
#include "ftxui/dom/elements.hpp" // for text, hbox, separator, Element, operator|, vbox, border
#include "ftxui/util/ref.hpp" // for Ref
using namespace ftxui;
Element LoremIpsum() {
return vbox({
text("FTXUI: A powerful library for building user interfaces."),
text("Enjoy a rich set of components and a declarative style."),
text("Create beautiful and responsive UIs with minimal effort."),
text("Join the community and experience the power of FTXUI."),
});
}
int main() {
auto screen = ScreenInteractive::TerminalOutput();
auto quit =
Button("Quit", screen.ExitLoopClosure(), ButtonOption::Animated());
int selection_change_counter = 0;
std::string selection_content = "";
screen.SelectionChange([&] {
selection_change_counter++;
selection_content = screen.GetSelection();
});
// The components:
auto renderer = Renderer(quit, [&] {
return vbox({
text("Select changed: " + std::to_string(selection_change_counter) +
" times"),
text("Currently selected: "),
paragraph(selection_content) | vscroll_indicator | frame | border |
size(HEIGHT, EQUAL, 10),
window(text("Horizontal split"), hbox({
LoremIpsum(),
separator(),
LoremIpsum(),
separator(),
LoremIpsum(),
})),
window(text("Vertical split"), vbox({
LoremIpsum(),
separator(),
LoremIpsum(),
separator(),
LoremIpsum(),
})),
window(text("Grid split with different style"),
vbox({
hbox({
LoremIpsum(),
separator(),
LoremIpsum() //
| selectionBackgroundColor(Color::Yellow) //
| selectionColor(Color::Black) //
| selectionStyleReset,
separator(),
LoremIpsum() | selectionColor(Color::Blue),
}),
separator(),
hbox({
LoremIpsum() | selectionColor(Color::Red),
separator(),
LoremIpsum() | selectionStyle([](Pixel& pixel) {
pixel.underlined_double = true;
}),
separator(),
LoremIpsum(),
}),
})),
quit->Render(),
});
});
screen.Loop(renderer);
}

View File

@ -4,7 +4,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
auto screen = ScreenInteractive::TerminalOutput();
int value = 50;
auto slider = Slider("Value:", &value, 0, 100, 1);

View File

@ -0,0 +1,49 @@
// Copyright 2020 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 <array> // for array
#include <cmath> // for sin
#include <ftxui/component/component_base.hpp> // for ComponentBase
#include <ftxui/component/component_options.hpp> // for SliderOption
#include <ftxui/dom/direction.hpp> // for Direction, Direction::Up
#include <ftxui/dom/elements.hpp> // for size, GREATER_THAN, HEIGHT
#include <ftxui/util/ref.hpp> // for ConstRef, Ref
#include <memory> // for shared_ptr, __shared_ptr_access
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Horizontal, Slider, operator|=
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
using namespace ftxui;
int main() {
auto screen = ScreenInteractive::TerminalOutput();
std::array<int, 30> values;
for (size_t i = 0; i < values.size(); ++i) {
values[i] = 50 + 20 * std::sin(i * 0.3);
}
auto layout_horizontal = Container::Horizontal({});
for (auto& value : values) {
// In C++17:
SliderOption<int> option;
option.value = &value;
option.max = 100;
option.increment = 5;
option.direction = Direction::Up;
layout_horizontal->Add(Slider<int>(option));
/* In C++20:
layout_horizontal->Add(Slider<int>({
.value = &values[i],
.max = 100,
.increment = 5,
.direction = Direction::Up,
}));
*/
}
layout_horizontal |= size(HEIGHT, GREATER_THAN, 20);
screen.Loop(layout_horizontal);
}

View File

@ -1,3 +1,6 @@
// Copyright 2020 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 <memory> // for allocator, shared_ptr, __shared_ptr_access
#include <string> // for char_traits, operator+, to_string
@ -23,7 +26,7 @@ Element ColorString(int red, int green, int blue) {
);
}
int main(int argc, const char* argv[]) {
int main() {
int red = 128;
int green = 25;
int blue = 100;
@ -56,7 +59,3 @@ int main(int argc, const char* argv[]) {
auto screen = ScreenInteractive::TerminalOutput();
screen.Loop(renderer);
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -1,3 +1,6 @@
// Copyright 2020 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 <memory> // for allocator, __shared_ptr_access, shared_ptr
#include <string> // for string, basic_string
#include <vector> // for vector
@ -10,7 +13,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
std::vector<std::string> tab_values{
"tab_1",
"tab_2",
@ -65,7 +68,3 @@ int main(int argc, const char* argv[]) {
auto screen = ScreenInteractive::TerminalOutput();
screen.Loop(renderer);
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -1,3 +1,6 @@
// Copyright 2020 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 <memory> // for allocator, __shared_ptr_access, shared_ptr
#include <string> // for string, basic_string
#include <vector> // for vector
@ -10,7 +13,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
std::vector<std::string> tab_values{
"tab_1",
"tab_2",
@ -65,7 +68,3 @@ int main(int argc, const char* argv[]) {
auto screen = ScreenInteractive::TerminalOutput();
screen.Loop(renderer);
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -0,0 +1,34 @@
// Copyright 2020 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 <memory> // for allocator, __shared_ptr_access, shared_ptr
#include <string> // for string
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Input, Renderer, ResizableSplitLeft
#include "ftxui/component/component_base.hpp" // for ComponentBase, Component
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for operator|, separator, text, Element, flex, vbox, border
int main() {
using namespace ftxui;
std::string content_1;
std::string content_2;
auto textarea_1 = Input(&content_1);
auto textarea_2 = Input(&content_2);
int size = 50;
auto layout = ResizableSplitLeft(textarea_1, textarea_2, &size);
auto component = Renderer(layout, [&] {
return vbox({
text("Input:"),
separator(),
layout->Render() | flex,
}) |
border;
});
auto screen = ScreenInteractive::Fullscreen();
screen.Loop(component);
}

View File

@ -1,3 +1,6 @@
// Copyright 2020 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 <memory> // for allocator, __shared_ptr_access
#include <string> // for string, basic_string
#include <vector> // for vector
@ -10,7 +13,7 @@
using namespace ftxui;
int main(int argc, const char* argv[]) {
int main() {
std::vector<std::string> toggle_1_entries = {
"On",
"Off",
@ -59,7 +62,3 @@ int main(int argc, const char* argv[]) {
auto screen = ScreenInteractive::TerminalOutput();
screen.Loop(renderer);
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -0,0 +1,88 @@
// Copyright 2023 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>
#include <ftxui/component/screen_interactive.hpp>
using namespace ftxui;
Component DummyWindowContent() {
class Impl : public ComponentBase {
private:
bool checked[3] = {false, false, false};
float slider = 50;
public:
Impl() {
Add(Container::Vertical({
Checkbox("Check me", &checked[0]),
Checkbox("Check me", &checked[1]),
Checkbox("Check me", &checked[2]),
Slider("Slider", &slider, 0.f, 100.f),
}));
}
};
return Make<Impl>();
}
int main() {
int window_1_left = 20;
int window_1_top = 10;
int window_1_width = 40;
int window_1_height = 20;
auto window_1 = Window({
.inner = DummyWindowContent(),
.title = "First window",
.left = &window_1_left,
.top = &window_1_top,
.width = &window_1_width,
.height = &window_1_height,
});
auto window_2 = Window({
.inner = DummyWindowContent(),
.title = "My window",
.left = 40,
.top = 20,
});
auto window_3 = Window({
.inner = DummyWindowContent(),
.title = "My window",
.left = 60,
.top = 30,
});
auto window_4 = Window({
.inner = DummyWindowContent(),
});
auto window_5 = Window({});
auto window_container = Container::Stacked({
window_1,
window_2,
window_3,
window_4,
window_5,
});
auto display_win_1 = Renderer([&] {
return text("window_1: " + //
std::to_string(window_1_width) + "x" +
std::to_string(window_1_height) + " + " +
std::to_string(window_1_left) + "," +
std::to_string(window_1_top));
});
auto layout = Container::Vertical({
display_win_1,
window_container,
});
auto screen = ScreenInteractive::Fullscreen();
screen.Loop(layout);
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,60 @@
// Copyright 2022 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 <cstdlib> // for system, EXIT_SUCCESS
#include <iostream> // for operator<<, basic_ostream, basic_ostream::operator<<, cout, endl, flush, ostream, basic_ostream<>::__ostream_type, cin
#include <memory> // for shared_ptr, __shared_ptr_access, allocator
#include <string> // for getline, string
#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Button, Horizontal, Renderer
#include "ftxui/component/component_base.hpp" // for ComponentBase
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
#include "ftxui/dom/elements.hpp" // for operator|, filler, Element, borderEmpty, hbox, size, paragraph, vbox, LESS_THAN, border, center, HEIGHT, WIDTH
int main() {
using namespace ftxui;
auto screen = ScreenInteractive::Fullscreen();
// When pressing this button, "screen.WithRestoredIO" will execute the
// temporarily uninstall the terminal hook and execute the provided callback
// function. This allow running the application in a non-interactive mode.
auto btn_run = Button("Execute with restored IO", screen.WithRestoredIO([] {
std::cout << "This is a child program using stdin/stdout." << std::endl;
for (int i = 0; i < 10; ++i) {
std::cout << "Please enter 10 strings (" << i << "/10)" << std::flush;
std::string input;
std::getline(std::cin, input);
}
}));
auto btn_quit = Button("Quit", screen.ExitLoopClosure());
auto layout = Container::Horizontal({
btn_run,
btn_quit,
});
auto renderer = Renderer(layout, [&] {
auto explanation = paragraph(
"After clicking this button, the ScreenInteractive will be "
"suspended and access to stdin/stdout will temporarilly be "
"restore for running a function.");
auto element = vbox({
explanation | borderEmpty,
hbox({
btn_run->Render(),
filler(),
btn_quit->Render(),
}),
});
element = element | borderEmpty | border | size(WIDTH, LESS_THAN, 80) |
size(HEIGHT, LESS_THAN, 20) | center;
return element;
});
screen.Loop(renderer);
return EXIT_SUCCESS;
}

View File

@ -1,13 +1,21 @@
set(DIRECTORY_LIB dom)
example(border)
example(border_colored)
example(border_style)
example(canvas)
example(color_gallery)
example(color_info_palette256)
example(color_truecolor_HSV)
example(color_truecolor_RGB)
example(dbox)
example(gauge)
example(gauge_direction)
example(graph)
example(gridbox)
example(hflow)
example(html_like)
example(linear_gradient)
example(package_manager)
example(paragraph)
example(separator)
@ -17,13 +25,14 @@ example(spinner)
example(style_blink)
example(style_bold)
example(style_color)
example(color_truecolor_RGB)
example(color_truecolor_HSV)
example(color_info_palette256)
example(style_dim)
example(gridbox)
example(style_gallery)
example(style_hyperlink)
example(style_inverted)
example(style_italic)
example(style_strikethrough)
example(style_underlined)
example(style_underlined_double)
example(table)
example(vbox_hbox)
example(window)
example(vflow)

View File

@ -1,11 +1,15 @@
// Copyright 2020 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 <stdlib.h> // for EXIT_SUCCESS
#include <ftxui/dom/elements.hpp> // for text, operator|, vbox, border, Element, Fit, hbox
#include <ftxui/screen/screen.hpp> // for Full, Screen
#include <memory> // for allocator
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/box.hpp" // for ftxui
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto document = //
hbox({
@ -30,8 +34,5 @@ int main(int argc, const char* argv[]) {
auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
Render(screen, document);
screen.Print();
return EXIT_SUCCESS;
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@ -0,0 +1,39 @@
// Copyright 2020 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/dom/elements.hpp> // for operator|, text, Element, Fit, borderDouble, borderHeavy, borderLight, borderRounded, vbox
#include <ftxui/screen/screen.hpp> // for Screen
#include <iostream> // for endl, cout, ostream
#include <memory> // for allocator
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main() {
using namespace ftxui;
auto make_boxed = [] {
return vbox({
text("borderLight") | borderStyled(LIGHT, Color::Red),
text("borderDashed") | borderStyled(DASHED, Color::Green),
text("borderHeavy") | borderStyled(HEAVY, Color::Blue),
text("borderDouble") | borderStyled(DOUBLE, Color::Yellow),
text("borderRounded") | borderStyled(ROUNDED, Color::Cyan),
});
};
auto document = hbox({
make_boxed(),
separator() | color(Color::Red),
make_boxed(),
separator() | color(Color::Red),
make_boxed(),
}) |
borderStyled(ROUNDED, Color::Red);
auto screen =
Screen::Create(Dimension::Fit(document), Dimension::Fit(document));
Render(screen, document);
screen.Print();
std::cout << std::endl;
}

View File

@ -1,16 +1,20 @@
#include <ftxui/dom/elements.hpp> // for text, operator|, vbox, border, Element, Fit, hbox
#include <ftxui/screen/screen.hpp> // for Full, Screen
#include <iostream>
#include <memory> // for allocator
// Copyright 2020 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/dom/elements.hpp> // for operator|, text, Element, Fit, borderDouble, borderHeavy, borderLight, borderRounded, vbox
#include <ftxui/screen/screen.hpp> // for Screen
#include <iostream> // for endl, cout, ostream
#include <memory> // for allocator
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/box.hpp" // for ftxui
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for ftxui
int main(int argc, const char* argv[]) {
int main() {
using namespace ftxui;
auto document = vbox({
text("borderLight") | borderLight,
text("borderDashed") | borderDashed,
text("borderHeavy") | borderHeavy,
text("borderDouble") | borderDouble,
text("borderRounded") | borderRounded,
@ -22,7 +26,3 @@ int main(int argc, const char* argv[]) {
screen.Print();
std::cout << std::endl;
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

48
examples/dom/canvas.cpp Normal file
View File

@ -0,0 +1,48 @@
// Copyright 2020 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 <stdio.h> // for getchar
#include <cmath> // for cos
#include <ftxui/dom/elements.hpp> // for Fit, canvas, operator|, border, Element
#include <ftxui/screen/screen.hpp> // for Pixel, Screen
#include <vector> // for vector, allocator
#include "ftxui/dom/canvas.hpp" // for Canvas
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/color.hpp" // for Color, Color::Red, Color::Blue, Color::Green, ftxui
int main() {
using namespace ftxui;
auto c = Canvas(100, 100);
c.DrawText(0, 0, "This is a canvas", [](Pixel& p) {
p.foreground_color = Color::Red;
p.underlined = true;
});
// Triangle:
c.DrawPointLine(10, 10, 80, 10, Color::Red);
c.DrawPointLine(80, 10, 80, 40, Color::Blue);
c.DrawPointLine(80, 40, 10, 10, Color::Green);
// Circle, not filled and filled:
c.DrawPointCircle(30, 50, 20);
c.DrawPointCircleFilled(40, 40, 10);
// Plot a function:
std::vector<int> ys(100);
for (int x = 0; x < 100; x++)
ys[x] = int(80 + 20 * cos(x * 0.2));
for (int x = 0; x < 99; x++)
c.DrawPointLine(x, ys[x], x + 1, ys[x + 1], Color::Red);
auto document = canvas(&c) | border;
auto screen = Screen::Create(Dimension::Fit(document));
Render(screen, document);
screen.Print();
getchar();
return 0;
}

Some files were not shown because too many files have changed in this diff Show More