Commit Graph

34 Commits

Author SHA1 Message Date
Henrik Gaßmann
7d4452f45c
Add an UDL for combined hex RGB colors (#203)
In order to allow using the literal on its own it has been put into the
inline namespace `literals`.
2021-09-14 14:22:30 +02:00
Arthur Sonzogni
9a54528bca
Update examples to use std::string. (#182)
In examples and tests, use std::string.

In addtion:
1. Address follow-up from:
https://github.com/ArthurSonzogni/FTXUI/pull/179
2. Fix a bug when Input is used with std::string.
2021-08-09 00:27:37 +02:00
Arthur Sonzogni
3b4ab618a3
Prefer std::string over std::wstring. (#179)
In the past, FTXUI switched from std::string to std::wstring to support
fullwidth characters. The reasons was that fullwidth characters can be
stored inside a single wchar_t.

Then FTXUI added support for combining characters. A single glygh
doesn't even fit a wchar_t. Instead, a glyph can be arbitrary large.

The usage of wstring doesn't really fit the new model and have several
drawbacks:
1. It doesn't simplify the implementation of FTXUI, because of combining
   characters.
2. It reduces drawing performance by 2x.
3. It increase Screen's memory allocation by 2x.

This patch converts FTXUI to use std::string internally. It now exposes
std::string based API. The std::wstring API remains, but is now
deprecated.

Tests and examples haven't been update to show the breakage is limited.
They will be updated in a second set of patches.

Bug: https://github.com/ArthurSonzogni/FTXUI/issues/153
Co-authored-by: Tushar Maheshwari <tushar27192@gmail.com>
2021-08-08 23:25:20 +02:00
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
3f005d7715
Add focusable Renderer. (#173) 2021-08-06 20:32:33 +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
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
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
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
6f87740801 Compatify the Screen memory.
Instead of storing all the booleans with 5 bytes, use a bit field.
The size of a Pixel has been reduced by 25%, from 20 byte to 15 bytes.
2021-06-12 21:45:55 +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
30a85c4c5b
Clear terminal on resize. (#99) 2021-05-17 00:44:37 +02:00
Arthur Sonzogni
2723616dc8
Make StringRef borrow reference only when taking a pointer. (#91) 2021-05-15 01:34:37 +02:00
ArthurSonzogni
048efb6912
Add {Const,}StringRef to simplify components. 2021-05-14 21:47:51 +02:00
ArthurSonzogni
155758c073
Use IWYU. 2021-05-01 23:19:07 +02:00
ArthurSonzogni
890a41a64c
Add mouse implementation of most components. 2021-04-18 22:33:41 +02:00
ArthurSonzogni
cac94439ff
Add webassembly support 2021-03-21 23:30:46 +01:00
Robin Lindén
0a9a72cbaa
Workaround Windows.h breaking the Color::RGB function (#70)
wingdi.h (included via Windows.h) defines an RGB macro that breaks
things. If a user really wants that macro in the same file as FTXUI they
can move the Windows.h include to after the inclusion of FTXUI's
headers.
2021-02-09 14:18:29 +01:00
Arthur Sonzogni
d969c74341
Improve color handling. (#49) 2020-10-16 22:31:24 +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
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
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
f506be941d Add automatic formatting and license. 2020-04-19 21:01:09 +02: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
ArthurSonzogni
a8fdfafe6a Support the -pedantic flag. 2020-02-11 21:44:55 +01:00
ArthurSonzogni
16ae64dfb4 Fix using undefined value bug. 2019-07-01 00:43:00 +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
ef0de8d873 Add support for nxxm.
[nxxm](https://nxxm.github.io)
2019-02-02 02:25:06 +01:00