Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V5.1.0 #976

Open
wants to merge 47 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
19ffc37
Feature: `hscroll_indicator` (#753)
ArthurSonzogni Sep 26, 2023
cc998af
Scrollbar coloring (#755)
clement-roblot Oct 2, 2023
37259ac
fix the doxygen documentation by moving comments at the right place (…
benoitdudu Oct 19, 2023
19dd2af
Fix Input onchange not called (#776)
chrysante Nov 11, 2023
64436fc
Checkbox button debounce (#774)
clement-roblot Nov 11, 2023
d6918c6
feature: allow fullscreen without alternative screen (#777)
ArthurSonzogni Nov 11, 2023
4dd9d4b
Fix default for ScreenInteractive::Fullscreen()
ArthurSonzogni Nov 19, 2023
6618d09
Restore cursor shape on exit. (#793)
ArthurSonzogni Dec 17, 2023
1d797ee
Restore cursor shape on exit. (#793) (#794)
ArthurSonzogni Dec 17, 2023
aceabdb
Add missing Checkbox() implementation (#796)
ParticleG Dec 23, 2023
2759cfa
ftxui_set_options: properly check the current compiler. (#802)
nyyakko Jan 8, 2024
6039aed
Button: invoke `on_click` at the end. (#807)
ArthurSonzogni Jan 10, 2024
c8c3f83
Make Checkbox take focus when clicked (#810)
jason-e Jan 17, 2024
fed24da
Update mainpage.md
ArthurSonzogni Jan 25, 2024
f81c5d9
Revert change to button example. (#835)
ArthurSonzogni Mar 30, 2024
d8617ec
Problem with setting the cursor position on the right screen edge whe…
jglanycon Apr 3, 2024
3b6e0d5
Feature: Dropdown options with callback (#826)
jeptechnology Apr 6, 2024
231c1df
Fix minor compile error.
ArthurSonzogni Apr 7, 2024
57ebf6c
Fix ResizableSplit handling keyboard navigation incorrectly (#842)
na-trium-144 Apr 18, 2024
a006bca
Separate a reusable Image class from Screen (#834)
Epixu Apr 27, 2024
03e6685
Flush before applying a new configuration. (#848)
ArthurSonzogni Apr 27, 2024
2a69cd7
Prefer Exit() over OnExit() (#847)
ClancyWalters Apr 27, 2024
9beb235
Apply clang-tidy.
ArthurSonzogni Apr 28, 2024
9b6c4a7
Allow user to specify window element border. (#849)
hexmarsh Apr 28, 2024
5daedf7
Enable raw keyboard input (#832)
jglanycon Apr 28, 2024
e3eb8b1
Fix `Menu` focus. (#850)
ArthurSonzogni Apr 28, 2024
343e3ab
Generate compile commands for clangd. (#855)
ArthurSonzogni May 1, 2024
306d1b6
Update flex.cpp (#860)
cuppajoeman May 6, 2024
abddaa0
Update homescreen.cpp (#859)
cuppajoeman May 6, 2024
1b2017e
Update index.html (#858)
cuppajoeman May 6, 2024
3a51d78
Dropdown: Fix title not updated.
ArthurSonzogni May 13, 2024
697671d
Dropdown: Fix title not updated. (#851)
ArthurSonzogni May 15, 2024
43cf8e7
Solve issues with atomic copy (#867)
felrock May 26, 2024
67984b2
Fix Color::HSV(h,0,v)
ArthurSonzogni Jun 2, 2024
128e721
Color alpha support. (#884)
ArthurSonzogni Jun 13, 2024
b05ff6a
add missing include guard for screen/pixel.hpp (#890)
LiAuTraver Jun 27, 2024
f35dc7b
Added -fPIC compile option (#913)
pbosetti Aug 11, 2024
995a33a
Table: support initializer list constructor. (#915)
ArthurSonzogni Aug 13, 2024
0855d00
Apply Clang-tidy (#918)
ArthurSonzogni Aug 16, 2024
6a790ed
Quickfix
ArthurSonzogni Aug 16, 2024
d5099af
Fix CQ failures.
ArthurSonzogni Aug 17, 2024
024ce39
Add `SliderWithCallback` component (#938)
mikolajlubiak Oct 29, 2024
8e25a75
Allow a Dimension::Fit to extend beyond the terminal maximum height (…
LordWhiro Nov 7, 2024
aae4e55
Fixed typo on border (#956)
BrianAnakPintar Nov 20, 2024
a015d8b
Clear terminal output of interactive screen on resize if alternate sc…
dangooddd Nov 27, 2024
6900283
Fix: Properly changing window title text color #940 (#961)
Chessom Dec 1, 2024
634870f
Avoid breaking changes.
ArthurSonzogni Dec 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Checks: "*,
-android-*,
-bugprone-easily-swappable-parameters,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-pro-type-union-access,
-fuchsia-*,
-google-*,
-hicpp-signed-bitwise,
Expand All @@ -26,6 +27,7 @@ Checks: "*,
-readability-simplify-boolean-expr,
-readability-static-accessed-through-instance,
-readability-use-anyofallof,
-readability-avoid-nested-conditional-operator,
-zircon-*,
"
WarningsAsErrors: ''
Expand Down
24 changes: 14 additions & 10 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: Build

on:
create:
tags:
-v*
push:
branches:
- main
Expand All @@ -28,10 +26,11 @@ jobs:
compiler: llvm
gcov_executable: "llvm-cov gcov"

- name: MacOS clang
os: macos-latest
compiler: llvm
gcov_executable: "llvm-cov gcov"
# https://github.com/aminya/setup-cpp/issues/246
#- name: MacOS clang
#os: macos-latest
#compiler: llvm
#gcov_executable: "llvm-cov gcov"

- name: Windows MSVC
os: windows-latest
Expand All @@ -44,7 +43,7 @@ jobs:
id: cpu-cores

- name: "Checkout repository"
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: "Setup Cpp"
uses: aminya/setup-cpp@v1
Expand Down Expand Up @@ -79,11 +78,16 @@ jobs:
cmake
--build ./build

- name: Unix - Test and coverage
- name: Unix - Test
if: runner.os != 'Windows'
working-directory: ./build
run: >
ctest -C Debug --rerun-failed --output-on-failure;

- name: Unix - coverage
if: runner.os != 'Windows'
working-directory: ./build
run: >
gcovr
-j ${{env.nproc}}
--delete
Expand Down Expand Up @@ -155,7 +159,7 @@ jobs:
id: cpu-cores

- name: "Checkout repository"
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: "Install cmake"
uses: lukka/get-cmake@latest
Expand Down Expand Up @@ -186,7 +190,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: "Install cmake"
uses: lukka/get-cmake@latest
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
*
!*/

# Ignore build directories generated by default MSVC CMake integration
# (otherwise causes terribly slow indexing)
out/

# Allowed top-level files:
!.clang-format
!.clang-tidy
Expand Down
49 changes: 49 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,57 @@ current (development)
---------------------

### Component
- Feature: Add support for raw input. Allowing more keys to be detected.
- Feature: Add `ScreenInteractive::ForceHandleCtrlC(false)` to allow component
to fully override the default `Ctrl+C` handler.
- Feature: Add `ScreenInteractive::ForceHandleCtrlZ(false)` to allow component
to fully override the default `Ctrl+Z` handler.
- Feature: Add `Mouse::WeelLeft` and `Mouse::WeelRight` events on supported
terminals.
- Feature: Add `Event::DebugString()`.
- Feature: Add support for `Input`'s insert mode. Add `InputOption::insert`
option. Added by @mingsheng13.
- Feature: Add `DropdownOption` to configure the dropdown. See #826.
- Bugfix/Breaking change: `Mouse transition`:
- Detect when the mouse move, as opposed to being pressed.
The Mouse::Moved motion was added.
- Dragging the mouse with the left button pressed now avoids activating
multiple checkboxes.
- A couple of components are now activated when the mouse is pressed,
as opposed to being released.
This fixes: https://github.com/ArthurSonzogni/FTXUI/issues/773
This fixes: https://github.com/ArthurSonzogni/FTXUI/issues/792
- Bugfix: mouse.control is now reported correctly.
- Feature: Add `ScreenInteractive::FullscreenPrimaryScreen()`. This allows
displaying a fullscreen component on the primary screen, as opposed to the
alternate screen.
- Bugfix: `Input` `onchange` was not called on backspace or delete key.
Fixed by @chrysante in chrysante in PR #776.
- Bugfix: Propertly restore cursor shape on exit. See #792.
- Bugfix: Fix cursor position in when in the last column. See #831.
- Bugfix: Fix `ResizeableSplit` keyboard navigation. Fixed by #842.
- Bugfix: Fix `Menu` focus. See #841
- Feature: Add `SliderOption::on_change`. This allows to set a callback when the
slider value changes. See #938.

### Dom
- Feature: Add `hscroll_indicator`. It display an horizontal indicator
reflecting the current scroll position. Proposed by @ibrahimnasson in
[issue 752](https://github.com/ArthurSonzogni/FTXUI/issues/752)
- Feature: Add `extend_beyond_screen` option to `Dimension::Fit(..)`, allowing
the element to be larger than the screen. Proposed by @LordWhiro. See #572 and
#949.

### Screen
- Feature: Add `Box::IsEmpty()`.
- Feature: Color transparency
- Add `Color::RGBA(r,g,b,a)`.
- Add `Color::HSVA(r,g,b,a)`.
- Add `Color::Blend(Color)`.
- Add `Color::IsOpaque()`

### Util
- Feature: Support arbitrary `Adapter` for `ConstStringListRef`. See #843.

### Build
- Support for cmake's "unity/jumbo" builds. Fixed by @ClausKlein.
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,22 @@ else()
${FTXUI_MICROSOFT_TERMINAL_FALLBACK_HELP_TEXT} OFF)
endif()

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include(cmake/ftxui_message.cmake)

add_library(screen
include/ftxui/screen/box.hpp
include/ftxui/screen/color.hpp
include/ftxui/screen/color_info.hpp
include/ftxui/screen/image.hpp
include/ftxui/screen/pixel.hpp
include/ftxui/screen/screen.hpp
include/ftxui/screen/string.hpp
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/terminal.cpp
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ A simple cross-platform C++ library for terminal based user interfaces!

## Feature
* Functional style. Inspired by
[[1]](https://hackernoon.com/building-reactive-terminal-interfaces-in-c-d392ce34e649?gi=d9fb9ce35901)
[1](https://hackernoon.com/building-reactive-terminal-interfaces-in-c-d392ce34e649?gi=d9fb9ce35901)
and [React](https://reactjs.org/)
* Simple and elegant syntax (in my opinion)
* Keyboard & mouse navigation.
Expand Down
8 changes: 7 additions & 1 deletion cmake/ftxui_set_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,16 @@ function(ftxui_set_options library)

# Force Microsoft Visual Studio to decode sources files in UTF-8. This applies
# to the library and the library users.
if (MSVC)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(${library} PUBLIC "/utf-8")
endif()

# CMake does automatically add -fPIC when linking a shared library, but it
# does not add it when linking a static library. This is a problem when the
# static library is later linked into a shared library.
# Doing it helps some users.
set_property(TARGET ${library} PROPERTY POSITION_INDEPENDENT_CODE ON)

# Add as many warning as possible:
if (WIN32)
if (MSVC)
Expand Down
1 change: 1 addition & 0 deletions cmake/ftxui_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ add_executable(ftxui-tests
src/ftxui/component/menu_test.cpp
src/ftxui/component/modal_test.cpp
src/ftxui/component/radiobox_test.cpp
src/ftxui/util/ref_test.cpp
src/ftxui/component/receiver_test.cpp
src/ftxui/component/resizable_split_test.cpp
src/ftxui/component/screen_interactive_test.cpp
Expand Down
1 change: 1 addition & 0 deletions doc/mainpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE)
FetchContent_Declare(ftxui
GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui
# Important: Specify a GIT_TAG XXXXX here.
GIT_TAG main
)

FetchContent_GetProperties(ftxui)
Expand Down
2 changes: 2 additions & 0 deletions examples/component/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ example(collapsible)
example(composition)
example(custom_loop)
example(dropdown)
example(dropdown_custom)
example(flexbox_gallery)
example(focus)
example(focus_cursor)
Expand All @@ -25,6 +26,7 @@ example(menu2)
example(menu_entries)
example(menu_entries_animated)
example(menu_in_frame)
example(menu_in_frame_horizontal)
example(menu_multiple)
example(menu_style)
example(menu_underline_animated_gallery)
Expand Down
33 changes: 30 additions & 3 deletions examples/component/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,40 @@

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 Style() {
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;

// clang-format off
auto btn_dec_01 = Button("-1", [&] { value += 1; }, Style());
auto btn_inc_01 = Button("+1", [&] { value -= 1; }, Style());
auto btn_dec_10 = Button("-10", [&] { value -= 10; }, Style());
auto btn_inc_10 = Button("+10", [&] { value += 10; }, Style());
// clang-format on

// The tree of components. This defines how to navigate using the keyboard.
auto buttons = Container::Horizontal({
Button("Decrease", [&] { value--; }),
Button("Increase", [&] { value++; }),
// The selected `row` is shared to get a grid layout.
int row = 0;
auto buttons = Container::Vertical({
Container::Horizontal({btn_dec_01, btn_inc_01}, &row) | flex,
Container::Horizontal({btn_dec_10, btn_inc_10}, &row) | flex,
});

// Modify the way to render them on screen:
Expand Down
104 changes: 104 additions & 0 deletions examples/component/dropdown_custom.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.
#include <string> // for basic_string, string, allocator
#include <vector> // for vector

#include "ftxui/component/captured_mouse.hpp" // for ftxui
#include "ftxui/component/component.hpp" // for Dropdown, Horizontal, Vertical
#include "ftxui/component/screen_interactive.hpp" // for ScreenInteractive

int main() {
using namespace ftxui;

std::vector<std::string> entries = {
"tribute", "clearance", "ally", "bend", "electronics",
"module", "era", "cultural", "sniff", "nationalism",
"negotiation", "deliver", "figure", "east", "tribute",
"clearance", "ally", "bend", "electronics", "module",
"era", "cultural", "sniff", "nationalism", "negotiation",
"deliver", "figure", "east", "tribute", "clearance",
"ally", "bend", "electronics", "module", "era",
"cultural", "sniff", "nationalism", "negotiation", "deliver",
"figure", "east",
};

auto dropdown_1 = Dropdown({
.radiobox = {.entries = &entries},
.transform =
[](bool open, Element checkbox, Element radiobox) {
if (open) {
return vbox({
checkbox | inverted,
radiobox | vscroll_indicator | frame |
size(HEIGHT, LESS_THAN, 10),
filler(),
});
}
return vbox({
checkbox,
filler(),
});
},
});

auto dropdown_2 = Dropdown({
.radiobox = {.entries = &entries},
.transform =
[](bool open, Element checkbox, Element radiobox) {
if (open) {
return vbox({
checkbox | inverted,
radiobox | vscroll_indicator | frame |
size(HEIGHT, LESS_THAN, 10) | bgcolor(Color::Blue),
filler(),
});
}
return vbox({
checkbox | bgcolor(Color::Blue),
filler(),
});
},
});

auto dropdown_3 = Dropdown({
.radiobox =
{
.entries = &entries,
.transform =
[](const EntryState& s) {
auto t = text(s.label) | borderEmpty;
if (s.active) {
t |= bold;
}
if (s.focused) {
t |= inverted;
}
return t;
},
},
.transform =
[](bool open, Element checkbox, Element radiobox) {
checkbox |= borderEmpty;
if (open) {
return vbox({
checkbox | inverted,
radiobox | vscroll_indicator | frame |
size(HEIGHT, LESS_THAN, 20) | bgcolor(Color::Red),
filler(),
});
}
return vbox({
checkbox | bgcolor(Color::Red),
filler(),
});
},
});

auto screen = ScreenInteractive::FitComponent();
screen.Loop(Container::Horizontal({
dropdown_1,
dropdown_2,
dropdown_3,
}));
}
Loading