36 Commits

Author SHA1 Message Date
Arthur Sonzogni
068cf29e67 Merge c2df863e5d into 07fd3e685a 2025-04-26 17:24:43 +00:00
ArthurSonzogni
c2df863e5d tmp 2025-04-26 19:24:34 +02:00
ArthurSonzogni
2a5d7646da Add publish to BCR 2025-04-26 02:38:32 +02:00
ArthurSonzogni
8e055a5a61 update workflow 2025-04-26 01:29:39 +02:00
ArthurSonzogni
378e30bef0 update workflow 2025-04-26 01:25:29 +02:00
ArthurSonzogni
2270fe628f tmp 2025-04-26 01:14:09 +02:00
ArthurSonzogni
44d25564ee Fix MSVC 2025-04-26 01:10:42 +02:00
ArthurSonzogni
a9b54106d4 Fix /utf-8 2025-04-26 00:55:47 +02:00
ArthurSonzogni
31ec197811 Set c++ standard. 2025-04-26 00:44:44 +02:00
ArthurSonzogni
3184033f4d update workdflow. 2025-04-26 00:16:41 +02:00
ArthurSonzogni
632f8032bc Update workflow. 2025-04-26 00:05:25 +02:00
ArthurSonzogni
1d7d84c155 Update workflow 2025-04-24 15:07:17 +02:00
ArthurSonzogni
fd5e5c77e5 Update bazel workflow. 2025-04-24 14:48:55 +02:00
ArthurSonzogni
c8a14f5d70 Update workflow. 2025-04-24 14:43:35 +02:00
ArthurSonzogni
321c308a98 Update workflow file. 2025-04-24 14:41:44 +02:00
ArthurSonzogni
8feac77d8c Update workflow file. 2025-04-24 14:39:15 +02:00
ArthurSonzogni
dad4a67fcb Update workflow 2025-04-24 14:34:13 +02:00
ArthurSonzogni
d6006d3475 Update workflow. 2025-04-24 14:29:21 +02:00
ArthurSonzogni
f69adb605a Update workflow 2025-04-24 14:23:23 +02:00
ArthurSonzogni
e185d6d475 Fix workflow. 2025-04-24 03:36:04 +02:00
ArthurSonzogni
f8d4880517 fix workflow. 2025-04-24 03:20:03 +02:00
ArthurSonzogni
38869c4aaa fix workflow. 2025-04-24 03:16:12 +02:00
ArthurSonzogni
4a75d49478 Fix workflow file. 2025-04-24 03:12:57 +02:00
ArthurSonzogni
c3d03dc716 Fix workflow issue. 2025-04-24 03:11:13 +02:00
ArthurSonzogni
053a1d8290 Setup bazel in workflow 2025-04-24 03:05:01 +02:00
ArthurSonzogni
45bf24f8ea Add workflow + examples + tests 2025-04-24 03:02:10 +02:00
ArthurSonzogni
f128c442cc Support Bazel
BUG:https://github.com/ArthurSonzogni/FTXUI/issues/1032
2025-04-23 19:58:34 +02:00
Arthur Sonzogni
07fd3e685a Bugfix: Avoid crash with ResizeableSplit. (#1025)
Component
---------
- Bugfix: Fix a crash with ResizeableSplit. See #1023.
  - Clamp screen size to terminal size.
  - Disallow `ResizeableSplit` with negative size.

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

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

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

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

Bug:https://github.com/ArthurSonzogni/FTXUI/issues/1017
Bug:https://github.com/ArthurSonzogni/FTXUI/issues/1019
2025-03-28 12:08:59 +01:00
ArthurSonzogni
327f43b175 v6.0.0 2025-03-27 19:19:44 +01:00
Arthur Sonzogni
5bf8ee819b Update README.md 2025-03-23 23:55:31 +01:00
Arthur Sonzogni
d5b741b2be Update README.md 2025-03-23 19:26:36 +01:00
ArthurSonzogni
b69e0f8b91 v6.0.0 2025-03-23 18:19:57 +01:00
24 changed files with 573 additions and 45 deletions

9
.bcr/README.md Normal file
View File

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

View File

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

25
.bcr/presubmit.yml Normal file
View File

@@ -0,0 +1,25 @@
# 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.
bcr_test_module:
module_path: "."
matrix:
platform: [
"debian11",
"macos",
"macos-arm64",
"ubuntu2204",
"windows",
]
bazel: [
6.x,
7.x,
8.x,
]
tasks:
run_tests:
name: "Run test module"
platform: ${{ platform }}
bazel: ${{ bazel }}
test_targets:
- "//..."

View File

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

View File

@@ -10,8 +10,41 @@ on:
- main - main
jobs: jobs:
test:
name: "Tests" test_bazel:
name: "Test Bazel"
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
compiler: gcc
- os: ubuntu-latest
compiler: llvm
- os: macos-latest
compiler: llvm
- os: macos-latest
compiler: gcc
- os: windows-latest
compiler: cl
runs-on: ${{ matrix.os }}
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
- name: "Build with Bazel"
run: bazel build ...
- name: "Tests with Bazel"
run: bazel run tests
test_cmake:
name: "Tests CMake"
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@@ -104,7 +137,7 @@ jobs:
--gcov-executable '${{ matrix.gcov_executable }}'; --gcov-executable '${{ matrix.gcov_executable }}';
- name: Windows - Test and coverage - name: Windows - Test and coverage
if: runner.os == 'Windows' && false if: runner.os == 'Windows'
working-directory: ./build working-directory: ./build
run: > run: >
OpenCppCoverage.exe OpenCppCoverage.exe
@@ -122,7 +155,9 @@ jobs:
# Create a release on new v* tags # Create a release on new v* tags
release: release:
needs: test needs:
- test_cmake
- test_bazel
if: ${{ github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v') }} if: ${{ github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v') }}
name: "Create release" name: "Create release"
runs-on: ubuntu-latest runs-on: ubuntu-latest

28
.github/workflows/publish_to_bcr.yaml vendored Normal file
View File

@@ -0,0 +1,28 @@
on:
# Run the publish workflow after a successful release.
workflow_call:
inputs:
tag_name:
required: true
type: string
# Allow manual triggering of the workflow.
workflow_dispatch:
inputs:
tag_name:
required: true
type: string
jobs:
publish:
uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@[version]
with:
tag_name: ${{ inputs.tag_name }}
# GitHub repository which is a fork of the upstream where the Pull Request will be opened.
registry_fork: ArthurSonzogni/bazel-central-registry
permissions:
attestations: write
contents: write
id-token: write
secrets:
publish_token: ${{ secrets.PUBLISH_TOKEN }}

8
.gitignore vendored
View File

@@ -20,6 +20,10 @@ out/
!flake.nix !flake.nix
!ftxui.pc.in !ftxui.pc.in
!iwyu.imp !iwyu.imp
!WORKSPACE.bazel
!BUILD.bazel
!MODULE.bazel
!.bazelrc
# .github directory: # .github directory:
!.github/**/*.yaml !.github/**/*.yaml
@@ -29,6 +33,10 @@ out/
!cmake/**/*.in !cmake/**/*.in
!cmake/**/*.cmake !cmake/**/*.cmake
# bazel directory:
!bazel/**/*.bzl
!.bcr/*
# doc directory: # doc directory:
!doc/**/Doxyfile.in !doc/**/Doxyfile.in
!doc/**/*.txt !doc/**/*.txt

255
BUILD.bazel Normal file
View File

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

View File

@@ -1,8 +1,41 @@
Changelog Changelog
========= =========
current (development) Next release (2025-04-01)
--------------------- -------------------------
### Build
- Feature: Support `bazel`. See #1032. Proposed by @kcc.
### Component
- Bugfix: Fix a crash with ResizeableSplit. See #1023.
- Clamp screen size to terminal size.
- Disallow `ResizeableSplit` with negative size.
### Dom
- Bugfix: Disallow specifying a negative size constraint. See #1023.
6.0.2 (2025-03-30)
-----
### Component
- BugFix: Fix major crash on Windows affecting all components. See #1020
- BugFix: Fix focusRelative.
6.0.1 (2025-03-28)
-----
Same as v6.0.0.
Due to a problem tag v6.0.0 was replaced. This isn't a good practice and affect
developers that started using it in the short timeframe. Submitting a new
release with the same content is the best way to fix this.
See #1017 and #1019.
6.0.0 (2025-03-23)
-----
### Component ### Component
- Feature: Add support for raw input. Allowing more keys to be detected. - Feature: Add support for raw input. Allowing more keys to be detected.
@@ -71,6 +104,10 @@ current (development)
- See `selectionStyleReset` decorator. - See `selectionStyleReset` decorator.
- Breaking change: Change how "focus"/"select" are handled. This fixes the - Breaking change: Change how "focus"/"select" are handled. This fixes the
behavior. behavior.
- Breaking change: `Component::OnRender()` becomes the method to override to
render a component. This replaces `Component::Render()` that is still in use
to call the rendering method on the children. This change allows to fix a
couple of issues around focus handling.
### Screen ### Screen
- Feature: Add `Box::IsEmpty()`. - Feature: Add `Box::IsEmpty()`.

View File

@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.12)
project(ftxui project(ftxui
LANGUAGES CXX LANGUAGES CXX
VERSION 5.0.0 VERSION 6.0.2
DESCRIPTION "C++ Functional Terminal User Interface." DESCRIPTION "C++ Functional Terminal User Interface."
) )

13
MODULE.bazel Normal file
View File

@@ -0,0 +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.0.3")
# Build deps.
bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "platforms", version = "0.0.11")
# Test deps.
bazel_dep(name = "googletest", version = "1.16.0.bcr.1")

View File

@@ -42,7 +42,7 @@ 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), vcpkg, pkgbuild, conan. * Multiple packages: CMake [FetchContent]([https://bewagner.net/programming/2020/05/02/cmake-fetchcontent/](https://cmake.org/cmake/help/latest/module/FetchContent.html)) (preferred),Bazel, vcpkg, pkgbuild, conan.
* Good 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
@@ -372,7 +372,7 @@ include(FetchContent)
FetchContent_Declare(ftxui FetchContent_Declare(ftxui
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
GIT_TAG v5.0.0 GIT_TAG v6.0.2
) )
FetchContent_GetProperties(ftxui) FetchContent_GetProperties(ftxui)
@@ -383,20 +383,19 @@ endif()
``` ```
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](...)
- [vcpkg](https://vcpkgx.com/details.html?package=ftxui) - [vcpkg](https://vcpkgx.com/details.html?package=ftxui)
- [Arch Linux PKGBUILD](https://aur.archlinux.org/packages/ftxui-git/). - [Arch Linux PKGBUILD](https://aur.archlinux.org/packages/ftxui-git/).
- [conan.io](https://conan.io/center/ftxui) - [conan.io](https://conan.io/center/ftxui)
- [openSUSE](https://build.opensuse.org/package/show/devel:libraries:c_c++/ftxui) - [openSUSE](https://build.opensuse.org/package/show/devel:libraries:c_c++/ftxui)
- -
[![Packaging status](https://repology.org/badge/vertical-allrepos/ftxui.svg)](https://repology.org/project/ftxui/versions) [![Packaging status](https://repology.org/badge/vertical-allrepos/libftxui.svg)](https://repology.org/project/libftxui/versions)
If you choose to build and link FTXUI yourself, `ftxui-component` must be first in the linking order relative to the other FTXUI libraries, i.e. 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 . . .
``` ```
## Contributors ## Contributors
<a href="https://github.com/ArthurSonzogni/FTXUI/graphs/contributors"> <a href="https://github.com/ArthurSonzogni/FTXUI/graphs/contributors">

4
WORKSPACE.bazel Normal file
View File

@@ -0,0 +1,4 @@
# Copyright 2025 Arthur Sonzogni. All rights reserved.
# Use of this source code is governed by the MIT license that can be found in
# the LICENSE file.
workspace(name = "ftxui")

94
bazel/ftxui.bzl Normal file
View File

@@ -0,0 +1,94 @@
# 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"],
})
def msvc_copts():
MSVC_COPTS = [
# Force Microsoft Visual Studio to decode sources files in UTF-8.
"/utf-8",
# Force Microsoft Visual Studio to interpret the source files as
# Unicode.
"/DUNICODE",
"/D_UNICODE",
# Fallback for Microsoft Terminal.
"/DFTXUI_MICROSOFT_TERMINAL_FALLBACK",
]
return select({
"@rules_cc//cc/compiler:msvc-cl": MSVC_COPTS,
"@rules_cc//cc/compiler:clang-cl": MSVC_COPTS,
"//conditions:default": [],
})
def pthread_linkopts():
return select({
# With MSVC, threading is already built-in (you don't need -pthread.
"@rules_cc//cc/compiler:msvc-cl": [],
"@rules_cc//cc/compiler:clang-cl": [],
"@rules_cc//cc/compiler:clang": ["-pthread"],
"@rules_cc//cc/compiler:gcc": ["-pthread"],
"//conditions:default": ["-pthread"],
})
def ftxui_cc_library(
name,
srcs,
hdrs,
linkopts = [],
deps = []):
cc_library(
name = name,
srcs = srcs,
hdrs = hdrs,
linkopts = linkopts,
deps = deps,
strip_include_prefix = "",
include_prefix = "",
includes = [
"include",
"src",
],
copts = cpp17() + msvc_copts(),
visibility = ["//visibility:public"],
)
def generate_examples():
cpp_files = native.glob(["examples/**/*.cpp"])
for src in cpp_files:
# Skip failing examples due to the color_info_sorted_2d.ipp dependency.
if src == "examples/component/homescreen.cpp" or \
src == "examples/dom/color_info_palette256.cpp" or \
src == "examples/dom/color_gallery.cpp":
continue
# Turn "examples/component/button.cpp" → "example_component_button"
name = src.replace("/", "_").replace(".cpp", "")
native.cc_binary(
name = name,
srcs = [src],
deps = ["//:component"],
copts = cpp20() + msvc_copts(),
)

View File

@@ -19,7 +19,7 @@ using namespace ftxui;
int main() { int main() {
auto screen = ScreenInteractive::TerminalOutput(); auto screen = ScreenInteractive::TerminalOutput();
std::array<int, 30> values; std::array<int, 30> values;
for (int i = 0; i < values.size(); ++i) { for (size_t i = 0; i < values.size(); ++i) {
values[i] = 50 + 20 * std::sin(i * 0.3); values[i] = 50 + 20 * std::sin(i * 0.3);
} }

View File

@@ -12,7 +12,6 @@
int main() { int main() {
using namespace ftxui; using namespace ftxui;
int saturation = 255;
Elements red_line; Elements red_line;
Elements green_line; Elements green_line;
Elements blue_line; Elements blue_line;

View File

@@ -10,6 +10,7 @@
#include <memory> // for shared_ptr #include <memory> // for shared_ptr
#include <string> // for operator<<, string #include <string> // for operator<<, string
#include <thread> // for sleep_for #include <thread> // for sleep_for
#include <utility> // for ignore
#include <vector> // for vector #include <vector> // for vector
#include "ftxui/dom/node.hpp" // for Render #include "ftxui/dom/node.hpp" // for Render
@@ -49,6 +50,7 @@ int main() {
std::string reset_position; std::string reset_position;
for (int i = 0;; ++i) { for (int i = 0;; ++i) {
std::ignore = i;
auto document = hbox({ auto document = hbox({
vbox({ vbox({
graph(std::ref(my_graph)), graph(std::ref(my_graph)),

View File

@@ -266,7 +266,7 @@ TEST(MenuTest, MenuEntryIndex) {
menu->OnEvent(Event::ArrowDown); menu->OnEvent(Event::ArrowDown);
menu->OnEvent(Event::ArrowDown); menu->OnEvent(Event::ArrowDown);
menu->OnEvent(Event::Return); menu->OnEvent(Event::Return);
for (int index = 0; index < menu->ChildCount(); index++) { for (size_t index = 0; index < menu->ChildCount(); index++) {
EXPECT_EQ(menu->ChildAt(index)->Index(), index); EXPECT_EQ(menu->ChildAt(index)->Index(), index);
} }
} }

View File

@@ -77,16 +77,16 @@ class ResizableSplitBase : public ComponentBase {
switch (options_->direction()) { switch (options_->direction()) {
case Direction::Left: case Direction::Left:
options_->main_size() = event.mouse().x - box_.x_min; options_->main_size() = std::max(0, event.mouse().x - box_.x_min);
return true; return true;
case Direction::Right: case Direction::Right:
options_->main_size() = box_.x_max - event.mouse().x; options_->main_size() = std::max(0, box_.x_max - event.mouse().x);
return true; return true;
case Direction::Up: case Direction::Up:
options_->main_size() = event.mouse().y - box_.y_min; options_->main_size() = std::max(0, event.mouse().y - box_.y_min);
return true; return true;
case Direction::Down: case Direction::Down:
options_->main_size() = box_.y_max - event.mouse().y; options_->main_size() = std::max(0, box_.y_max - event.mouse().y);
return true; return true;
} }

View File

@@ -34,6 +34,7 @@
#include "ftxui/dom/requirement.hpp" // for Requirement #include "ftxui/dom/requirement.hpp" // for Requirement
#include "ftxui/screen/pixel.hpp" // for Pixel #include "ftxui/screen/pixel.hpp" // for Pixel
#include "ftxui/screen/terminal.hpp" // for Dimensions, Size #include "ftxui/screen/terminal.hpp" // for Dimensions, Size
#include "ftxui/screen/util.hpp" // for util::clamp
#if defined(_WIN32) #if defined(_WIN32)
#define DEFINE_CONSOLEV2_PROPERTIES #define DEFINE_CONSOLEV2_PROPERTIES
@@ -917,15 +918,15 @@ void ScreenInteractive::Draw(Component component) {
break; break;
case Dimension::TerminalOutput: case Dimension::TerminalOutput:
dimx = terminal.dimx; dimx = terminal.dimx;
dimy = document->requirement().min_y; dimy = util::clamp(document->requirement().min_y, 0, terminal.dimy);
break; break;
case Dimension::Fullscreen: case Dimension::Fullscreen:
dimx = terminal.dimx; dimx = terminal.dimx;
dimy = terminal.dimy; dimy = terminal.dimy;
break; break;
case Dimension::FitComponent: case Dimension::FitComponent:
dimx = std::min(document->requirement().min_x, terminal.dimx); dimx = util::clamp(document->requirement().min_x, 0, terminal.dimx);
dimy = std::min(document->requirement().min_y, terminal.dimy); dimy = util::clamp(document->requirement().min_y, 0, terminal.dimy);
break; break;
} }

View File

@@ -36,7 +36,7 @@ Decorator focusPositionRelative(float x, float y) {
void ComputeRequirement() override { void ComputeRequirement() override {
NodeDecorator::ComputeRequirement(); NodeDecorator::ComputeRequirement();
requirement_.focused.enabled = false; requirement_.focused.enabled = true;
requirement_.focused.node = this; requirement_.focused.node = this;
requirement_.focused.box.x_min = int(float(requirement_.min_x) * x_); requirement_.focused.box.x_min = int(float(requirement_.min_x) * x_);
requirement_.focused.box.y_min = int(float(requirement_.min_y) * y_); requirement_.focused.box.y_min = int(float(requirement_.min_y) * y_);

View File

@@ -125,6 +125,8 @@ void Render(Screen& screen, Node* node, Selection& selection) {
node->Select(selection); node->Select(selection);
} }
if (node->requirement().focused.enabled
#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
// Setting the cursor to the right position allow folks using CJK (China, // Setting the cursor to the right position allow folks using CJK (China,
// Japanese, Korean, ...) characters to see their [input method editor] // Japanese, Korean, ...) characters to see their [input method editor]
// displayed at the right location. See [issue]. // displayed at the right location. See [issue].
@@ -136,16 +138,14 @@ void Render(Screen& screen, Node* node, Selection& selection) {
// https://github.com/ArthurSonzogni/FTXUI/issues/2#issuecomment-505282355 // https://github.com/ArthurSonzogni/FTXUI/issues/2#issuecomment-505282355
// //
// Unfortunately, Microsoft terminal do not handle properly hiding the // Unfortunately, Microsoft terminal do not handle properly hiding the
// cursor. Instead the character under the cursor is hidden, which is a big // cursor. Instead the character under the cursor is hidden, which is a
// problem. As a result, we can't enable setting cursor to the right // big problem. As a result, we can't enable setting cursor to the right
// location. It will be displayed at the bottom right corner. // location. It will be displayed at the bottom right corner.
// See: // See:
// https://github.com/microsoft/terminal/issues/1203 // https://github.com/microsoft/terminal/issues/1203
// https://github.com/microsoft/terminal/issues/3093 // https://github.com/microsoft/terminal/issues/3093
if (node->requirement().focused.enabled &&
#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK) node->requirement().focused.cursor_shape != Screen::Cursor::Shape::Hidden
||
node->requirement().focused.cursor_shape == Screen::Cursor::Shape::Hidden
#endif #endif
) { ) {
screen.SetCursor(Screen::Cursor{ screen.SetCursor(Screen::Cursor{

View File

@@ -127,8 +127,6 @@ TEST(SelectionTest, SelectionOnChangeSquashedEvents) {
} }
TEST(SelectionTest, StyleSelection) { TEST(SelectionTest, StyleSelection) {
int selectionChangeCounter = 0;
auto element = hbox({ auto element = hbox({
text("Lorem "), text("Lorem "),
text("ipsum") | selectionColor(Color::Red), text("ipsum") | selectionColor(Color::Red),

View File

@@ -19,7 +19,7 @@ class Size : public Node {
: Node(unpack(std::move(child))), : Node(unpack(std::move(child))),
direction_(direction), direction_(direction),
constraint_(constraint), constraint_(constraint),
value_(value) {} value_(std::max(0, value)) {}
void ComputeRequirement() override { void ComputeRequirement() override {
Node::ComputeRequirement(); Node::ComputeRequirement();