mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-05-06 17:21:13 +08:00
Compare commits
204 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4604adb502 | ||
![]() |
add5f40d31 | ||
![]() |
805db9bdea | ||
![]() |
784f53fd7e | ||
![]() |
799d8a267e | ||
![]() |
f4513702b0 | ||
![]() |
ba6716c6e1 | ||
![]() |
694fa6bf5c | ||
![]() |
625915b52c | ||
![]() |
2d4c114008 | ||
![]() |
aa80d8bac9 | ||
![]() |
bcdcf70348 | ||
![]() |
4231c4903b | ||
![]() |
10d73d365f | ||
![]() |
07fd3e685a | ||
![]() |
09eb2f7fb0 | ||
![]() |
1144e13125 | ||
![]() |
4ba7dd2c5e | ||
![]() |
ee24bec3ba | ||
![]() |
327f43b175 | ||
![]() |
5bf8ee819b | ||
![]() |
d5b741b2be | ||
![]() |
b69e0f8b91 | ||
![]() |
67163c2571 | ||
![]() |
2c9a828402 | ||
![]() |
bc682d25a6 | ||
![]() |
96e8b8d92e | ||
![]() |
f2fb434e31 | ||
![]() |
b0e087ecef | ||
![]() |
8519e9b0f3 | ||
![]() |
36c669c194 | ||
![]() |
d75108e960 | ||
![]() |
15587dad01 | ||
![]() |
c58a234f05 | ||
![]() |
c89569f5a7 | ||
![]() |
f6a690a942 | ||
![]() |
6fafa2dfed | ||
![]() |
751c8fab26 | ||
![]() |
daa421fa6a | ||
![]() |
e213cfda37 | ||
![]() |
58ff448e76 | ||
![]() |
dfa461b46b | ||
![]() |
0683285f01 | ||
![]() |
7f74917887 | ||
![]() |
ad0392ec39 | ||
![]() |
70bc44d28b | ||
![]() |
55af678fb9 | ||
![]() |
edaa7a24e7 | ||
![]() |
8922e6d55e | ||
![]() |
99df1ac8ba | ||
![]() |
1d40687a40 | ||
![]() |
dfb9558eaf | ||
![]() |
c5357acbaa | ||
![]() |
fbd56cdf43 | ||
![]() |
66d1c1f61f | ||
![]() |
f5d8c7deb5 | ||
![]() |
535290bb3b | ||
![]() |
fcd050c017 | ||
![]() |
d7de24cd9e | ||
![]() |
547d9278d8 | ||
![]() |
5a9ef876a1 | ||
![]() |
307e4eb4b3 | ||
![]() |
b28d57086a | ||
![]() |
ff305147ca | ||
![]() |
d6a2049483 | ||
![]() |
b5e11ba1f6 | ||
![]() |
a715a767b5 | ||
![]() |
7b1f4d435b | ||
![]() |
ecacb22d37 | ||
![]() |
af49b57e60 | ||
![]() |
4913379625 | ||
![]() |
d40cafde5c | ||
![]() |
65296b9aa3 | ||
![]() |
a58e6e6bcf | ||
![]() |
8a2a9b0799 | ||
![]() |
6a755f3760 | ||
![]() |
d386df6f94 | ||
![]() |
d38b14ffb6 | ||
![]() |
7e3e1d4bca | ||
![]() |
affa787244 | ||
![]() |
014bdb4a05 | ||
![]() |
293ff179f6 | ||
![]() |
1f6e1101e8 | ||
![]() |
0dfd59bd09 | ||
![]() |
e03a0797be | ||
![]() |
3c9fa60d28 | ||
![]() |
2216f3a5da | ||
![]() |
f609c12846 | ||
![]() |
ce5ac6b12f | ||
![]() |
f495ce029c | ||
![]() |
810657dab8 | ||
![]() |
65bbb4f0eb | ||
![]() |
5112d9139d | ||
![]() |
91a162a30e | ||
![]() |
4d5cc41c65 | ||
![]() |
cc3bcbf069 | ||
![]() |
d0634e1ca0 | ||
![]() |
a7b6785420 | ||
![]() |
348c3853d4 | ||
![]() |
bfadcb7165 | ||
![]() |
6c2b43a2aa | ||
![]() |
b970cb6ea8 | ||
![]() |
c31aecf2ed | ||
![]() |
e8589dd533 | ||
![]() |
0631c3ab3f | ||
![]() |
d548a18658 | ||
![]() |
f499d34f7e | ||
![]() |
d4c9c5e226 | ||
![]() |
62c0b43caf | ||
![]() |
c24a274292 | ||
![]() |
20d4be286b | ||
![]() |
550a59f0a5 | ||
![]() |
5db2be0f4d | ||
![]() |
8d1665022a | ||
![]() |
e5978a8e76 | ||
![]() |
0f1588e3d1 | ||
![]() |
dd6a5d371f | ||
![]() |
05c7bee6dd | ||
![]() |
cdf28903a7 | ||
![]() |
49a48820dd | ||
![]() |
5724f8483b | ||
![]() |
7e6b7386ce | ||
![]() |
20baaef5b8 | ||
![]() |
eb9a701fd7 | ||
![]() |
1e6df78ec2 | ||
![]() |
b3f1edc385 | ||
![]() |
f7304c28c3 | ||
![]() |
acbdb50747 | ||
![]() |
8ae1c95d18 | ||
![]() |
8058e1af6c | ||
![]() |
06ba1c10b9 | ||
![]() |
461d557674 | ||
![]() |
e2a205ed0d | ||
![]() |
00e63993ce | ||
![]() |
b0a7f88f07 | ||
![]() |
cebe49dd23 | ||
![]() |
4debd4f3de | ||
![]() |
bb43ce1875 | ||
![]() |
0930142597 | ||
![]() |
21fe59dee8 | ||
![]() |
5094b5f3fb | ||
![]() |
e5eb822d44 | ||
![]() |
b50f1fffc8 | ||
![]() |
43240a5fd4 | ||
![]() |
e19550ae69 | ||
![]() |
79f8293a0d | ||
![]() |
c2fef9d377 | ||
![]() |
b2f66c7386 | ||
![]() |
455998d759 | ||
![]() |
e73e7f0d68 | ||
![]() |
5b5c6e1402 | ||
![]() |
e9e1451f3c | ||
![]() |
34688fdd8c | ||
![]() |
da32a8ba0a | ||
![]() |
d9712cf1e8 | ||
![]() |
98b31ff1fe | ||
![]() |
67717ab923 | ||
![]() |
d587737633 | ||
![]() |
c3c3a2b11f | ||
![]() |
ff5817b8a6 | ||
![]() |
7b7177b59c | ||
![]() |
d4c6cebea3 | ||
![]() |
c6f0dd60ee | ||
![]() |
7d7be0e9da | ||
![]() |
59bbe3ed5e | ||
![]() |
d464a071da | ||
![]() |
8bea9261bc | ||
![]() |
3e5322944d | ||
![]() |
332f229e49 | ||
![]() |
806bacf15a | ||
![]() |
d00d946282 | ||
![]() |
d93b687bde | ||
![]() |
69557d4623 | ||
![]() |
f1303626f5 | ||
![]() |
b1c53bcd15 | ||
![]() |
5e1af6bb69 | ||
![]() |
4b9b0635c4 | ||
![]() |
8dbda8551f | ||
![]() |
38827dda5b | ||
![]() |
6e059dadd5 | ||
![]() |
9bfa241627 | ||
![]() |
4d77353852 | ||
![]() |
7de4f8683d | ||
![]() |
6215240b37 | ||
![]() |
a602013179 | ||
![]() |
e23dbc7473 | ||
![]() |
1397c10234 | ||
![]() |
4bdbf6352d | ||
![]() |
2d6ea25682 | ||
![]() |
900a1e060f | ||
![]() |
898b8d672e | ||
![]() |
896c0f2f6e | ||
![]() |
eed7e2ea70 | ||
![]() |
e177409bd3 | ||
![]() |
422c30cd34 | ||
![]() |
0b57be9c49 | ||
![]() |
a366c5a423 | ||
![]() |
e83e90ced2 | ||
![]() |
2991b0389e | ||
![]() |
9efa0f7874 | ||
![]() |
2dc95d6a5d | ||
![]() |
9b074d1e27 | ||
![]() |
436c237213 | ||
![]() |
90d18a2d20 |
9
.bcr/README.md
Normal file
9
.bcr/README.md
Normal 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.
|
16
.bcr/metadata.template.json
Normal file
16
.bcr/metadata.template.json
Normal 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
21
.bcr/presubmit.yml
Normal 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'
|
||||||
|
|
5
.bcr/source.template.json
Normal file
5
.bcr/source.template.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"integrity": "",
|
||||||
|
"strip_prefix": "",
|
||||||
|
"url": "https://github.com/ArthurSonzogni/FTXUI/releases/download/{TAG}/source.tar.gz"
|
||||||
|
}
|
21
.clang-tidy
21
.clang-tidy
@ -1,23 +1,34 @@
|
|||||||
---
|
---
|
||||||
Checks: "*,
|
Checks: "*,
|
||||||
|
-*-macro-usage,
|
||||||
|
-*-magic-numbers,
|
||||||
|
-*-narrowing-conversions
|
||||||
|
-*-unnecessary-value-param,
|
||||||
|
-*-uppercase-literal-suffix,
|
||||||
-abseil-*,
|
-abseil-*,
|
||||||
-altera-*,
|
-altera-*,
|
||||||
-android-*,
|
-android-*,
|
||||||
-fuchsia-*,
|
|
||||||
-google-*,
|
|
||||||
-llvm*,
|
|
||||||
-modernize-use-trailing-return-type,
|
|
||||||
-zircon-*,
|
|
||||||
-bugprone-easily-swappable-parameters,
|
-bugprone-easily-swappable-parameters,
|
||||||
-cppcoreguidelines-non-private-member-variables-in-classes,
|
-cppcoreguidelines-non-private-member-variables-in-classes,
|
||||||
|
-cppcoreguidelines-pro-type-union-access,
|
||||||
|
-fuchsia-*,
|
||||||
|
-google-*,
|
||||||
|
-hicpp-signed-bitwise,
|
||||||
|
-llvm*,
|
||||||
-misc-no-recursion,
|
-misc-no-recursion,
|
||||||
-misc-non-private-member-variables-in-classes,
|
-misc-non-private-member-variables-in-classes,
|
||||||
-modernize-use-nodiscard,
|
-modernize-use-nodiscard,
|
||||||
|
-modernize-use-trailing-return-type,
|
||||||
-readability-avoid-const-params-in-decls,
|
-readability-avoid-const-params-in-decls,
|
||||||
-readability-else-after-return,
|
-readability-else-after-return,
|
||||||
-readability-identifier-length,
|
-readability-identifier-length,
|
||||||
-readability-implicit-bool-conversion,
|
-readability-implicit-bool-conversion,
|
||||||
|
-readability-non-const-parameter,
|
||||||
|
-readability-simplify-boolean-expr,
|
||||||
-readability-static-accessed-through-instance,
|
-readability-static-accessed-through-instance,
|
||||||
|
-readability-use-anyofallof,
|
||||||
|
-readability-avoid-nested-conditional-operator,
|
||||||
|
-zircon-*,
|
||||||
"
|
"
|
||||||
WarningsAsErrors: ''
|
WarningsAsErrors: ''
|
||||||
HeaderFilterRegex: ''
|
HeaderFilterRegex: ''
|
||||||
|
173
.github/workflows/build.yaml
vendored
173
.github/workflows/build.yaml
vendored
@ -1,19 +1,52 @@
|
|||||||
name: Build
|
name: Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
create:
|
# On new commits to main:
|
||||||
tags:
|
|
||||||
-v*
|
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- main
|
||||||
|
|
||||||
|
# On pull requests:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
|
||||||
name: "Tests"
|
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:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@ -21,7 +54,6 @@ jobs:
|
|||||||
- name: Linux GCC
|
- name: Linux GCC
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
compiler: gcc
|
compiler: gcc
|
||||||
gcov_executable: gcov
|
|
||||||
|
|
||||||
- name: Linux Clang
|
- name: Linux Clang
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
@ -39,8 +71,12 @@ jobs:
|
|||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
|
- name: Get number of CPU cores
|
||||||
|
uses: SimenB/github-actions-cpu-cores@v1
|
||||||
|
id: cpu-cores
|
||||||
|
|
||||||
- name: "Checkout repository"
|
- name: "Checkout repository"
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: "Setup Cpp"
|
- name: "Setup Cpp"
|
||||||
uses: aminya/setup-cpp@v1
|
uses: aminya/setup-cpp@v1
|
||||||
@ -49,7 +85,7 @@ jobs:
|
|||||||
vcvarsall: ${{ contains(matrix.os, 'windows' )}}
|
vcvarsall: ${{ contains(matrix.os, 'windows' )}}
|
||||||
cmake: true
|
cmake: true
|
||||||
ninja: true
|
ninja: true
|
||||||
clangtidy: true
|
clangtidy: false
|
||||||
cppcheck: false
|
cppcheck: false
|
||||||
gcovr: "5.0"
|
gcovr: "5.0"
|
||||||
opencppcoverage: true
|
opencppcoverage: true
|
||||||
@ -61,23 +97,30 @@ jobs:
|
|||||||
cmake -S .
|
cmake -S .
|
||||||
-B ./build
|
-B ./build
|
||||||
-DCMAKE_BUILD_TYPE:STRING=Debug
|
-DCMAKE_BUILD_TYPE:STRING=Debug
|
||||||
|
-DCMAKE_BUILD_PARALLEL_LEVEL=${{ steps.cpu-cores.outputs.count }}
|
||||||
-DFTXUI_ENABLE_COVERAGE:BOOL=ON
|
-DFTXUI_ENABLE_COVERAGE:BOOL=ON
|
||||||
-DFTXUI_BUILD_DOCS:BOOL=OFF
|
-DFTXUI_BUILD_DOCS:BOOL=OFF
|
||||||
-DFTXUI_BUILD_EXAMPLES:BOOL=ON
|
-DFTXUI_BUILD_EXAMPLES:BOOL=ON
|
||||||
-DFTXUI_BUILD_TESTS:BOOL=ON
|
-DFTXUI_BUILD_TESTS:BOOL=ON
|
||||||
-DFTXUI_BUILD_TESTS_FUZZER:BOOL=OFF
|
-DFTXUI_BUILD_TESTS_FUZZER:BOOL=OFF
|
||||||
-DFTXUI_ENABLE_INSTALL:BOOL=ON ;
|
-DFTXUI_ENABLE_INSTALL:BOOL=ON
|
||||||
|
-DFTXUI_DEV_WARNINGS:BOOL=ON ;
|
||||||
|
|
||||||
- name: "Build"
|
- name: "Build"
|
||||||
run: >
|
run: >
|
||||||
cmake
|
cmake
|
||||||
--build ./build
|
--build ./build
|
||||||
|
|
||||||
- name: Unix - Test and coverage
|
- name: Unix - Test
|
||||||
if: runner.os != 'Windows'
|
if: runner.os != 'Windows'
|
||||||
working-directory: ./build
|
working-directory: ./build
|
||||||
run: >
|
run: >
|
||||||
ctest -C Debug --rerun-failed --output-on-failure;
|
ctest -C Debug --rerun-failed --output-on-failure;
|
||||||
|
|
||||||
|
- name: Unix - coverage
|
||||||
|
if: matrix.gcov_executable != ''
|
||||||
|
working-directory: ./build
|
||||||
|
run: >
|
||||||
gcovr
|
gcovr
|
||||||
-j ${{env.nproc}}
|
-j ${{env.nproc}}
|
||||||
--delete
|
--delete
|
||||||
@ -111,109 +154,3 @@ jobs:
|
|||||||
flags: ${{ runner.os }}
|
flags: ${{ runner.os }}
|
||||||
name: ${{ runner.os }}-coverage
|
name: ${{ runner.os }}-coverage
|
||||||
files: ./build/coverage.xml
|
files: ./build/coverage.xml
|
||||||
|
|
||||||
# Create a release on new v* tags
|
|
||||||
release:
|
|
||||||
needs: test
|
|
||||||
if: ${{ github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v') }}
|
|
||||||
name: "Create release"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
steps:
|
|
||||||
- name: "Create release"
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
id: create_release
|
|
||||||
with:
|
|
||||||
draft: true
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
# Build artifact for the release
|
|
||||||
package:
|
|
||||||
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: "Checkout repository"
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: "Install cmake"
|
|
||||||
uses: lukka/get-cmake@latest
|
|
||||||
|
|
||||||
- name: "Build packages"
|
|
||||||
run: >
|
|
||||||
mkdir build;
|
|
||||||
cd build;
|
|
||||||
cmake ..
|
|
||||||
-DCMAKE_BUILD_TYPE=Release
|
|
||||||
-DFTXUI_BUILD_DOCS=OFF
|
|
||||||
-DFTXUI_BUILD_EXAMPLES=OFF
|
|
||||||
-DFTXUI_BUILD_TESTS=OFF
|
|
||||||
-DFTXUI_BUILD_TESTS_FUZZER=OFF
|
|
||||||
-DFTXUI_ENABLE_INSTALL=ON;
|
|
||||||
cmake --build . --target package;
|
|
||||||
- uses: shogo82148/actions-upload-release-asset@v1
|
|
||||||
with:
|
|
||||||
upload_url: ${{ needs.release.outputs.upload_url }}
|
|
||||||
asset_path: ${{ matrix.asset_path }}
|
|
||||||
overwrite: true
|
|
||||||
|
|
||||||
documentation:
|
|
||||||
if: github.ref == 'refs/heads/master'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: "Checkout repository"
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- 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;
|
|
||||||
cmake --build . --target doc;
|
|
||||||
cmake --build . ;
|
|
||||||
rsync -amv
|
|
||||||
--include='*/'
|
|
||||||
--include='*.html'
|
|
||||||
--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
|
|
||||||
|
60
.github/workflows/documentation.yaml
vendored
Normal file
60
.github/workflows/documentation.yaml
vendored
Normal 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
|
24
.github/workflows/publish.yaml
vendored
Normal file
24
.github/workflows/publish.yaml
vendored
Normal 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 }}
|
100
.github/workflows/release.yaml
vendored
Normal file
100
.github/workflows/release.yaml
vendored
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
# On push to a tag:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
# On manual trigger:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
# Needed to mint attestations
|
||||||
|
id-token: write
|
||||||
|
attestations: write
|
||||||
|
# Needed to upload release assets
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
name: "Create release"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
steps:
|
||||||
|
- name: "Create release"
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
id: create_release
|
||||||
|
with:
|
||||||
|
draft: true
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
# 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: "Checkout repository"
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: "Install cmake"
|
||||||
|
uses: lukka/get-cmake@latest
|
||||||
|
|
||||||
|
- name: "Build packages"
|
||||||
|
run: >
|
||||||
|
mkdir build;
|
||||||
|
cd build;
|
||||||
|
cmake ..
|
||||||
|
-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
|
||||||
|
-DFTXUI_DEV_WARNINGS=ON ;
|
||||||
|
cmake --build . --target package;
|
||||||
|
|
||||||
|
- uses: shogo82148/actions-upload-release-asset@v1
|
||||||
|
with:
|
||||||
|
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
|
70
.gitignore
vendored
Normal file
70
.gitignore
vendored
Normal 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
|
251
BUILD.bazel
Normal file
251
BUILD.bazel
Normal 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()
|
224
CHANGELOG.md
224
CHANGELOG.md
@ -1,8 +1,228 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
current (development)
|
Future release
|
||||||
---------------------
|
------------
|
||||||
|
|
||||||
|
### 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
|
4.0.0
|
||||||
-----
|
-----
|
||||||
|
@ -1,17 +1,20 @@
|
|||||||
cmake_minimum_required(VERSION 3.11)
|
cmake_minimum_required(VERSION 3.12)
|
||||||
|
|
||||||
project(ftxui
|
project(ftxui
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
VERSION 4.0.0
|
VERSION 6.1.8
|
||||||
|
DESCRIPTION "C++ Functional Terminal User Interface."
|
||||||
)
|
)
|
||||||
|
|
||||||
option(FTXUI_BUILD_DOCS "Set to ON to build docs" ON)
|
option(FTXUI_QUIET "Set to ON for FTXUI to be quiet" OFF)
|
||||||
option(FTXUI_BUILD_EXAMPLES "Set to ON to build examples" ON)
|
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 "Set to ON to build tests" OFF)
|
||||||
option(FTXUI_BUILD_TESTS_FUZZER "Set to ON to enable fuzzing" OFF)
|
option(FTXUI_BUILD_TESTS_FUZZER "Set to ON to enable fuzzing" OFF)
|
||||||
option(FTXUI_ENABLE_INSTALL "Generate the install target" ON)
|
option(FTXUI_ENABLE_INSTALL "Generate the install target" ON)
|
||||||
option(FTXUI_CLANG_TIDY "Execute clang-tidy" OFF)
|
option(FTXUI_CLANG_TIDY "Execute clang-tidy" OFF)
|
||||||
option(FTXUI_ENABLE_COVERAGE "Execute code coverage" 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 \
|
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 \
|
terminal used will be one of Microsoft and use a set of reasonnable fallback \
|
||||||
@ -24,16 +27,22 @@ else()
|
|||||||
${FTXUI_MICROSOFT_TERMINAL_FALLBACK_HELP_TEXT} OFF)
|
${FTXUI_MICROSOFT_TERMINAL_FALLBACK_HELP_TEXT} OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
include(cmake/ftxui_message.cmake)
|
||||||
|
|
||||||
add_library(screen
|
add_library(screen
|
||||||
include/ftxui/screen/box.hpp
|
include/ftxui/screen/box.hpp
|
||||||
include/ftxui/screen/color.hpp
|
include/ftxui/screen/color.hpp
|
||||||
include/ftxui/screen/color_info.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/screen.hpp
|
||||||
include/ftxui/screen/string.hpp
|
include/ftxui/screen/string.hpp
|
||||||
src/ftxui/screen/box.cpp
|
src/ftxui/screen/box.cpp
|
||||||
src/ftxui/screen/color.cpp
|
src/ftxui/screen/color.cpp
|
||||||
src/ftxui/screen/color_info.cpp
|
src/ftxui/screen/color_info.cpp
|
||||||
|
src/ftxui/screen/image.cpp
|
||||||
src/ftxui/screen/screen.cpp
|
src/ftxui/screen/screen.cpp
|
||||||
src/ftxui/screen/string.cpp
|
src/ftxui/screen/string.cpp
|
||||||
src/ftxui/screen/terminal.cpp
|
src/ftxui/screen/terminal.cpp
|
||||||
@ -42,12 +51,15 @@ add_library(screen
|
|||||||
|
|
||||||
add_library(dom
|
add_library(dom
|
||||||
include/ftxui/dom/canvas.hpp
|
include/ftxui/dom/canvas.hpp
|
||||||
|
include/ftxui/dom/direction.hpp
|
||||||
include/ftxui/dom/elements.hpp
|
include/ftxui/dom/elements.hpp
|
||||||
include/ftxui/dom/flexbox_config.hpp
|
include/ftxui/dom/flexbox_config.hpp
|
||||||
include/ftxui/dom/node.hpp
|
include/ftxui/dom/node.hpp
|
||||||
include/ftxui/dom/requirement.hpp
|
include/ftxui/dom/requirement.hpp
|
||||||
|
include/ftxui/dom/selection.hpp
|
||||||
include/ftxui/dom/take_any_args.hpp
|
include/ftxui/dom/take_any_args.hpp
|
||||||
src/ftxui/dom/automerge.cpp
|
src/ftxui/dom/automerge.cpp
|
||||||
|
src/ftxui/dom/selection_style.cpp
|
||||||
src/ftxui/dom/blink.cpp
|
src/ftxui/dom/blink.cpp
|
||||||
src/ftxui/dom/bold.cpp
|
src/ftxui/dom/bold.cpp
|
||||||
src/ftxui/dom/border.cpp
|
src/ftxui/dom/border.cpp
|
||||||
@ -70,12 +82,16 @@ add_library(dom
|
|||||||
src/ftxui/dom/graph.cpp
|
src/ftxui/dom/graph.cpp
|
||||||
src/ftxui/dom/gridbox.cpp
|
src/ftxui/dom/gridbox.cpp
|
||||||
src/ftxui/dom/hbox.cpp
|
src/ftxui/dom/hbox.cpp
|
||||||
|
src/ftxui/dom/hyperlink.cpp
|
||||||
src/ftxui/dom/inverted.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.cpp
|
||||||
src/ftxui/dom/node_decorator.cpp
|
src/ftxui/dom/node_decorator.cpp
|
||||||
src/ftxui/dom/paragraph.cpp
|
src/ftxui/dom/paragraph.cpp
|
||||||
src/ftxui/dom/reflect.cpp
|
src/ftxui/dom/reflect.cpp
|
||||||
src/ftxui/dom/scroll_indicator.cpp
|
src/ftxui/dom/scroll_indicator.cpp
|
||||||
|
src/ftxui/dom/selection.cpp
|
||||||
src/ftxui/dom/separator.cpp
|
src/ftxui/dom/separator.cpp
|
||||||
src/ftxui/dom/size.cpp
|
src/ftxui/dom/size.cpp
|
||||||
src/ftxui/dom/spinner.cpp
|
src/ftxui/dom/spinner.cpp
|
||||||
@ -125,6 +141,7 @@ add_library(component
|
|||||||
src/ftxui/component/terminal_input_parser.cpp
|
src/ftxui/component/terminal_input_parser.cpp
|
||||||
src/ftxui/component/terminal_input_parser.hpp
|
src/ftxui/component/terminal_input_parser.hpp
|
||||||
src/ftxui/component/util.cpp
|
src/ftxui/component/util.cpp
|
||||||
|
src/ftxui/component/window.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(dom
|
target_link_libraries(dom
|
||||||
|
9
MODULE.bazel
Normal file
9
MODULE.bazel
Normal 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")
|
107
README.md
107
README.md
@ -1,13 +1,15 @@
|
|||||||
<p align="center">
|
<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/>
|
<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="#"><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="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/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/forks/ArthurSonzogni/FTXUI"></img></a>
|
||||||
<a href="#"><img src="https://img.shields.io/github/repo-size/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>
|
<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">
|
<a href="https://codecov.io/gh/ArthurSonzogni/FTXUI">
|
||||||
<img src="https://codecov.io/gh/ArthurSonzogni/FTXUI/branch/master/graph/badge.svg?token=C41FdRpNVA"/>
|
<img src="https://codecov.io/gh/ArthurSonzogni/FTXUI/branch/master/graph/badge.svg?token=C41FdRpNVA"/>
|
||||||
</a>
|
</a>
|
||||||
@ -22,15 +24,15 @@
|
|||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## FTXUI
|
# FTXUI
|
||||||
|
|
||||||
<i>Functional Terminal (X) User interface</i>
|
<i>Functional Terminal (X) User interface</i>
|
||||||
|
|
||||||
A simple C++ library for terminal based user interfaces!
|
A simple cross-platform C++ library for terminal based user interfaces!
|
||||||
|
|
||||||
## Feature
|
## Feature
|
||||||
* Functional style. Inspired by
|
* 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/)
|
and [React](https://reactjs.org/)
|
||||||
* Simple and elegant syntax (in my opinion)
|
* Simple and elegant syntax (in my opinion)
|
||||||
* Keyboard & mouse navigation.
|
* Keyboard & mouse navigation.
|
||||||
@ -38,10 +40,10 @@ A simple C++ library for terminal based user interfaces!
|
|||||||
* 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 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)
|
* Support for drawing. [Demo](https://arthursonzogni.github.io/FTXUI/examples/?file=component/canvas_animated)
|
||||||
* No dependencies
|
* No dependencies
|
||||||
* Cross platform: Linux/MacOS (main target), WebAssembly, Windows (Thanks to contributors!).
|
* **Cross platform**: Linux/MacOS (main target), WebAssembly, Windows (Thanks to contributors!).
|
||||||
* Learn by [examples](#documentation), and [tutorials](#documentation)
|
* Learn by [examples](#documentation), and [tutorials](#documentation)
|
||||||
* Multiple packages: CMake [FetchContent](https://bewagner.net/programming/2020/05/02/cmake-fetchcontent/) (preferred), vcpkg, pkgbuild, conan.
|
* 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 practises: documentation, tests, fuzzers, performance tests, automated CI, automated packaging, etc...
|
* Good practices: documentation, tests, fuzzers, performance tests, automated CI, automated packaging, etc...
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
@ -50,40 +52,28 @@ A simple C++ library for terminal based user interfaces!
|
|||||||
- [Examples (WebAssembly)](https://arthursonzogni.github.io/FTXUI/examples/)
|
- [Examples (WebAssembly)](https://arthursonzogni.github.io/FTXUI/examples/)
|
||||||
- [Build using CMake](https://arthursonzogni.github.io/FTXUI/#build-cmake)
|
- [Build using CMake](https://arthursonzogni.github.io/FTXUI/#build-cmake)
|
||||||
|
|
||||||
## Operating systems
|
|
||||||
|
|
||||||
This is expected to be cross platform. This supports / tests:
|
|
||||||
- WebAssembly
|
|
||||||
- Linux
|
|
||||||
- MacOS
|
|
||||||
- Windows
|
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
~~~cpp
|
~~~cpp
|
||||||
vbox({
|
vbox({
|
||||||
hbox({
|
hbox({
|
||||||
text("left") | border,
|
text("one") | border,
|
||||||
text("middle") | border | flex,
|
text("two") | border | flex,
|
||||||
text("right") | border,
|
text("three") | border | flex,
|
||||||
}),
|
}),
|
||||||
gauge(0.5) | border,
|
|
||||||
|
gauge(0.25) | color(Color::Red),
|
||||||
|
gauge(0.50) | color(Color::White),
|
||||||
|
gauge(0.75) | color(Color::Blue),
|
||||||
});
|
});
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
~~~bash
|

|
||||||
┌────┐┌───────────────────────────────────────────────────────────────┐┌─────┐
|
|
||||||
│left││middle ││right│
|
|
||||||
└────┘└───────────────────────────────────────────────────────────────┘└─────┘
|
|
||||||
┌────────────────────────────────────────────────────────────────────────────┐
|
|
||||||
│██████████████████████████████████████ │
|
|
||||||
└────────────────────────────────────────────────────────────────────────────┘
|
|
||||||
~~~
|
|
||||||
|
|
||||||
## Short gallery
|
## Short gallery
|
||||||
|
|
||||||
#### DOM
|
#### DOM
|
||||||
|
|
||||||
This module defines a hierarchical set of Element. An element manages layout and can be responsive to the terminal dimensions.
|
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
|
They are declared in [<ftxui/dom/elements.hpp>](https://arthursonzogni.github.io/FTXUI/elements_8hpp_source.html
|
||||||
)
|
)
|
||||||
@ -103,7 +93,7 @@ Element can become flexible using the the `flex` decorator.
|
|||||||

|

|
||||||
|
|
||||||
|
|
||||||
[Example](https://arthursonzogni.github.io/FTXUI/examples_2dom_2gridbox_8cpp-example.htmlp) using gridbox:
|
[Example](https://arthursonzogni.github.io/FTXUI/examples_2dom_2gridbox_8cpp-example.html) using gridbox:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@ -119,6 +109,7 @@ Element can become flexible using the the `flex` decorator.
|
|||||||
|
|
||||||
An element can be decorated using the functions:
|
An element can be decorated using the functions:
|
||||||
- `bold`
|
- `bold`
|
||||||
|
- `italic`
|
||||||
- `dim`
|
- `dim`
|
||||||
- `inverted`
|
- `inverted`
|
||||||
- `underlined`
|
- `underlined`
|
||||||
@ -127,6 +118,7 @@ An element can be decorated using the functions:
|
|||||||
- `strikethrough`
|
- `strikethrough`
|
||||||
- `color`
|
- `color`
|
||||||
- `bgcolor`
|
- `bgcolor`
|
||||||
|
- `hyperlink`
|
||||||
|
|
||||||
[Example](https://arthursonzogni.github.io/FTXUI/examples_2dom_2style_gallery_8cpp-example.html)
|
[Example](https://arthursonzogni.github.io/FTXUI/examples_2dom_2style_gallery_8cpp-example.html)
|
||||||
|
|
||||||
@ -208,7 +200,7 @@ Complex [examples](https://github.com/ArthurSonzogni/FTXUI/blob/master/examples/
|
|||||||
|
|
||||||
#### Component
|
#### Component
|
||||||
|
|
||||||
The ftxui/component is needed when you want to produce dynamic UI, reactive to the user's input. It defines a set of ftxui::Component. A component reacts to Events (keyboard, mouse, resize, ...) and Render Element (see previous section).
|
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)
|
Prebuilt components are declared in [<ftxui/component/component.hpp>](https://arthursonzogni.github.io/FTXUI/component_8hpp_source.html)
|
||||||
|
|
||||||
@ -301,8 +293,11 @@ Prebuilt components are declared in [<ftxui/component/component.hpp>](https://ar
|
|||||||
|
|
||||||
</details>
|
</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
|
## Project using FTXUI
|
||||||
@ -310,12 +305,12 @@ Prebuilt components are declared in [<ftxui/component/component.hpp>](https://ar
|
|||||||
Feel free to add your projects here:
|
Feel free to add your projects here:
|
||||||
- [json-tui](https://github.com/ArthurSonzogni/json-tui)
|
- [json-tui](https://github.com/ArthurSonzogni/json-tui)
|
||||||
- [git-tui](https://github.com/ArthurSonzogni/git-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)
|
- [rgb-tui](https://github.com/ArthurSonzogni/rgb-tui)
|
||||||
- [chrome-log-beautifier](https://github.com/ArthurSonzogni/chrome-log-beautifier)
|
- [chrome-log-beautifier](https://github.com/ArthurSonzogni/chrome-log-beautifier)
|
||||||
- [x86-64 CPU Architecture Simulation](https://github.com/AnisBdz/CPU)
|
- [x86-64 CPU Architecture Simulation](https://github.com/AnisBdz/CPU)
|
||||||
- [ltuiny](https://github.com/adrianoviana87/ltuiny)
|
- [ltuiny](https://github.com/adrianoviana87/ltuiny)
|
||||||
- [i3-termdialogs](https://github.com/mibli/i3-termdialogs)
|
- [i3-termdialogs](https://github.com/mibli/i3-termdialogs)
|
||||||
- [Just-Fast](https://github.com/GiuseppeCesarano/just-fast)
|
|
||||||
- [simpPRU](https://github.com/VedantParanjape/simpPRU)
|
- [simpPRU](https://github.com/VedantParanjape/simpPRU)
|
||||||
- [Pigeon ROS TUI](https://github.com/PigeonSensei/Pigeon_ros_tui)
|
- [Pigeon ROS TUI](https://github.com/PigeonSensei/Pigeon_ros_tui)
|
||||||
- [hastur](https://github.com/robinlinden/hastur)
|
- [hastur](https://github.com/robinlinden/hastur)
|
||||||
@ -330,8 +325,32 @@ Feel free to add your projects here:
|
|||||||
- [turing_cmd](https://github.com/DanArmor/turing_cmd)
|
- [turing_cmd](https://github.com/DanArmor/turing_cmd)
|
||||||
- [StartUp](https://github.com/StubbornVegeta/StartUp)
|
- [StartUp](https://github.com/StubbornVegeta/StartUp)
|
||||||
- [eCAL monitor](https://github.com/eclipse-ecal/ecal)
|
- [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)
|
||||||
|
|
||||||
## [cpp-best-practices/game_jam](https://github.com/cpp-best-practices/game_jam)
|
### [cpp-best-practices/game_jam](https://github.com/cpp-best-practices/game_jam)
|
||||||
|
|
||||||
Several games using the FTXUI have been made during the Game Jam:
|
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/)
|
- [TermBreaker](https://github.com/ArthurSonzogni/termBreaker) [**[Play web version]**](https://arthursonzogni.com/TermBreaker/)
|
||||||
@ -346,16 +365,15 @@ Several games using the FTXUI have been made during the Game Jam:
|
|||||||
- [smoothlife](https://github.com/cpp-best-practices/game_jam/blob/main/Jam1_April_2022/smoothlife.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)
|
- [Consu](https://github.com/cpp-best-practices/game_jam/blob/main/Jam1_April_2022/consu.md)
|
||||||
|
|
||||||
## External package
|
## Utilization
|
||||||
|
|
||||||
It is **highly** recommended to use CMake FetchContent to depend on FTXUI. This
|
It is **highly** recommended to use CMake FetchContent to depend on FTXUI so you may specify which commit you would like to depend on.
|
||||||
way you can specify which commit you would like to depend on.
|
|
||||||
```cmake
|
```cmake
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
|
|
||||||
FetchContent_Declare(ftxui
|
FetchContent_Declare(ftxui
|
||||||
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
|
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
|
||||||
GIT_TAG v3.0.0
|
GIT_TAG v6.1.8
|
||||||
)
|
)
|
||||||
|
|
||||||
FetchContent_GetProperties(ftxui)
|
FetchContent_GetProperties(ftxui)
|
||||||
@ -365,10 +383,19 @@ if(NOT ftxui_POPULATED)
|
|||||||
endif()
|
endif()
|
||||||
```
|
```
|
||||||
|
|
||||||
If you don't, the following packages have been created:
|
If you don't, FTXUI may be used from the following packages:
|
||||||
|
- [bazel](...)
|
||||||
- [vcpkg](https://vcpkgx.com/details.html?package=ftxui)
|
- [vcpkg](https://vcpkgx.com/details.html?package=ftxui)
|
||||||
- [Arch Linux PKGBUILD](https://aur.archlinux.org/packages/ftxui-git/).
|
- [Arch Linux PKGBUILD](https://aur.archlinux.org/packages/ftxui-git/).
|
||||||
- [conan.io](https://conan.io/center/ftxui)
|
- [conan.io](https://conan.io/center/ftxui)
|
||||||
|
- [openSUSE](https://build.opensuse.org/package/show/devel:libraries:c_c++/ftxui)
|
||||||
|
-
|
||||||
|
[](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
|
## Contributors
|
||||||
|
|
||||||
|
4
WORKSPACE.bazel
Normal file
4
WORKSPACE.bazel
Normal 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
115
bazel/ftxui.bzl
Normal 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(),
|
||||||
|
)
|
@ -2,3 +2,5 @@
|
|||||||
|
|
||||||
include(CMakeFindDependencyMacro)
|
include(CMakeFindDependencyMacro)
|
||||||
find_dependency(Threads)
|
find_dependency(Threads)
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/ftxui-targets.cmake")
|
@ -4,5 +4,5 @@ add_library(ftxui::component ALIAS component)
|
|||||||
export(
|
export(
|
||||||
TARGETS screen dom component
|
TARGETS screen dom component
|
||||||
NAMESPACE ftxui::
|
NAMESPACE ftxui::
|
||||||
FILE ${PROJECT_BINARY_DIR}/ftxui-targets.cmake
|
FILE "${PROJECT_BINARY_DIR}/ftxui-targets.cmake"
|
||||||
)
|
)
|
||||||
|
@ -13,7 +13,7 @@ include(FetchContent)
|
|||||||
|
|
||||||
FetchContent_Declare(googlebenchmark
|
FetchContent_Declare(googlebenchmark
|
||||||
GIT_REPOSITORY "https://github.com/google/benchmark"
|
GIT_REPOSITORY "https://github.com/google/benchmark"
|
||||||
GIT_TAG 62937f91b5c763a8e119d0c20c67b87bde8eff1c
|
GIT_TAG "015d1a091af6937488242b70121858bce8fd40e9" # v1.8.2
|
||||||
GIT_PROGRESS TRUE
|
GIT_PROGRESS TRUE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ set(BUILD_GMOCK OFF CACHE INTERNAL "")
|
|||||||
set(INSTALL_GTEST OFF CACHE INTERNAL "")
|
set(INSTALL_GTEST OFF CACHE INTERNAL "")
|
||||||
set(gtest_force_shared_crt ON CACHE INTERNAL "")
|
set(gtest_force_shared_crt ON CACHE INTERNAL "")
|
||||||
add_subdirectory(
|
add_subdirectory(
|
||||||
${googletest_SOURCE_DIR}
|
"${googletest_SOURCE_DIR}"
|
||||||
${googletest_BINARY_DIR}
|
"${googletest_BINARY_DIR}"
|
||||||
EXCLUDE_FROM_ALL
|
EXCLUDE_FROM_ALL
|
||||||
)
|
)
|
||||||
|
@ -5,22 +5,16 @@ endif()
|
|||||||
set(CMAKE_C_COMPILER clang)
|
set(CMAKE_C_COMPILER clang)
|
||||||
set(CMAKE_CXX_COMPILER clang++)
|
set(CMAKE_CXX_COMPILER clang++)
|
||||||
|
|
||||||
function(fuzz name)
|
function(fuzz source)
|
||||||
|
set(name "ftxui-${source}")
|
||||||
add_executable(${name}
|
add_executable(${name}
|
||||||
src/ftxui/component/${name}.cpp
|
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_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)
|
endfunction(fuzz)
|
||||||
|
|
||||||
fuzz(terminal_input_parser_test_fuzzer)
|
fuzz(terminal_input_parser_test_fuzzer)
|
||||||
|
@ -3,31 +3,58 @@ if(NOT FTXUI_ENABLE_INSTALL)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
install(TARGETS screen dom component
|
include(CMakePackageConfigHelpers)
|
||||||
EXPORT ftxui-export
|
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
# ------------------------------------------------------------------------------
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
# 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(
|
||||||
|
DIRECTORY include/ftxui
|
||||||
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||||
|
)
|
||||||
|
|
||||||
include(CMakePackageConfigHelpers)
|
# ------------------------------------------------------------------------------
|
||||||
configure_package_config_file(ftxui-config.cmake.in
|
# Install the exported cmake targets for use in other CMake projects.
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/ftxui-config.cmake
|
# ------------------------------------------------------------------------------
|
||||||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/ftxui/cmake
|
install(
|
||||||
|
EXPORT ftxui-targets
|
||||||
|
NAMESPACE 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
|
PATH_VARS CMAKE_INSTALL_INCLUDEDIR
|
||||||
)
|
)
|
||||||
write_basic_package_version_file(
|
write_basic_package_version_file(
|
||||||
ftxui-config-version.cmake
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake/ftxui-config-version.cmake"
|
||||||
VERSION ${PACKAGE_VERSION}
|
VERSION ${PACKAGE_VERSION}
|
||||||
COMPATIBILITY AnyNewerVersion
|
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"
|
||||||
)
|
)
|
||||||
|
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ftxui-config.cmake
|
# ------------------------------------------------------------------------------
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ftxui
|
# Create and install pkg-config file for easy use of library in build systems
|
||||||
)
|
# other than CMake:
|
||||||
install(EXPORT ftxui-export
|
# ------------------------------------------------------------------------------
|
||||||
FILE ftxui-config-version.cmake
|
configure_file(ftxui.pc.in ${CMAKE_CURRENT_BINARY_DIR}/ftxui.pc @ONLY)
|
||||||
NAMESPACE ftxui::
|
install(
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ftxui
|
FILES "${CMAKE_CURRENT_BINARY_DIR}/ftxui.pc"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
|
||||||
)
|
)
|
||||||
|
17
cmake/ftxui_message.cmake
Normal file
17
cmake/ftxui_message.cmake
Normal 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("└─────────────────────────────────────")
|
@ -1,18 +1,16 @@
|
|||||||
find_program(CLANG_TIDY_EXE NAMES "clang-tidy" DOC "Path to clang-tidy executable" )
|
find_program(CLANG_TIDY_EXE NAMES "clang-tidy" DOC "Path to clang-tidy executable" )
|
||||||
if(NOT CLANG_TIDY_EXE)
|
|
||||||
message(STATUS "clang-tidy not found.")
|
|
||||||
else()
|
|
||||||
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
function(ftxui_set_options library)
|
function(ftxui_set_options library)
|
||||||
message(STATUS "ftxui_set_options " ${library})
|
|
||||||
set_target_properties(${library} PROPERTIES VERSION ${PROJECT_VERSION})
|
set_target_properties(${library} PROPERTIES VERSION ${PROJECT_VERSION})
|
||||||
if (NOT ${library} MATCHES "ftxui-*")
|
if (NOT ${library} MATCHES "ftxui-*")
|
||||||
set_target_properties(${library} PROPERTIES OUTPUT_NAME "ftxui-${library}")
|
set_target_properties(${library} PROPERTIES OUTPUT_NAME "ftxui-${library}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CLANG_TIDY_EXE AND FTXUI_CLANG_TIDY)
|
if (FTXUI_CLANG_TIDY)
|
||||||
|
if (NOT CLANG_TIDY_EXE)
|
||||||
|
message(FATAL_ERROR "clang-tidy requested but executable not found")
|
||||||
|
endif()
|
||||||
|
|
||||||
set_target_properties(${library}
|
set_target_properties(${library}
|
||||||
PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-warnings-as-errors=*"
|
PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-warnings-as-errors=*"
|
||||||
)
|
)
|
||||||
@ -43,23 +41,27 @@ function(ftxui_set_options library)
|
|||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
)
|
)
|
||||||
|
|
||||||
# C++17 is used. We require fold expression at least.
|
target_compile_features(${library} PUBLIC cxx_std_17)
|
||||||
set_target_properties(${library} PROPERTIES
|
|
||||||
CXX_STANDARD 17
|
|
||||||
CXX_EXTENSIONS OFF
|
|
||||||
)
|
|
||||||
|
|
||||||
# Force Microsoft Visual Studio to decode sources files in UTF-8. This applies
|
# Force Microsoft Visual Studio to decode sources files in UTF-8. This applies
|
||||||
# to the library and the library users.
|
# to the library and the library users.
|
||||||
if (MSVC)
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
target_compile_options(${library} PUBLIC "/utf-8")
|
target_compile_options(${library} PUBLIC "/utf-8")
|
||||||
endif()
|
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:
|
# Add as many warning as possible:
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
|
if(FTXUI_DEV_WARNINGS)
|
||||||
target_compile_options(${library} PRIVATE "/W3")
|
target_compile_options(${library} PRIVATE "/W3")
|
||||||
target_compile_options(${library} PRIVATE "/WX")
|
target_compile_options(${library} PRIVATE "/WX")
|
||||||
|
endif()
|
||||||
target_compile_options(${library} PRIVATE "/wd4244")
|
target_compile_options(${library} PRIVATE "/wd4244")
|
||||||
target_compile_options(${library} PRIVATE "/wd4267")
|
target_compile_options(${library} PRIVATE "/wd4267")
|
||||||
target_compile_options(${library} PRIVATE "/D_CRT_SECURE_NO_WARNINGS")
|
target_compile_options(${library} PRIVATE "/D_CRT_SECURE_NO_WARNINGS")
|
||||||
@ -67,14 +69,29 @@ function(ftxui_set_options library)
|
|||||||
# Force Win32 to UNICODE
|
# Force Win32 to UNICODE
|
||||||
target_compile_definitions(${library} PRIVATE UNICODE _UNICODE)
|
target_compile_definitions(${library} PRIVATE UNICODE _UNICODE)
|
||||||
else()
|
else()
|
||||||
|
if(FTXUI_DEV_WARNINGS)
|
||||||
target_compile_options(${library} PRIVATE "-Wall")
|
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 "-Werror")
|
||||||
target_compile_options(${library} PRIVATE "-Wmissing-declarations")
|
target_compile_options(${library} PRIVATE "-Wextra")
|
||||||
|
|
||||||
|
target_compile_options(${library} PRIVATE "-Wcast-align")
|
||||||
target_compile_options(${library} PRIVATE "-Wdeprecated")
|
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 "-Wshadow")
|
||||||
|
target_compile_options(${library} PRIVATE "-Wunused")
|
||||||
endif()
|
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)
|
if (FTXUI_MICROSOFT_TERMINAL_FALLBACK)
|
||||||
target_compile_definitions(${library}
|
target_compile_definitions(${library}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
if (NOT FTXUI_BUILD_TESTS OR
|
if (NOT FTXUI_BUILD_TESTS)
|
||||||
NOT ${CMAKE_VERSION} VERSION_GREATER "3.11.4")
|
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -14,11 +13,13 @@ add_executable(ftxui-tests
|
|||||||
src/ftxui/component/component_test.cpp
|
src/ftxui/component/component_test.cpp
|
||||||
src/ftxui/component/component_test.cpp
|
src/ftxui/component/component_test.cpp
|
||||||
src/ftxui/component/container_test.cpp
|
src/ftxui/component/container_test.cpp
|
||||||
|
src/ftxui/component/dropdown_test.cpp
|
||||||
src/ftxui/component/hoverable_test.cpp
|
src/ftxui/component/hoverable_test.cpp
|
||||||
src/ftxui/component/input_test.cpp
|
src/ftxui/component/input_test.cpp
|
||||||
src/ftxui/component/menu_test.cpp
|
src/ftxui/component/menu_test.cpp
|
||||||
src/ftxui/component/modal_test.cpp
|
src/ftxui/component/modal_test.cpp
|
||||||
src/ftxui/component/radiobox_test.cpp
|
src/ftxui/component/radiobox_test.cpp
|
||||||
|
src/ftxui/util/ref_test.cpp
|
||||||
src/ftxui/component/receiver_test.cpp
|
src/ftxui/component/receiver_test.cpp
|
||||||
src/ftxui/component/resizable_split_test.cpp
|
src/ftxui/component/resizable_split_test.cpp
|
||||||
src/ftxui/component/screen_interactive_test.cpp
|
src/ftxui/component/screen_interactive_test.cpp
|
||||||
@ -37,7 +38,11 @@ add_executable(ftxui-tests
|
|||||||
src/ftxui/dom/gauge_test.cpp
|
src/ftxui/dom/gauge_test.cpp
|
||||||
src/ftxui/dom/gridbox_test.cpp
|
src/ftxui/dom/gridbox_test.cpp
|
||||||
src/ftxui/dom/hbox_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/scroll_indicator_test.cpp
|
||||||
|
src/ftxui/dom/selection_test.cpp
|
||||||
src/ftxui/dom/separator_test.cpp
|
src/ftxui/dom/separator_test.cpp
|
||||||
src/ftxui/dom/spinner_test.cpp
|
src/ftxui/dom/spinner_test.cpp
|
||||||
src/ftxui/dom/table_test.cpp
|
src/ftxui/dom/table_test.cpp
|
||||||
@ -56,10 +61,23 @@ target_link_libraries(ftxui-tests
|
|||||||
target_include_directories(ftxui-tests
|
target_include_directories(ftxui-tests
|
||||||
PRIVATE src
|
PRIVATE src
|
||||||
)
|
)
|
||||||
ftxui_set_options(ftxui-tests)
|
target_compile_features(ftxui-tests PRIVATE cxx_std_20)
|
||||||
target_compile_features(ftxui-tests PUBLIC cxx_std_20)
|
|
||||||
|
# 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()
|
||||||
|
|
||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
gtest_discover_tests(ftxui-tests
|
gtest_discover_tests(ftxui-tests
|
||||||
DISCOVERY_TIMEOUT 600
|
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)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
find_program(iwyu_path NAMES include-what-you-use iwyu)
|
find_program(iwyu_path NAMES include-what-you-use iwyu)
|
||||||
if(iwyu_path)
|
if(iwyu_path)
|
||||||
set_property(TARGET ${lib}
|
set_property(TARGET ${lib}
|
||||||
PROPERTY ${iwyu_path} -Xiwyu
|
PROPERTY "${iwyu_path}" -Xiwyu
|
||||||
--mapping_file ${CMAKE_CURRENT_SOURCE_DIR}/iwyu.imp
|
--mapping_file "${CMAKE_CURRENT_SOURCE_DIR}/iwyu.imp"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
132
doc/mainpage.md
132
doc/mainpage.md
@ -50,41 +50,17 @@ int main(void) {
|
|||||||
└────┘└────────────────────────────────────┘└─────┘
|
└────┘└────────────────────────────────────┘└─────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
# Build {#build}
|
## Configure {#configure}
|
||||||
|
### Using CMake and find_package {#build-cmake-find-package}
|
||||||
|
|
||||||
## Using CMake {#build-cmake}
|
Assuming FTXUI is available or installed on the system.
|
||||||
|
|
||||||
This is an example configuration for your **CMakeLists.txt**
|
**CMakeLists.txt**
|
||||||
|
|
||||||
CMakeLists.txt
|
|
||||||
```cmake
|
```cmake
|
||||||
cmake_minimum_required (VERSION 3.11)
|
cmake_minimum_required (VERSION 3.11)
|
||||||
|
find_package(ftxui 5 REQUIRED)
|
||||||
# --- Fetch FTXUI --------------------------------------------------------------
|
project(ftxui-starter LANGUAGES CXX VERSION 1.0.0)
|
||||||
include(FetchContent)
|
|
||||||
|
|
||||||
set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
|
|
||||||
FetchContent_Declare(ftxui
|
|
||||||
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
|
|
||||||
# Important: Specify a GIT_TAG XXXXX here.
|
|
||||||
)
|
|
||||||
|
|
||||||
FetchContent_GetProperties(ftxui)
|
|
||||||
if(NOT ftxui_POPULATED)
|
|
||||||
FetchContent_Populate(ftxui)
|
|
||||||
add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
project(ftxui-starter
|
|
||||||
LANGUAGES CXX
|
|
||||||
VERSION 1.0.0
|
|
||||||
)
|
|
||||||
|
|
||||||
add_executable(ftxui-starter src/main.cpp)
|
add_executable(ftxui-starter src/main.cpp)
|
||||||
target_include_directories(ftxui-starter PRIVATE src)
|
|
||||||
|
|
||||||
target_link_libraries(ftxui-starter
|
target_link_libraries(ftxui-starter
|
||||||
PRIVATE ftxui::screen
|
PRIVATE ftxui::screen
|
||||||
PRIVATE ftxui::dom
|
PRIVATE ftxui::dom
|
||||||
@ -93,7 +69,33 @@ target_link_libraries(ftxui-starter
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Subsequently, you build the project in the standard fashion as follows:
|
### Using CMake and FetchContent {#build-cmake}
|
||||||
|
|
||||||
|
If you want to fetch FTXUI using cmake:
|
||||||
|
|
||||||
|
**CMakeLists.txt**
|
||||||
|
```cmake
|
||||||
|
cmake_minimum_required (VERSION 3.11)
|
||||||
|
|
||||||
|
include(FetchContent)
|
||||||
|
set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
|
||||||
|
FetchContent_Declare(ftxui
|
||||||
|
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
|
||||||
|
GIT_TAG main # Important: Specify a version or a commit hash here.
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(ftxui)
|
||||||
|
|
||||||
|
project(ftxui-starter LANGUAGES CXX VERSION 1.0.0)
|
||||||
|
add_executable(ftxui-starter src/main.cpp)
|
||||||
|
target_link_libraries(ftxui-starter
|
||||||
|
PRIVATE ftxui::screen
|
||||||
|
PRIVATE ftxui::dom
|
||||||
|
PRIVATE ftxui::component # Not needed for this example.
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
cmake ..
|
cmake ..
|
||||||
@ -113,18 +115,16 @@ The project is comprised of 3 modules:
|
|||||||
|
|
||||||
3. **ftxui/component** The module is required if your program needs to respond
|
3. **ftxui/component** The module is required if your program needs to respond
|
||||||
to user input. It defines a set of `ftxui::Component`. These components can
|
to user input. It defines a set of `ftxui::Component`. These components can
|
||||||
be utilized to navigate the program by using the arrow keys and interacting
|
be utilized to navigate using the arrow keys *and/or* cursor. There are
|
||||||
with widgets such as the checkbox. You can also make you own components.
|
several builtin widgets like checkbox/inputbox/etc to interact with. You can
|
||||||
The use can navigates
|
combine them, or even define your own custom components.
|
||||||
using the arrow keys and interact with widgets like checkbox/inputbox/... You
|
|
||||||
can make you own components.
|
|
||||||
|
|
||||||
# screen {#module-screen}
|
# screen {#module-screen}
|
||||||
|
|
||||||
This is the visual element of the program. It defines a `ftxui::Screen`, which
|
This is the visual element of the program. It defines a `ftxui::Screen`, which
|
||||||
is a grid of `ftxui::Pixel`. A Pixel represents a Unicode character and its
|
is a grid of `ftxui::Pixel`. A Pixel represents a Unicode character and its
|
||||||
associated style (bold, colors, etc.). The screen can be printed as a string
|
associated style (bold, italic, colors, etc.). The screen can be printed as a
|
||||||
using `ftxui::Screen::ToString()`. The following example highlights this
|
string using `ftxui::Screen::ToString()`. The following example highlights this
|
||||||
process:
|
process:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
@ -444,12 +444,43 @@ ftxui::Color::HSV(uint8_t hue, uint8_t saturation, uint8_t value);
|
|||||||
<script id="asciicast-xwzzghmqcqzIuyLwCpQFEqbEu" src="https://asciinema.org/a/xwzzghmqcqzIuyLwCpQFEqbEu.js" async></script>
|
<script id="asciicast-xwzzghmqcqzIuyLwCpQFEqbEu" src="https://asciinema.org/a/xwzzghmqcqzIuyLwCpQFEqbEu.js" async></script>
|
||||||
@endhtmlonly
|
@endhtmlonly
|
||||||
|
|
||||||
|
## LinearGradient #{#dom-linear-gradient}
|
||||||
|
|
||||||
|
FTXUI supports linear gradient. Either on the foreground or the background.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
Decorator color(const LinearGradient&);
|
||||||
|
Decorator bgcolor(const LinearGradient&);
|
||||||
|
```
|
||||||
|
|
||||||
|
A `ftxui::LinearGradient` is defined by an angle in degree, and a list of color
|
||||||
|
stops.
|
||||||
|
```cpp
|
||||||
|
auto gradient = LinearGradient()
|
||||||
|
.Angle(45)
|
||||||
|
.AddStop(0.0, Color::Red)
|
||||||
|
.AddStop(0.5, Color::Green)
|
||||||
|
.AddStop(1.0, Color::Blue);
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also use simplified constructors:
|
||||||
|
```cpp
|
||||||
|
LinearGradient(Color::Red, Color::Blue);
|
||||||
|
```
|
||||||
|
```cpp
|
||||||
|
LinearGradient(45, Color::Red, Color::Blue);
|
||||||
|
```
|
||||||
|
|
||||||
|
See [demo](https://arthursonzogni.github.io/FTXUI/examples/?file=component/linear_gradient_gallery).
|
||||||
|
|
||||||
|
|
||||||
## Style {#dom-style}
|
## Style {#dom-style}
|
||||||
In addition to colored text and colored backgrounds. Many terminals support text
|
In addition to colored text and colored backgrounds. Many terminals support text
|
||||||
effects such as: `bold`, `dim`, `underlined`, `inverted`, `blink`.
|
effects such as: `bold`, `italic`, `dim`, `underlined`, `inverted`, `blink`.
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
Element bold(Element);
|
Element bold(Element);
|
||||||
|
Element italic(Element);
|
||||||
Element dim(Element);
|
Element dim(Element);
|
||||||
Element inverted(Element);
|
Element inverted(Element);
|
||||||
Element underlined(Element);
|
Element underlined(Element);
|
||||||
@ -458,6 +489,8 @@ Element strikethrough(Element);
|
|||||||
Element blink(Element);
|
Element blink(Element);
|
||||||
Decorator color(Color);
|
Decorator color(Color);
|
||||||
Decorator bgcolor(Color);
|
Decorator bgcolor(Color);
|
||||||
|
Decorator colorgrad(LinearGradient);
|
||||||
|
Decorator bgcolorgrad(LinearGradient);
|
||||||
```
|
```
|
||||||
|
|
||||||
[Example](https://arthursonzogni.github.io/FTXUI/examples_2dom_2style_gallery_8cpp-example.html)
|
[Example](https://arthursonzogni.github.io/FTXUI/examples_2dom_2style_gallery_8cpp-example.html)
|
||||||
@ -563,7 +596,6 @@ Simple [example](https://github.com/ArthurSonzogni/FTXUI/blob/master/examples/do
|
|||||||
Complex [example](https://github.com/ArthurSonzogni/FTXUI/blob/master/examples/component/canvas_animated.cpp):
|
Complex [example](https://github.com/ArthurSonzogni/FTXUI/blob/master/examples/component/canvas_animated.cpp):
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
# component {#module-component}
|
# component {#module-component}
|
||||||
|
|
||||||
The `ftxui::component` module defines the logic that produces interactive
|
The `ftxui::component` module defines the logic that produces interactive
|
||||||
@ -604,6 +636,26 @@ Produced by: `ftxui::Input()` from "ftxui/component/component.hpp"
|
|||||||
<script id="asciicast-223719" src="https://asciinema.org/a/223719.js" async></script>
|
<script id="asciicast-223719" src="https://asciinema.org/a/223719.js" async></script>
|
||||||
@endhtmlonly
|
@endhtmlonly
|
||||||
|
|
||||||
|
### Filtered input
|
||||||
|
|
||||||
|
On can filter out the characters received by the input component, using
|
||||||
|
`ftxui::CatchEvent`.
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
std::string phone_number;
|
||||||
|
Component input = Input(&phone_number, "phone number");
|
||||||
|
|
||||||
|
// Filter out non-digit characters.
|
||||||
|
input |= CatchEvent([&](Event event) {
|
||||||
|
return event.is_character() && !std::isdigit(event.character()[0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Filter out characters past the 10th one.
|
||||||
|
input |= CatchEvent([&](Event event) {
|
||||||
|
return event.is_character() && phone_number.size() >= 10;
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
## Menu {#component-menu}
|
## Menu {#component-menu}
|
||||||
|
|
||||||
Defines a menu object. It contains a list of entries, one of them is selected.
|
Defines a menu object. It contains a list of entries, one of them is selected.
|
||||||
|
@ -8,24 +8,21 @@ function(example name)
|
|||||||
target_link_libraries(ftxui_example_${name} PUBLIC ${DIRECTORY_LIB})
|
target_link_libraries(ftxui_example_${name} PUBLIC ${DIRECTORY_LIB})
|
||||||
file(RELATIVE_PATH dir ${EXAMPLES_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
file(RELATIVE_PATH dir ${EXAMPLES_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
set_property(GLOBAL APPEND PROPERTY FTXUI::EXAMPLES ${dir}/${name})
|
set_property(GLOBAL APPEND PROPERTY FTXUI::EXAMPLES ${dir}/${name})
|
||||||
set_target_properties(ftxui_example_${name} PROPERTIES
|
target_compile_features(ftxui_example_${name} PRIVATE cxx_std_20)
|
||||||
CXX_STANDARD 20
|
|
||||||
)
|
|
||||||
endfunction(example)
|
endfunction(example)
|
||||||
|
|
||||||
add_subdirectory(component)
|
add_subdirectory(component)
|
||||||
add_subdirectory(dom)
|
add_subdirectory(dom)
|
||||||
|
|
||||||
if (EMSCRIPTEN)
|
if (EMSCRIPTEN)
|
||||||
# 32MB should be enough to run all the examples, in debug mode.
|
string(APPEND CMAKE_EXE_LINKER_FLAGS " -s ALLOW_MEMORY_GROWTH=1")
|
||||||
target_link_options(component PUBLIC "SHELL: -s TOTAL_MEMORY=33554432")
|
target_link_options(component PUBLIC "SHELL: -s ALLOW_MEMORY_GROWTH=1")
|
||||||
target_link_options(component PUBLIC "SHELL: -s ASSERTIONS=1")
|
|
||||||
#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)
|
get_property(EXAMPLES GLOBAL PROPERTY FTXUI::EXAMPLES)
|
||||||
foreach(file
|
foreach(file
|
||||||
"index.html"
|
"index.html"
|
||||||
|
"index.mjs"
|
||||||
|
"index.css"
|
||||||
"sw.js"
|
"sw.js"
|
||||||
"run_webassembly.py")
|
"run_webassembly.py")
|
||||||
configure_file(${file} ${file})
|
configure_file(${file} ${file})
|
||||||
|
@ -11,18 +11,23 @@ example(collapsible)
|
|||||||
example(composition)
|
example(composition)
|
||||||
example(custom_loop)
|
example(custom_loop)
|
||||||
example(dropdown)
|
example(dropdown)
|
||||||
|
example(dropdown_custom)
|
||||||
example(flexbox_gallery)
|
example(flexbox_gallery)
|
||||||
example(focus)
|
example(focus)
|
||||||
example(focus_cursor)
|
example(focus_cursor)
|
||||||
example(gallery)
|
example(gallery)
|
||||||
example(homescreen)
|
example(homescreen)
|
||||||
example(input)
|
example(input)
|
||||||
|
example(input_in_frame)
|
||||||
|
example(input_style)
|
||||||
|
example(linear_gradient_gallery)
|
||||||
example(maybe)
|
example(maybe)
|
||||||
example(menu)
|
example(menu)
|
||||||
example(menu2)
|
example(menu2)
|
||||||
example(menu_entries)
|
example(menu_entries)
|
||||||
example(menu_entries_animated)
|
example(menu_entries_animated)
|
||||||
example(menu_in_frame)
|
example(menu_in_frame)
|
||||||
|
example(menu_in_frame_horizontal)
|
||||||
example(menu_multiple)
|
example(menu_multiple)
|
||||||
example(menu_style)
|
example(menu_style)
|
||||||
example(menu_underline_animated_gallery)
|
example(menu_underline_animated_gallery)
|
||||||
@ -34,10 +39,14 @@ example(radiobox)
|
|||||||
example(radiobox_in_frame)
|
example(radiobox_in_frame)
|
||||||
example(renderer)
|
example(renderer)
|
||||||
example(resizable_split)
|
example(resizable_split)
|
||||||
|
example(scrollbar)
|
||||||
|
example(selection)
|
||||||
example(slider)
|
example(slider)
|
||||||
example(slider_direction)
|
example(slider_direction)
|
||||||
example(slider_rgb)
|
example(slider_rgb)
|
||||||
example(tab_horizontal)
|
example(tab_horizontal)
|
||||||
example(tab_vertical)
|
example(tab_vertical)
|
||||||
|
example(textarea)
|
||||||
example(toggle)
|
example(toggle)
|
||||||
|
example(window)
|
||||||
example(with_restored_io)
|
example(with_restored_io)
|
||||||
|
@ -1,40 +1,9 @@
|
|||||||
#include <memory> // for shared_ptr, __shared_ptr_access
|
#include "ftxui/component/component.hpp"
|
||||||
#include <string> // for operator+, to_string
|
#include "ftxui/component/screen_interactive.hpp"
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
int main(){
|
||||||
#include "ftxui/component/component.hpp" // for Button, Horizontal, Renderer
|
auto screen = ftxui::ScreenInteractive::Fullscreen();
|
||||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
auto testComponent = ftxui::Renderer([](){return ftxui::text("test Component");});
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
screen.Loop(testComponent);
|
||||||
#include "ftxui/dom/elements.hpp" // for separator, gauge, text, 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 buttons = Container::Horizontal({
|
|
||||||
Button("Decrease", [&] { value--; }),
|
|
||||||
Button("Increase", [&] { value++; }),
|
|
||||||
});
|
|
||||||
|
|
||||||
// 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;
|
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.
|
|
||||||
|
@ -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 <memory> // for shared_ptr, __shared_ptr_access
|
||||||
#include <string> // for operator+, to_string
|
#include <string> // for operator+, to_string
|
||||||
|
|
||||||
@ -11,7 +14,7 @@
|
|||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
int value = 50;
|
int value = 50;
|
||||||
|
|
||||||
// The tree of components. This defines how to navigate using the keyboard.
|
// The tree of components. This defines how to navigate using the keyboard.
|
||||||
@ -40,7 +43,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
screen.Loop(component);
|
screen.Loop(component);
|
||||||
return 0;
|
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.
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// 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 <memory> // for allocator, __shared_ptr_access, shared_ptr
|
||||||
#include <string> // for to_string, operator+
|
#include <string> // for to_string, operator+
|
||||||
|
|
||||||
@ -11,17 +14,16 @@
|
|||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
auto on_click = [&] { counter++; };
|
auto on_click = [&] { counter++; };
|
||||||
|
|
||||||
auto button_style = ButtonOption::Animated(Color::Default, Color::GrayDark,
|
auto style = ButtonOption::Animated(Color::Default, Color::GrayDark,
|
||||||
Color::Default, Color::White);
|
Color::Default, Color::White);
|
||||||
|
|
||||||
auto container = Container::Vertical({});
|
auto container = Container::Vertical({});
|
||||||
for (int i = 0; i < 30; ++i) {
|
for (int i = 0; i < 30; ++i) {
|
||||||
auto button =
|
auto button = Button("Button " + std::to_string(i), on_click, style);
|
||||||
Button("Button " + std::to_string(i), on_click, &button_style);
|
|
||||||
container->Add(button);
|
container->Add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +45,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
|
||||||
|
@ -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 operator+, to_string
|
#include <string> // for operator+, to_string
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||||
@ -10,7 +13,7 @@
|
|||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
int value = 0;
|
int value = 0;
|
||||||
auto action = [&] { value++; };
|
auto action = [&] { value++; };
|
||||||
auto action_renderer =
|
auto action_renderer =
|
||||||
@ -55,7 +58,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
screen.Loop(buttons);
|
screen.Loop(buttons);
|
||||||
return 0;
|
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.
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// 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 <cmath> // for sin, cos
|
||||||
#include <ftxui/dom/elements.hpp> // for canvas, Element, separator, hbox, operator|, border
|
#include <ftxui/dom/elements.hpp> // for canvas, Element, separator, hbox, operator|, border
|
||||||
#include <ftxui/screen/screen.hpp> // for Pixel
|
#include <ftxui/screen/screen.hpp> // for Pixel
|
||||||
@ -14,7 +17,7 @@
|
|||||||
#include "ftxui/dom/canvas.hpp" // for Canvas
|
#include "ftxui/dom/canvas.hpp" // for Canvas
|
||||||
#include "ftxui/screen/color.hpp" // for Color, Color::Red, Color::Blue, Color::Green, ftxui
|
#include "ftxui/screen/color.hpp" // for Color, Color::Red, Color::Blue, Color::Green, ftxui
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int mouse_x = 0;
|
int mouse_x = 0;
|
||||||
@ -257,7 +260,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
|
||||||
|
@ -1,31 +1,38 @@
|
|||||||
#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(int argc, const char* argv[]) {
|
|
||||||
using namespace ftxui;
|
|
||||||
|
|
||||||
Component input_list = Container::Vertical({});
|
|
||||||
std::vector<std::string> items(100, "");
|
|
||||||
for (int 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copyright 2021 Arthur Sonzogni. All rights reserved.
|
// Copyright 2021 Arthur Sonzogni. All rights reserved.
|
||||||
// Use of this source code is governed by the MIT license that can be found in
|
// Use of this source code is governed by the MIT license that can be found in
|
||||||
// the LICENSE file.
|
// 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() {
|
||||||
|
bool download = false;
|
||||||
|
bool upload = false;
|
||||||
|
bool ping = false;
|
||||||
|
|
||||||
|
auto container = Container::Vertical({
|
||||||
|
Checkbox("Download", &download),
|
||||||
|
Checkbox("Upload", &upload),
|
||||||
|
Checkbox("Ping", &ping),
|
||||||
|
});
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
@ -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 <array> // for array
|
#include <array> // for array
|
||||||
#include <memory> // for shared_ptr, __shared_ptr_access
|
#include <memory> // for shared_ptr, __shared_ptr_access
|
||||||
#include <string> // for operator+, to_string
|
#include <string> // for operator+, to_string
|
||||||
@ -10,7 +13,7 @@
|
|||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
std::array<bool, 30> states;
|
std::array<bool, 30> states;
|
||||||
|
|
||||||
auto container = Container::Vertical({});
|
auto container = Container::Vertical({});
|
||||||
@ -29,7 +32,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
return 0;
|
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.
|
|
||||||
|
@ -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, make_shared, __shared_ptr_access
|
#include <memory> // for allocator, make_shared, __shared_ptr_access
|
||||||
#include <utility> // for move
|
#include <utility> // for move
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
@ -26,7 +29,7 @@ Component Empty() {
|
|||||||
return std::make_shared<ComponentBase>();
|
return std::make_shared<ComponentBase>();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
auto component =
|
auto component =
|
||||||
Collapsible("Collapsible 1",
|
Collapsible("Collapsible 1",
|
||||||
Inner({
|
Inner({
|
||||||
@ -52,7 +55,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
ScreenInteractive::FitComponent().Loop(component);
|
ScreenInteractive::FitComponent().Loop(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// 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 <memory> // for allocator, shared_ptr, __shared_ptr_access
|
||||||
#include <string> // for operator+, to_string
|
#include <string> // for operator+, to_string
|
||||||
|
|
||||||
@ -11,7 +14,7 @@ using namespace ftxui;
|
|||||||
|
|
||||||
// An example of how to compose multiple components into one and maintain their
|
// An example of how to compose multiple components into one and maintain their
|
||||||
// interactiveness.
|
// interactiveness.
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
auto left_count = 0;
|
auto left_count = 0;
|
||||||
auto right_count = 0;
|
auto right_count = 0;
|
||||||
|
|
||||||
@ -58,7 +61,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Thanks to Chris Morgan for this example!
|
// 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.
|
|
||||||
|
@ -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 <stdlib.h> // for EXIT_SUCCESS
|
||||||
#include <chrono> // for milliseconds
|
#include <chrono> // for milliseconds
|
||||||
#include <ftxui/component/event.hpp> // for Event
|
#include <ftxui/component/event.hpp> // for Event
|
||||||
@ -11,7 +14,7 @@
|
|||||||
#include "ftxui/component/loop.hpp" // for Loop
|
#include "ftxui/component/loop.hpp" // for Loop
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
auto screen = ScreenInteractive::FitComponent();
|
auto screen = ScreenInteractive::FitComponent();
|
||||||
|
|
||||||
@ -49,7 +52,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
return EXIT_SUCCESS;
|
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.
|
|
||||||
|
@ -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 basic_string, string, allocator
|
#include <string> // for basic_string, string, allocator
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
@ -5,7 +8,7 @@
|
|||||||
#include "ftxui/component/component.hpp" // for Dropdown, Horizontal, Vertical
|
#include "ftxui/component/component.hpp" // for Dropdown, Horizontal, Vertical
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
std::vector<std::string> entries = {
|
std::vector<std::string> entries = {
|
||||||
@ -39,7 +42,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
auto screen = ScreenInteractive::FitComponent();
|
auto screen = ScreenInteractive::FitComponent();
|
||||||
screen.Loop(layout);
|
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.
|
|
||||||
|
104
examples/component/dropdown_custom.cpp
Normal file
104
examples/component/dropdown_custom.cpp
Normal 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,
|
||||||
|
}));
|
||||||
|
}
|
@ -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 <stddef.h> // for size_t
|
#include <stddef.h> // for size_t
|
||||||
#include <memory> // for shared_ptr, __shared_ptr_access, allocator
|
#include <memory> // for shared_ptr, __shared_ptr_access, allocator
|
||||||
#include <string> // for string, basic_string, to_string, operator+, char_traits
|
#include <string> // for string, basic_string, to_string, operator+, char_traits
|
||||||
@ -13,7 +16,7 @@
|
|||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
auto screen = ScreenInteractive::Fullscreen();
|
auto screen = ScreenInteractive::Fullscreen();
|
||||||
|
|
||||||
int direction_index = 0;
|
int direction_index = 0;
|
||||||
@ -186,7 +189,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
return 0;
|
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.
|
|
||||||
|
@ -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 <memory> // for allocator, shared_ptr, __shared_ptr_access
|
||||||
#include <string> // for operator+, char_traits, to_string, string
|
#include <string> // for operator+, char_traits, to_string, string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
@ -31,7 +34,7 @@ Element make_grid() {
|
|||||||
return gridbox(rows);
|
return gridbox(rows);
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
float focus_x = 0.5f;
|
float focus_x = 0.5f;
|
||||||
float focus_y = 0.5f;
|
float focus_y = 0.5f;
|
||||||
|
|
||||||
@ -64,7 +67,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
return 0;
|
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.
|
|
||||||
|
@ -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 <ftxui/component/captured_mouse.hpp> // for ftxui
|
#include <ftxui/component/captured_mouse.hpp> // for ftxui
|
||||||
#include <string> // for allocator, operator+, char_traits, string
|
#include <string> // for allocator, operator+, char_traits, string
|
||||||
|
|
||||||
@ -19,7 +22,7 @@ Component Instance(std::string label, Decorator focusCursor) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
auto screen = ScreenInteractive::Fullscreen();
|
auto screen = ScreenInteractive::Fullscreen();
|
||||||
screen.Loop(Container::Vertical({
|
screen.Loop(Container::Vertical({
|
||||||
Instance("focus", focus),
|
Instance("focus", focus),
|
||||||
@ -32,7 +35,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
}));
|
}));
|
||||||
return 0;
|
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.
|
|
||||||
|
@ -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 <functional> // for function
|
||||||
#include <memory> // for shared_ptr, allocator, __shared_ptr_access
|
#include <memory> // for shared_ptr, allocator, __shared_ptr_access
|
||||||
#include <string> // for string, basic_string
|
#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();
|
auto screen = ScreenInteractive::FitComponent();
|
||||||
|
|
||||||
// -- Menu
|
// -- Menu
|
||||||
@ -94,7 +97,25 @@ int main(int argc, const char* argv[]) {
|
|||||||
});
|
});
|
||||||
sliders = Wrap("Slider", sliders);
|
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({
|
auto layout = Container::Vertical({
|
||||||
menu,
|
menu,
|
||||||
toggle,
|
toggle,
|
||||||
@ -103,6 +124,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
input,
|
input,
|
||||||
sliders,
|
sliders,
|
||||||
button,
|
button,
|
||||||
|
lorel_ipsum,
|
||||||
});
|
});
|
||||||
|
|
||||||
auto component = Renderer(layout, [&] {
|
auto component = Renderer(layout, [&] {
|
||||||
@ -120,6 +142,8 @@ int main(int argc, const char* argv[]) {
|
|||||||
sliders->Render(),
|
sliders->Render(),
|
||||||
separator(),
|
separator(),
|
||||||
button->Render(),
|
button->Render(),
|
||||||
|
separator(),
|
||||||
|
lorel_ipsum->Render(),
|
||||||
}) |
|
}) |
|
||||||
xflex | size(WIDTH, GREATER_THAN, 40) | border;
|
xflex | size(WIDTH, GREATER_THAN, 40) | border;
|
||||||
});
|
});
|
||||||
@ -128,7 +152,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
return 0;
|
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.
|
|
||||||
|
@ -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 <stddef.h> // for size_t
|
#include <stddef.h> // for size_t
|
||||||
#include <array> // for array
|
#include <array> // for array
|
||||||
#include <atomic> // for atomic
|
#include <atomic> // for atomic
|
||||||
@ -24,7 +27,7 @@
|
|||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
auto screen = ScreenInteractive::Fullscreen();
|
auto screen = ScreenInteractive::Fullscreen();
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@ -261,7 +264,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Spiner
|
// Spinner
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
auto spinner_tab_renderer = Renderer([&] {
|
auto spinner_tab_renderer = Renderer([&] {
|
||||||
Elements entries;
|
Elements entries;
|
||||||
@ -421,7 +424,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
auto paragraph_renderer_left = Renderer([&] {
|
auto paragraph_renderer_left = Renderer([&] {
|
||||||
std::string str =
|
std::string str =
|
||||||
"Lorem Ipsum is simply dummy text of the printing and typesetting "
|
"Lorem Ipsum is simply dummy text of the printing and typesetting "
|
||||||
"industry. Lorem Ipsum has been the industry's standard dummy text "
|
"industry.\nLorem Ipsum has been the industry's standard dummy text "
|
||||||
"ever since the 1500s, when an unknown printer took a galley of type "
|
"ever since the 1500s, when an unknown printer took a galley of type "
|
||||||
"and scrambled it to make a type specimen book.";
|
"and scrambled it to make a type specimen book.";
|
||||||
return vbox({
|
return vbox({
|
||||||
@ -487,15 +490,24 @@ int main(int argc, const char* argv[]) {
|
|||||||
},
|
},
|
||||||
&tab_index);
|
&tab_index);
|
||||||
|
|
||||||
|
auto exit_button =
|
||||||
|
Button("Exit", [&] { screen.Exit(); }, ButtonOption::Animated());
|
||||||
|
|
||||||
auto main_container = Container::Vertical({
|
auto main_container = Container::Vertical({
|
||||||
|
Container::Horizontal({
|
||||||
tab_selection,
|
tab_selection,
|
||||||
|
exit_button,
|
||||||
|
}),
|
||||||
tab_content,
|
tab_content,
|
||||||
});
|
});
|
||||||
|
|
||||||
auto main_renderer = Renderer(main_container, [&] {
|
auto main_renderer = Renderer(main_container, [&] {
|
||||||
return vbox({
|
return vbox({
|
||||||
text("FTXUI Demo") | bold | hcenter,
|
text("FTXUI Demo") | bold | hcenter,
|
||||||
tab_selection->Render(),
|
hbox({
|
||||||
|
tab_selection->Render() | flex,
|
||||||
|
exit_button->Render(),
|
||||||
|
}),
|
||||||
tab_content->Render() | flex,
|
tab_content->Render() | flex,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -521,7 +533,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
return 0;
|
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 |
@ -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 <memory> // for allocator, __shared_ptr_access
|
||||||
#include <string> // for char_traits, operator+, string, basic_string
|
#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/dom/elements.hpp" // for text, hbox, separator, Element, operator|, vbox, border
|
||||||
#include "ftxui/util/ref.hpp" // for Ref
|
#include "ftxui/util/ref.hpp" // for Ref
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
|
// The data:
|
||||||
std::string first_name;
|
std::string first_name;
|
||||||
std::string last_name;
|
std::string last_name;
|
||||||
std::string password;
|
std::string password;
|
||||||
|
std::string phoneNumber;
|
||||||
|
|
||||||
|
// The basic input components:
|
||||||
Component input_first_name = Input(&first_name, "first name");
|
Component input_first_name = Input(&first_name, "first name");
|
||||||
Component input_last_name = Input(&last_name, "last name");
|
Component input_last_name = Input(&last_name, "last name");
|
||||||
|
|
||||||
|
// The password input component:
|
||||||
InputOption password_option;
|
InputOption password_option;
|
||||||
password_option.password = true;
|
password_option.password = true;
|
||||||
Component input_password = Input(&password, "password", password_option);
|
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({
|
auto component = Container::Vertical({
|
||||||
input_first_name,
|
input_first_name,
|
||||||
input_last_name,
|
input_last_name,
|
||||||
input_password,
|
input_password,
|
||||||
|
input_phone_number,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Tweak how the component tree is rendered:
|
||||||
auto renderer = Renderer(component, [&] {
|
auto renderer = Renderer(component, [&] {
|
||||||
return vbox({
|
return vbox({
|
||||||
text("Hello " + first_name + " " + last_name),
|
|
||||||
separator(),
|
|
||||||
hbox(text(" First name : "), input_first_name->Render()),
|
hbox(text(" First name : "), input_first_name->Render()),
|
||||||
hbox(text(" Last name : "), input_last_name->Render()),
|
hbox(text(" Last name : "), input_last_name->Render()),
|
||||||
hbox(text(" Password : "), input_password->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;
|
border;
|
||||||
});
|
});
|
||||||
@ -43,7 +66,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
screen.Loop(renderer);
|
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.
|
|
||||||
|
30
examples/component/input_in_frame.cpp
Normal file
30
examples/component/input_in_frame.cpp
Normal 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);
|
||||||
|
}
|
97
examples/component/input_style.cpp
Normal file
97
examples/component/input_style.cpp
Normal 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);
|
||||||
|
}
|
55
examples/component/linear_gradient_gallery.cpp
Normal file
55
examples/component/linear_gradient_gallery.cpp
Normal 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);
|
||||||
|
}
|
@ -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 <string> // for string, allocator, basic_string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
@ -10,7 +13,7 @@
|
|||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
std::vector<std::string> entries = {
|
std::vector<std::string> entries = {
|
||||||
"entry 1",
|
"entry 1",
|
||||||
"entry 2",
|
"entry 2",
|
||||||
@ -36,7 +39,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
screen.Loop(layout);
|
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.
|
|
||||||
|
@ -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 <functional> // for function
|
||||||
#include <iostream> // for basic_ostream::operator<<, operator<<, endl, basic_ostream, basic_ostream<>::__ostream_type, cout, ostream
|
#include <iostream> // for basic_ostream::operator<<, operator<<, endl, basic_ostream, basic_ostream<>::__ostream_type, cout, ostream
|
||||||
#include <string> // for string, basic_string, allocator
|
#include <string> // for string, basic_string, allocator
|
||||||
@ -8,7 +11,7 @@
|
|||||||
#include "ftxui/component/component_options.hpp" // for MenuOption
|
#include "ftxui/component/component_options.hpp" // for MenuOption
|
||||||
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
|
|
||||||
@ -21,13 +24,9 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
MenuOption option;
|
MenuOption option;
|
||||||
option.on_enter = screen.ExitLoopClosure();
|
option.on_enter = screen.ExitLoopClosure();
|
||||||
auto menu = Menu(&entries, &selected, &option);
|
auto menu = Menu(&entries, &selected, option);
|
||||||
|
|
||||||
screen.Loop(menu);
|
screen.Loop(menu);
|
||||||
|
|
||||||
std::cout << "Selected element = " << selected << std::endl;
|
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.
|
|
||||||
|
@ -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 <functional> // for function
|
||||||
#include <memory> // for allocator, __shared_ptr_access
|
#include <memory> // for allocator, __shared_ptr_access
|
||||||
#include <string> // for string, basic_string, operator+, to_string
|
#include <string> // for string, basic_string, operator+, to_string
|
||||||
@ -10,7 +13,7 @@
|
|||||||
#include "ftxui/component/screen_interactive.hpp" // for Component, ScreenInteractive
|
#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
|
#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;
|
using namespace ftxui;
|
||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
|
|
||||||
@ -27,9 +30,9 @@ int main(int argc, const char* argv[]) {
|
|||||||
int left_menu_selected = 0;
|
int left_menu_selected = 0;
|
||||||
int right_menu_selected = 0;
|
int right_menu_selected = 0;
|
||||||
Component left_menu_ =
|
Component left_menu_ =
|
||||||
Menu(&left_menu_entries, &left_menu_selected, &menu_option);
|
Menu(&left_menu_entries, &left_menu_selected, menu_option);
|
||||||
Component right_menu_ =
|
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({
|
Component container = Container::Horizontal({
|
||||||
left_menu_,
|
left_menu_,
|
||||||
@ -74,7 +77,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
screen.Loop(renderer);
|
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.
|
|
||||||
|
@ -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 <functional> // for function
|
||||||
#include <iostream> // for basic_ostream::operator<<, operator<<, endl, basic_ostream, basic_ostream<>::__ostream_type, cout, ostream
|
#include <iostream> // for basic_ostream::operator<<, operator<<, endl, basic_ostream, basic_ostream<>::__ostream_type, cout, ostream
|
||||||
#include <memory> // for allocator, shared_ptr, __shared_ptr_access
|
#include <memory> // for allocator, shared_ptr, __shared_ptr_access
|
||||||
@ -28,7 +31,7 @@ MenuEntryOption Colored(ftxui::Color c) {
|
|||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
|
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
@ -76,7 +79,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
std::cout << "Selected element = " << selected << std::endl;
|
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.
|
|
||||||
|
@ -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 <iostream> // for basic_ostream::operator<<, operator<<, endl, basic_ostream, basic_ostream<>::__ostream_type, cout, ostream
|
#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 <memory> // for shared_ptr, __shared_ptr_access
|
||||||
#include <string> // for to_string, allocator
|
#include <string> // for to_string, allocator
|
||||||
@ -24,7 +27,7 @@ MenuEntryOption Colored(ftxui::Color c) {
|
|||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
|
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
@ -60,7 +63,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
std::cout << "Selected element = " << selected << std::endl;
|
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.
|
|
||||||
|
@ -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 <memory> // for shared_ptr, __shared_ptr_access
|
||||||
#include <string> // for string, basic_string, operator+, to_string
|
#include <string> // for string, basic_string, operator+, to_string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
@ -10,7 +13,7 @@
|
|||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
std::vector<std::string> entries;
|
std::vector<std::string> entries;
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
|
|
||||||
@ -27,7 +30,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
return 0;
|
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.
|
|
||||||
|
30
examples/component/menu_in_frame_horizontal.cpp
Normal file
30
examples/component/menu_in_frame_horizontal.cpp
Normal 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;
|
||||||
|
}
|
@ -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 <stdlib.h> // for EXIT_SUCCESS
|
||||||
#include <memory> // for allocator, __shared_ptr_access
|
#include <memory> // for allocator, __shared_ptr_access
|
||||||
#include <string> // for string, operator+, basic_string, to_string, char_traits
|
#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};
|
int menu_selected[] = {0, 0, 0};
|
||||||
std::vector<std::vector<std::string>> menu_entries = {
|
std::vector<std::vector<std::string>> menu_entries = {
|
||||||
{
|
{
|
||||||
@ -72,7 +75,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
screen.Loop(global);
|
screen.Loop(global);
|
||||||
return EXIT_SUCCESS;
|
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.
|
|
||||||
|
@ -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 <array> // for array
|
#include <array> // for array
|
||||||
#include <chrono> // for milliseconds
|
#include <chrono> // for milliseconds
|
||||||
#include <functional> // for function
|
#include <functional> // for function
|
||||||
@ -30,7 +33,7 @@ Component HMenu3(std::vector<std::string>* entries, int* selected);
|
|||||||
Component HMenu4(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);
|
Component HMenu5(std::vector<std::string>* entries, int* selected);
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
|
|
||||||
std::vector<std::string> entries{
|
std::vector<std::string> entries{
|
||||||
@ -110,7 +113,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
Component VMenu1(std::vector<std::string>* entries, int* selected) {
|
Component VMenu1(std::vector<std::string>* entries, int* selected) {
|
||||||
auto option = MenuOption::Vertical();
|
auto option = MenuOption::Vertical();
|
||||||
option.entries.transform = [](EntryState state) {
|
option.entries_option.transform = [](EntryState state) {
|
||||||
state.label = (state.active ? "> " : " ") + state.label;
|
state.label = (state.active ? "> " : " ") + state.label;
|
||||||
Element e = text(state.label);
|
Element e = text(state.label);
|
||||||
if (state.focused)
|
if (state.focused)
|
||||||
@ -124,7 +127,7 @@ Component VMenu1(std::vector<std::string>* entries, int* selected) {
|
|||||||
|
|
||||||
Component VMenu2(std::vector<std::string>* entries, int* selected) {
|
Component VMenu2(std::vector<std::string>* entries, int* selected) {
|
||||||
auto option = MenuOption::Vertical();
|
auto option = MenuOption::Vertical();
|
||||||
option.entries.transform = [](EntryState state) {
|
option.entries_option.transform = [](EntryState state) {
|
||||||
state.label += (state.active ? " <" : " ");
|
state.label += (state.active ? " <" : " ");
|
||||||
Element e = hbox(filler(), text(state.label));
|
Element e = hbox(filler(), text(state.label));
|
||||||
if (state.focused)
|
if (state.focused)
|
||||||
@ -138,7 +141,7 @@ Component VMenu2(std::vector<std::string>* entries, int* selected) {
|
|||||||
|
|
||||||
Component VMenu3(std::vector<std::string>* entries, int* selected) {
|
Component VMenu3(std::vector<std::string>* entries, int* selected) {
|
||||||
auto option = MenuOption::Vertical();
|
auto option = MenuOption::Vertical();
|
||||||
option.entries.transform = [](EntryState state) {
|
option.entries_option.transform = [](EntryState state) {
|
||||||
Element e = state.active ? text("[" + state.label + "]")
|
Element e = state.active ? text("[" + state.label + "]")
|
||||||
: text(" " + state.label + " ");
|
: text(" " + state.label + " ");
|
||||||
if (state.focused)
|
if (state.focused)
|
||||||
@ -155,7 +158,7 @@ Component VMenu3(std::vector<std::string>* entries, int* selected) {
|
|||||||
|
|
||||||
Component VMenu4(std::vector<std::string>* entries, int* selected) {
|
Component VMenu4(std::vector<std::string>* entries, int* selected) {
|
||||||
auto option = MenuOption::Vertical();
|
auto option = MenuOption::Vertical();
|
||||||
option.entries.transform = [](EntryState state) {
|
option.entries_option.transform = [](EntryState state) {
|
||||||
if (state.active && state.focused) {
|
if (state.active && state.focused) {
|
||||||
return text(state.label) | color(Color::Yellow) | bgcolor(Color::Black) |
|
return text(state.label) | color(Color::Yellow) | bgcolor(Color::Black) |
|
||||||
bold;
|
bold;
|
||||||
@ -175,7 +178,7 @@ Component VMenu4(std::vector<std::string>* entries, int* selected) {
|
|||||||
|
|
||||||
Component VMenu5(std::vector<std::string>* entries, int* selected) {
|
Component VMenu5(std::vector<std::string>* entries, int* selected) {
|
||||||
auto option = MenuOption::Vertical();
|
auto option = MenuOption::Vertical();
|
||||||
option.entries.transform = [](EntryState state) {
|
option.entries_option.transform = [](EntryState state) {
|
||||||
auto element = text(state.label);
|
auto element = text(state.label);
|
||||||
if (state.active && state.focused) {
|
if (state.active && state.focused) {
|
||||||
return element | borderDouble;
|
return element | borderDouble;
|
||||||
@ -201,19 +204,19 @@ Component VMenu6(std::vector<std::string>* entries, int* selected) {
|
|||||||
|
|
||||||
Component VMenu7(std::vector<std::string>* entries, int* selected) {
|
Component VMenu7(std::vector<std::string>* entries, int* selected) {
|
||||||
auto option = MenuOption::Vertical();
|
auto option = MenuOption::Vertical();
|
||||||
option.entries.animated_colors.foreground.enabled = true;
|
option.entries_option.animated_colors.foreground.enabled = true;
|
||||||
option.entries.animated_colors.background.enabled = true;
|
option.entries_option.animated_colors.background.enabled = true;
|
||||||
option.entries.animated_colors.background.active = Color::Red;
|
option.entries_option.animated_colors.background.active = Color::Red;
|
||||||
option.entries.animated_colors.background.inactive = Color::Black;
|
option.entries_option.animated_colors.background.inactive = Color::Black;
|
||||||
option.entries.animated_colors.foreground.active = Color::White;
|
option.entries_option.animated_colors.foreground.active = Color::White;
|
||||||
option.entries.animated_colors.foreground.inactive = Color::Red;
|
option.entries_option.animated_colors.foreground.inactive = Color::Red;
|
||||||
return Menu(entries, selected, option);
|
return Menu(entries, selected, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
Component VMenu8(std::vector<std::string>* entries, int* selected) {
|
Component VMenu8(std::vector<std::string>* entries, int* selected) {
|
||||||
auto option = MenuOption::Vertical();
|
auto option = MenuOption::Vertical();
|
||||||
option.entries.animated_colors.foreground.Set(Color::Red, Color::White,
|
option.entries_option.animated_colors.foreground.Set(
|
||||||
std::chrono::milliseconds(500));
|
Color::Red, Color::White, std::chrono::milliseconds(500));
|
||||||
return Menu(entries, selected, option);
|
return Menu(entries, selected, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +243,7 @@ Component HMenu5(std::vector<std::string>* entries, int* selected) {
|
|||||||
auto option = MenuOption::HorizontalAnimated();
|
auto option = MenuOption::HorizontalAnimated();
|
||||||
option.underline.SetAnimation(std::chrono::milliseconds(1500),
|
option.underline.SetAnimation(std::chrono::milliseconds(1500),
|
||||||
animation::easing::ElasticOut);
|
animation::easing::ElasticOut);
|
||||||
option.entries.transform = [](EntryState state) {
|
option.entries_option.transform = [](EntryState state) {
|
||||||
Element e = text(state.label) | hcenter | flex;
|
Element e = text(state.label) | hcenter | flex;
|
||||||
if (state.active && state.focused)
|
if (state.active && state.focused)
|
||||||
e = e | bold;
|
e = e | bold;
|
||||||
@ -252,7 +255,3 @@ Component HMenu5(std::vector<std::string>* entries, int* selected) {
|
|||||||
option.underline.color_active = Color::Red;
|
option.underline.color_active = Color::Red;
|
||||||
return Menu(entries, selected, option);
|
return Menu(entries, selected, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
|
||||||
|
@ -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 <chrono> // for operator""ms, literals
|
#include <chrono> // for operator""ms, literals
|
||||||
#include <memory> // for allocator, shared_ptr, __shared_ptr_access
|
#include <memory> // for allocator, shared_ptr, __shared_ptr_access
|
||||||
#include <string> // for string, operator+, to_string, basic_string
|
#include <string> // for string, operator+, to_string, basic_string
|
||||||
@ -27,7 +30,7 @@ Component Text(const std::string& t) {
|
|||||||
return Renderer([t] { return text(t) | borderEmpty; });
|
return Renderer([t] { return text(t) | borderEmpty; });
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
std::vector<std::string> tab_values{
|
std::vector<std::string> tab_values{
|
||||||
"Tab 1", "Tab 2", "Tab 3", "A very very long tab", "탭",
|
"Tab 1", "Tab 2", "Tab 3", "A very very long tab", "탭",
|
||||||
@ -88,7 +91,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
screen.Loop(container);
|
screen.Loop(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// 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/component_options.hpp> // for ButtonOption
|
||||||
#include <ftxui/component/mouse.hpp> // for ftxui
|
#include <ftxui/component/mouse.hpp> // for ftxui
|
||||||
#include <functional> // for function
|
#include <functional> // for function
|
||||||
@ -77,7 +80,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
screen.Loop(main_component);
|
screen.Loop(main_component);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
|
||||||
|
@ -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 <memory> // for allocator, shared_ptr, __shared_ptr_access
|
||||||
#include <string> // for string, basic_string, char_traits, operator+
|
#include <string> // for string, basic_string, char_traits, operator+
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
@ -8,7 +11,7 @@
|
|||||||
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
#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
|
#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[]) {
|
int main() {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
|
|
||||||
@ -88,7 +91,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
screen.Loop(main_renderer);
|
screen.Loop(main_renderer);
|
||||||
return 0;
|
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.
|
|
||||||
|
@ -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 <memory> // for allocator, shared_ptr, __shared_ptr_access
|
||||||
#include <string> // for operator+, string, char_traits, basic_string
|
#include <string> // for operator+, string, char_traits, basic_string
|
||||||
|
|
||||||
@ -35,7 +38,7 @@ void Nested(std::string path) {
|
|||||||
screen.Loop(renderer);
|
screen.Loop(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
auto screen = ScreenInteractive::FitComponent();
|
auto screen = ScreenInteractive::FitComponent();
|
||||||
auto button_quit = Button("Quit", screen.ExitLoopClosure());
|
auto button_quit = Button("Quit", screen.ExitLoopClosure());
|
||||||
auto button_nested = Button("Nested", [] { Nested(""); });
|
auto button_nested = Button("Nested", [] { Nested(""); });
|
||||||
@ -45,7 +48,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
}));
|
}));
|
||||||
return 0;
|
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.
|
|
||||||
|
@ -18,137 +18,48 @@
|
|||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
std::string Stringify(Event event) {
|
std::string Code(Event event) {
|
||||||
std::string out;
|
std::string codes;
|
||||||
for (auto& it : event.input())
|
for (auto& it : event.input()) {
|
||||||
out += " " + std::to_string((unsigned int)it);
|
codes += " " + std::to_string((unsigned int)it);
|
||||||
|
|
||||||
out = "(" + out + " ) -> ";
|
|
||||||
if (event.is_character()) {
|
|
||||||
out += "Event::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) {
|
return codes;
|
||||||
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 if (event == Event::ArrowLeft) {
|
|
||||||
out += "Event::ArrowLeft";
|
|
||||||
} else if (event == Event::ArrowRight) {
|
|
||||||
out += "Event::ArrowRight";
|
|
||||||
} else if (event == Event::ArrowUp) {
|
|
||||||
out += "Event::ArrowUp";
|
|
||||||
} else if (event == Event::ArrowDown) {
|
|
||||||
out += "Event::ArrowDown";
|
|
||||||
} else if (event == Event::ArrowLeftCtrl) {
|
|
||||||
out += "Event::ArrowLeftCtrl";
|
|
||||||
} else if (event == Event ::ArrowRightCtrl) {
|
|
||||||
out += "Event::ArrowRightCtrl";
|
|
||||||
} else if (event == Event::ArrowUpCtrl) {
|
|
||||||
out += "Event::ArrowUpCtrl";
|
|
||||||
} else if (event == Event::ArrowDownCtrl) {
|
|
||||||
out += "Event::ArrowDownCtrl";
|
|
||||||
} else if (event == Event::Backspace) {
|
|
||||||
out += "Event::Backspace";
|
|
||||||
} else if (event == Event::Delete) {
|
|
||||||
out += "Event::Delete";
|
|
||||||
} else if (event == Event::Escape) {
|
|
||||||
out += "Event::Escape";
|
|
||||||
} else if (event == Event::Return) {
|
|
||||||
out += "Event::Return";
|
|
||||||
} else if (event == Event::Tab) {
|
|
||||||
out += "Event::Tab";
|
|
||||||
} else if (event == Event::TabReverse) {
|
|
||||||
out += "Event::TabReverse";
|
|
||||||
} else if (event == Event::F1) {
|
|
||||||
out += "Event::F1";
|
|
||||||
} else if (event == Event::F2) {
|
|
||||||
out += "Event::F2";
|
|
||||||
} else if (event == Event::F3) {
|
|
||||||
out += "Event::F3";
|
|
||||||
} else if (event == Event::F4) {
|
|
||||||
out += "Event::F4";
|
|
||||||
} else if (event == Event::F5) {
|
|
||||||
out += "Event::F5";
|
|
||||||
} else if (event == Event::F6) {
|
|
||||||
out += "Event::F6";
|
|
||||||
} else if (event == Event::F7) {
|
|
||||||
out += "Event::F7";
|
|
||||||
} else if (event == Event::F8) {
|
|
||||||
out += "Event::F8";
|
|
||||||
} else if (event == Event::F9) {
|
|
||||||
out += "Event::F9";
|
|
||||||
} else if (event == Event::F10) {
|
|
||||||
out += "Event::F10";
|
|
||||||
} else if (event == Event::F11) {
|
|
||||||
out += "Event::F11";
|
|
||||||
} else if (event == Event::F12) {
|
|
||||||
out += "Event::F12";
|
|
||||||
} else if (event == Event::Home) {
|
|
||||||
out += "Event::Home";
|
|
||||||
} else if (event == Event::End) {
|
|
||||||
out += "Event::End";
|
|
||||||
} else if (event == Event::PageUp) {
|
|
||||||
out += "Event::PageUp";
|
|
||||||
} else if (event == Event::PageDown) {
|
|
||||||
out += "Event::PageDown";
|
|
||||||
} else if (event == Event::Custom) {
|
|
||||||
out += "Custom";
|
|
||||||
} else {
|
|
||||||
out += "(special)";
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
|
|
||||||
std::vector<Event> keys;
|
std::vector<Event> keys;
|
||||||
|
|
||||||
auto component = Renderer([&] {
|
auto left_column = Renderer([&] {
|
||||||
Elements children;
|
Elements children = {
|
||||||
for (size_t i = std::max(0, (int)keys.size() - 20); i < keys.size(); ++i)
|
text("Codes"),
|
||||||
children.push_back(text(Stringify(keys[i])));
|
separator(),
|
||||||
return window(text("keys"), vbox(std::move(children)));
|
};
|
||||||
|
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);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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) {
|
component |= CatchEvent([&](Event event) {
|
||||||
keys.push_back(event);
|
keys.push_back(event);
|
||||||
return true;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
screen.Loop(component);
|
screen.Loop(component);
|
||||||
|
@ -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 <string> // for string, allocator, basic_string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
@ -7,7 +10,7 @@
|
|||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
std::vector<std::string> radiobox_list = {
|
std::vector<std::string> radiobox_list = {
|
||||||
"Use gcc",
|
"Use gcc",
|
||||||
"Use clang",
|
"Use clang",
|
||||||
@ -20,7 +23,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
screen.Loop(Radiobox(&radiobox_list, &selected));
|
screen.Loop(Radiobox(&radiobox_list, &selected));
|
||||||
return 0;
|
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.
|
|
||||||
|
@ -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 <memory> // for shared_ptr, __shared_ptr_access
|
||||||
#include <string> // for string, basic_string, operator+, to_string
|
#include <string> // for string, basic_string, operator+, to_string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
@ -10,7 +13,7 @@
|
|||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
std::vector<std::string> entries;
|
std::vector<std::string> entries;
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
|
|
||||||
@ -27,7 +30,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
return 0;
|
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.
|
|
||||||
|
@ -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 <memory> // for shared_ptr, allocator, __shared_ptr_access
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
#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/dom/elements.hpp" // for operator|, Element, text, bold, border, center, color
|
||||||
#include "ftxui/screen/color.hpp" // for Color, Color::Red
|
#include "ftxui/screen/color.hpp" // for Color, Color::Red
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
auto screen = ScreenInteractive::FitComponent();
|
auto screen = ScreenInteractive::FitComponent();
|
||||||
|
|
||||||
@ -43,7 +46,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
renderer_wrap,
|
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.
|
|
||||||
|
@ -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 <memory> // for shared_ptr, allocator, __shared_ptr_access
|
||||||
|
|
||||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||||
@ -8,7 +11,7 @@
|
|||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
auto screen = ScreenInteractive::Fullscreen();
|
auto screen = ScreenInteractive::Fullscreen();
|
||||||
|
|
||||||
auto middle = Renderer([] { return text("middle") | center; });
|
auto middle = Renderer([] { return text("middle") | center; });
|
||||||
@ -33,7 +36,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
screen.Loop(renderer);
|
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.
|
|
||||||
|
112
examples/component/scrollbar.cpp
Normal file
112
examples/component/scrollbar.cpp
Normal 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;
|
||||||
|
}
|
87
examples/component/selection.cpp
Normal file
87
examples/component/selection.cpp
Normal 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);
|
||||||
|
}
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
int value = 50;
|
int value = 50;
|
||||||
auto slider = Slider("Value:", &value, 0, 100, 1);
|
auto slider = Slider("Value:", &value, 0, 100, 1);
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
|
// 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 <array> // for array
|
||||||
#include <cmath> // for sin
|
#include <cmath> // for sin
|
||||||
#include <ftxui/component/component_base.hpp> // for ComponentBase
|
#include <ftxui/component/component_base.hpp> // for ComponentBase
|
||||||
#include <ftxui/component/component_options.hpp> // for SliderOption
|
#include <ftxui/component/component_options.hpp> // for SliderOption
|
||||||
#include <ftxui/dom/elements.hpp> // for size, GREATER_THAN, GaugeDirection, GaugeDirection::Up, HEIGHT
|
#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 <ftxui/util/ref.hpp> // for ConstRef, Ref
|
||||||
#include <memory> // for shared_ptr, __shared_ptr_access
|
#include <memory> // for shared_ptr, __shared_ptr_access
|
||||||
|
|
||||||
@ -12,21 +16,21 @@
|
|||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
std::array<int, 30> values;
|
std::array<int, 30> values;
|
||||||
for (int i = 0; i < values.size(); ++i) {
|
for (size_t i = 0; i < values.size(); ++i) {
|
||||||
values[i] = 50 + 20 * std::sin(i * 0.3);
|
values[i] = 50 + 20 * std::sin(i * 0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto layout_horizontal = Container::Horizontal({});
|
auto layout_horizontal = Container::Horizontal({});
|
||||||
for (int i = 0; i < values.size(); ++i) {
|
for (auto& value : values) {
|
||||||
// In C++17:
|
// In C++17:
|
||||||
SliderOption<int> option;
|
SliderOption<int> option;
|
||||||
option.value = &values[i];
|
option.value = &value;
|
||||||
option.max = 100;
|
option.max = 100;
|
||||||
option.increment = 5;
|
option.increment = 5;
|
||||||
option.direction = GaugeDirection::Up;
|
option.direction = Direction::Up;
|
||||||
layout_horizontal->Add(Slider<int>(option));
|
layout_horizontal->Add(Slider<int>(option));
|
||||||
|
|
||||||
/* In C++20:
|
/* In C++20:
|
||||||
@ -34,7 +38,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
.value = &values[i],
|
.value = &values[i],
|
||||||
.max = 100,
|
.max = 100,
|
||||||
.increment = 5,
|
.increment = 5,
|
||||||
.direction = GaugeDirection::Up,
|
.direction = Direction::Up,
|
||||||
}));
|
}));
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
@ -43,7 +47,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
screen.Loop(layout_horizontal);
|
screen.Loop(layout_horizontal);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
|
||||||
|
@ -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 <memory> // for allocator, shared_ptr, __shared_ptr_access
|
||||||
#include <string> // for char_traits, operator+, to_string
|
#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 red = 128;
|
||||||
int green = 25;
|
int green = 25;
|
||||||
int blue = 100;
|
int blue = 100;
|
||||||
@ -56,7 +59,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
screen.Loop(renderer);
|
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.
|
|
||||||
|
@ -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 <memory> // for allocator, __shared_ptr_access, shared_ptr
|
||||||
#include <string> // for string, basic_string
|
#include <string> // for string, basic_string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
@ -10,7 +13,7 @@
|
|||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
std::vector<std::string> tab_values{
|
std::vector<std::string> tab_values{
|
||||||
"tab_1",
|
"tab_1",
|
||||||
"tab_2",
|
"tab_2",
|
||||||
@ -65,7 +68,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
screen.Loop(renderer);
|
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.
|
|
||||||
|
@ -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 <memory> // for allocator, __shared_ptr_access, shared_ptr
|
||||||
#include <string> // for string, basic_string
|
#include <string> // for string, basic_string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
@ -10,7 +13,7 @@
|
|||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
std::vector<std::string> tab_values{
|
std::vector<std::string> tab_values{
|
||||||
"tab_1",
|
"tab_1",
|
||||||
"tab_2",
|
"tab_2",
|
||||||
@ -65,7 +68,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
screen.Loop(renderer);
|
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.
|
|
||||||
|
34
examples/component/textarea.cpp
Normal file
34
examples/component/textarea.cpp
Normal 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);
|
||||||
|
}
|
@ -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 <memory> // for allocator, __shared_ptr_access
|
||||||
#include <string> // for string, basic_string
|
#include <string> // for string, basic_string
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
@ -10,7 +13,7 @@
|
|||||||
|
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
std::vector<std::string> toggle_1_entries = {
|
std::vector<std::string> toggle_1_entries = {
|
||||||
"On",
|
"On",
|
||||||
"Off",
|
"Off",
|
||||||
@ -59,7 +62,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
auto screen = ScreenInteractive::TerminalOutput();
|
auto screen = ScreenInteractive::TerminalOutput();
|
||||||
screen.Loop(renderer);
|
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.
|
|
||||||
|
88
examples/component/window.cpp
Normal file
88
examples/component/window.cpp
Normal 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;
|
||||||
|
}
|
@ -1,3 +1,6 @@
|
|||||||
|
// 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 <cstdlib> // for system, EXIT_SUCCESS
|
||||||
#include <iostream> // for operator<<, basic_ostream, basic_ostream::operator<<, cout, endl, flush, ostream, basic_ostream<>::__ostream_type, cin
|
#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 <memory> // for shared_ptr, __shared_ptr_access, allocator
|
||||||
@ -55,7 +58,3 @@ int main() {
|
|||||||
screen.Loop(renderer);
|
screen.Loop(renderer);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
|
||||||
|
@ -1,19 +1,21 @@
|
|||||||
set(DIRECTORY_LIB dom)
|
set(DIRECTORY_LIB dom)
|
||||||
|
|
||||||
example(border)
|
example(border)
|
||||||
|
example(border_colored)
|
||||||
example(border_style)
|
example(border_style)
|
||||||
|
example(canvas)
|
||||||
example(color_gallery)
|
example(color_gallery)
|
||||||
example(color_info_palette256)
|
example(color_info_palette256)
|
||||||
example(color_truecolor_HSV)
|
example(color_truecolor_HSV)
|
||||||
example(color_truecolor_RGB)
|
example(color_truecolor_RGB)
|
||||||
example(dbox)
|
example(dbox)
|
||||||
example(canvas)
|
|
||||||
example(gauge)
|
example(gauge)
|
||||||
example(gauge_direction)
|
example(gauge_direction)
|
||||||
example(graph)
|
example(graph)
|
||||||
example(gridbox)
|
example(gridbox)
|
||||||
example(hflow)
|
example(hflow)
|
||||||
example(html_like)
|
example(html_like)
|
||||||
|
example(linear_gradient)
|
||||||
example(package_manager)
|
example(package_manager)
|
||||||
example(paragraph)
|
example(paragraph)
|
||||||
example(separator)
|
example(separator)
|
||||||
@ -25,11 +27,12 @@ example(style_bold)
|
|||||||
example(style_color)
|
example(style_color)
|
||||||
example(style_dim)
|
example(style_dim)
|
||||||
example(style_gallery)
|
example(style_gallery)
|
||||||
|
example(style_hyperlink)
|
||||||
example(style_inverted)
|
example(style_inverted)
|
||||||
|
example(style_italic)
|
||||||
example(style_strikethrough)
|
example(style_strikethrough)
|
||||||
example(style_underlined)
|
example(style_underlined)
|
||||||
example(style_underlined_double)
|
example(style_underlined_double)
|
||||||
example(table)
|
example(table)
|
||||||
example(vbox_hbox)
|
example(vbox_hbox)
|
||||||
example(vflow)
|
example(vflow)
|
||||||
example(window)
|
|
||||||
|
@ -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 <stdlib.h> // for EXIT_SUCCESS
|
||||||
#include <ftxui/dom/elements.hpp> // for text, operator|, vbox, border, Element, Fit, hbox
|
#include <ftxui/dom/elements.hpp> // for text, operator|, vbox, border, Element, Fit, hbox
|
||||||
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
@ -33,7 +36,3 @@ int main() {
|
|||||||
screen.Print();
|
screen.Print();
|
||||||
return EXIT_SUCCESS;
|
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.
|
|
||||||
|
39
examples/dom/border_colored.cpp
Normal file
39
examples/dom/border_colored.cpp
Normal 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;
|
||||||
|
}
|
@ -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 <ftxui/dom/elements.hpp> // for operator|, text, Element, Fit, borderDouble, borderHeavy, borderLight, borderRounded, vbox
|
#include <ftxui/dom/elements.hpp> // for operator|, text, Element, Fit, borderDouble, borderHeavy, borderLight, borderRounded, vbox
|
||||||
#include <ftxui/screen/screen.hpp> // for Screen
|
#include <ftxui/screen/screen.hpp> // for Screen
|
||||||
#include <iostream> // for endl, cout, ostream
|
#include <iostream> // for endl, cout, ostream
|
||||||
@ -6,11 +9,12 @@
|
|||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/color.hpp" // for ftxui
|
#include "ftxui/screen/color.hpp" // for ftxui
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
auto document = vbox({
|
auto document = vbox({
|
||||||
text("borderLight") | borderLight,
|
text("borderLight") | borderLight,
|
||||||
|
text("borderDashed") | borderDashed,
|
||||||
text("borderHeavy") | borderHeavy,
|
text("borderHeavy") | borderHeavy,
|
||||||
text("borderDouble") | borderDouble,
|
text("borderDouble") | borderDouble,
|
||||||
text("borderRounded") | borderRounded,
|
text("borderRounded") | borderRounded,
|
||||||
@ -22,7 +26,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
screen.Print();
|
screen.Print();
|
||||||
std::cout << std::endl;
|
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.
|
|
||||||
|
@ -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 <stdio.h> // for getchar
|
#include <stdio.h> // for getchar
|
||||||
#include <cmath> // for cos
|
#include <cmath> // for cos
|
||||||
#include <ftxui/dom/elements.hpp> // for Fit, canvas, operator|, border, Element
|
#include <ftxui/dom/elements.hpp> // for Fit, canvas, operator|, border, Element
|
||||||
@ -8,7 +11,7 @@
|
|||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/color.hpp" // for Color, Color::Red, Color::Blue, Color::Green, ftxui
|
#include "ftxui/screen/color.hpp" // for Color, Color::Red, Color::Blue, Color::Green, ftxui
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
auto c = Canvas(100, 100);
|
auto c = Canvas(100, 100);
|
||||||
@ -43,7 +46,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
return 0;
|
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.
|
|
||||||
|
@ -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 <ftxui/screen/color_info.hpp> // for ColorInfo
|
#include <ftxui/screen/color_info.hpp> // for ColorInfo
|
||||||
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <ftxui/screen/terminal.hpp> // for ColorSupport, Color, Palette16, Palette256, TrueColor
|
#include <ftxui/screen/terminal.hpp> // for ColorSupport, Color, Palette16, Palette256, TrueColor
|
||||||
@ -136,7 +139,3 @@ int main() {
|
|||||||
|
|
||||||
return 0;
|
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.
|
|
||||||
|
@ -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 <ftxui/dom/elements.hpp> // for text, bgcolor, hbox, operator|, Elements, Fit, vbox, Element
|
#include <ftxui/dom/elements.hpp> // for text, bgcolor, hbox, operator|, Elements, Fit, vbox, Element
|
||||||
#include <ftxui/screen/color_info.hpp> // for ColorInfo
|
#include <ftxui/screen/color_info.hpp> // for ColorInfo
|
||||||
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
@ -10,7 +13,7 @@
|
|||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
#include "./color_info_sorted_2d.ipp" // for ColorInfoSorted2D
|
#include "./color_info_sorted_2d.ipp" // for ColorInfoSorted2D
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
std::vector<std::vector<ColorInfo>> info_columns = ColorInfoSorted2D();
|
std::vector<std::vector<ColorInfo>> info_columns = ColorInfoSorted2D();
|
||||||
|
|
||||||
// Draw every columns
|
// Draw every columns
|
||||||
@ -34,7 +37,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
return 0;
|
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.
|
|
||||||
|
@ -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 <ftxui/dom/elements.hpp> // for operator|, Elements, Fit, bgcolor, color, hbox, text, vbox, Element
|
#include <ftxui/dom/elements.hpp> // for operator|, Elements, Fit, bgcolor, color, hbox, text, vbox, Element
|
||||||
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <memory> // for allocator
|
#include <memory> // for allocator
|
||||||
@ -6,7 +9,7 @@
|
|||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/color.hpp" // for Color, ftxui
|
#include "ftxui/screen/color.hpp" // for Color, ftxui
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int saturation = 255;
|
int saturation = 255;
|
||||||
@ -30,7 +33,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
return 0;
|
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.
|
|
||||||
|
@ -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 <ftxui/dom/elements.hpp> // for hbox, text, bgcolor, operator|, vbox, Elements, window, Element, Fit
|
#include <ftxui/dom/elements.hpp> // for hbox, text, bgcolor, operator|, vbox, Elements, window, Element, Fit
|
||||||
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <memory> // for allocator
|
#include <memory> // for allocator
|
||||||
@ -6,10 +9,9 @@
|
|||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/color.hpp" // for Color, ftxui
|
#include "ftxui/screen/color.hpp" // for Color, ftxui
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
int saturation = 255;
|
|
||||||
Elements red_line;
|
Elements red_line;
|
||||||
Elements green_line;
|
Elements green_line;
|
||||||
Elements blue_line;
|
Elements blue_line;
|
||||||
@ -49,7 +51,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
return 0;
|
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.
|
|
||||||
|
@ -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 <ftxui/dom/elements.hpp> // for text, operator|, border, Element, vbox, center, Fit, dbox
|
#include <ftxui/dom/elements.hpp> // for text, operator|, border, Element, vbox, center, Fit, dbox
|
||||||
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <memory> // for allocator
|
#include <memory> // for allocator
|
||||||
@ -5,7 +8,7 @@
|
|||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/color.hpp" // for ftxui
|
#include "ftxui/screen/color.hpp" // for ftxui
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
auto document = dbox({
|
auto document = dbox({
|
||||||
vbox({
|
vbox({
|
||||||
@ -24,7 +27,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
return 0;
|
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.
|
|
||||||
|
@ -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 <chrono> // for operator""s, chrono_literals
|
#include <chrono> // for operator""s, chrono_literals
|
||||||
#include <ftxui/dom/elements.hpp> // for text, gauge, operator|, flex, hbox, Element
|
#include <ftxui/dom/elements.hpp> // for text, gauge, operator|, flex, hbox, Element
|
||||||
#include <ftxui/screen/screen.hpp> // for Screen
|
#include <ftxui/screen/screen.hpp> // for Screen
|
||||||
@ -8,7 +11,7 @@
|
|||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/color.hpp" // for ftxui
|
#include "ftxui/screen/color.hpp" // for ftxui
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
@ -31,7 +34,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
}
|
}
|
||||||
std::cout << std::endl;
|
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.
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// 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 <chrono> // for operator""s, chrono_literals
|
#include <chrono> // for operator""s, chrono_literals
|
||||||
#include <ftxui/dom/elements.hpp> // for filler, operator|, separator, text, border, Element, vbox, vtext, hbox, center, gaugeDown, gaugeLeft, gaugeRight, gaugeUp
|
#include <ftxui/dom/elements.hpp> // for filler, operator|, separator, text, border, Element, vbox, vtext, hbox, center, gaugeDown, gaugeLeft, gaugeRight, gaugeUp
|
||||||
#include <ftxui/screen/screen.hpp> // for Screen
|
#include <ftxui/screen/screen.hpp> // for Screen
|
||||||
@ -8,7 +11,7 @@
|
|||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/color.hpp" // for ftxui
|
#include "ftxui/screen/color.hpp" // for ftxui
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
@ -73,7 +76,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
}
|
}
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
|
||||||
|
@ -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 <chrono> // for operator""s, chrono_literals
|
#include <chrono> // for operator""s, chrono_literals
|
||||||
#include <cmath> // for sin
|
#include <cmath> // for sin
|
||||||
#include <ftxui/dom/elements.hpp> // for graph, operator|, separator, color, Element, vbox, flex, inverted, operator|=, Fit, hbox, size, border, GREATER_THAN, HEIGHT
|
#include <ftxui/dom/elements.hpp> // for graph, operator|, separator, color, Element, vbox, flex, inverted, operator|=, Fit, hbox, size, border, GREATER_THAN, HEIGHT
|
||||||
@ -7,6 +10,7 @@
|
|||||||
#include <memory> // for shared_ptr
|
#include <memory> // for shared_ptr
|
||||||
#include <string> // for operator<<, string
|
#include <string> // for operator<<, string
|
||||||
#include <thread> // for sleep_for
|
#include <thread> // for sleep_for
|
||||||
|
#include <utility> // for ignore
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
|
||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
@ -46,6 +50,7 @@ int main() {
|
|||||||
|
|
||||||
std::string reset_position;
|
std::string reset_position;
|
||||||
for (int i = 0;; ++i) {
|
for (int i = 0;; ++i) {
|
||||||
|
std::ignore = i;
|
||||||
auto document = hbox({
|
auto document = hbox({
|
||||||
vbox({
|
vbox({
|
||||||
graph(std::ref(my_graph)),
|
graph(std::ref(my_graph)),
|
||||||
@ -80,7 +85,3 @@ int main() {
|
|||||||
|
|
||||||
return 0;
|
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.
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
// 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 <stdio.h> // for getchar
|
#include <stdio.h> // for getchar
|
||||||
#include <ftxui/dom/elements.hpp> // for Elements, gridbox, Fit, operator|, text, border, Element
|
#include <ftxui/dom/elements.hpp> // for Elements, gridbox, Fit, operator|, text, border, Element
|
||||||
#include <ftxui/screen/screen.hpp> // for Screen
|
#include <ftxui/screen/screen.hpp> // for Screen
|
||||||
@ -6,7 +9,7 @@
|
|||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/color.hpp" // for ftxui
|
#include "ftxui/screen/color.hpp" // for ftxui
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
auto cell = [](const char* t) { return text(t) | border; };
|
auto cell = [](const char* t) { return text(t) | border; };
|
||||||
auto document = //
|
auto document = //
|
||||||
@ -43,7 +46,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
|
||||||
|
@ -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 <stdio.h> // for getchar
|
#include <stdio.h> // for getchar
|
||||||
#include <ftxui/dom/elements.hpp> // for operator|, size, Element, text, hcenter, Decorator, Fit, WIDTH, hflow, window, EQUAL, GREATER_THAN, HEIGHT, bold, border, dim, LESS_THAN
|
#include <ftxui/dom/elements.hpp> // for operator|, size, Element, text, hcenter, Decorator, Fit, WIDTH, hflow, window, EQUAL, GREATER_THAN, HEIGHT, bold, border, dim, LESS_THAN
|
||||||
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
@ -6,7 +9,7 @@
|
|||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/color.hpp" // for ftxui
|
#include "ftxui/screen/color.hpp" // for ftxui
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
auto make_box = [](int dimx, int dimy) {
|
auto make_box = [](int dimx, int dimy) {
|
||||||
std::string title = std::to_string(dimx) + "x" + std::to_string(dimy);
|
std::string title = std::to_string(dimx) + "x" + std::to_string(dimy);
|
||||||
@ -47,7 +50,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
return 0;
|
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.
|
|
||||||
|
@ -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 <chrono> // for operator""s, chrono_literals
|
#include <chrono> // for operator""s, chrono_literals
|
||||||
#include <ftxui/screen/screen.hpp> // for Screen
|
#include <ftxui/screen/screen.hpp> // for Screen
|
||||||
#include <iostream> // for cout, ostream
|
#include <iostream> // for cout, ostream
|
||||||
@ -9,7 +12,7 @@
|
|||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
#include "ftxui/screen/color.hpp" // for Color, Color::Red
|
#include "ftxui/screen/color.hpp" // for Color, Color::Red
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
@ -54,7 +57,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
return 0;
|
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.
|
|
||||||
|
25
examples/dom/linear_gradient.cpp
Normal file
25
examples/dom/linear_gradient.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// 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/dom/elements.hpp> // for bgcolor, operator|, operator|=, text, center, Element
|
||||||
|
#include <ftxui/dom/linear_gradient.hpp> // for LinearGradient::Stop, LinearGradient
|
||||||
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
|
#include <memory> // for allocator, shared_ptr
|
||||||
|
|
||||||
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
|
#include "ftxui/screen/color.hpp" // for Color, Color::DeepPink1, Color::DeepSkyBlue1, Color::Yellow, ftxui
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
using namespace ftxui;
|
||||||
|
auto document = text("gradient") | center;
|
||||||
|
|
||||||
|
document |= bgcolor(LinearGradient()
|
||||||
|
.Angle(45)
|
||||||
|
.Stop(Color::DeepPink1)
|
||||||
|
.Stop(Color::DeepSkyBlue1));
|
||||||
|
auto screen = Screen::Create(Dimension::Full(), Dimension::Full());
|
||||||
|
Render(screen, document);
|
||||||
|
screen.Print();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@ -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 <chrono> // for operator""s, chrono_literals
|
#include <chrono> // for operator""s, chrono_literals
|
||||||
#include <ftxui/dom/elements.hpp> // for operator|, text, Element, hbox, bold, color, filler, separator, vbox, window, gauge, Fit, size, dim, EQUAL, WIDTH
|
#include <ftxui/dom/elements.hpp> // for operator|, text, Element, hbox, bold, color, filler, separator, vbox, window, gauge, Fit, size, dim, EQUAL, WIDTH
|
||||||
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
@ -12,7 +15,7 @@
|
|||||||
#include "ftxui/dom/node.hpp" // for Render
|
#include "ftxui/dom/node.hpp" // for Render
|
||||||
#include "ftxui/screen/color.hpp" // for Color, Color::Green, Color::Red, Color::RedLight, ftxui
|
#include "ftxui/screen/color.hpp" // for Color, Color::Green, Color::Red, Color::RedLight, ftxui
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
|
|
||||||
struct Task {
|
struct Task {
|
||||||
@ -143,7 +146,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
}
|
}
|
||||||
std::cout << std::endl;
|
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.
|
|
||||||
|
@ -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 <chrono> // for operator""s, chrono_literals
|
#include <chrono> // for operator""s, chrono_literals
|
||||||
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
#include <ftxui/screen/screen.hpp> // for Full, Screen
|
||||||
#include <iostream> // for cout, ostream
|
#include <iostream> // for cout, ostream
|
||||||
@ -10,13 +13,13 @@
|
|||||||
#include "ftxui/screen/box.hpp" // for ftxui
|
#include "ftxui/screen/box.hpp" // for ftxui
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
int main(int argc, const char* argv[]) {
|
int main() {
|
||||||
using namespace ftxui;
|
using namespace ftxui;
|
||||||
std::string p =
|
std::string p =
|
||||||
R"(In probability theory and statistics, Bayes' theorem (alternatively Bayes' law or Bayes' rule) describes the probability of an event, based on prior knowledge of conditions that might be related to the event. For example, if cancer is related to age, then, using Bayes' theorem, a person's age can be used to more accurately assess the probability that they have cancer, compared to the assessment of the probability of cancer made without knowledge of the person's age. One of the many applications of Bayes' theorem is Bayesian inference, a particular approach to statistical inference. When applied, the probabilities involved in Bayes' theorem may have different probability interpretations. With the Bayesian probability interpretation the theorem expresses how a subjective degree of belief should rationally change to account for availability of related evidence. Bayesian inference is fundamental to Bayesian statistics.)";
|
R"(In probability theory and statistics, Bayes' theorem (alternatively Bayes' law or Bayes' rule) describes the probability of an event, based on prior knowledge of conditions that might be related to the event. For example, if cancer is related to age, then, using Bayes' theorem, a person's age can be used to more accurately assess the probability that they have cancer, compared to the assessment of the probability of cancer made without knowledge of the person's age. One of the many applications of Bayes' theorem is Bayesian inference, a particular approach to statistical inference. When applied, the probabilities involved in Bayes' theorem may have different probability interpretations. With the Bayesian probability interpretation the theorem expresses how a subjective degree of belief should rationally change to account for availability of related evidence. Bayesian inference is fundamental to Bayesian statistics.)";
|
||||||
|
|
||||||
std::string reset_position;
|
std::string reset_position;
|
||||||
for (int i = 0;; ++i) {
|
while (true) {
|
||||||
auto document = vbox({
|
auto document = vbox({
|
||||||
hflow(paragraph(p)),
|
hflow(paragraph(p)),
|
||||||
separator(),
|
separator(),
|
||||||
@ -48,7 +51,3 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
return 0;
|
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.
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user