Commit Graph

134 Commits

Author SHA1 Message Date
ronak69
44a46aabeb LibLine: Refresh the line after case-change operations
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.
2023-08-07 22:51:49 +03:30
Andreas Kling
ddbe6bd7b4 Userland: Rename Core::Object to Core::EventReceiver
This is a more precise description of what this class actually does.
2023-08-06 20:39:51 +02:00
Nico Weber
66e210e406 Everywhere: Use nested namespace qualifiers 2023-07-12 10:05:42 +03:30
Timothy Flynn
c911781c21 Everywhere: Remove needless trailing semi-colons after functions
This is a new option in clang-format-16.
2023-07-08 10:32:56 +01:00
Timothy Flynn
aff81d318b Everywhere: Run clang-format
The following command was used to clang-format these files:

    clang-format-16 -i $(find . \
        -not \( -path "./\.*" -prune \) \
        -not \( -path "./Base/*" -prune \) \
        -not \( -path "./Build/*" -prune \) \
        -not \( -path "./Toolchain/*" -prune \) \
        -not \( -path "./Ports/*" -prune \) \
        -type f -name "*.cpp" -o -name "*.h")
2023-07-08 10:32:56 +01:00
Ali Mohammad Pur
e1e04884b9 LibLine: Handle any errors propagated through refresh_display()
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.
2023-07-03 19:07:33 +03:30
Ali Mohammad Pur
7e5f1fa895 LibLine: Defer handling SIGWINCH and SIGINT
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.
2023-07-02 16:27:52 +03:30
Ben Wiederhake
c4a9afe31a LibLine: Avoid unnecessary copies of style spans 2023-06-15 08:07:17 +02:00
Tim Schumacher
ad899b179f LibLine: Ignore ENOENT errors when loading old history
A missing history file is just an empty history, so ignore that error
and replace it with an empty array.

This regressed in f93ee3142d.
2023-06-03 05:52:52 +02:00
Ben Wiederhake
f93ee3142d LibLine: Unify history reading, prefer File over DeprecatedFile 2023-05-27 07:16:01 +02:00
Ben Wiederhake
9eeda5719e LibLine: Prefer File::read_until_eof over DeprecatedFile::read_all 2023-05-19 21:36:37 +02:00
Andreas Kling
3de8dd921e Userland: Remove serialize-to-JSON functions only used for Inspector 2023-04-25 14:48:40 +02:00
Andreas Kling
411d36719e LibCore: Simplify Core::Notifier by only allowing one event type
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.
2023-04-25 14:48:40 +02:00
Ben Wiederhake
560133a0c6 Everywhere: Remove unused DeprecatedString includes 2023-04-09 22:00:54 +02:00
Ali Mohammad Pur
e312d6530b LibLine: Unify the is-empty flag in Style::unify_with() as well
Not doing so can make the final unified state incorrectly marked as
empty, and will make LibLine ignore the style.
2023-03-20 23:25:21 +01:00
Tim Schumacher
ae51c1821c Everywhere: Remove unintentional partial stream reads and writes 2023-03-13 15:16:20 +00:00
Tim Schumacher
ecd1862859 AK: Rename Stream::write_entire_buffer to Stream::write_until_depleted
No functional changes.
2023-03-13 15:16:20 +00:00
Tim Schumacher
a3f73e7d85 AK: Rename Stream::read_entire_buffer to Stream::read_until_filled
No functional changes.
2023-03-13 15:16:20 +00:00
Tim Schumacher
d5871f5717 AK: Rename Stream::{read,write} to Stream::{read_some,write_some}
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.
2023-03-13 15:16:20 +00:00
Andreas Kling
a504ac3e2a Everywhere: Rename equals_ignoring_case => equals_ignoring_ascii_case
Let's make it clear that these functions deal with ASCII case only.
2023-03-10 13:15:44 +01:00
Tim Schumacher
43f98ac6e1 Everywhere: Remove the AK:: qualifier from Stream usages 2023-02-13 00:50:07 +00:00
Tim Schumacher
874c7bba28 LibCore: Remove Stream.h 2023-02-13 00:50:07 +00:00
Tim Schumacher
606a3982f3 LibCore: Move Stream-based file into the Core namespace 2023-02-13 00:50:07 +00:00
Tim Schumacher
d43a7eae54 LibCore: Rename File to DeprecatedFile
As usual, this removes many unused includes and moves used includes
further down the chain.
2023-02-13 00:50:07 +00:00
Ali Mohammad Pur
c045d09840 LibLine: Quit event loop when an error occurs on update
Previously we were crashing, which was excessive, if we can't read
anymore, we should just return with an error.
2023-02-01 01:04:42 +03:30
Tim Schumacher
093cf428a3 AK: Move memory streams from LibCore 2023-01-29 19:16:44 -07:00
Tim Schumacher
8464da1439 AK: Move Stream and SeekableStream from LibCore
`Stream` will be qualified as `AK::Stream` until we remove the
`Core::Stream` namespace. `IODevice` now reuses the `SeekMode` that is
defined by `SeekableStream`, since defining its own would require us to
qualify it with `AK::SeekMode` everywhere.
2023-01-29 19:16:44 -07:00
Linus Groh
6e7459322d AK: Remove StringBuilder::build() in favor of to_deprecated_string()
Having an alias function that only wraps another one is silly, and
keeping the more obvious name should flush out more uses of deprecated
strings.
No behavior change.
2023-01-27 20:38:49 +00:00
Tim Schumacher
40cb41a16c LibLine: Do a whole bunch of internal error propagation 2023-01-16 21:04:48 +00:00
Tim Schumacher
f9f1e1dd49 LibLine: Port most functions to Core::Stream 2023-01-16 21:04:48 +00:00
Ben Wiederhake
6b7ce19161 Everywhere: Remove unused includes of LibC/stdlib.h
These instances were detected by searching for files that include
stdlib.h, but don't match the regex:

\\b(_abort|abort|abs|aligned_alloc|arc4random|arc4random_buf|arc4random_
uniform|atexit|atof|atoi|atol|atoll|bsearch|calloc|clearenv|div|div_t|ex
it|_Exit|EXIT_FAILURE|EXIT_SUCCESS|free|getenv|getprogname|grantpt|labs|
ldiv|ldiv_t|llabs|lldiv|lldiv_t|malloc|malloc_good_size|malloc_size|mble
n|mbstowcs|mbtowc|mkdtemp|mkstemp|mkstemps|mktemp|posix_memalign|posix_o
penpt|ptsname|ptsname_r|putenv|qsort|qsort_r|rand|RAND_MAX|random|reallo
c|realpath|secure_getenv|serenity_dump_malloc_stats|serenity_setenv|sete
nv|setprogname|srand|srandom|strtod|strtof|strtol|strtold|strtoll|strtou
l|strtoull|system|unlockpt|unsetenv|wcstombs|wctomb)\\b

(Without the linebreaks.)

This regex is pessimistic, so there might be more files that don't
actually use anything from the stdlib.

In theory, one might use LibCPP to detect things like this
automatically, but let's do this one step after another.
2023-01-02 20:27:20 -05:00
Timothy Flynn
a67ad665b1 LibLine: Convert strings to time_t using signed conversion methods
The time_t type itself is signed, and the result of this conversion is
always stored as time_t, so let's not use to_uint<>.
2022-12-16 10:06:26 +01:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Zaggy1024
7aabda37d1 LibVT/LibLine: Delete words when pressing Ctrl+Backspace in Terminal 2022-11-20 03:57:17 +03:30
Matteo Benetti
f84b2e9e7d LibLine: Fix save line condition
Fix condition used by actual_rendered_string_length_step() to
check if the line reached the desired length.
2022-11-11 22:16:27 +03:30
Lucas CHOLLET
4a9218451d LibLine: Consider URL in actual_rendered_string_length
This allows to not count URLs' metadata for the visible length.
2022-11-10 12:34:21 +03:30
Lucas CHOLLET
299ca10fd5 LibLine: Support wrapping lines in actual_rendered_string_metrics
This will allow us to use this API to split an input to visible lines of
a specified width.
2022-11-10 12:34:21 +03:30
Daniel Bertalan
4296425bd8 Everywhere: Remove redundant inequality comparison operators
C++20 can automatically synthesize `operator!=` from `operator==`, so
there is no point in writing such functions by hand if all they do is
call through to `operator==`.

This fixes a compile error with compilers that implement P2468 (Clang
16 currently). This paper restores the C++17 behavior that if both
`T::operator==(U)` and `T::operator!=(U)` exist, `U == T` won't be
rewritten in reverse to call `T::operator==(U)`. Removing `!=` operators
makes the rewriting possible again.
See https://reviews.llvm.org/D134529#3853062
2022-11-06 10:25:08 -07:00
Ali Mohammad Pur
922fa2e9d0 LibLine: Avoid crashing on a 0x0 terminal
Some terminals start with a 0x0 buffer, run the shell, then switch to
a normal buffer size; avoid crashing in this case.

Also downgrade the paging TODO to a FIXME, a slightly broken terminal is
okay if all you're doing is using unimplemented features such as putting
too much text into the terminal.
2022-11-03 00:01:42 +03:30
Tim Schumacher
ce2f1b845f Everywhere: Mark dependencies of most targets as PRIVATE
Otherwise, we end up propagating those dependencies into targets that
link against that library, which creates unnecessary link-time
dependencies.

Also included are changes to readd now missing dependencies to tools
that actually need them.
2022-11-01 14:49:09 +00:00
Tim Schumacher
7834e26ddb Everywhere: Explicitly link all binaries against the LibC target
Even though the toolchain implicitly links against -lc, it does not know
where it should get LibC from except for the sysroot. In the case of
Clang this causes it to pick up the LibC stub instead, which might be
slightly outdated and feature missing symbols.

This is currently not an issue that manifests because we pass through
the dependency on LibC and other libraries by accident, which causes
CMake to link against the LibC target (instead of just the library),
and thus points the linker at the build output directory.

Since we are looking to fix that in the upcoming commits, let's make
sure that everything will still be able to find the proper LibC first.
2022-11-01 14:49:09 +00:00
Ben Wiederhake
a99cd09891 Libraries: Add missing includes, add namespace qualifiers
This remained undetected for a long time as HeaderCheck is disabled by
default. This commit makes the following file compile again:

    // file: compile_me.cpp
    #include <LibDNS/Question.h>
    // That's it, this was enough to cause a compilation error.

Likewise for most other files touched by this commit.
2022-09-18 13:27:24 -04:00
sin-ack
57c8677b5c LibLine: Ignore empty spans when stylizing
Previously we would erroneously apply the stylization to the whoever
called stylize next. Now we first check whether the span is non-empty
before stylizing. All non-empty spans must have at least one character
in them (end-exclusive).
2022-07-17 00:51:31 +00:00
sin-ack
c8585b77d2 Everywhere: Replace single-char StringView op. arguments with chars
This prevents us from needing a sv suffix, and potentially reduces the
need to run generic code for a single character (as contains,
starts_with, ends_with etc. for a char will be just a length and
equality check).

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack
c70f45ff44 Everywhere: Explicitly specify the size in StringView constructors
This commit moves the length calculations out to be directly on the
StringView users. This is an important step towards the goal of removing
StringView(char const*), as it moves the responsibility of calculating
the size of the string to the user of the StringView (which will prevent
naive uses causing OOB access).
2022-07-12 23:11:35 +02:00
Ali Mohammad Pur
910a44d5f2 LibLine: Use the real shown line count around in cleanup()
Previously we would leave artifacts on screen if a change caused the
buffer to span fewer lines than the current buffer.
This commit records the shown line count and uses that instead of trying
to guess the previous line count (and failing most of the time).
2022-06-22 15:45:27 +02:00
Ali Mohammad Pur
78dc77f7e4 LibLine: Add support for user-controlled masking 2022-05-25 23:17:15 +01:00
Ali Mohammad Pur
c257d27f0b LibLine: Turn bracketed paste mode off in Editor::restore()
We turn it on in initialize(), so turn it off in restore().
Not all CLI applications can handle this mode correctly, and there's no
reason to leave it on.
2022-05-25 23:17:15 +01:00