Commit Graph

146 Commits

Author SHA1 Message Date
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