mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-07-27 23:58:00 +08:00
Compare commits
5 Commits
4f2fd75b76
...
40b64d064b
Author | SHA1 | Date | |
---|---|---|---|
![]() |
40b64d064b | ||
![]() |
08b8a3b28f | ||
![]() |
5cfed50702 | ||
![]() |
b307a175ed | ||
![]() |
baa5973128 |
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,21 +1,36 @@
|
|||||||
matrix:
|
matrix:
|
||||||
platform:
|
bazel:
|
||||||
- centos7
|
- 7.x
|
||||||
- debian10
|
- 8.x
|
||||||
- ubuntu2004
|
- rolling
|
||||||
|
unix_platform:
|
||||||
|
- debian11
|
||||||
|
- ubuntu2204
|
||||||
- macos
|
- macos
|
||||||
|
- macos_arm64
|
||||||
|
win_platform:
|
||||||
- windows
|
- windows
|
||||||
bazel: [6.x, 7.x, 8.x]
|
|
||||||
tasks:
|
tasks:
|
||||||
verify_targets:
|
|
||||||
name: Build and test.
|
unix_test:
|
||||||
platform: ${{ platform }}
|
name: Verify build targets on Unix
|
||||||
|
platform: ${{ unix_platform }}
|
||||||
bazel: ${{ bazel }}
|
bazel: ${{ bazel }}
|
||||||
|
build_flags:
|
||||||
|
- --cxxopt=-std=c++20
|
||||||
build_targets:
|
build_targets:
|
||||||
- '@ftxui//:ftxui'
|
|
||||||
- '@ftxui//:screen'
|
|
||||||
- '@ftxui//:dom'
|
- '@ftxui//:dom'
|
||||||
- '@ftxui//:component'
|
- '@ftxui//:component'
|
||||||
test_targets:
|
- '@ftxui//:screen'
|
||||||
- '@ftxui//:tests'
|
|
||||||
|
|
||||||
|
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'
|
||||||
|
25
.github/workflows/build.yaml
vendored
25
.github/workflows/build.yaml
vendored
@ -14,25 +14,30 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
test_bazel:
|
test_bazel:
|
||||||
name: "Bazel, ${{ matrix.compiler }}, ${{ matrix.os }}"
|
name: "Bazel, ${{ matrix.cxx }}, ${{ matrix.os }}"
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
compiler: gcc
|
cxx: g++
|
||||||
|
cc: gcc
|
||||||
|
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
compiler: llvm
|
cxx: clang++
|
||||||
|
cc: clang
|
||||||
|
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
compiler: llvm
|
cxx: g++
|
||||||
|
cc: gcc
|
||||||
|
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
compiler: gcc
|
cxx: clang++
|
||||||
|
cc: clang
|
||||||
|
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
compiler: cl
|
cxx: cl
|
||||||
|
cc: cl
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
@ -40,10 +45,16 @@ jobs:
|
|||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: "Build with Bazel"
|
- name: "Build with Bazel"
|
||||||
|
env:
|
||||||
|
CC: ${{ matrix.cc }}
|
||||||
|
CXX: ${{ matrix.cxx }}
|
||||||
run: bazel build ...
|
run: bazel build ...
|
||||||
|
|
||||||
- name: "Tests with Bazel"
|
- name: "Tests with Bazel"
|
||||||
run: bazel run tests
|
env:
|
||||||
|
CC: ${{ matrix.cc }}
|
||||||
|
CXX: ${{ matrix.cxx }}
|
||||||
|
run: bazel test --test_output=all ...
|
||||||
|
|
||||||
test_cmake:
|
test_cmake:
|
||||||
name: "CMake, ${{ matrix.compiler }}, ${{ matrix.os }}"
|
name: "CMake, ${{ matrix.compiler }}, ${{ matrix.os }}"
|
||||||
|
57
BUILD.bazel
57
BUILD.bazel
@ -12,23 +12,19 @@
|
|||||||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
|
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
|
||||||
load(":bazel/ftxui.bzl", "ftxui_cc_library")
|
load(":bazel/ftxui.bzl", "ftxui_cc_library")
|
||||||
load(":bazel/ftxui.bzl", "generate_examples")
|
load(":bazel/ftxui.bzl", "generate_examples")
|
||||||
load(":bazel/ftxui.bzl", "cpp20")
|
|
||||||
load(":bazel/ftxui.bzl", "windows_copts")
|
load(":bazel/ftxui.bzl", "windows_copts")
|
||||||
load(":bazel/ftxui.bzl", "pthread_linkopts")
|
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.
|
# @ftxui:screen is a module that provides a screen buffer and color management
|
||||||
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
|
# 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
|
# contain a glyph, a color, and other attributes. The library also provides
|
||||||
# functions to manipulate the screen.
|
# 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.
|
# "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 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
|
# nodes to create a document. A document is responsive to the size of the
|
||||||
@ -130,7 +126,7 @@ ftxui_cc_library(
|
|||||||
deps = [":screen"],
|
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
|
# updating a ftxui::dom document on the screen. It is a higher level API than
|
||||||
# ftxui:dom.
|
# ftxui:dom.
|
||||||
#
|
#
|
||||||
@ -167,6 +163,13 @@ ftxui_cc_library(
|
|||||||
"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",
|
"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 = [
|
hdrs = [
|
||||||
"include/ftxui/component/animation.hpp",
|
"include/ftxui/component/animation.hpp",
|
||||||
@ -182,7 +185,10 @@ ftxui_cc_library(
|
|||||||
"include/ftxui/component/task.hpp",
|
"include/ftxui/component/task.hpp",
|
||||||
],
|
],
|
||||||
linkopts = pthread_linkopts(),
|
linkopts = pthread_linkopts(),
|
||||||
deps = [":dom"],
|
deps = [
|
||||||
|
":dom",
|
||||||
|
":screen",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
# FTXUI's tests
|
# FTXUI's tests
|
||||||
@ -205,7 +211,6 @@ cc_test(
|
|||||||
"src/ftxui/component/resizable_split_test.cpp",
|
"src/ftxui/component/resizable_split_test.cpp",
|
||||||
"src/ftxui/component/slider_test.cpp",
|
"src/ftxui/component/slider_test.cpp",
|
||||||
"src/ftxui/component/terminal_input_parser_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/component/toggle_test.cpp",
|
||||||
"src/ftxui/dom/blink_test.cpp",
|
"src/ftxui/dom/blink_test.cpp",
|
||||||
"src/ftxui/dom/bold_test.cpp",
|
"src/ftxui/dom/bold_test.cpp",
|
||||||
@ -233,6 +238,17 @@ cc_test(
|
|||||||
"src/ftxui/screen/string_test.cpp",
|
"src/ftxui/screen/string_test.cpp",
|
||||||
"src/ftxui/util/ref_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:
|
# TODO: Enable the two tests timing out with Bazel:
|
||||||
# - "src/ftxui/component/screen_interactive_test.cpp",
|
# - "src/ftxui/component/screen_interactive_test.cpp",
|
||||||
# - "src/ftxui/dom/selection_test.cpp",
|
# - "src/ftxui/dom/selection_test.cpp",
|
||||||
@ -241,9 +257,12 @@ cc_test(
|
|||||||
"include",
|
"include",
|
||||||
"src",
|
"src",
|
||||||
],
|
],
|
||||||
copts = cpp20() + windows_copts(),
|
copts = windows_copts(),
|
||||||
deps = [
|
deps = [
|
||||||
"//:ftxui",
|
":screen",
|
||||||
|
":dom",
|
||||||
|
":component",
|
||||||
|
"@googletest//:gtest",
|
||||||
"@googletest//:gtest_main",
|
"@googletest//:gtest_main",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
20
CHANGELOG.md
20
CHANGELOG.md
@ -1,9 +1,20 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
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
|
### dom
|
||||||
- Bugfix: Restore the `dbox` behavior from ftxui 5.0.0. To apply bgcolor
|
- Bugfix: Restore the `dbox` behavior from ftxui 5.0.0. To apply bgcolor
|
||||||
blending between the two layers, a new `dboxBlend` will be added.
|
blending between the two layers, a new `dboxBlend` will be added.
|
||||||
@ -14,13 +25,6 @@ Future release
|
|||||||
### Build
|
### Build
|
||||||
- Feature: Support `bazel` build system. See #1032.
|
- Feature: Support `bazel` build system. See #1032.
|
||||||
Proposed by Kostya Serebryany @kcc
|
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**
|
**BUILD.bazel**
|
||||||
```bazel
|
```bazel
|
||||||
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.12)
|
|||||||
|
|
||||||
project(ftxui
|
project(ftxui
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
VERSION 6.1.8
|
VERSION 6.1.9
|
||||||
DESCRIPTION "C++ Functional Terminal User Interface."
|
DESCRIPTION "C++ Functional Terminal User Interface."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
16
MODULE.bazel
16
MODULE.bazel
@ -1,9 +1,13 @@
|
|||||||
# FTXUI Module.
|
# FTXUI module.
|
||||||
module(name = "ftxui", version = "6.1.8", compatibility_level = 6)
|
module(
|
||||||
|
name = "ftxui",
|
||||||
|
version = "6.1.9",
|
||||||
|
compatibility_level = 6,
|
||||||
|
)
|
||||||
|
|
||||||
# Build deps.
|
# Build dependencies.
|
||||||
bazel_dep(name = "rules_cc", version = "0.1.1")
|
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.
|
# Test dependencies.
|
||||||
bazel_dep(name = "googletest", version = "1.16.0.bcr.1")
|
bazel_dep(name = "googletest", version = "1.14.0.bcr.1", dev_dependency = True)
|
||||||
|
70
README.md
70
README.md
@ -42,15 +42,24 @@ A simple cross-platform C++ library for terminal based user interfaces!
|
|||||||
* 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/](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...
|
* Good practices: documentation, tests, fuzzers, performance tests, automated CI, automated packaging, etc...
|
||||||
|
|
||||||
## Documentation
|
## 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/)
|
- [Documentation](https://arthursonzogni.github.io/FTXUI/)
|
||||||
- [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)
|
||||||
|
- [Build using Bazel](https://arthursonzogni.github.io/FTXUI/#build-bazel)
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
~~~cpp
|
~~~cpp
|
||||||
@ -365,33 +374,62 @@ 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)
|
||||||
|
|
||||||
## 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.
|
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
|
```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 v6.1.8
|
GIT_TAG v6.1.9
|
||||||
)
|
)
|
||||||
|
FetchContent_MakeAvailable(ftxui)
|
||||||
|
|
||||||
FetchContent_GetProperties(ftxui)
|
target_link_libraries(your_target PRIVATE
|
||||||
if(NOT ftxui_POPULATED)
|
# Chose a submodule
|
||||||
FetchContent_Populate(ftxui)
|
ftxui::component
|
||||||
add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL)
|
ftxui::dom
|
||||||
endif()
|
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:
|
If you don't, FTXUI may be used from the following packages:
|
||||||
- [bazel](...)
|
- CMake [FetchContent]([https://bewagner.net/programming/2020/05/02/cmake-fetchcontent/](https://cmake.org/cmake/help/latest/module/FetchContent.html)) (preferred),
|
||||||
- [vcpkg](https://vcpkgx.com/details.html?package=ftxui)
|
- [Bazel](https://registry.bazel.build/modules/ftxui),
|
||||||
- [Arch Linux PKGBUILD](https://aur.archlinux.org/packages/ftxui-git/).
|
- [vcpkg](https://vcpkg.link/ports/ftxui),
|
||||||
- [conan.io](https://conan.io/center/ftxui)
|
- [Conan](https://conan.io/center/recipes/ftxui)
|
||||||
- [openSUSE](https://build.opensuse.org/package/show/devel:libraries:c_c++/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)
|
[](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.
|
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
|
```bash
|
||||||
g++ . . . -lftxui-component -lftxui-dom -lftxui-screen . . .
|
g++ . . . -lftxui-component -lftxui-dom -lftxui-screen . . .
|
||||||
|
@ -1,24 +1,7 @@
|
|||||||
# ftxui_common.bzl
|
# ftxui_common.bzl
|
||||||
|
|
||||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||||
|
load("@rules_cc//cc:defs.bzl", "cc_binary")
|
||||||
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.
|
# Microsoft terminal is a bit buggy ¯\_(ツ)_/¯ and MSVC uses bad defaults.
|
||||||
def windows_copts():
|
def windows_copts():
|
||||||
@ -45,7 +28,8 @@ def windows_copts():
|
|||||||
# This
|
# This
|
||||||
# - Replace missing font symbols by others.
|
# - Replace missing font symbols by others.
|
||||||
# - Reduce screen position pooling frequency to deals against a Microsoft
|
# - 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/microsoft/terminal/pull/7583
|
||||||
# - https://github.com/ArthurSonzogni/FTXUI/issues/136
|
# - https://github.com/ArthurSonzogni/FTXUI/issues/136
|
||||||
"-DFTXUI_MICROSOFT_TERMINAL_FALLBACK",
|
"-DFTXUI_MICROSOFT_TERMINAL_FALLBACK",
|
||||||
@ -71,8 +55,8 @@ def pthread_linkopts():
|
|||||||
|
|
||||||
def ftxui_cc_library(
|
def ftxui_cc_library(
|
||||||
name,
|
name,
|
||||||
srcs,
|
srcs = [],
|
||||||
hdrs,
|
hdrs = [],
|
||||||
linkopts = [],
|
linkopts = [],
|
||||||
deps = []):
|
deps = []):
|
||||||
|
|
||||||
@ -88,12 +72,13 @@ def ftxui_cc_library(
|
|||||||
"include",
|
"include",
|
||||||
"src",
|
"src",
|
||||||
],
|
],
|
||||||
copts = cpp17() + windows_copts(),
|
copts = windows_copts(),
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Compile all the examples in the examples/ directory.
|
# 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():
|
def generate_examples():
|
||||||
cpp_files = native.glob(["examples/**/*.cpp"])
|
cpp_files = native.glob(["examples/**/*.cpp"])
|
||||||
|
|
||||||
@ -107,9 +92,13 @@ def generate_examples():
|
|||||||
# Turn "examples/component/button.cpp" → "example_component_button"
|
# Turn "examples/component/button.cpp" → "example_component_button"
|
||||||
name = src.replace("/", "_").replace(".cpp", "")
|
name = src.replace("/", "_").replace(".cpp", "")
|
||||||
|
|
||||||
native.cc_binary(
|
cc_binary(
|
||||||
name = name,
|
name = name,
|
||||||
srcs = [src],
|
srcs = [src],
|
||||||
deps = ["//:component"],
|
deps = [
|
||||||
copts = cpp20() + windows_copts(),
|
":component",
|
||||||
|
":dom",
|
||||||
|
":screen",
|
||||||
|
],
|
||||||
|
copts = windows_copts(),
|
||||||
)
|
)
|
||||||
|
@ -81,7 +81,7 @@ include(FetchContent)
|
|||||||
set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
|
set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
|
||||||
FetchContent_Declare(ftxui
|
FetchContent_Declare(ftxui
|
||||||
GIT_REPOSITORY https://github.com/ArthurSonzogni/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)
|
FetchContent_MakeAvailable(ftxui)
|
||||||
|
|
||||||
@ -94,13 +94,33 @@ target_link_libraries(ftxui-starter
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Build
|
### Using Bazel {#build-bazel}
|
||||||
|
|
||||||
```bash
|
See [ftxui module](https://registry.bazel.build/modules/ftxui) from the Bazel
|
||||||
mkdir build && cd build
|
Central Registry.
|
||||||
cmake ..
|
|
||||||
make
|
See also this [starter](https://github.com/ArthurSonzogni/ftxui-bazel) project.
|
||||||
./main
|
|
||||||
|
**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}
|
# List of modules. {#modules}
|
||||||
|
@ -48,25 +48,38 @@ Dimensions& FallbackSize() {
|
|||||||
return g_fallback_size;
|
return g_fallback_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Safe(const char* c) {
|
|
||||||
return (c != nullptr) ? c : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Contains(const std::string& s, const char* key) {
|
bool Contains(const std::string& s, const char* key) {
|
||||||
return s.find(key) != std::string::npos;
|
return s.find(key) != std::string::npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/gabime/spdlog/blob/885b5473e291833b148eeac3b7ce227e582cd88b/include/spdlog/details/os-inl.h#L566
|
||||||
|
std::string getenv_safe(const char *field) {
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#if defined(__cplusplus_winrt)
|
||||||
|
return std::string{}; // not supported under uwp
|
||||||
|
#else
|
||||||
|
size_t len = 0;
|
||||||
|
char buf[1024];
|
||||||
|
bool ok = ::getenv_s(&len, buf, sizeof(buf), field) == 0;
|
||||||
|
return ok ? buf : std::string{};
|
||||||
|
#endif
|
||||||
|
#else // revert to getenv
|
||||||
|
char *buf = ::getenv(field); // NOLINT(*-mt-unsafe)
|
||||||
|
return buf ? buf : std::string{};
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
Terminal::Color ComputeColorSupport() {
|
Terminal::Color ComputeColorSupport() {
|
||||||
#if defined(__EMSCRIPTEN__)
|
#if defined(__EMSCRIPTEN__)
|
||||||
return Terminal::Color::TrueColor;
|
return Terminal::Color::TrueColor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string COLORTERM = Safe(std::getenv("COLORTERM")); // NOLINT
|
std::string COLORTERM = getenv_safe("COLORTERM");
|
||||||
if (Contains(COLORTERM, "24bit") || Contains(COLORTERM, "truecolor")) {
|
if (Contains(COLORTERM, "24bit") || Contains(COLORTERM, "truecolor")) {
|
||||||
return Terminal::Color::TrueColor;
|
return Terminal::Color::TrueColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string TERM = Safe(std::getenv("TERM")); // NOLINT
|
std::string TERM = getenv_safe("TERM");
|
||||||
if (Contains(COLORTERM, "256") || Contains(TERM, "256")) {
|
if (Contains(COLORTERM, "256") || Contains(TERM, "256")) {
|
||||||
return Terminal::Color::Palette256;
|
return Terminal::Color::Palette256;
|
||||||
}
|
}
|
||||||
|
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
|
Loading…
Reference in New Issue
Block a user