LibLocale was split off from LibUnicode a couple years ago to reduce the
number of applications on SerenityOS that depend on CLDR data. Now that
we use ICU, both LibUnicode and LibLocale are actually linking in this
data. And since vcpkg gives us static libraries, both libraries are over
30MB in size.
This patch reverts the separation and merges LibLocale into LibUnicode
again. We now have just one library that includes the ICU data.
Further, this will let LibUnicode share the locale cache that previously
would only exist in LibLocale.
These changes are compatible with clang-format 16 and will be mandatory
when we eventually bump clang-format version. So, since there are no
real downsides, let's commit them now.
A bunch of users used consume_specific with a constant ByteString
literal, which can be replaced by an allocation-free StringView literal.
The generic consume_while overload gains a requires clause so that
consume_specific("abc") causes a more understandable and actionable
error.
Every cut operation (erase last word backward/forward, erase line till
start/end) stores the erased characters in `m_last_erased` u32 vector.
The last erased characters will get inserted into the buffer when
`Ctrl+Y` (`insert_last_erased()` internal function) is pressed.
Two new internal functions `cursor_left_nonspace_word()` (`Ctrl+Alt+B`)
and `cursor_right_nonspace_word()` (`Ctrl+Alt+F`) that jump the cursor
left or right until a non-space character.
Same implementation as the alphanumeric word jump functions
`cursor_left_word()` (`Alt+B`) and `cursor_right_word()` (`Alt+F`).
In a bunch of cases, this actually ends up simplifying the code as
to_number will handle something such as:
```
Optional<I> opt;
if constexpr (IsSigned<I>)
opt = view.to_int<I>();
else
opt = view.to_uint<I>();
```
For us.
The main goal here however is to have a single generic number conversion
API between all of the String classes.
This caused a dangling reference down the line, which lead to funny
things like the following:
> cd Bui[tab]
> cd Bui^@^@
By returning a direct reference to the suggestion in question, we can be
sure that the referenced object is alive until the next suggestion
cycle.
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).
This commit is auto-generated:
$ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
Meta Ports Ladybird Tests Kernel)
$ perl -pie 's/\bDeprecatedString\b/ByteString/g;
s/deprecated_string/byte_string/g' $xs
$ clang-format --style=file -i \
$(git diff --name-only | grep \.cpp\|\.h)
$ gn format $(git ls-files '*.gn' '*.gni')
This makes using the line editor much nicer when multi-code-point
graphemes are present in the input (e.g. flag emojis, or some cjk
glyphs), and avoids messing up the buffer when deleting text, or
cursoring around.
This commit fixes the odd state after pasting some text containing
multibyte code points.
This also increases the input buffer size, as reading 16 bytes at a time
felt slightly laggy when pasting a large number of emojis :^)
Previously, we stored two representations of the same string in
`CompletionSuggestion` object: one for the bytes and the other for the
code points corresponding to those bytes. To minimize duplication, this
patch combine both representations into a single UTF-8 string, which is
already supported by our new String class.
Following this update, we successfully reduce the size of each object
from 376 bytes to 256 bytes
We forgot to reset all the variables that keep track of suggestion
state, resulting in an underflow value when calculating the lines to
display completion suggestions later.
Setting `m_times_tab_pressed` to 0 apparently forces it to recalculate
the those variables and seems to fix the problem.
Fixes#22128
We previously left it at the end of the final line, which caused the
next prompt to start offset to the right:
|$ foo^C
| $
This commit makes LibLine move to the beginning of that line,
making it so the next prompt shows up at the beginning of the line:
|$ foo^C
|$
While parsing DSR response, we might encounter invalid characters, for
example, when we `cat` a binary file. Previously, we just pushed those
characters in `m_incomplete_data` buffer, which worked fine until we
didn't get a terminating character. We kept increasing coordinate value
and crashed in following assertion.
Previously, case-change operations did not produce visible results.
As of now, setting `m_chars_touched_in_the_middle` to a non-zero value
results in refreshing the whole line. So case-change operations now set
that variable (causing a line refresh) in order to produce visible
results as expected.
This can only realistically happen when the terminal no longer exists,
so quitting with an error here is the better solution as the application
will soon be killed anyway.
Fixes#19742.
Fixes#19017.
Performing these immediately can introduce a race condition between the
user's signal-related logic and LibLine's own, so defer the handlers to
make sure they run when our terminal IO cannot interfere with the
user's.
Not a single client of this API actually used the event mask feature to
listen for readability AND writability.
Let's simplify the API and have only one hook: on_activation.
Similar to POSIX read, the basic read and write functions of AK::Stream
do not have a lower limit of how much data they read or write (apart
from "none at all").
Rename the functions to "read some [data]" and "write some [data]" (with
"data" being omitted, since everything here is reading and writing data)
to make them sufficiently distinct from the functions that ensure to
use the entire buffer (which should be the go-to function for most
usages).
No functional changes, just a lot of new FIXMEs.