mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-12-16 01:48:56 +08:00
Compare commits
34 Commits
v6.1.5
...
4b8c8ea00d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b8c8ea00d | ||
|
|
08b8a3b28f | ||
|
|
9e1120c146 | ||
|
|
5cfed50702 | ||
|
|
b307a175ed | ||
|
|
4604adb502 | ||
|
|
006ec1cbed | ||
|
|
add5f40d31 | ||
|
|
16c25ae441 | ||
|
|
805db9bdea | ||
|
|
784f53fd7e | ||
|
|
799d8a267e | ||
|
|
f4513702b0 | ||
|
|
05b4bffe3b | ||
|
|
ffc6dcd3bf | ||
|
|
f6dceabdc9 | ||
|
|
cb8ebdeb44 | ||
|
|
dd37fba100 | ||
|
|
4d627c1ffb | ||
|
|
1dff6a5c35 | ||
|
|
0c67566427 | ||
|
|
85c3dc45ca | ||
|
|
84f691e9d3 | ||
|
|
2e36aa061a | ||
|
|
8ed06a4812 | ||
|
|
571f6dcdcf | ||
|
|
e57c275512 | ||
|
|
1c37cdd192 | ||
|
|
772d4ebeed | ||
|
|
5f5bc9019d | ||
|
|
f87b6a4d12 | ||
|
|
0d50fa25fe | ||
|
|
730ebeed1d | ||
|
|
69928b374e |
7
.bazelrc
Normal file
7
.bazelrc
Normal file
@@ -0,0 +1,7 @@
|
||||
build --features=layering_check
|
||||
build --enable_bzlmod
|
||||
|
||||
build --enable_platform_specific_config
|
||||
build:linux --cxxopt=-std=c++20
|
||||
build:macos --cxxopt=-std=c++20
|
||||
build:windows --cxxopt=-std:c++20
|
||||
@@ -1,24 +1,36 @@
|
||||
# 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.
|
||||
matrix:
|
||||
platform:
|
||||
- centos7
|
||||
- debian10
|
||||
- ubuntu2004
|
||||
- macos
|
||||
- windows
|
||||
bazel: [6.x, 7.x, 8.x]
|
||||
bazel:
|
||||
- 7.x
|
||||
- 8.x
|
||||
- rolling
|
||||
unix_platform:
|
||||
- debian11
|
||||
- ubuntu2204
|
||||
- macos
|
||||
- macos_arm64
|
||||
win_platform:
|
||||
- windows
|
||||
|
||||
tasks:
|
||||
verify_targets:
|
||||
name: Build and test.
|
||||
platform: ${{ platform }}
|
||||
|
||||
unix_test:
|
||||
name: Verify build targets on Unix
|
||||
platform: ${{ unix_platform }}
|
||||
bazel: ${{ bazel }}
|
||||
build_flags:
|
||||
- --cxxopt=-std=c++20
|
||||
build_targets:
|
||||
- '@ftxui//:ftxui'
|
||||
- '@ftxui//:screen'
|
||||
- '@ftxui//:dom'
|
||||
- '@ftxui//:component'
|
||||
test_targets:
|
||||
- '@ftxui//:tests'
|
||||
- '@ftxui//:screen'
|
||||
|
||||
windows_test:
|
||||
name: Verify build targets
|
||||
platform: ${{ win_platform }}
|
||||
bazel: ${{ bazel }}
|
||||
build_flags:
|
||||
- --cxxopt=/std:c++20
|
||||
build_targets:
|
||||
- '@ftxui//:dom'
|
||||
- '@ftxui//:component'
|
||||
- '@ftxui//:screen'
|
||||
|
||||
210
.github/workflows/build.yaml
vendored
210
.github/workflows/build.yaml
vendored
@@ -14,25 +14,30 @@ on:
|
||||
jobs:
|
||||
|
||||
test_bazel:
|
||||
name: "Bazel, ${{ matrix.compiler }}, ${{ matrix.os }}"
|
||||
name: "Bazel, ${{ matrix.cxx }}, ${{ matrix.os }}"
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
compiler: gcc
|
||||
cxx: g++
|
||||
cc: gcc
|
||||
|
||||
- os: ubuntu-latest
|
||||
compiler: llvm
|
||||
cxx: clang++
|
||||
cc: clang
|
||||
|
||||
- os: macos-latest
|
||||
compiler: llvm
|
||||
cxx: g++
|
||||
cc: gcc
|
||||
|
||||
- os: macos-latest
|
||||
compiler: gcc
|
||||
cxx: clang++
|
||||
cc: clang
|
||||
|
||||
- os: windows-latest
|
||||
compiler: cl
|
||||
cxx: cl
|
||||
cc: cl
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
@@ -40,10 +45,16 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: "Build with Bazel"
|
||||
env:
|
||||
CC: ${{ matrix.cc }}
|
||||
CXX: ${{ matrix.cxx }}
|
||||
run: bazel build ...
|
||||
|
||||
- name: "Tests with Bazel"
|
||||
run: bazel run tests
|
||||
env:
|
||||
CC: ${{ matrix.cc }}
|
||||
CXX: ${{ matrix.cxx }}
|
||||
run: bazel test --test_output=all ...
|
||||
|
||||
test_cmake:
|
||||
name: "CMake, ${{ matrix.compiler }}, ${{ matrix.os }}"
|
||||
@@ -154,3 +165,188 @@ jobs:
|
||||
flags: ${{ runner.os }}
|
||||
name: ${{ runner.os }}-coverage
|
||||
files: ./build/coverage.xml
|
||||
|
||||
test_modules:
|
||||
name: "Test modules"
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
compiler: llvm
|
||||
# TODO add gcc / msvc
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: "Checkout repository"
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: "Setup Cpp"
|
||||
uses: aminya/setup-cpp@v1
|
||||
with:
|
||||
compiler: ${{ matrix.compiler }}
|
||||
vcvarsall: ${{ contains(matrix.os, 'windows' )}}
|
||||
cmake: true
|
||||
ninja: true
|
||||
clangtidy: false
|
||||
cppcheck: false
|
||||
opencppcoverage: false
|
||||
|
||||
- name: "Generate ./examples_modules"
|
||||
run: >
|
||||
./tools/generate_examples_modules.sh
|
||||
|
||||
- name: "Build modules"
|
||||
run: >
|
||||
mkdir build;
|
||||
cd build;
|
||||
cmake ..
|
||||
-DCMAKE_GENERATOR=Ninja
|
||||
-DFTXUI_BUILD_MODULES=ON
|
||||
-DFTXUI_BUILD_EXAMPLES=ON
|
||||
-DCMAKE_BUILD_TYPE=Debug
|
||||
-DFTXUI_BUILD_DOCS=OFF
|
||||
-DFTXUI_BUILD_TESTS=OFF
|
||||
-DFTXUI_BUILD_TESTS_FUZZER=OFF
|
||||
-DFTXUI_ENABLE_INSTALL=ON
|
||||
-DFTXUI_DEV_WARNINGS=ON ;
|
||||
cmake --build .
|
||||
|
||||
# Create a release on new v* tags
|
||||
release:
|
||||
needs:
|
||||
- test_cmake
|
||||
- test_bazel
|
||||
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_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
|
||||
|
||||
|
||||
documentation:
|
||||
if: github.ref == 'refs/heads/main'
|
||||
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
|
||||
|
||||
21
.github/workflows/publish.yaml
vendored
21
.github/workflows/publish.yaml
vendored
@@ -9,33 +9,16 @@ on:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
# Fire as soon as the Release workflow completes
|
||||
workflow_run:
|
||||
workflows:
|
||||
- Release
|
||||
types:
|
||||
- completed
|
||||
|
||||
permissions:
|
||||
|
||||
attestations: write
|
||||
contents: write
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v0.0.4
|
||||
# Only run on manual dispatch, or when Release finishes successfully
|
||||
if: |
|
||||
github.event_name == 'workflow_dispatch' ||
|
||||
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
|
||||
with:
|
||||
# If manual: use the input, otherwise grab the tag from the completed run
|
||||
tag_name: ${{
|
||||
github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name ||
|
||||
github.event_name == 'workflow_run' && github.event.workflow_run.head_branch
|
||||
}}
|
||||
tag_name: ${{ github.event.inputs.tag_name }}
|
||||
registry_fork: ArthurSonzogni/bazel-central-registry
|
||||
attest: false
|
||||
|
||||
secrets:
|
||||
publish_token: ${{ secrets.PUBLISH_TOKEN }}
|
||||
|
||||
18
.github/workflows/release.yaml
vendored
18
.github/workflows/release.yaml
vendored
@@ -92,27 +92,9 @@ jobs:
|
||||
run: >
|
||||
git archive --format=tar.gz -o source.tar.gz HEAD
|
||||
|
||||
- name: Generate source attestation
|
||||
id: attest_source
|
||||
uses: actions/attest-build-provenance@v2
|
||||
with:
|
||||
subject-path: source.tar.gz
|
||||
|
||||
- name: Write source.intoto.jsonl
|
||||
run:
|
||||
jq --compact-output < "${{ steps.attest_source.outputs.bundle-path }}" \
|
||||
> source.tar.gz.intoto.jsonl
|
||||
|
||||
- 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
|
||||
|
||||
- name: "Upload source attestation"
|
||||
uses: shogo82148/actions-upload-release-asset@v1
|
||||
with:
|
||||
upload_url: ${{ needs.release.outputs.upload_url }}
|
||||
asset_path: source.tar.gz.intoto.jsonl
|
||||
overwrite: true
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -62,8 +62,10 @@ out/
|
||||
!include/ftxui/**/*.cpp
|
||||
|
||||
# src directory:
|
||||
!src/ftxui/*.cppm
|
||||
!src/ftxui/**/*.hpp
|
||||
!src/ftxui/**/*.cpp
|
||||
!src/ftxui/**/*.cppm
|
||||
|
||||
# tools directory:
|
||||
!tools/**/*.sh
|
||||
|
||||
57
BUILD.bazel
57
BUILD.bazel
@@ -12,23 +12,19 @@
|
||||
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 depending on all of the ftxui submodules.
|
||||
# Note that component depends on dom and screen, so ftxui is just an alias for
|
||||
# component.
|
||||
# ┌component──┐
|
||||
# │┌dom──────┐│
|
||||
# ││┌screen─┐││
|
||||
# └┴┴───────┴┴┘
|
||||
alias(name = "ftxui", actual = ":component")
|
||||
|
||||
# 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
|
||||
# @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.
|
||||
@@ -60,7 +56,7 @@ ftxui_cc_library(
|
||||
],
|
||||
)
|
||||
|
||||
# ftxui:dom is a library that provides a way to create and manipulate a
|
||||
# @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
|
||||
@@ -130,7 +126,7 @@ ftxui_cc_library(
|
||||
deps = [":screen"],
|
||||
)
|
||||
|
||||
# ftxui:component is a library to create "dynamic" component renderering and
|
||||
# @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.
|
||||
#
|
||||
@@ -167,6 +163,13 @@ ftxui_cc_library(
|
||||
"src/ftxui/component/terminal_input_parser.hpp",
|
||||
"src/ftxui/component/util.cpp",
|
||||
"src/ftxui/component/window.cpp",
|
||||
|
||||
# Private header from ftxui:dom.
|
||||
"src/ftxui/dom/node_decorator.hpp",
|
||||
|
||||
# Private header from ftxui:screen.
|
||||
"src/ftxui/screen/string_internal.hpp",
|
||||
"src/ftxui/screen/util.hpp",
|
||||
],
|
||||
hdrs = [
|
||||
"include/ftxui/component/animation.hpp",
|
||||
@@ -182,7 +185,10 @@ ftxui_cc_library(
|
||||
"include/ftxui/component/task.hpp",
|
||||
],
|
||||
linkopts = pthread_linkopts(),
|
||||
deps = [":dom"],
|
||||
deps = [
|
||||
":dom",
|
||||
":screen",
|
||||
],
|
||||
)
|
||||
|
||||
# FTXUI's tests
|
||||
@@ -205,7 +211,6 @@ cc_test(
|
||||
"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",
|
||||
@@ -233,6 +238,17 @@ cc_test(
|
||||
"src/ftxui/screen/string_test.cpp",
|
||||
"src/ftxui/util/ref_test.cpp",
|
||||
|
||||
# Private header from ftxui:screen for string_test.cpp.
|
||||
"src/ftxui/screen/string_internal.hpp",
|
||||
|
||||
# Private header from ftxui::component for
|
||||
# terminal_input_parser_test.cpp.
|
||||
"src/ftxui/component/terminal_input_parser.hpp",
|
||||
|
||||
# Private header from ftxui::dom for
|
||||
# flexbox_helper_test.cpp.
|
||||
"src/ftxui/dom/flexbox_helper.hpp",
|
||||
|
||||
# TODO: Enable the two tests timing out with Bazel:
|
||||
# - "src/ftxui/component/screen_interactive_test.cpp",
|
||||
# - "src/ftxui/dom/selection_test.cpp",
|
||||
@@ -241,9 +257,12 @@ cc_test(
|
||||
"include",
|
||||
"src",
|
||||
],
|
||||
copts = cpp20() + windows_copts(),
|
||||
copts = windows_copts(),
|
||||
deps = [
|
||||
"//:ftxui",
|
||||
":screen",
|
||||
":dom",
|
||||
":component",
|
||||
"@googletest//:gtest",
|
||||
"@googletest//:gtest_main",
|
||||
],
|
||||
)
|
||||
|
||||
48
CHANGELOG.md
48
CHANGELOG.md
@@ -1,22 +1,50 @@
|
||||
Changelog
|
||||
=========
|
||||
|
||||
Future release
|
||||
------------
|
||||
Development
|
||||
-----------
|
||||
|
||||
6.1.4 (2025-05-01)
|
||||
### Build
|
||||
- Feature: Support C++20 modules.
|
||||
This requires:
|
||||
- Using the Ninja or MSVC generator
|
||||
- A recent Clang/GCC/MSVC compiler.
|
||||
- Cmake 3.28 or higher.
|
||||
Usage:
|
||||
```cpp
|
||||
import ftxui;
|
||||
import ftxui.component;
|
||||
import ftxui.dom;
|
||||
import ftxui.screen;
|
||||
```
|
||||
Thanks @mikomikotaishi for PR #1015.
|
||||
|
||||
|
||||
Future release
|
||||
=======
|
||||
6.1.9 (2025-05-07
|
||||
|
||||
### Build
|
||||
If all goes well (pending), ftxui 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.9")
|
||||
```
|
||||
|
||||
Thanks @robinlinden and @kcc for the reviews.
|
||||
|
||||
### 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.4")
|
||||
```
|
||||
|
||||
**BUILD.bazel**
|
||||
```bazel
|
||||
|
||||
@@ -1,20 +1,26 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
option(FTXUI_BUILD_DOCS "Set to ON to build docs" OFF)
|
||||
option(FTXUI_BUILD_EXAMPLES "Set to ON to build examples" OFF)
|
||||
option(FTXUI_BUILD_MODULES "Build the C++20 modules" 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_CLANG_TIDY "Execute clang-tidy" OFF)
|
||||
option(FTXUI_DEV_WARNINGS "Enable more compiler warnings and warnings as errors" OFF)
|
||||
option(FTXUI_ENABLE_COVERAGE "Execute code coverage" OFF)
|
||||
option(FTXUI_ENABLE_INSTALL "Generate the install target" ON)
|
||||
option(FTXUI_QUIET "Set to ON for FTXUI to be quiet" OFF)
|
||||
|
||||
if (FTXUI_BUILD_MODULES)
|
||||
cmake_minimum_required(VERSION 3.28.2)
|
||||
else()
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
endif()
|
||||
|
||||
project(ftxui
|
||||
LANGUAGES CXX
|
||||
VERSION 6.1.4
|
||||
VERSION 6.1.9
|
||||
DESCRIPTION "C++ Functional Terminal User Interface."
|
||||
)
|
||||
|
||||
option(FTXUI_QUIET "Set to ON for FTXUI to be quiet" OFF)
|
||||
option(FTXUI_BUILD_EXAMPLES "Set to ON to build examples" OFF)
|
||||
option(FTXUI_BUILD_DOCS "Set to ON to build docs" OFF)
|
||||
option(FTXUI_BUILD_TESTS "Set to ON to build tests" OFF)
|
||||
option(FTXUI_BUILD_TESTS_FUZZER "Set to ON to enable fuzzing" OFF)
|
||||
option(FTXUI_ENABLE_INSTALL "Generate the install target" ON)
|
||||
option(FTXUI_CLANG_TIDY "Execute clang-tidy" OFF)
|
||||
option(FTXUI_ENABLE_COVERAGE "Execute code coverage" OFF)
|
||||
option(FTXUI_DEV_WARNINGS "Enable more compiler warnings and warnings as errors" OFF)
|
||||
|
||||
set(FTXUI_MICROSOFT_TERMINAL_FALLBACK_HELP_TEXT "On windows, assume the \
|
||||
terminal used will be one of Microsoft and use a set of reasonnable fallback \
|
||||
@@ -176,6 +182,13 @@ include(cmake/iwyu.cmake)
|
||||
include(cmake/ftxui_export.cmake)
|
||||
include(cmake/ftxui_install.cmake)
|
||||
include(cmake/ftxui_package.cmake)
|
||||
include(cmake/ftxui_modules.cmake)
|
||||
|
||||
add_subdirectory(examples)
|
||||
add_subdirectory(doc)
|
||||
add_subdirectory(examples)
|
||||
|
||||
# You can generate ./examples_modules/ by running
|
||||
# ./tools/generate_examples_modules.sh
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples_modules/CMakeLists.txt")
|
||||
add_subdirectory(examples_modules)
|
||||
endif()
|
||||
|
||||
20
MODULE.bazel
20
MODULE.bazel
@@ -1,13 +1,13 @@
|
||||
# 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.
|
||||
# FTXUI module.
|
||||
module(
|
||||
name = "ftxui",
|
||||
version = "6.1.9",
|
||||
compatibility_level = 6,
|
||||
)
|
||||
|
||||
# FTXUI Module.
|
||||
module(name = "ftxui", version = "6.1.4")
|
||||
|
||||
# Build deps.
|
||||
# Build dependencies.
|
||||
bazel_dep(name = "rules_cc", version = "0.1.1")
|
||||
bazel_dep(name = "platforms", version = "0.0.11")
|
||||
bazel_dep(name = "platforms", version = "0.0.10")
|
||||
|
||||
# Test deps.
|
||||
bazel_dep(name = "googletest", version = "1.16.0.bcr.1")
|
||||
# Test dependencies.
|
||||
bazel_dep(name = "googletest", version = "1.14.0.bcr.1", dev_dependency = True)
|
||||
|
||||
75
README.md
75
README.md
@@ -40,17 +40,27 @@ A simple cross-platform 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 drawing. [Demo](https://arthursonzogni.github.io/FTXUI/examples/?file=component/canvas_animated)
|
||||
* No dependencies
|
||||
* Module support
|
||||
* **Cross platform**: Linux/MacOS (main target), WebAssembly, Windows (Thanks to contributors!).
|
||||
* Learn by [examples](#documentation), and [tutorials](#documentation)
|
||||
* Multiple packages: CMake [FetchContent]([https://bewagner.net/programming/2020/05/02/cmake-fetchcontent/](https://cmake.org/cmake/help/latest/module/FetchContent.html)) (preferred),Bazel, vcpkg, pkgbuild, conan.
|
||||
* Multiple packages:
|
||||
- CMake [FetchContent]([https://bewagner.net/programming/2020/05/02/cmake-fetchcontent/](https://cmake.org/cmake/help/latest/module/FetchContent.html)) (preferred)
|
||||
- [Bazel](https://registry.bazel.build/modules/ftxui)
|
||||
- [vcpkg](https://vcpkg.link/ports/ftxui)
|
||||
- [Conan](https://conan.io/center/recipes/ftxui) [Debian package](https://tracker.debian.org/pkg/ftxui)
|
||||
- [Ubuntu package](https://launchpad.net/ubuntu/+source/ftxui)
|
||||
- [Arch Linux](https://aur.archlinux.org/packages/ftxui/)
|
||||
- [OpenSUSE](https://build.opensuse.org/package/show/devel:libraries:c_c++/ftxui)
|
||||
* Good practices: documentation, tests, fuzzers, performance tests, automated CI, automated packaging, etc...
|
||||
|
||||
## Documentation
|
||||
|
||||
- [Starter example project](https://github.com/ArthurSonzogni/ftxui-starter)
|
||||
- [Starter CMake](https://github.com/ArthurSonzogni/ftxui-starter)
|
||||
- [Starter Bazel](https://github.com/ArthurSonzogni/ftxui-bazel)
|
||||
- [Documentation](https://arthursonzogni.github.io/FTXUI/)
|
||||
- [Examples (WebAssembly)](https://arthursonzogni.github.io/FTXUI/examples/)
|
||||
- [Build using CMake](https://arthursonzogni.github.io/FTXUI/#build-cmake)
|
||||
- [Build using Bazel](https://arthursonzogni.github.io/FTXUI/#build-bazel)
|
||||
|
||||
## Example
|
||||
~~~cpp
|
||||
@@ -348,6 +358,8 @@ Feel free to add your projects here:
|
||||
- [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)
|
||||
- [openJuice](https://github.com/mikomikotaishi/openJuice)
|
||||
- [SHOOT!](https://github.com/ShingZhanho/ENGG1340-Project-25Spring)
|
||||
|
||||
### [cpp-best-practices/game_jam](https://github.com/cpp-best-practices/game_jam)
|
||||
|
||||
@@ -364,38 +376,69 @@ 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)
|
||||
- [Consu](https://github.com/cpp-best-practices/game_jam/blob/main/Jam1_April_2022/consu.md)
|
||||
|
||||
## Utilization
|
||||
## Build using CMake
|
||||
|
||||
It is **highly** recommended to use CMake FetchContent to depend on FTXUI so you may specify which commit you would like to depend on.
|
||||
```cmake
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(ftxui
|
||||
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
|
||||
GIT_TAG v6.1.4
|
||||
GIT_TAG v6.1.9
|
||||
)
|
||||
FetchContent_MakeAvailable(ftxui)
|
||||
|
||||
FetchContent_GetProperties(ftxui)
|
||||
if(NOT ftxui_POPULATED)
|
||||
FetchContent_Populate(ftxui)
|
||||
add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
target_link_libraries(your_target PRIVATE
|
||||
# Chose a submodule
|
||||
ftxui::component
|
||||
ftxui::dom
|
||||
ftxui::screen
|
||||
)
|
||||
```
|
||||
|
||||
# Build using Bazel
|
||||
|
||||
**MODULE.bazel**
|
||||
```starlark
|
||||
bazel_dep(
|
||||
name = "ftxui",
|
||||
version = "v6.1.9",
|
||||
)
|
||||
```
|
||||
|
||||
**BUILD.bazel**
|
||||
```starlark
|
||||
cc_binary(
|
||||
name = "your_target",
|
||||
srcs = ["your_source.cc"],
|
||||
deps = [
|
||||
"@ftxui//:ftxui_component",
|
||||
"@ftxui//:ftxui_dom",
|
||||
"@ftxui//:ftxui_screen",
|
||||
],
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
# Build with something else:
|
||||
If you don't, FTXUI may be used from the following packages:
|
||||
- [bazel](...)
|
||||
- [vcpkg](https://vcpkgx.com/details.html?package=ftxui)
|
||||
- [Arch Linux PKGBUILD](https://aur.archlinux.org/packages/ftxui-git/).
|
||||
- [conan.io](https://conan.io/center/ftxui)
|
||||
- [openSUSE](https://build.opensuse.org/package/show/devel:libraries:c_c++/ftxui)
|
||||
-
|
||||
- CMake [FetchContent]([https://bewagner.net/programming/2020/05/02/cmake-fetchcontent/](https://cmake.org/cmake/help/latest/module/FetchContent.html)) (preferred),
|
||||
- [Bazel](https://registry.bazel.build/modules/ftxui),
|
||||
- [vcpkg](https://vcpkg.link/ports/ftxui),
|
||||
- [Conan](https://conan.io/center/recipes/ftxui)
|
||||
- [Debian package](https://tracker.debian.org/pkg/ftxui),
|
||||
- [Ubuntu package](https://launchpad.net/ubuntu/+source/ftxui),
|
||||
- [Arch Linux](https://aur.archlinux.org/packages/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 . . .
|
||||
```
|
||||
|
||||
To build FTXUI with modules, ensure that you are using a generator like Ninja or Visual Studio that supports modules, and pass the flag `FTXUI_BUILD_MODULES`.
|
||||
|
||||
## Contributors
|
||||
|
||||
<a href="https://github.com/ArthurSonzogni/FTXUI/graphs/contributors">
|
||||
|
||||
@@ -1,24 +1,7 @@
|
||||
# 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"],
|
||||
})
|
||||
load("@rules_cc//cc:defs.bzl", "cc_binary")
|
||||
|
||||
# Microsoft terminal is a bit buggy ¯\_(ツ)_/¯ and MSVC uses bad defaults.
|
||||
def windows_copts():
|
||||
@@ -45,7 +28,8 @@ def windows_copts():
|
||||
# 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.
|
||||
# race condition. This was fixed in 2020, but clients are still using
|
||||
# old versions.
|
||||
# - https://github.com/microsoft/terminal/pull/7583
|
||||
# - https://github.com/ArthurSonzogni/FTXUI/issues/136
|
||||
"-DFTXUI_MICROSOFT_TERMINAL_FALLBACK",
|
||||
@@ -71,8 +55,8 @@ def pthread_linkopts():
|
||||
|
||||
def ftxui_cc_library(
|
||||
name,
|
||||
srcs,
|
||||
hdrs,
|
||||
srcs = [],
|
||||
hdrs = [],
|
||||
linkopts = [],
|
||||
deps = []):
|
||||
|
||||
@@ -88,12 +72,13 @@ def ftxui_cc_library(
|
||||
"include",
|
||||
"src",
|
||||
],
|
||||
copts = cpp17() + windows_copts(),
|
||||
copts = 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.
|
||||
# This is useful to check the Bazel is always synchronized against CMake
|
||||
# definitions.
|
||||
def generate_examples():
|
||||
cpp_files = native.glob(["examples/**/*.cpp"])
|
||||
|
||||
@@ -107,9 +92,13 @@ def generate_examples():
|
||||
# Turn "examples/component/button.cpp" → "example_component_button"
|
||||
name = src.replace("/", "_").replace(".cpp", "")
|
||||
|
||||
native.cc_binary(
|
||||
cc_binary(
|
||||
name = name,
|
||||
srcs = [src],
|
||||
deps = ["//:component"],
|
||||
copts = cpp20() + windows_copts(),
|
||||
deps = [
|
||||
":component",
|
||||
":dom",
|
||||
":screen",
|
||||
],
|
||||
copts = windows_copts(),
|
||||
)
|
||||
|
||||
@@ -5,13 +5,14 @@ function(ftxui_message msg)
|
||||
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_EXAMPLES : ${FTXUI_BUILD_EXAMPLES}")
|
||||
ftxui_message("│ FTXUI_BUILD_MODULES : ${FTXUI_BUILD_MODULES}")
|
||||
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("│ FTXUI_DEV_WARNINGS : ${FTXUI_DEV_WARNINGS}")
|
||||
ftxui_message("│ FTXUI_ENABLE_COVERAGE : ${FTXUI_ENABLE_COVERAGE}")
|
||||
ftxui_message("│ FTXUI_ENABLE_INSTALL : ${FTXUI_ENABLE_INSTALL}")
|
||||
ftxui_message("│ FTXUI_QUIET : ${FTXUI_QUIET}")
|
||||
ftxui_message("└─────────────────────────────────────")
|
||||
|
||||
81
cmake/ftxui_modules.cmake
Normal file
81
cmake/ftxui_modules.cmake
Normal file
@@ -0,0 +1,81 @@
|
||||
if (NOT FTXUI_BUILD_MODULES)
|
||||
return()
|
||||
endif()
|
||||
|
||||
add_library(ftxui-modules)
|
||||
|
||||
target_sources(ftxui-modules
|
||||
PUBLIC FILE_SET CXX_MODULES FILES
|
||||
src/ftxui/component.cppm
|
||||
src/ftxui/component/Animation.cppm
|
||||
src/ftxui/component/CapturedMouse.cppm
|
||||
src/ftxui/component/Component.cppm
|
||||
src/ftxui/component/ComponentBase.cppm
|
||||
src/ftxui/component/ComponentOptions.cppm
|
||||
src/ftxui/component/Event.cppm
|
||||
src/ftxui/component/Loop.cppm
|
||||
src/ftxui/component/Mouse.cppm
|
||||
src/ftxui/component/Receiver.cppm
|
||||
src/ftxui/component/ScreenInteractive.cppm
|
||||
src/ftxui/component/Task.cppm
|
||||
src/ftxui/dom.cppm
|
||||
src/ftxui/dom/Canvas.cppm
|
||||
src/ftxui/dom/Deprecated.cppm
|
||||
src/ftxui/dom/Direction.cppm
|
||||
src/ftxui/dom/Elements.cppm
|
||||
src/ftxui/dom/FlexboxConfig.cppm
|
||||
src/ftxui/dom/LinearGradient.cppm
|
||||
src/ftxui/dom/Node.cppm
|
||||
src/ftxui/dom/Requirement.cppm
|
||||
src/ftxui/dom/Selection.cppm
|
||||
src/ftxui/dom/Table.cppm
|
||||
src/ftxui/screen.cppm
|
||||
src/ftxui/screen/Box.cppm
|
||||
src/ftxui/screen/Color.cppm
|
||||
src/ftxui/screen/ColorInfo.cppm
|
||||
src/ftxui/screen/Deprecated.cppm
|
||||
src/ftxui/screen/Image.cppm
|
||||
src/ftxui/screen/Pixel.cppm
|
||||
src/ftxui/screen/Screen.cppm
|
||||
src/ftxui/screen/String.cppm
|
||||
src/ftxui/screen/Terminal.cppm
|
||||
src/ftxui/util.cppm
|
||||
src/ftxui/util/AutoReset.cppm
|
||||
src/ftxui/util/Ref.cppm
|
||||
)
|
||||
|
||||
target_link_libraries(ftxui-modules
|
||||
PUBLIC
|
||||
ftxui::screen
|
||||
ftxui::dom
|
||||
ftxui::component
|
||||
)
|
||||
|
||||
target_compile_features(ftxui-modules PUBLIC cxx_std_20)
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
target_compile_options(${name} PUBLIC -fmodules-ts)
|
||||
endif ()
|
||||
|
||||
add_library(ftxui::modules ALIAS ftxui-modules)
|
||||
|
||||
if(FTXUI_ENABLE_INSTALL)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
install(TARGETS ftxui-modules
|
||||
EXPORT ftxui-targets
|
||||
FILE_SET CXX_MODULES
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ftxui
|
||||
FILE_SET HEADERS
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ftxui
|
||||
INCLUDES
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ftxui
|
||||
)
|
||||
install(EXPORT ftxui-targets
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ftxui
|
||||
CXX_MODULES_DIRECTORY ${CMAKE_INSTALL_LIBDIR}/cmake/ftxui
|
||||
)
|
||||
install(FILES my_package-config.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ftxui
|
||||
)
|
||||
endif()
|
||||
@@ -81,7 +81,7 @@ 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.
|
||||
GIT_TAG 6.1.9
|
||||
)
|
||||
FetchContent_MakeAvailable(ftxui)
|
||||
|
||||
@@ -94,13 +94,33 @@ target_link_libraries(ftxui-starter
|
||||
)
|
||||
```
|
||||
|
||||
## Build
|
||||
### Using Bazel {#build-bazel}
|
||||
|
||||
```bash
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
make
|
||||
./main
|
||||
See [ftxui module](https://registry.bazel.build/modules/ftxui) from the Bazel
|
||||
Central Registry.
|
||||
|
||||
See also this [starter](https://github.com/ArthurSonzogni/ftxui-bazel) project.
|
||||
|
||||
**Module.bazel**
|
||||
```starlark
|
||||
bazel_dep(
|
||||
name = "ftxui",
|
||||
version = "6.1.9",
|
||||
)
|
||||
```
|
||||
|
||||
**BUILD.bazel**
|
||||
```starlark
|
||||
cc_binary(
|
||||
name = "main",
|
||||
srcs = ["main.cpp"],
|
||||
deps = [
|
||||
# Choose one of the following:
|
||||
"@ftxui//:dom",
|
||||
"@ftxui//:screen",
|
||||
"@ftxui//:component",
|
||||
],
|
||||
)
|
||||
```
|
||||
|
||||
# List of modules. {#modules}
|
||||
|
||||
@@ -1,9 +1,65 @@
|
||||
#include "ftxui/component/component.hpp"
|
||||
#include "ftxui/component/screen_interactive.hpp"
|
||||
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
||||
// Use of this source code is governed by the MIT license that can be found in
|
||||
// the LICENSE file.
|
||||
#include <memory> // for shared_ptr, __shared_ptr_access
|
||||
#include <string> // for operator+, to_string
|
||||
|
||||
int main(){
|
||||
auto screen = ftxui::ScreenInteractive::Fullscreen();
|
||||
auto testComponent = ftxui::Renderer([](){return ftxui::text("test Component");});
|
||||
screen.Loop(testComponent);
|
||||
return 0;
|
||||
#include "ftxui/component/captured_mouse.hpp" // for ftxui
|
||||
#include "ftxui/component/component.hpp" // for Button, Horizontal, Renderer
|
||||
#include "ftxui/component/component_base.hpp" // for ComponentBase
|
||||
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive
|
||||
#include "ftxui/dom/elements.hpp" // for separator, gauge, text, Element, operator|, vbox, border
|
||||
|
||||
using namespace ftxui;
|
||||
|
||||
// This is a helper function to create a button with a custom style.
|
||||
// The style is defined by a lambda function that takes an EntryState and
|
||||
// returns an Element.
|
||||
// We are using `center` to center the text inside the button, then `border` to
|
||||
// add a border around the button, and finally `flex` to make the button fill
|
||||
// the available space.
|
||||
ButtonOption ButtonStyle() {
|
||||
auto option = ButtonOption::Animated();
|
||||
option.transform = [](const EntryState& s) {
|
||||
auto element = text(s.label);
|
||||
if (s.focused) {
|
||||
element |= bold;
|
||||
}
|
||||
return element | center | borderEmpty | flex;
|
||||
};
|
||||
return option;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int value = 50;
|
||||
|
||||
// The tree of components. This defines how to navigate using the keyboard.
|
||||
auto buttons = Container::Vertical({
|
||||
Container::Horizontal({
|
||||
Button(
|
||||
"-1", [&] { value--; }, ButtonStyle()),
|
||||
Button(
|
||||
"+1", [&] { value++; }, ButtonStyle()),
|
||||
}) | flex,
|
||||
Container::Horizontal({
|
||||
Button(
|
||||
"-10", [&] { value -= 10; }, ButtonStyle()),
|
||||
Button(
|
||||
"+10", [&] { value += 10; }, ButtonStyle()),
|
||||
}) | flex,
|
||||
});
|
||||
|
||||
// Modify the way to render them on screen:
|
||||
auto component = Renderer(buttons, [&] {
|
||||
return vbox({
|
||||
text("value = " + std::to_string(value)),
|
||||
separator(),
|
||||
buttons->Render() | flex,
|
||||
}) |
|
||||
flex | border;
|
||||
});
|
||||
|
||||
auto screen = ScreenInteractive::Fullscreen();
|
||||
screen.Loop(component);
|
||||
return 0;
|
||||
}
|
||||
|
||||
18
src/ftxui/component.cppm
Normal file
18
src/ftxui/component.cppm
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @file component.cppm
|
||||
* @brief Module file for FTXUI component operations.
|
||||
*/
|
||||
|
||||
export module ftxui.component;
|
||||
|
||||
export import ftxui.component.Animation;
|
||||
export import ftxui.component.CapturedMouse;
|
||||
export import ftxui.component.Component;
|
||||
export import ftxui.component.ComponentBase;
|
||||
export import ftxui.component.ComponentOptions;
|
||||
export import ftxui.component.Event;
|
||||
export import ftxui.component.Loop;
|
||||
export import ftxui.component.Mouse;
|
||||
export import ftxui.component.Receiver;
|
||||
export import ftxui.component.ScreenInteractive;
|
||||
export import ftxui.component.Task;
|
||||
66
src/ftxui/component/Animation.cppm
Normal file
66
src/ftxui/component/Animation.cppm
Normal file
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* @file Animation.cppm
|
||||
* @brief Module file for the Animation namespace of the Component module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/component/animation.hpp>
|
||||
|
||||
export module ftxui.component.Animation;
|
||||
|
||||
/**
|
||||
* @namespace ftxui::animation
|
||||
* @brief The FTXUI ftxui::animation:: namespace
|
||||
*/
|
||||
export namespace ftxui::animation {
|
||||
using ftxui::animation::RequestAnimationFrame;
|
||||
|
||||
using ftxui::animation::Clock;
|
||||
using ftxui::animation::TimePoint;
|
||||
using ftxui::animation::Duration;
|
||||
|
||||
using ftxui::animation::Params;
|
||||
|
||||
/**
|
||||
* @namespace easing
|
||||
* @brief The FTXUI sf::animation::easing:: namespace
|
||||
*/
|
||||
namespace easing {
|
||||
using ftxui::animation::easing::Function;
|
||||
|
||||
using ftxui::animation::easing::Linear;
|
||||
using ftxui::animation::easing::QuadraticIn;
|
||||
using ftxui::animation::easing::QuadraticOut;
|
||||
using ftxui::animation::easing::QuadraticInOut;
|
||||
using ftxui::animation::easing::CubicIn;
|
||||
using ftxui::animation::easing::CubicOut;
|
||||
using ftxui::animation::easing::CubicInOut;
|
||||
using ftxui::animation::easing::QuarticIn;
|
||||
using ftxui::animation::easing::QuarticOut;
|
||||
using ftxui::animation::easing::QuarticInOut;
|
||||
using ftxui::animation::easing::QuinticIn;
|
||||
using ftxui::animation::easing::QuinticOut;
|
||||
using ftxui::animation::easing::QuinticInOut;
|
||||
using ftxui::animation::easing::SineIn;
|
||||
using ftxui::animation::easing::SineOut;
|
||||
using ftxui::animation::easing::SineInOut;
|
||||
using ftxui::animation::easing::CircularIn;
|
||||
using ftxui::animation::easing::CircularOut;
|
||||
using ftxui::animation::easing::CircularInOut;
|
||||
using ftxui::animation::easing::ExponentialIn;
|
||||
using ftxui::animation::easing::ExponentialOut;
|
||||
using ftxui::animation::easing::ExponentialInOut;
|
||||
using ftxui::animation::easing::ElasticIn;
|
||||
using ftxui::animation::easing::ElasticOut;
|
||||
using ftxui::animation::easing::ElasticInOut;
|
||||
using ftxui::animation::easing::BackIn;
|
||||
using ftxui::animation::easing::BackOut;
|
||||
using ftxui::animation::easing::BackInOut;
|
||||
using ftxui::animation::easing::BounceIn;
|
||||
using ftxui::animation::easing::BounceOut;
|
||||
using ftxui::animation::easing::BounceInOut;
|
||||
}
|
||||
|
||||
using ftxui::animation::Animator;
|
||||
}
|
||||
18
src/ftxui/component/CapturedMouse.cppm
Normal file
18
src/ftxui/component/CapturedMouse.cppm
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @file CapturedMouse.cppm
|
||||
* @brief Module file for the CapturedMouseInterface class of the Component module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/component/captured_mouse.hpp>
|
||||
|
||||
export module ftxui.component.CapturedMouse;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::CapturedMouseInterface;
|
||||
}
|
||||
61
src/ftxui/component/Component.cppm
Normal file
61
src/ftxui/component/Component.cppm
Normal file
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @file Component.cppm
|
||||
* @brief Module file for the Component classes of the Component module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/component/component.hpp>
|
||||
|
||||
export module ftxui.component.Component;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::ButtonOption;
|
||||
using ftxui::CheckboxOption;
|
||||
using ftxui::Event;
|
||||
using ftxui::InputOption;
|
||||
using ftxui::MenuOption;
|
||||
using ftxui::RadioboxOption;
|
||||
using ftxui::MenuEntryOption;
|
||||
|
||||
using ftxui::Make;
|
||||
|
||||
using ftxui::ComponentDecorator;
|
||||
using ftxui::ElementDecorator;
|
||||
|
||||
using ftxui::operator|;
|
||||
using ftxui::operator|=;
|
||||
|
||||
namespace Container {
|
||||
using ftxui::Container::Vertical;
|
||||
using ftxui::Container::Horizontal;
|
||||
using ftxui::Container::Tab;
|
||||
using ftxui::Container::Stacked;
|
||||
}
|
||||
|
||||
using ftxui::Button;
|
||||
using ftxui::Checkbox;
|
||||
using ftxui::Input;
|
||||
using ftxui::Menu;
|
||||
using ftxui::MenuEntry;
|
||||
using ftxui::Radiobox;
|
||||
using ftxui::Dropdown;
|
||||
using ftxui::Toggle;
|
||||
using ftxui::Slider;
|
||||
using ftxui::ResizableSplit;
|
||||
using ftxui::ResizableSplitLeft;
|
||||
using ftxui::ResizableSplitRight;
|
||||
using ftxui::ResizableSplitTop;
|
||||
using ftxui::ResizableSplitBottom;
|
||||
using ftxui::Renderer;
|
||||
using ftxui::CatchEvent;
|
||||
using ftxui::Maybe;
|
||||
using ftxui::Modal;
|
||||
using ftxui::Collapsible;
|
||||
using ftxui::Hoverable;
|
||||
using ftxui::Window;
|
||||
}
|
||||
28
src/ftxui/component/ComponentBase.cppm
Normal file
28
src/ftxui/component/ComponentBase.cppm
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @file ComponentBase.cppm
|
||||
* @brief Module file for the ComponentBase class of the Component module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/component/component_base.hpp>
|
||||
|
||||
export module ftxui.component.ComponentBase;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::Delegate;
|
||||
using ftxui::Focus;
|
||||
using ftxui::Event;
|
||||
|
||||
namespace animation {
|
||||
using ftxui::animation::Params;
|
||||
}
|
||||
|
||||
using ftxui::ComponentBase;
|
||||
using ftxui::Component;
|
||||
using ftxui::Components;
|
||||
}
|
||||
33
src/ftxui/component/ComponentOptions.cppm
Normal file
33
src/ftxui/component/ComponentOptions.cppm
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @file ComponentOptions.cppm
|
||||
* @brief Module file for options for the Component class of the Component module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/component/component_options.hpp>
|
||||
|
||||
export module ftxui.component.ComponentOptions;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::EntryState;
|
||||
using ftxui::UnderlineOption;
|
||||
using ftxui::AnimatedColorOption;
|
||||
using ftxui::AnimatedColorsOption;
|
||||
using ftxui::MenuEntryOption;
|
||||
using ftxui::MenuOption;
|
||||
using ftxui::ButtonOption;
|
||||
using ftxui::CheckboxOption;
|
||||
using ftxui::InputState;
|
||||
using ftxui::InputOption;
|
||||
using ftxui::RadioboxOption;
|
||||
using ftxui::ResizableSplitOption;
|
||||
using ftxui::SliderOption;
|
||||
using ftxui::WindowRenderState;
|
||||
using ftxui::WindowOptions;
|
||||
using ftxui::DropdownOption;
|
||||
}
|
||||
21
src/ftxui/component/Event.cppm
Normal file
21
src/ftxui/component/Event.cppm
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @file Event.cppm
|
||||
* @brief Module file for the Event struct of the Component module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/component/event.hpp>
|
||||
|
||||
export module ftxui.component.Event;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::ScreenInteractive;
|
||||
using ftxui::ComponentBase;
|
||||
|
||||
using ftxui::Event;
|
||||
}
|
||||
22
src/ftxui/component/Loop.cppm
Normal file
22
src/ftxui/component/Loop.cppm
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @file Loop.cppm
|
||||
* @brief Module file for the Loop class of the Component module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/component/loop.hpp>
|
||||
|
||||
export module ftxui.component.Loop;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::ComponentBase;
|
||||
using ftxui::Component;
|
||||
using ftxui::ScreenInteractive;
|
||||
|
||||
using ftxui::Loop;
|
||||
}
|
||||
18
src/ftxui/component/Mouse.cppm
Normal file
18
src/ftxui/component/Mouse.cppm
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @file Mouse.cppm
|
||||
* @brief Module file for the Mouse struct of the Component module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/component/mouse.hpp>
|
||||
|
||||
export module ftxui.component.Mouse;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::Mouse;
|
||||
}
|
||||
22
src/ftxui/component/Receiver.cppm
Normal file
22
src/ftxui/component/Receiver.cppm
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @file Receiver.cppm
|
||||
* @brief Module file for the Receiver class of the Component module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/component/receiver.hpp>
|
||||
|
||||
export module ftxui.component.Receiver;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::SenderImpl;
|
||||
using ftxui::ReceiverImpl;
|
||||
using ftxui::Sender;
|
||||
using ftxui::Receiver;
|
||||
using ftxui::MakeReceiver;
|
||||
}
|
||||
25
src/ftxui/component/ScreenInteractive.cppm
Normal file
25
src/ftxui/component/ScreenInteractive.cppm
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @file ScreenInteractive.cppm
|
||||
* @brief Module file for the ScreenInteractive class of the Component module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/component/screen_interactive.hpp>
|
||||
|
||||
export module ftxui.component.ScreenInteractive;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::ComponentBase;
|
||||
using ftxui::Loop;
|
||||
using ftxui::Event;
|
||||
using ftxui::Component;
|
||||
|
||||
using ftxui::Screen;
|
||||
using ftxui::ScreenInteractivePrivate;
|
||||
using ftxui::ScreenInteractive;
|
||||
}
|
||||
20
src/ftxui/component/Task.cppm
Normal file
20
src/ftxui/component/Task.cppm
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @file Task.cppm
|
||||
* @brief Module file for the Task class of the Component module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/component/task.hpp>
|
||||
|
||||
export module ftxui.component.Task;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::AnimationTask;
|
||||
using ftxui::Closure;
|
||||
using ftxui::Task;
|
||||
}
|
||||
17
src/ftxui/dom.cppm
Normal file
17
src/ftxui/dom.cppm
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @file dom.cppm
|
||||
* @brief Module file for FTXUI main operations.
|
||||
*/
|
||||
|
||||
export module ftxui.dom;
|
||||
|
||||
export import ftxui.dom.Canvas;
|
||||
export import ftxui.dom.Deprecated;
|
||||
export import ftxui.dom.Direction;
|
||||
export import ftxui.dom.Elements;
|
||||
export import ftxui.dom.FlexboxConfig;
|
||||
export import ftxui.dom.LinearGradient;
|
||||
export import ftxui.dom.Node;
|
||||
export import ftxui.dom.Requirement;
|
||||
export import ftxui.dom.Selection;
|
||||
export import ftxui.dom.Table;
|
||||
18
src/ftxui/dom/Canvas.cppm
Normal file
18
src/ftxui/dom/Canvas.cppm
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @file Canvas.cppm
|
||||
* @brief Module file for the Canvas struct of the Dom module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/dom/canvas.hpp>
|
||||
|
||||
export module ftxui.dom.Canvas;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::Canvas;
|
||||
}
|
||||
20
src/ftxui/dom/Deprecated.cppm
Normal file
20
src/ftxui/dom/Deprecated.cppm
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @file Deprecated.cppm
|
||||
* @brief Module file for deprecated parts of the Dom module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/dom/deprecated.hpp>
|
||||
|
||||
export module ftxui.dom.Deprecated;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::text;
|
||||
using ftxui::vtext;
|
||||
using ftxui::paragraph;
|
||||
}
|
||||
18
src/ftxui/dom/Direction.cppm
Normal file
18
src/ftxui/dom/Direction.cppm
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @file Direction.cppm
|
||||
* @brief Module file for the Direction enum of the Dom module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/dom/direction.hpp>
|
||||
|
||||
export module ftxui.dom.Direction;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::Direction;
|
||||
}
|
||||
130
src/ftxui/dom/Elements.cppm
Normal file
130
src/ftxui/dom/Elements.cppm
Normal file
@@ -0,0 +1,130 @@
|
||||
/**
|
||||
* @file Canvas.cppm
|
||||
* @brief Module file for the Element classes and functions of the Dom module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/dom/elements.hpp>
|
||||
|
||||
export module ftxui.dom.Elements;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::Node;
|
||||
using ftxui::Element;
|
||||
using ftxui::Elements;
|
||||
using ftxui::Decorator;
|
||||
using ftxui::GraphFunction;
|
||||
|
||||
using ftxui::BorderStyle;
|
||||
|
||||
using ftxui::operator|;
|
||||
using ftxui::operator|=;
|
||||
|
||||
using ftxui::text;
|
||||
using ftxui::vtext;
|
||||
using ftxui::separator;
|
||||
using ftxui::separatorLight;
|
||||
using ftxui::separatorDashed;
|
||||
using ftxui::separatorHeavy;
|
||||
using ftxui::separatorDouble;
|
||||
using ftxui::separatorEmpty;
|
||||
using ftxui::separatorStyled;
|
||||
using ftxui::separatorCharacter;
|
||||
using ftxui::separatorHSelector;
|
||||
using ftxui::separatorVSelector;
|
||||
using ftxui::gauge;
|
||||
using ftxui::gaugeLeft;
|
||||
using ftxui::gaugeRight;
|
||||
using ftxui::gaugeUp;
|
||||
using ftxui::gaugeDown;
|
||||
using ftxui::gaugeDirection;
|
||||
using ftxui::border;
|
||||
using ftxui::borderLight;
|
||||
using ftxui::borderDashed;
|
||||
using ftxui::borderHeavy;
|
||||
using ftxui::borderDouble;
|
||||
using ftxui::borderRounded;
|
||||
using ftxui::borderEmpty;
|
||||
using ftxui::borderStyled;
|
||||
using ftxui::borderWith;
|
||||
using ftxui::window;
|
||||
using ftxui::spinner;
|
||||
using ftxui::paragraph;
|
||||
using ftxui::paragraphAlignLeft;
|
||||
using ftxui::paragraphAlignRight;
|
||||
using ftxui::paragraphAlignCenter;
|
||||
using ftxui::paragraphAlignJustify;
|
||||
using ftxui::graph;
|
||||
using ftxui::emptyElement;
|
||||
using ftxui::canvas;
|
||||
|
||||
using ftxui::bold;
|
||||
using ftxui::dim;
|
||||
using ftxui::inverted;
|
||||
using ftxui::underlined;
|
||||
using ftxui::underlinedDouble;
|
||||
using ftxui::blink;
|
||||
using ftxui::strikethrough;
|
||||
using ftxui::color;
|
||||
using ftxui::bgcolor;
|
||||
using ftxui::focusPosition;
|
||||
using ftxui::focusPositionRelative;
|
||||
using ftxui::automerge;
|
||||
using ftxui::hyperlink;
|
||||
using ftxui::selectionStyleReset;
|
||||
using ftxui::selectionColor;
|
||||
using ftxui::selectionBackgroundColor;
|
||||
using ftxui::selectionForegroundColor;
|
||||
using ftxui::selectionStyle;
|
||||
|
||||
using ftxui::hbox;
|
||||
using ftxui::vbox;
|
||||
using ftxui::dbox;
|
||||
using ftxui::flexbox;
|
||||
using ftxui::gridbox;
|
||||
using ftxui::hflow;
|
||||
using ftxui::vflow;
|
||||
|
||||
using ftxui::flex;
|
||||
using ftxui::flex_grow;
|
||||
using ftxui::flex_shrink;
|
||||
using ftxui::xflex;
|
||||
using ftxui::xflex_grow;
|
||||
using ftxui::xflex_shrink;
|
||||
using ftxui::yflex;
|
||||
using ftxui::yflex_grow;
|
||||
using ftxui::yflex_shrink;
|
||||
using ftxui::notflex;
|
||||
using ftxui::filler;
|
||||
|
||||
using ftxui::WidthOrHeight;
|
||||
using ftxui::Constraint;
|
||||
using ftxui::size;
|
||||
|
||||
using ftxui::focusCursorBlock;
|
||||
using ftxui::focusCursorBlockBlinking;
|
||||
using ftxui::focusCursorBar;
|
||||
using ftxui::focusCursorBarBlinking;
|
||||
using ftxui::focusCursorUnderline;
|
||||
using ftxui::focusCursorUnderlineBlinking;
|
||||
|
||||
using ftxui::vscroll_indicator;
|
||||
using ftxui::hscroll_indicator;
|
||||
using ftxui::reflect;
|
||||
using ftxui::clear_under;
|
||||
|
||||
using ftxui::hcenter;
|
||||
using ftxui::vcenter;
|
||||
using ftxui::center;
|
||||
using ftxui::align_right;
|
||||
using ftxui::nothing;
|
||||
|
||||
namespace Dimension {
|
||||
using ftxui::Dimension::Fit;
|
||||
}
|
||||
}
|
||||
18
src/ftxui/dom/FlexboxConfig.cppm
Normal file
18
src/ftxui/dom/FlexboxConfig.cppm
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @file FlexboxConfig.cppm
|
||||
* @brief Module file for the FlexboxConfig struct of the Dom module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/dom/flexbox_config.hpp>
|
||||
|
||||
export module ftxui.dom.FlexboxConfig;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::FlexboxConfig;
|
||||
}
|
||||
18
src/ftxui/dom/LinearGradient.cppm
Normal file
18
src/ftxui/dom/LinearGradient.cppm
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @file LinearGradient.cppm
|
||||
* @brief Module file for the LinearGradient struct of the Dom module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/dom/linear_gradient.hpp>
|
||||
|
||||
export module ftxui.dom.LinearGradient;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::LinearGradient;
|
||||
}
|
||||
25
src/ftxui/dom/Node.cppm
Normal file
25
src/ftxui/dom/Node.cppm
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @file Node.cppm
|
||||
* @brief Module file for the Node class of the Dom module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/dom/node.hpp>
|
||||
|
||||
export module ftxui.dom.Node;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::Node;
|
||||
using ftxui::Screen;
|
||||
|
||||
using ftxui::Element;
|
||||
using ftxui::Elements;
|
||||
|
||||
using ftxui::Render;
|
||||
using ftxui::GetNodeSelectedContent;
|
||||
}
|
||||
18
src/ftxui/dom/Requirement.cppm
Normal file
18
src/ftxui/dom/Requirement.cppm
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @file Requirement.cppm
|
||||
* @brief Module file for the Requirement struct of the Dom module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/dom/requirement.hpp>
|
||||
|
||||
export module ftxui.dom.Requirement;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::Requirement;
|
||||
}
|
||||
18
src/ftxui/dom/Selection.cppm
Normal file
18
src/ftxui/dom/Selection.cppm
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @file Selection.cppm
|
||||
* @brief Module file for the Selection class of the Dom module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/dom/selection.hpp>
|
||||
|
||||
export module ftxui.dom.Selection;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::Selection;
|
||||
}
|
||||
19
src/ftxui/dom/Table.cppm
Normal file
19
src/ftxui/dom/Table.cppm
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @file Table.cppm
|
||||
* @brief Module file for the Table class of the Dom module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/dom/table.hpp>
|
||||
|
||||
export module ftxui.dom.Table;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::Table;
|
||||
using ftxui::TableSelection;
|
||||
}
|
||||
@@ -45,59 +45,6 @@ class DBox : public Node {
|
||||
child->SetBox(box);
|
||||
}
|
||||
}
|
||||
|
||||
void Render(Screen& screen) override {
|
||||
if (children_.size() <= 1) {
|
||||
Node::Render(screen);
|
||||
return;
|
||||
}
|
||||
|
||||
const int width = box_.x_max - box_.x_min + 1;
|
||||
const int height = box_.y_max - box_.y_min + 1;
|
||||
std::vector<Pixel> pixels(std::size_t(width * height));
|
||||
|
||||
for (auto& child : children_) {
|
||||
child->Render(screen);
|
||||
|
||||
// Accumulate the pixels
|
||||
Pixel* acc = pixels.data();
|
||||
for (int x = 0; x < width; ++x) {
|
||||
for (int y = 0; y < height; ++y) {
|
||||
auto& pixel = screen.PixelAt(x + box_.x_min, y + box_.y_min);
|
||||
acc->background_color =
|
||||
Color::Blend(acc->background_color, pixel.background_color);
|
||||
acc->automerge = pixel.automerge || acc->automerge;
|
||||
if (pixel.character.empty()) {
|
||||
acc->foreground_color =
|
||||
Color::Blend(acc->foreground_color, pixel.background_color);
|
||||
} else {
|
||||
acc->blink = pixel.blink;
|
||||
acc->bold = pixel.bold;
|
||||
acc->dim = pixel.dim;
|
||||
acc->inverted = pixel.inverted;
|
||||
acc->italic = pixel.italic;
|
||||
acc->underlined = pixel.underlined;
|
||||
acc->underlined_double = pixel.underlined_double;
|
||||
acc->strikethrough = pixel.strikethrough;
|
||||
acc->hyperlink = pixel.hyperlink;
|
||||
acc->character = pixel.character;
|
||||
acc->foreground_color = pixel.foreground_color;
|
||||
}
|
||||
++acc; // NOLINT
|
||||
|
||||
pixel = Pixel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Render the accumulated pixels:
|
||||
Pixel* acc = pixels.data();
|
||||
for (int x = 0; x < width; ++x) {
|
||||
for (int y = 0; y < height; ++y) {
|
||||
screen.PixelAt(x + box_.x_min, y + box_.y_min) = *acc++; // NOLINT
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
||||
11
src/ftxui/ftxui.cppm
Normal file
11
src/ftxui/ftxui.cppm
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @file ftxui.cppm
|
||||
* @brief Module file re-exporting all FTXUI submodules.
|
||||
*/
|
||||
|
||||
export module ftxui;
|
||||
|
||||
export import ftxui.component;
|
||||
export import ftxui.dom;
|
||||
export import ftxui.screen;
|
||||
export import ftxui.util;
|
||||
16
src/ftxui/screen.cppm
Normal file
16
src/ftxui/screen.cppm
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @file screen.cppm
|
||||
* @brief Module file for FTXUI screen operations.
|
||||
*/
|
||||
|
||||
export module ftxui.screen;
|
||||
|
||||
export import ftxui.screen.Box;
|
||||
export import ftxui.screen.Color;
|
||||
export import ftxui.screen.ColorInfo;
|
||||
export import ftxui.screen.Deprecated;
|
||||
export import ftxui.screen.Image;
|
||||
export import ftxui.screen.Pixel;
|
||||
export import ftxui.screen.Screen;
|
||||
export import ftxui.screen.String;
|
||||
export import ftxui.screen.Terminal;
|
||||
18
src/ftxui/screen/Box.cppm
Normal file
18
src/ftxui/screen/Box.cppm
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @file Box.cppm
|
||||
* @brief Module file for the Box struct of the Screen module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/screen/box.hpp>
|
||||
|
||||
export module ftxui.screen.Box;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::Box;
|
||||
}
|
||||
22
src/ftxui/screen/Color.cppm
Normal file
22
src/ftxui/screen/Color.cppm
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @file Color.cppm
|
||||
* @brief Module file for the Color class of the Screen module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/screen/color.hpp>
|
||||
|
||||
export module ftxui.screen.Color;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::Color;
|
||||
|
||||
inline namespace literals {
|
||||
using ftxui::literals::operator""_rgb;
|
||||
}
|
||||
}
|
||||
20
src/ftxui/screen/ColorInfo.cppm
Normal file
20
src/ftxui/screen/ColorInfo.cppm
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @file ColorInfo.cppm
|
||||
* @brief Module file for the ColorInfo struct of the Screen module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/screen/color_info.hpp>
|
||||
|
||||
export module ftxui.screen.ColorInfo;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::ColorInfo;
|
||||
|
||||
using ftxui::GetColorInfo;
|
||||
}
|
||||
19
src/ftxui/screen/Deprecated.cppm
Normal file
19
src/ftxui/screen/Deprecated.cppm
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @file Box.cppm
|
||||
* @brief Module file for the deprecated parts of the Screen module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/screen/deprecated.hpp>
|
||||
|
||||
export module ftxui.screen.Deprecated;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::wchar_width;
|
||||
using ftxui::wstring_width;
|
||||
}
|
||||
18
src/ftxui/screen/Image.cppm
Normal file
18
src/ftxui/screen/Image.cppm
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @file Image.cppm
|
||||
* @brief Module file for the Image class of the Screen module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/screen/image.hpp>
|
||||
|
||||
export module ftxui.screen.Image;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::Image;
|
||||
}
|
||||
18
src/ftxui/screen/Pixel.cppm
Normal file
18
src/ftxui/screen/Pixel.cppm
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @file Pixel.cppm
|
||||
* @brief Module file for the Pixel struct of the Screen module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/screen/pixel.hpp>
|
||||
|
||||
export module ftxui.screen.Pixel;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::Pixel;
|
||||
}
|
||||
24
src/ftxui/screen/Screen.cppm
Normal file
24
src/ftxui/screen/Screen.cppm
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @file Screen.cppm
|
||||
* @brief Module file for the Screen class of the Screen module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/screen/screen.hpp>
|
||||
|
||||
export module ftxui.screen.Screen;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
namespace Dimension {
|
||||
using ftxui::Dimension::Fixed;
|
||||
using ftxui::Dimension::Full;
|
||||
}
|
||||
|
||||
using ftxui::Image;
|
||||
using ftxui::Screen;
|
||||
}
|
||||
22
src/ftxui/screen/String.cppm
Normal file
22
src/ftxui/screen/String.cppm
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @file String.cppm
|
||||
* @brief Module file for string functions of the Screen module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/screen/string.hpp>
|
||||
|
||||
export module ftxui.screen.String;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::to_string;
|
||||
using ftxui::to_wstring;
|
||||
using ftxui::string_width;
|
||||
using ftxui::Utf8ToGlyphs;
|
||||
using ftxui::CellToGlyphIndex;
|
||||
}
|
||||
26
src/ftxui/screen/Terminal.cppm
Normal file
26
src/ftxui/screen/Terminal.cppm
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @file Terminal.cppm
|
||||
* @brief Module file for the Terminal namespace of the Screen module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/screen/terminal.hpp>
|
||||
|
||||
export module ftxui.screen.Terminal;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::Dimensions;
|
||||
|
||||
namespace Terminal {
|
||||
using ftxui::Terminal::Size;
|
||||
using ftxui::Terminal::SetFallbackSize;
|
||||
using ftxui::Terminal::Color;
|
||||
using ftxui::Terminal::ColorSupport;
|
||||
using ftxui::Terminal::SetColorSupport;
|
||||
}
|
||||
}
|
||||
9
src/ftxui/util.cppm
Normal file
9
src/ftxui/util.cppm
Normal file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* @file util.cppm
|
||||
* @brief Module file for FTXUI utility operations.
|
||||
*/
|
||||
|
||||
export module ftxui.util;
|
||||
|
||||
export import ftxui.util.AutoReset;
|
||||
export import ftxui.util.Ref;
|
||||
18
src/ftxui/util/AutoReset.cppm
Normal file
18
src/ftxui/util/AutoReset.cppm
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @file AutoReset.cppm
|
||||
* @brief Module file for the AutoReset class of the Util module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/util/autoreset.hpp>
|
||||
|
||||
export module ftxui.util.AutoReset;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::AutoReset;
|
||||
}
|
||||
22
src/ftxui/util/Ref.cppm
Normal file
22
src/ftxui/util/Ref.cppm
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @file Ref.cppm
|
||||
* @brief Module file for the Ref classes of the Util module
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ftxui/util/ref.hpp>
|
||||
|
||||
export module ftxui.util.Ref;
|
||||
|
||||
/**
|
||||
* @namespace ftxui
|
||||
* @brief The FTXUI ftxui:: namespace
|
||||
*/
|
||||
export namespace ftxui {
|
||||
using ftxui::ConstRef;
|
||||
using ftxui::Ref;
|
||||
using ftxui::StringRef;
|
||||
using ftxui::ConstStringRef;
|
||||
using ftxui::ConstStringListRef;
|
||||
}
|
||||
29
tools/generate_examples_modules.sh
Executable file
29
tools/generate_examples_modules.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Generate ./examples_modules from ./examples to using C++20 modules instead of
|
||||
# #includes for ftxui.
|
||||
# This is useful for testing ftxui with modules. This ensures we don't forget
|
||||
# to update the FTXUI modules when adding new features to FTXUI.
|
||||
|
||||
echo "Generating ./examples_modules"
|
||||
rm -rf ./examples_modules
|
||||
cp -r ./examples ./examples_modules
|
||||
|
||||
for file in ./examples_modules/**/*.cpp; do
|
||||
echo "Generating $file"
|
||||
|
||||
sed -i '/#include "ftxui/d' "$file"
|
||||
sed -i '/#include <ftxui/d' "$file"
|
||||
sed -i '1i\import ftxui.component;' "$file"
|
||||
sed -i '2i\import ftxui.dom;' "$file"
|
||||
sed -i '3i\import ftxui.screen;' "$file"
|
||||
sed -i '4i\import ftxui.util;' "$file"
|
||||
sed -i '5i\\' "$file"
|
||||
done
|
||||
|
||||
# Modify the CMakeLists.txt file to link against ftxui-modules
|
||||
sed -i 's/${DIRECTORY_LIB}/ftxui-modules/g' ./examples_modules/CMakeLists.txt
|
||||
sed -i 's/ftxui_example_/ftxui_modules_example_/g' ./examples_modules/CMakeLists.txt
|
||||
|
||||
|
||||
|
||||
18
tools/test_bazel.sh
Executable file
18
tools/test_bazel.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
# This script tests the project with different versions of Bazel and compilers
|
||||
# locally. This avoids waiting on the CI to run the tests.
|
||||
|
||||
for ver in \
|
||||
"6.0.0" \
|
||||
"7.0.0" \
|
||||
"8.0.0"
|
||||
do
|
||||
for cc in \
|
||||
"gcc" \
|
||||
"clang"
|
||||
do
|
||||
echo "=== Testing with Bazel ${ver} with ${cc} ==="
|
||||
USE_BAZEL_VERSION=${ver} CC=${cc} bazel clean --expunge
|
||||
USE_BAZEL_VERSION=${ver} CC=${cc} bazel build //...
|
||||
USE_BAZEL_VERSION=${ver} CC=${cc} bazel test //...
|
||||
done
|
||||
done
|
||||
Reference in New Issue
Block a user