Commit Graph

324 Commits

Author SHA1 Message Date
Arthur Sonzogni
1ff894f6f5
Address @tusharpm comments. (#178)
@tusharpm let two comments in:
https://github.com/ArthurSonzogni/FTXUI/pull/175
but this already landed in:
https://github.com/ArthurSonzogni/FTXUI/pull/173

Address them here.
2021-08-08 08:49:46 +02:00
Arthur Sonzogni
d197e2f4fb
Switch to rounded borders. (#175)
They are nicer.
It would be nice supporting a way for FTXUI to let the user chose what
they prefer instead.
2021-08-07 22:30:55 +02:00
Arthur Sonzogni
3f005d7715
Add focusable Renderer. (#173) 2021-08-06 20:32:33 +02:00
Arthur Sonzogni
26e26fd41a
Add non focusable components. (#172) 2021-08-05 22:40:40 +02:00
Tushar Maheshwari
49e8cc57d3
Extract common struct Dimensions from Terminal (#171)
- Convert Dimension to namespace to allow defining Fit method from dom.
- Use Dimensions extracted from Terminal as replacement struct.
- Convert Terminal to namespace as it only defines static members.
- Remove dom references from screen library (circular dependency).
2021-08-02 23:19:29 +02:00
Tushar Maheshwari
7f95d59954
Deduplicate logic in ComponentBase members (#162)
- Invoke DetachAllChildren from ~ComponentBase
- Define Focused using Active
- Compact TakeFocus loop code
- const-correctness for Parent, Active and Focused
2021-07-21 00:37:44 +02:00
Tushar Maheshwari
09805e5e86
Miscellaneous refactoring (#160)
* Reorganize ContainerBase

- Reduce Container overloads using default arguments
- Extract member function pointers to virtual functions
- Separate classes for Vertical, Horizontal and Tab containers

* Collect unpack from NodeDecorator subclasses

* Reduce redundant expansion for aliases
2021-07-20 09:59:47 +02:00
Arthur Sonzogni
210e8c5863
Add general fuzzer. (#159) 2021-07-17 15:53:25 +02:00
Tushar Maheshwari
21d746e858
Remove explicit default destructors (#157)
From CppCoreGuidelines:

Rule of Zero: C.20: If you can avoid defining default operations, do.
C.52: Use inheriting constructors to import constructors into a derived class that does not need further explicit initialization.
DRY forward and using declarations.
Miscellaneous:

Fix format.sh to output examples with normalised paths in sorted order.

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2021-07-17 12:02:08 +02:00
Arthur Sonzogni
b3a333b417
Add support for password for input element. (#158)
This fixes:
https://github.com/ArthurSonzogni/FTXUI/issues/139

CC:@Creapermann
2021-07-17 10:36:50 +02:00
Arthur Sonzogni
a56bb50807
Fix compilation errors. (#155) 2021-07-15 22:45:10 +02:00
Felix Heitmann
c34494ce26
Allows components to remove a child or access to children in general (#152)
Allows components to remove a child or access to children in general.

Co-authored-by: Felix Heitmann <fheitmann@se-gpu-03.intern.plath.de>
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2021-07-15 15:29:33 +02:00
Arthur Sonzogni
9b7ddb1130
Resolve compile error on cygwin. (#151)
This should solve issue:
https://github.com/ArthurSonzogni/FTXUI/issues/149
2021-07-14 14:41:31 +02:00
ArthurSonzogni
9820832fea Improve the documentation. 2021-07-11 12:23:42 +02:00
ArthurSonzogni
5c4cd1add1 Execute IWYU 2021-07-11 12:23:42 +02:00
ArthurSonzogni
7f514ff41c Remove toggle.hpp 2021-07-11 12:23:42 +02:00
ArthurSonzogni
bead2134d6 Remove radiobox.hpp 2021-07-11 12:23:42 +02:00
ArthurSonzogni
d5cb4648d2 Remove menu.hpp 2021-07-11 12:23:42 +02:00
ArthurSonzogni
0ca7da630b Remove container.hpp 2021-07-11 12:23:42 +02:00
ArthurSonzogni
26db8228f9 Remove input.hpp 2021-07-11 12:23:42 +02:00
ArthurSonzogni
7ee6edfd1f Remove checkbox.hpp 2021-07-11 12:23:42 +02:00
ArthurSonzogni
e66ebe5443 Remove button.hpp 2021-07-11 12:23:42 +02:00
ArthurSonzogni
f53dc139e9 Add documentation for options. 2021-07-11 12:23:42 +02:00
ArthurSonzogni
fac373494d Add option for Toggle. 2021-07-11 12:23:42 +02:00
ArthurSonzogni
ae6473363d Add option for radiobox 2021-07-11 12:23:42 +02:00
ArthurSonzogni
33b3d1c7ab Add option for input. 2021-07-11 12:23:42 +02:00
ArthurSonzogni
2b7daf061f Add options for checkbox. 2021-07-11 12:23:42 +02:00
ArthurSonzogni
359100ca73 Add option for Button. 2021-07-11 12:23:42 +02:00
ArthurSonzogni
cd84b187b3 Introduce Options and use them for Menu.
Introduce Options for components. This allows me to add new features,
without updating functions signatures.
2021-07-11 12:23:42 +02:00
Arthur Sonzogni
81b428af5a
Implement Fallback for microsoft's terminals. (#138)
I finally got access to a computer using the Microsoft's Windows OS.
That's the opportunity to find and mitigate all the problems
encountered. This patch:

1. Introduce an option and a C++ definition to enable fallback for
   Microsoft's terminal emulators. This allows me to see/test the
   Microsoft output from Linux. This also allows Windows users to remove
   the fallback and target non Microsoft terminals on Windows if needed.

2. Microsoft's terminal suffer from a race condition bug when reporting
   the cursor position:
   https://github.com/microsoft/terminal/pull/7583.
   The mitigation is not to ask for the cursor position in fullscreen
   mode where it isn't really needed and request it less often.
   This fixes: https://github.com/ArthurSonzogni/FTXUI/issues/136

3. Microsoft's terminal do not handle properly hidding the cursor. Instead
   the character under the cursor is hidden, which is a big problem. As
   a result, we don't enable setting the cursor to the best position for
   [input method editors](https://en.wikipedia.org/wiki/Input_method),
   It will be displayed at the bottom right corner.
   See:
   - https://github.com/microsoft/terminal/issues/1203
   - https://github.com/microsoft/terminal/issues/3093

4. Microsoft's terminals do not provide a way to query if they support
   colors. As a fallback, assume true colors is supported.
   See issue:
   - https://github.com/microsoft/terminal/issues/1040
   This mitigates:
   - https://github.com/ArthurSonzogni/FTXUI/issues/135

5. The "cmd" on Windows do not properly report its dimension. Powershell
   works correctly. As a fallback, use a 80x80 size instead of 0x0.

6. There are several dom elements and component displayed incorrectly,
   because the font used is missing several unicode glyph. Use
   alternatives or less detailled one as a fallback.
2021-07-04 17:38:31 +02:00
Shreyas Atre
bd21cac2b6
Menu of components (#131)
Allow Container::Vertical and Container::Horizontal to have an
external selector, similar to Container::Tab.

This is useful for implementing a menu of menu.

Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2021-06-27 17:53:17 +02:00
Arthur Sonzogni
8e98928c0c
Support combining characters. (#121)
Modify the ftxui::Pixel. Instead of storing a wchar, store a
std::wstring. Now a single pixel can store multiple codepoints.
If a codepoint is of size <=0, it will be appended to the previous
pixel.

Only ftxui::text() is supported. ftxui::vtext support still needs to be
added.

This causes the following CPU and memory regression:
- Memory: Pixel size increases by 200% (16 byte => 48byte).
- CPU:    Draw/Second decrease by 62.5% (16k draw/s => 6k draw/s on 80x80)

Both regressions are acceptable. There are still two orders of magnitude
(100x) before the levels where performance/memory concerns begins.

This fixes: https://github.com/ArthurSonzogni/FTXUI/issues/109
2021-06-26 01:32:27 +02:00
Arthur Sonzogni
93922f102f
Do not throw SIGINT after catching SIGINT signal (#128)
This fixes:
https://github.com/ArthurSonzogni/FTXUI/issues/117
2021-06-26 00:42:08 +02:00
Arthur Sonzogni
1fc86d31db
Add benchmark. (#127) 2021-06-26 00:08:21 +02:00
Arthur Sonzogni
ba5826eab7
Fix bug with std::raise(0) (#124)
A bug has been introduced in:
478d7e8bca

I purposefully allowed raising the signal zero, because I thought this
was doing nothing. See the response:
https://stackoverflow.com/a/32260528/5112390

but this is different on Windows.

See:
https://github.com/ArthurSonzogni/FTXUI/issues/117
2021-06-22 09:43:15 +02:00
ArthurSonzogni
20a05e99ca Execute IWYU and format. 2021-06-21 23:10:51 +02:00
ArthurSonzogni
91c5954fe2 Fix component ownership.
When switching from raw pointers toward shared_ptr, the destructor
wasn't updated correctly.

This patch:
- Fixes the issue.
- Add two regression tests.
- Use address sanitizer for the tests.

This fixes: https://github.com/ArthurSonzogni/FTXUI/issues/115
2021-06-21 22:58:49 +02:00
ArthurSonzogni
478d7e8bca On SIGINT, raise signal again.
When SIGINT is intercepted, quit the run loop and raise the signal
again.

I am not sure this addresses:
https://github.com/ArthurSonzogni/FTXUI/issues/117
Maybe?
2021-06-19 18:57:48 +02:00
ArthurSonzogni
18d1b04b7a terminal_input_parser: validate UTF8.
Make sure code points parsed are always valid UTF8. Don't assume stdin
is filled with valid data. Check for overlong UTF8 and add some tests.

The fuzzer has reached the following coverage:
- cov    : 204
- ft     : 754
- corp   : 62/12257b
- lim    : 2798
- exec/s : 1748
- rss    : 445Mb
- L      : 155/1946
- MS     : 3

Fixed:https://github.com/ArthurSonzogni/FTXUI/issues/118
2021-06-19 11:09:52 +02:00
ArthurSonzogni
986ea2b37e Add fuzzer for termin_input_parser
Current state: the fuzzer find interesting input immediately...
```
terminate called after throwing an instance of 'std::range_error'
  what():  wstring_convert::from_bytes
```

See: https://github.com/ArthurSonzogni/FTXUI/issues/118
2021-06-19 11:09:52 +02:00
ArthurSonzogni
2445dc03d3 Add "long" to slider. 2021-06-02 21:13:23 +02:00
ArthurSonzogni
2504a24ee0 Add documentation for ResizableSplit 2021-05-28 15:07:08 +02:00
ArthurSonzogni
bba2abbb60 Introduce ResizableSplit 2021-05-28 15:07:08 +02:00
Arthur Sonzogni
aacb677e84
Introduce CatchEvent (#104) 2021-05-23 12:53:20 +02:00
Arthur Sonzogni
87a1d75bf1
Fix unsigned/signed comparison issues. (#103)
Seen here:
https://github.com/VedantParanjape/simpPRU/runs/2613171696
2021-05-18 21:48:32 +02:00
Arthur Sonzogni
7b88656e25
Add option to have button without border. (#101) 2021-05-18 17:49:53 +02:00
Arthur Sonzogni
ab9d6feaa5
Fix separator() (#100)
separator() should modify only the character, not the background color.
2021-05-17 01:34:53 +02:00
Arthur Sonzogni
30a85c4c5b
Clear terminal on resize. (#99) 2021-05-17 00:44:37 +02:00
Arthur Sonzogni
a574a6c3ee
Pass -Wshadow (#97)
Requested from:
https://github.com/robinlinden/hastur/pull/12
2021-05-16 17:18:11 +02:00
Arthur Sonzogni
01f5d9f7bc
Remove flickering. (#95)
For some reason, ResetPosition() was also clearing the content. On very
slow terminal emulator like the one on Windows, flickering was visible.

This fixes:
https://github.com/ArthurSonzogni/FTXUI/issues/86
2021-05-16 10:59:19 +02:00
Arthur Sonzogni
ca0d74ac01
Warn for deprecated. (#94) 2021-05-16 09:57:55 +02:00
Arthur Sonzogni
69047ac1e4
Add warning for sign comparison. (#93) 2021-05-16 09:38:24 +02:00
Arthur Sonzogni
7daeac25c0
Modify signature of Container::Tab(...) (#92)
Take selector at the end to get more pleasing results with clang-format.
2021-05-15 02:32:42 +02:00
Arthur Sonzogni
2723616dc8
Make StringRef borrow reference only when taking a pointer. (#91) 2021-05-15 01:34:37 +02:00
ArthurSonzogni
fcc49fdce7
Format using iwyu. 2021-05-15 00:19:19 +02:00
ArthurSonzogni
048efb6912
Add {Const,}StringRef to simplify components. 2021-05-14 21:47:51 +02:00
ArthurSonzogni
9fdf235836
Improve the documentation. 2021-05-14 20:56:37 +02:00
ArthurSonzogni
c9aa1805eb
Add the Renderer component. 2021-05-13 11:44:47 +02:00
ArthurSonzogni
6d75cb2748
Make component more functionnal 2021-05-09 22:35:34 +02:00
ArthurSonzogni
be219633e3
Merge remote-tracking branch 'origin' into feature/mouse-support 2021-05-01 23:45:13 +02:00
ArthurSonzogni
155758c073
Use IWYU. 2021-05-01 23:19:07 +02:00
ArthurSonzogni
eb399d20c5
Capture mouse for the slider component. 2021-05-01 18:13:56 +02:00
ArthurSonzogni
0af8201023
Add the slider component. 2021-04-29 00:18:58 +02:00
ArthurSonzogni
f062634226
Fix compilation errors on WebAssembly and Windows. 2021-04-25 17:28:16 +02:00
ArthurSonzogni
a27c878a3f
Mouse support. Fix & verify Webassembly support.
There was some undefined behavior to be fixed in the terminal input
parser.

The behavior of flush seems to have change. The fix was to invert '\0'
and std::flush.
2021-04-25 16:58:16 +02:00
ArthurSonzogni
0b9b6c692a
Improve mouse support 2021-04-25 15:22:38 +02:00
ArthurSonzogni
8037a5fa5f
Improve mouse support for menu and toggle. 2021-04-24 18:16:13 +02:00
ArthurSonzogni
890a41a64c
Add mouse implementation of most components. 2021-04-18 22:33:41 +02:00
ArthurSonzogni
d685a8655e
Parse mouse middle 2021-04-18 18:42:42 +02:00
ArthurSonzogni
cbd13499ae
Parse mouse events. 2021-04-18 18:32:38 +02:00
柚木鉉
e54d4643f5 Update terminal.cpp 2021-04-10 22:35:51 +02:00
ArthurSonzogni
476b9deaf8
Enable mouse tracking.
Request terminal to send mouse position.

See:
https://github.com/ArthurSonzogni/FTXUI/issues/7
2021-04-05 22:03:37 +02:00
ArthurSonzogni
386a0f9eac Add tests for the input component. 2021-03-28 18:25:16 +02:00
d
160b1c8bbc Added Home, End, PageUp, PageDown events.
Added handling for Home and End for input component
2021-03-28 18:25:16 +02:00
Arthur Sonzogni
373b016ca9
Add webassembly support (#79) 2021-03-22 00:26:52 +01:00
ArthurSonzogni
cac94439ff
Add webassembly support 2021-03-21 23:30:46 +01:00
Arthur Sonzogni
a6a7f0a354
Add CI on github action. (#76) 2021-03-20 22:45:21 +01:00
jdfa
af4bf379bc
Swapped order of hidding cursor and setting alternative screen (#75)
On some terminal, going to the alternative screen disable cursor hiding.
 Swap of those commands fixed that issue.

Co-authored-by: d <d>
2021-03-16 09:46:02 +01:00
jdfa
9cc3779145
[Win] Fixed usage of ReadConsoleInput (#74)
ReadConsoleInput params: |nLength| is the size in array elements, not in byte.

Co-authored-by: d <d>
2021-03-13 21:02:01 +01:00
Robin Lindén
73a3c24394
Build with -Wmissing-declarations (#71)
This flag is used to find global functions defined without a previous
declaration. Usually it spots accidental globals, but in this case it
was just missing headers.
2021-02-11 00:45:42 +01:00
robobuggy
d0eab41344
Fixed infinite loop in Screen::ToString() for non-printable chars (#69) 2021-02-04 09:32:05 +01:00
Arthur Sonzogni
92ec5ab4ca
Support for color fallback. (#66)
On terminal not supporting some color palette, fallback toward the
closest one.
2020-12-23 14:45:57 +01:00
Arthur Sonzogni
305346542a
Fix terminal color detection support. (#65)
There was many obvious bugs, discovered here:
ad2a085469/Open-Source-Project-Anatomy/FTXUI.md
2020-12-23 12:20:01 +01:00
Arthur Sonzogni
406355df8c
Fix parsing of keys that are prefix of others. (#58)
The ESC key generates sequences that are prefix of others. For instance:
- ESC => [27]
- F1 =>  [27, 79, 8]

As a result, we can't generate the ESC event when receiving [27],
because it might be the start of the [27, 79, 8] sequence (or not).

Application usually applies a timeout to help detecting the ESC key.
This patch introduce a timeout. It is set to 50ms.

Bug: https://github.com/ArthurSonzogni/FTXUI/issues/55
2020-10-25 01:57:56 +02:00
Mike Wallio
1cb08fd606
Fix event const correctness (#56) 2020-10-24 16:47:03 +02:00
Arthur Sonzogni
d969c74341
Improve color handling. (#49) 2020-10-16 22:31:24 +02:00
Stephan Roslen
cfd0981a58
reset pixel style for newline (#54) 2020-10-16 21:26:59 +02:00
Stephan Roslen
e34dc1606e Fix crash on unset environment variable. 2020-10-15 21:57:14 +02:00
ArthurSonzogni
606e0efdfe Implement Input::on_change. 2020-09-20 11:47:06 +02:00
ArthurSonzogni
5291f660ca Automatically fix style. 2020-09-07 11:25:50 +02:00
ArthurSonzogni
d09996a6c7 Add more example for colors. 2020-09-07 11:25:50 +02:00
Damien D
dc8c090753 Add support for full RGB colors.
FTXUI supported only the 16 colors palette.
This patch adds support for the 256 palette and the TrueColor(8×8×8)
mode.

This was made by kerdelos@ and fixes issue:
https://github.com/ArthurSonzogni/FTXUI/issues/45

Co-authored-by: Damien D <kerdelos@gmail.com>
Co-authored-by: Arthur Sonzogni <sonzogniarthur@gmail.com>
2020-09-07 11:25:50 +02:00
ArthurSonzogni
6b70967c6d Add <algorithm> to border.cpp.
This fies an issue with Windows.
2020-08-28 23:54:25 +02:00
ArthurSonzogni
4ad4946de3 Add the modal dialog example.
New component: clear_under.
2020-08-28 23:54:25 +02:00
ArthurSonzogni
5a8ed208da Add the Button component. 2020-08-28 23:54:25 +02:00
ArthurSonzogni
81d79d311d Add TakeFocus and SetActiveChild.
This allows developers to set child children component must be the
currently active/focused one.

This can be used to "control" where the focus is, without user
interactions.
2020-08-28 23:54:25 +02:00
ArthurSonzogni
114ab4ae2a Add more documentation. 2020-08-28 23:54:25 +02:00
ArthurSonzogni
f2dc080a35 Variou details:
- Put the MIT copyright at the end.
- Move the directory /other -> tools
- Various improvements.
2020-08-28 23:54:25 +02:00
ArthurSonzogni
20b9a0f0f5 Add a doxygen documentation. 2020-08-15 10:38:14 +02:00
ArthurSonzogni
75c424cea9 Update document WIP. 2020-08-09 10:49:06 +02:00
vedantparanjape
177df31d41 Added tests for toggle component, OnEnter event 2020-08-05 01:34:46 +02:00
vedantparanjape
33a970530b Added on_enter() method to toggle
component
2020-08-05 01:34:46 +02:00
ArthurSonzogni
a4d72c4d50 Fix on_change() not called for Toggle.
Fix bug 35 and add some tests for the toggle component.

Bug:https://github.com/ArthurSonzogni/FTXUI/issues/35
2020-08-02 22:22:27 +02:00
ArthurSonzogni
8f87fc96ac Add regression test for issue 31.
See https://github.com/ArthurSonzogni/FTXUI/issues/31

Due to a bug fixed by:
https://github.com/ArthurSonzogni/FTXUI/pull/32
the character 'P' was not correctly converted into event.
2020-07-23 21:05:21 +02:00
Giuseppe Cesarano
d1d7a73b2d Fixed P conversion 2020-07-23 20:41:44 +02:00
ArthurSonzogni
5f624431f1 Set the correct key for "return" on Window.
This is related to:
https://github.com/ArthurSonzogni/FTXUI/issues/27
2020-07-21 21:50:03 +02:00
ArthurSonzogni
e3ca437a48 Introduce xflex and yflex. 2020-07-21 01:22:42 +02:00
ArthurSonzogni
22afacc28b Request Windows to emulate VT100.
This was previously supported on ScreenInteractive, this is now
universally supported.

This partially address:
https://github.com/ArthurSonzogni/FTXUI/issues/27
2020-07-16 23:40:15 +02:00
ArthurSonzogni
454b14c5c6 Improve support to mingw 2020-07-16 23:40:15 +02:00
ArthurSonzogni
d2b991d5a3 Split frame into {x,y}frame 2020-06-07 15:59:09 +02:00
ArthurSonzogni
08ee49f3e6 Add flex_grow and flex_shrink.
Two new elements:
- flex_grow  : Expand the element to occupy free space.
- flex_shrink: Minimize the element leave away missing space.

flex = flex_grow | flex_shrink.

Other changes:
- hbox and vbox are now non flexible by default.
- the vtext element has been added to help writting tests.
- Many new tests.
2020-06-07 02:30:45 +02:00
ArthurSonzogni
7f7775ba62 Simplify the requirement struct. 2020-06-01 16:24:22 +02:00
ArthurSonzogni
3490d56662 Improve performance.
Read all the input before drawing anything on the screen.
2020-06-01 16:16:08 +02:00
ArthurSonzogni
823e0906da Fix OnEvent being called on Empty containers. 2020-05-25 02:14:58 +02:00
ArthurSonzogni
b00fa7dc65 Fix issue 19.
This was introduced by previous patch.

See:
https://github.com/ArthurSonzogni/FTXUI/issues/19
2020-05-20 22:04:41 +02:00
ArthurSonzogni
e34f051f7a Simplify the Render(screen, document) function. 2020-05-20 21:23:59 +02:00
ArthurSonzogni
957387adaa Format. 2020-05-20 20:51:20 +02:00
ArthurSonzogni
e1a71d5b9f Use shared_ptr instead of unique_ptr for elements.
This allow users to pass it into initializer list. Then clang-format
will produce 'acceptable' indentations.

This fixes:
https://github.com/ArthurSonzogni/FTXUI/issues/18
2020-05-20 20:51:20 +02:00
ArthurSonzogni
76fc52441f Implement "alternative screen".
Apply this option automatically for "fullscreen" screen. Keep it
disabled for the other modes.

This fixes issue:
https://github.com/GiuseppeCesarano/just-fast/issues/2
2020-05-02 20:39:56 +02:00
ArthurSonzogni
ac3db36de8 Stop using fcntl
This fixes issue 16
https://github.com/ArthurSonzogni/FTXUI/issues/16

Some terminal like gnome-terminal seems not to support it correctly. It
turns out it wasn't totally useful using it.
2020-05-02 20:11:36 +02:00
ArthurSonzogni
1974e9f9fc Make flexible element to be shrinkable.
This make the application "just-fast" to look better.
2020-05-02 17:39:42 +02:00
ArthurSonzogni
cccbe5baa9 Fix non blocking I/O on POSIX. 2020-05-02 02:02:04 +02:00
ArthurSonzogni
2d292b5382 Make catching SIGNAL SIGINT to work also on windows. 2020-05-01 23:48:22 +02:00
ArthurSonzogni
898cd842e2 Catch SIGINT event.
This was an old features, but it has been removed mistakenly when
merging some patches.

This allow the terminal to be restored when the user kill the
application.
2020-05-01 23:45:17 +02:00
ArthurSonzogni
d8e0504ad0 Add timeout for getchar() in POSIX.
Previously, the thread pooling new characters being typed was waiting
for "one more char" being typed before being able to exit.

This patch adds a timeout for getchar(). This way, event if the user do
not press his/her keyboard, the program is still able to exit.

This fixes issue:
https://github.com/GiuseppeCesarano/just-fast/issues/2
2020-05-01 23:36:02 +02:00
ArthurSonzogni
f506be941d Add automatic formatting and license. 2020-04-19 21:01:09 +02:00
ArthurSonzogni
a09ebcc442 Fix bug with container on Windows.
This fix the bug from:
https://github.com/ArthurSonzogni/FTXUI/pull/11

About:
~~~
Bug: Focus handling not working

in the examples (e.g. checkbox.cpp) I can toggle the individual
checkboxes but I cannot move between items, I tried to understand the
focus implementation but am I unsure which keypresses would move focus
between different components
~~~
2020-04-17 01:15:17 +02:00
ArthurSonzogni
fce29a03b3 Run clang-format. 2020-03-27 01:42:46 +01:00
ArthurSonzogni
6e7b4526a0 Add ReceiverTest.
And fix a small bug with the Receiver not eating all the input.
2020-03-27 01:01:37 +01:00
ArthurSonzogni
e8ed0fbc6d Add ContainerTest 2020-03-27 01:01:37 +01:00
ArthurSonzogni
2cef695216 Add RadioboxTest 2020-03-27 01:01:37 +01:00
ArthurSonzogni
580e648147 Remove the pipe class. 2020-03-27 01:01:37 +01:00
ArthurSonzogni
6600e4fc03 Add ToggleTest. 2020-03-27 01:01:37 +01:00
ArthurSonzogni
f48bfcff10 Move tests next to their implementations. 2020-03-27 01:01:37 +01:00
ArthurSonzogni
20d4ee458a Fix layout bug detected thanks to dom_tests. 2020-03-25 19:10:46 +01:00
ArthurSonzogni
13d1cc1684 Fix missing include. 2020-03-25 18:31:27 +01:00
Mikael Olenfalk
a55baa1e9c Use the correct macro check if we are compiling for windows 2020-03-25 08:54:03 +01:00
ArthurSonzogni
5fc5766f1e Add Windows input.
Co-authored-by: Mikael Olenfalk <mikael@olenfalk.se>
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2020-03-25 02:24:43 +01:00
ArthurSonzogni
ff59c7bafa Fix compile on Windows. 2020-03-25 02:18:48 +01:00
ArthurSonzogni
6e22a10eb7 Fix compile error on OS where char is signed. 2020-03-25 02:01:31 +01:00
ArthurSonzogni
508b2ef048 Improve thread usages. 2020-03-25 01:15:46 +01:00
ArthurSonzogni
0a7b556a12 Switch name Producer/Consumer -> Sender/Receiver
The producer/consumer was created for:
https://github.com/ArthurSonzogni/FTXUI/pull/11

This patch makes rename everything from Producer/Consumer toward
Sender/Receiver.
2020-03-25 00:07:41 +01:00
ArthurSonzogni
09a1b16613 Add a Producer/Consumer system.
It allow you to create the two end of a pipe: A producer and consumer.
The producer can be moved into another thread.
Several producer can be created if necessary.

This will ease merging:
https://github.com/ArthurSonzogni/FTXUI/pull/11
2020-03-24 23:42:17 +01:00
ArthurSonzogni
6de8c63907 Readd 'resize' handling. It was mistakenly removed. 2020-03-24 01:26:06 +01:00
Mikael Olenfalk
f927d3d712 Win32: Switch codepage to UTF8 in Screen constructor
Co-authored-by: Mikael Olenfalk <mikael@olenfalk.se>
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2020-03-24 00:37:06 +01:00
Mikael Olenfalk
b2b42a8a04 Disable C++17 deprecation warnings 2020-03-23 22:44:13 +01:00
Mikael Olenfalk
71598cb18d Fix warning: Namespace uses itself 2020-03-23 21:46:44 +01:00
Mikael Olenfalk
40800ac019 Use Console API to set and restore terminal mode on Windows 2020-03-23 21:42:33 +01:00
ArthurSonzogni
493e734680 Set clang-format macro indent.
1) Set clang-format macro indent.
2) Run clang-format on every files.
2020-03-23 21:26:00 +01:00
Mikael Olenfalk
9e71c467f6 Use Console API to get terminal size on Windows
Co-authored-by: Mikael Olenfalk <mikael@olenfalk.se>
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2020-03-23 21:11:34 +01:00
Mikael Olenfalk
539ec45036 Add missing <algorithm> include 2020-03-23 21:03:25 +01:00
ArthurSonzogni
9ca8d41afc Improve ScreenInteractive. 2020-03-23 09:23:57 +01:00
ArthurSonzogni
a402cb4fbb Fix format. Try compile on Windows. 2020-03-22 22:32:44 +01:00
ArthurSonzogni
65705d5bc7 Fix werror=type-limit on systems with char=unsigned char. 2020-02-11 23:43:26 +01:00
ArthurSonzogni
1f1229564a Fix (maybe uninitialized) on weak compilers. 2020-02-11 22:34:01 +01:00
ArthurSonzogni
a8fdfafe6a Support the -pedantic flag. 2020-02-11 21:44:55 +01:00
Ilia Sharin
469d2cd736 Fix compilation issue on macOS(CLang compiler) where stdlib doesn't define quick_exit() 2020-02-02 15:27:46 -05:00
ArthurSonzogni
22f8f0d3b7 Using TAB key event.
A key event that makes use of TAB key to cycle the elements.

Co-authored-by: Trim Bresilla <trim.bresilla@gmail.com>"
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
2019-11-01 19:54:16 +01:00
ArthurSonzogni
7f0381e30a Emit a new line when a component is interrupted.
While running a component, make sure to reset the cursor at the end of
the component and insert a new line.

This fixes:
https://github.com/ArthurSonzogni/FTXUI/issues/6
2019-09-18 22:02:51 +02:00
ArthurSonzogni
e1efcf2d97 Make DEL to be a special character. 2019-07-02 23:09:20 +02:00
ArthurSonzogni
65e7fae7df Fix parsing of CSI escape sequence.
There was a bug, preventing the user from typing the DEL key.

This is related to bug:
https://github.com/ArthurSonzogni/FTXUI/issues/4
2019-07-01 00:44:50 +02:00
ArthurSonzogni
01ab335919 Implement key Delete in component > Input.
The BS  key is used to delete the character on the left of the cursor.
The DEL key is used to delete the character on the right of the cursor.

BackSpace was already implemented. This CL implements DEL.

This is related to bug:
https://github.com/ArthurSonzogni/FTXUI/issues/4
2019-07-01 00:40:55 +02:00
ArthurSonzogni
32871fcc6b Add -Wextra 2019-06-30 23:59:27 +02:00
ArthurSonzogni
a87e70c96e Handle terminal resize.
This is related to bug:
https://github.com/ArthurSonzogni/FTXUI/issues/3
2019-06-30 23:53:56 +02:00
ArthurSonzogni
b8a81bae9e Add focus element in input component while the placeholder is displayed.
This should fix:
https://github.com/ArthurSonzogni/FTXUI/issues/2
2019-06-30 10:11:48 +02:00
ArthurSonzogni
8b79b3af99 Fix compilation errors in clang. 2019-06-30 10:11:37 +02:00
ArthurSonzogni
86c3b60a6f Move the cursor to the input location.
Most CJK users use IME (input method) to type CJK characters. They need
the cursor to be at the correct location, not in the bottom right
corner.

This CL does:
 * Move the cursor the focus() element.
 * Hide the cursor (and show it at exit)
 * Intercept SIGINT to guarantee proper cleanup all the time.

This should fix the second issue mentionned on:
https://github.com/ArthurSonzogni/FTXUI/issues/2
2019-06-29 18:52:58 +02:00
ArthurSonzogni
eb6baaceea Support full-width characters (CJK)
+ 3 tests.

The goal is to fix:
https://github.com/ArthurSonzogni/FTXUI/issues/2#issuecomment-504871456
2019-06-24 23:39:37 +02:00
ArthurSonzogni
9c1913de51 Fix xterm parsing. unsigned vs signed char problem. 2019-06-23 17:59:34 +02:00
ArthurSonzogni
001a0ae925 Add UTF8 support and a better xterm parsing.
This fixes: https://github.com/ArthurSonzogni/FTXUI/issues/2
2019-06-23 17:52:31 +02:00
ArthurSonzogni
a366c9b9e2 Handle empty container. 2019-02-02 18:41:07 +01:00
ArthurSonzogni
15da9cdc18 Improve ScreenInteractive wait function. 2019-02-02 16:59:08 +01:00
ArthurSonzogni
ed416b5e1e Remove comments when terminal size is determined. 2019-02-02 11:48:17 +01:00
ArthurSonzogni
ef0de8d873 Add support for nxxm.
[nxxm](https://nxxm.github.io)
2019-02-02 02:25:06 +01:00