mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-06-24 08:01:13 +08:00
Merge 1d7d84c155
into 07fd3e685a
This commit is contained in:
commit
15052d26ef
55
.github/workflows/build.yaml
vendored
55
.github/workflows/build.yaml
vendored
@ -10,8 +10,55 @@ on:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: "Tests"
|
||||
|
||||
test_bazel:
|
||||
name: "Test Bazel"
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: Linux GCC
|
||||
os: ubuntu-latest
|
||||
compiler: gcc
|
||||
|
||||
- name: Linux Clang
|
||||
os: ubuntu-latest
|
||||
compiler: llvm
|
||||
|
||||
- name: MacOS clang
|
||||
os: macos-latest
|
||||
compiler: llvm
|
||||
|
||||
- name: Windows MSVC
|
||||
os: windows-latest
|
||||
compiler: cl
|
||||
|
||||
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' )}}
|
||||
|
||||
- name: "Install Bazel"
|
||||
uses: bazel-contrib/setup-bazel@0.14.0
|
||||
|
||||
# Need on macos. See https://github.com/bazelbuild/bazel/issues/21718
|
||||
- name: Clean Bazel cache
|
||||
run: bazel clean --expunge
|
||||
|
||||
- name: "Build with Bazel"
|
||||
run: bazel build ...
|
||||
|
||||
- name: "Tests with Bazel"
|
||||
run: bazel run tests
|
||||
|
||||
test_cmake:
|
||||
name: "Tests CMake"
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@ -122,7 +169,9 @@ jobs:
|
||||
|
||||
# Create a release on new v* tags
|
||||
release:
|
||||
needs: test
|
||||
needs:
|
||||
- test_cmake
|
||||
- test_bazel
|
||||
if: ${{ github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v') }}
|
||||
name: "Create release"
|
||||
runs-on: ubuntu-latest
|
||||
|
7
.gitignore
vendored
7
.gitignore
vendored
@ -20,6 +20,10 @@ out/
|
||||
!flake.nix
|
||||
!ftxui.pc.in
|
||||
!iwyu.imp
|
||||
!WORKSPACE.bazel
|
||||
!BUILD.bazel
|
||||
!MODULE.bazel
|
||||
!.bazelrc
|
||||
|
||||
# .github directory:
|
||||
!.github/**/*.yaml
|
||||
@ -29,6 +33,9 @@ out/
|
||||
!cmake/**/*.in
|
||||
!cmake/**/*.cmake
|
||||
|
||||
# bazel directory:
|
||||
!bazel/**/*.bzl
|
||||
|
||||
# doc directory:
|
||||
!doc/**/Doxyfile.in
|
||||
!doc/**/*.txt
|
||||
|
251
BUILD.bazel
Normal file
251
BUILD.bazel
Normal file
@ -0,0 +1,251 @@
|
||||
# Copyright 2025 Arthur Sonzogni. All rights reserved.
|
||||
# Use of this source code is governed by the MIT license that can be found in
|
||||
# the LICENSE file.
|
||||
|
||||
# TODO:
|
||||
# - 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", "generate_examples")
|
||||
|
||||
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 = ["-lpthread"],
|
||||
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",
|
||||
],
|
||||
copts = ["-std=c++20"],
|
||||
includes = [
|
||||
"include",
|
||||
"src",
|
||||
],
|
||||
deps = [
|
||||
"//:ftxui",
|
||||
"@googletest//:gtest_main",
|
||||
],
|
||||
)
|
||||
|
||||
generate_examples()
|
@ -1,8 +1,12 @@
|
||||
Changelog
|
||||
=========
|
||||
|
||||
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.
|
||||
|
9
MODULE.bazel
Normal file
9
MODULE.bazel
Normal file
@ -0,0 +1,9 @@
|
||||
# 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")
|
1
WORKSPACE.bazel
Normal file
1
WORKSPACE.bazel
Normal file
@ -0,0 +1 @@
|
||||
workspace(name = "ftxui")
|
44
bazel/ftxui.bzl
Normal file
44
bazel/ftxui.bzl
Normal file
@ -0,0 +1,44 @@
|
||||
# ftxui_common.bzl
|
||||
|
||||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
|
||||
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 = ["-std=c++17"],
|
||||
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"],
|
||||
)
|
@ -19,7 +19,7 @@ using namespace ftxui;
|
||||
int main() {
|
||||
auto screen = ScreenInteractive::TerminalOutput();
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
int main() {
|
||||
using namespace ftxui;
|
||||
|
||||
int saturation = 255;
|
||||
Elements red_line;
|
||||
Elements green_line;
|
||||
Elements blue_line;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <memory> // for shared_ptr
|
||||
#include <string> // for operator<<, string
|
||||
#include <thread> // for sleep_for
|
||||
#include <utility> // for ignore
|
||||
#include <vector> // for vector
|
||||
|
||||
#include "ftxui/dom/node.hpp" // for Render
|
||||
@ -49,6 +50,7 @@ int main() {
|
||||
|
||||
std::string reset_position;
|
||||
for (int i = 0;; ++i) {
|
||||
std::ignore = i;
|
||||
auto document = hbox({
|
||||
vbox({
|
||||
graph(std::ref(my_graph)),
|
||||
|
@ -266,7 +266,7 @@ TEST(MenuTest, MenuEntryIndex) {
|
||||
menu->OnEvent(Event::ArrowDown);
|
||||
menu->OnEvent(Event::ArrowDown);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -127,8 +127,6 @@ TEST(SelectionTest, SelectionOnChangeSquashedEvents) {
|
||||
}
|
||||
|
||||
TEST(SelectionTest, StyleSelection) {
|
||||
int selectionChangeCounter = 0;
|
||||
|
||||
auto element = hbox({
|
||||
text("Lorem "),
|
||||
text("ipsum") | selectionColor(Color::Red),
|
||||
|
Loading…
Reference in New Issue
Block a user