summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibLine
AgeCommit message (Collapse)Author
2023-01-16LibLine: Do a whole bunch of internal error propagationTim Schumacher
2023-01-16LibLine: Port most functions to `Core::Stream`Tim Schumacher
2023-01-02Everywhere: Remove unused includes of LibC/stdlib.hBen Wiederhake
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.
2022-12-16LibLine: Convert strings to time_t using signed conversion methodsTimothy Flynn
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-06Everywhere: Rename to_{string => deprecated_string}() where applicableLinus Groh
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-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
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-11-20LibVT/LibLine: Delete words when pressing Ctrl+Backspace in TerminalZaggy1024
2022-11-11LibLine: Fix save line conditionMatteo Benetti
Fix condition used by actual_rendered_string_length_step() to check if the line reached the desired length.
2022-11-10LibLine: Consider URL in `actual_rendered_string_length`Lucas CHOLLET
This allows to not count URLs' metadata for the visible length.
2022-11-10LibLine: Support wrapping lines in `actual_rendered_string_metrics`Lucas CHOLLET
This will allow us to use this API to split an input to visible lines of a specified width.
2022-11-06Everywhere: Remove redundant inequality comparison operatorsDaniel Bertalan
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-03LibLine: Avoid crashing on a 0x0 terminalAli Mohammad Pur
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-01Everywhere: Mark dependencies of most targets as PRIVATETim Schumacher
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-01Everywhere: Explicitly link all binaries against the LibC targetTim Schumacher
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-09-18Libraries: Add missing includes, add namespace qualifiersBen Wiederhake
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-07-17LibLine: Ignore empty spans when stylizingsin-ack
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-12Everywhere: Replace single-char StringView op. arguments with charssin-ack
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-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
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-12Everywhere: Explicitly specify the size in StringView constructorssin-ack
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-06-22LibLine: Use the real shown line count around in cleanup()Ali Mohammad Pur
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-05-25LibLine: Add support for user-controlled maskingAli Mohammad Pur
2022-05-25LibLine: Turn bracketed paste mode off in Editor::restore()Ali Mohammad Pur
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-04-18LibLine: Reset next suggestion index when resetting suggestionsAli Mohammad Pur
Otherwise we'd end up starting at the previous index on another suggestion list.
2022-04-18LibLine: Make it possible to avoid autocompletion if requestedAli Mohammad Pur
Setting 'allow_commit_without_listing' to false will now make LibLine show the suggestion before actually committing to it; this is useful for completions that will replace all the user input, where mistakes can go unnoticed without some visual cue.
2022-04-18LibLine: Respect the provided completion static offsetAli Mohammad Pur
Now that we can resolve these correctly and they're per-suggestion, we can finally use them for their intended purpose of letting suggestions overwrite stuff in the buffer.
2022-04-18LibLine: Don't use fdopen() for stream in edit_in_external_editor()Ali Mohammad Pur
We would have to fclose() it to be clean and nice, but that would close the fd; instead just duplicate it and write through that, this makes it actually write to the file.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-27LibLine: Avoid pointless size_t <-> ssize_t castAli Mohammad Pur
Just a small cleanup.
2022-03-27LibLine: Handle read events seriallyAli Mohammad Pur
Previously LibLine accepted read callbacks while it was in the process of reading input, this wasn't an issue as no async code was being executed up until the Shell autocompletion came along. Simply defer input processing while processing input to avoid causing problems. Fixes #13280.
2022-03-26LibLine: Add a display trivia field to suggestionsAli Mohammad Pur
These strings will be shown next to the completions as an optional hint or description.
2022-03-13Libraries: Use default constructors/destructors in LibLineLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2022-03-06LibLine: Reset suggestion index back to zero when fetching new onesAli Mohammad Pur
2022-03-06LibLine: Make sure suggestions have their *_views set correctlyAli Mohammad Pur
2022-03-06LibLine: Allow the embedder to optionally handle pasted data itselfAli Mohammad Pur
If the 'on_paste' callback is set, LibLine will buffer the pasted data and pass it over to the embedder to use as it pleases; in practice, this means that the users of LibLine can now escape or otherwise handle pasted data without the incremental codepoint-by-codepoint buildup.
2022-03-06LibLine+Userland: Make suggestion offsets per-suggestionAli Mohammad Pur
This allows the user to modify different parts of the input with different suggestions.
2022-03-06LibLine: Never assume a 25x80 terminalAli Mohammad Pur
Just reuse the lldb hack if the normal stderr ioctl fails for any reason, and read the size directly off /dev/tty.
2022-02-27LibLine: Update inline search cursor after kill_line (^U) commandNícolas F. R. A. Prado
After the kill_line (^U) command was used, searching backwards in the history would still filter based on the text previous to the deletion. Update the inline search cursor like already done in other internal functions, so the text used for search is the current one.
2022-02-16LibCore+Everywhere: Return ErrorOr from ConfigFile factory methodsSam Atkins
I've attempted to handle the errors gracefully where it was clear how to do so, and simple, but a lot of this was just adding `release_value_but_fixme_should_propagate_errors()` in places.
2022-02-13LibJS+LibLine: Run clang-formatAndreas Kling
2022-02-13LibLine: Fix loading of terminal dimensions when running under lldbAnonymous
2022-01-07LibLine: Replace call to vfork() with fork()Andrew Kaster
We don't actually have a non-trivial vfork implementation, so just call fork(). As a bonus, vfork() is deprecated in XCode 13.1 when targeting macOS Big Sur, so this removes a blocker from updating our macOS CI version.
2022-01-01LibLine: Avoid unnecessary copies in EditorBen Wiederhake
2021-12-16LibLine: Switch all files to use east-constAli Mohammad Pur
2021-12-16LibLine: Update the prompt origin after resize + suggestion redisplayAli Mohammad Pur
2021-12-16LibLine: Take the prompt into account when adjusting for a scrolled viewAli Mohammad Pur
Otherwise we'd end up putting the prompt *after* the previous prompt instead of *over* it when showing suggestions that span more lines than are available without scrolling.
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-11-10AK: Make ByteBuffer::try_* functions return ErrorOr<void>Andreas Kling
Same as Vector, ByteBuffer now also signals allocation failure by returning an ENOMEM Error instead of a bool, allowing us to use the TRY() and MUST() patterns.
2021-10-08Libraries: Fix -Wunreachable-code warnings from clangNico Weber
2021-09-07Everywhere: Behaviour => BehaviorAndreas Kling
2021-09-06Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safeAli Mohammad Pur