summaryrefslogtreecommitdiff
path: root/Libraries/LibLine
AgeCommit message (Collapse)Author
2021-01-12Libraries: Move to Userland/Libraries/Andreas Kling
2021-01-12AK: Simplify constructors and conversions from nullptr_tLenny Maiorani
Problem: - Many constructors are defined as `{}` rather than using the ` = default` compiler-provided constructor. - Some types provide an implicit conversion operator from `nullptr_t` instead of requiring the caller to default construct. This violates the C++ Core Guidelines suggestion to declare single-argument constructors explicit (https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c46-by-default-declare-single-argument-constructors-explicit). Solution: - Change default constructors to use the compiler-provided default constructor. - Remove implicit conversion operators from `nullptr_t` and change usage to enforce type consistency without conversion.
2021-01-11LibLine: Handle history across multiple concurrent sessions betterAnotherTest
- Store history entries as (timestamp)::(entry)\n\n - Merge the entries together when saving to avoid loss of history entries To ideally make having two concurrently open shells (or `js` repls or whatever) not overwrite each others' history entries.
2021-01-11Everywhere: Fix incorrect uses of String::format and StringBuilder::appendfSahan Fernando
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.
2021-01-10LibLine: Implement support for C-V<key>AnotherTest
This commit adds support for inserting in a "verbatim" mode where a single uninterpreted key is appended to the buffer. As this allows the user to input control characters, all control characters except \n (^M) are rendered in their caret form, with reverse video (SGR 7) applied to it. To not break cursor movement, the concept of "masked" characters is introduced to the StringMetrics interface, which can be mostly ignored by the rest of the system. It should be noted that unlike some other line editing libraries, LibLine does _not_ render a hard tab as a tab, but rather as '^I', which greatly simplifies cursor handling.
2021-01-10Everywhere: Convert a bunch of dbgprintf() to dbgln()Andreas Kling
2021-01-10LibLine: It's okay to be interrupted while reading the DSR responseAnotherTest
Fixes #4855.
2021-01-10LibLine: Don't clear the displayed buffer when interruptedAnotherTest
Since we always restart on a new line, there's no reason to clear the previous lines.
2021-01-10LibLine: Unregister signal handlers on destructionAnotherTest
This fixes an issue that shows up as a nice crash when "^R<enter>^C", which is actually the event loop trying to call into a deleted object (the search editor).
2021-01-09Everywhere: Replace a bundle of dbg with dbgln.asynts
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.Everything: The modifications in this commit were automatically made using the following command: find . -name '*.cpp' -exec sed -i -E 's/dbg\(\) << ("[^"{]*");/dbgln\(\1\);/' {} \;
2021-01-09Everywhere: Colour => ColorAndreas Kling
The system language is US English. :^)
2021-01-06LibLine: Don't ignore ^C inputs when there are no registered handlersAnotherTest
Some people really like their ^C's, let's not make them sad.
2021-01-04LibLine: Don't overwrite stuff when moving origin aroundAnotherTest
This fixes an issue (mainly) with multiline prompts, where a multiline prompt would overwrite the lines before it when libline tries to display it. To reproduce, set `PROMPT="a\nb\nc> "` in the shell, then press return a few times.
2020-12-31Everywhere: Re-format with clang-format-11Linus Groh
Compared to version 10 this fixes a bunch of formatting issues, mostly around structs/classes with attributes like [[gnu::packed]], and incorrect insertion of spaces in parameter types ("T &"/"T &&"). I also removed a bunch of // clang-format off/on and FIXME comments that are no longer relevant - on the other hand it tried to destroy a couple of neatly formatted comments, so I had to add some as well.
2020-12-30AK: Make binary_search signature more generic.asynts
2020-12-21Everywhere: Switch from (void) to [[maybe_unused]] (#4473)Lenny Maiorani
Problem: - `(void)` simply casts the expression to void. This is understood to indicate that it is ignored, but this is really a compiler trick to get the compiler to not generate a warning. Solution: - Use the `[[maybe_unused]]` attribute to indicate the value is unused. Note: - Functions taking a `(void)` argument list have also been changed to `()` because this is not needed and shows up in the same grep command.
2020-12-18LibLine: Treat leftover data in buffer as a read eventAnotherTest
Fixes #4328.
2020-12-18LibLine: Be less lazy when moving prompt origin rowAnotherTest
Fixes the issue where adding multiple lines in one refresh cycle would break cursor positioning.
2020-12-13LibCore: Make IODevice::read_line() return a StringAndreas Kling
Almost everyone using this API actually wanted String instead of a ByteBuffer anyway, and there were a bunch of slightly different ways clients would convert to String. Let's just cut out all the confusion and make it return String. :^)
2020-12-06LibLine: Don't make Editor::load_history() cut off a character per lineLinus Groh
For some reason we were not considering the last *two* characters from the line's ByteBuffer, with the comment next to it talking about \n and \0. However the buffer doesn't contain a null-byte, so we were effectively removing the newline and the last character from each history line!
2020-10-26Shell+LibLine: Support HISTCONTROL environment variableLinus Groh
This is implemented in Line::Editor meaning not only the Shell will respect it, but also js, Debugger etc. Possible values are "ignorespace", "ignoredups" and "ignoreboth", as documented in Shell-vars(7), for now. The default value for the anon user (set in .shellrc) is "ignoreboth".
2020-10-26Shell+LibLine: Move Shell::{load,save}_history() to Line::EditorLinus Groh
This allows us to easily re-use history loading and saving in other programs using Line::Editor, as well as implementing universally recognized HISTCONTROL.
2020-10-22LibLine: Support basic escaped characters in config fileAnotherTest
Until we can figure out how shift+enter works (or an alternative), this can be used to input literal newlines: ```ini [keybinds] \\\n=\n ```
2020-10-22LibLine: Support multi-character key callbacksAnotherTest
2020-10-04Shell+LibLine: Record the input offset of completionsAnotherTest
This makes the completion entry retain information about how much of the suggestion was part of the string that caused the match.
2020-09-26LibLine: Add a setter for the cursor positionAnotherTest
2020-09-15LibCore: Make Core::Object properties more dynamicAndreas Kling
Instead of everyone overriding save_to() and set_property() and doing a pretty asymmetric job of implementing the various properties, let's add a bit of structure here. Object properties are now represented by a Core::Property. Properties are registered with a getter and setter (optional) in constructors. I've added some convenience macros for creating and registering properties, but this does still feel a bit bulky. We'll have to iterate on this and see where it goes.
2020-09-15LibLine: Implement ctrl-del: It does the same thing as alt-d, delete-wordNico Weber
2020-09-15LibLine: Support Alt + Arrow left/rightNico Weber
It does the same thing as Ctrl + Arrow left/right: Wordwise movement.
2020-09-15LibVT+LibLine: Use `1;mods` CSI parameters for ctrl/alt/shift-arrow keysNico Weber
xterms send a bitmask (+ 1) in the 2nd CSI parameter if "special" keys (arrow keys, pgup/down, etc) are sent with modifiers held down. Serenity's Terminal used to send ^[[O, which is a nonexistent escape sequence and a misread of VT100's ^[O (ie the '[' is replaced by 'O'). Since the xterm scheme also supports shift and alt modifiers, switch to that. More flexible, and makes ctrl-left/right and alt-left/right work in SerenityOS's bash port. Also do this for page up/down. No behavior change for SerenityOS's Shell.
2020-09-15LibLine: Parse CSI parameters and immediatesNico Weber
No behavior change, but it makes it easy to handle page up and page down if we wanted to make them do something in libline.
2020-09-07LibLine: Make ^R search match the input anywhere in a given lineAnotherTest
This is closer to what other line editors (and shells) do, and makes ^R actually useful.
2020-09-07LibLine: Disable editing events while searchingAnotherTest
This also makes the editor clean as many lines as the searching took, for instance, in the case of <C-r><C-c>ls<tab>, two lines should be cleaned, not just one. Fixes #3413.
2020-09-07LibLine: Treat ^D as EOF only when the buffer is emptyAnotherTest
As opposed to when the cursor is at the start of the buffer. Fixes #3421.
2020-09-06LibLine: Do not reset suggestion state immediately when encountering escAnotherTest
Some multikey binding might depend on the suggestion state, and this is indeed the case for 'reverse tab', which is just '^[[Z'. Fixes #3407.
2020-08-31LibLine: Reset suggestion state on any non-tab keyAnotherTest
This fixes the following (and more!): ```sh $ /bin/dis<tab><tab><backspace><backspace><backspace><backspace><tab> $ /bink_benchmark ```
2020-08-23LibLine: Correct weird arrow up/down behaviourAnotherTest
Fixes #3270. Also removes a parameter from search(), as it had no effect.
2020-08-21LibLine: Do not ignore Ctrl-C when buffer is emptyAnotherTest
I am told that this is how people test their shells. That's bizarre to me, but sure :^)
2020-08-21LibLine: Handle interrupts/window size changes internallyAnotherTest
2020-08-21LibLine: Handle Ctrl-C and Ctrl-D in a way similar to other line editorsAnotherTest
Makes C-c print "^C" and continue prompting on a new line. Also fixes a problem where an interrupted get_line() would need more read()'s than required to update the display.
2020-08-20LibLine: Initialize the search editor when entering searchAnotherTest
Prior to this, no keybinding were installed on the search editor, and so editing wasn't really possible. Also fixes <C-r> making infinite search editors.
2020-08-18LibLine: Make actual_rendered_string_metrics() staticAnotherTest
This function didn't depend on the editor itself.
2020-08-18LibLine: Setup the keybindings after initialisationAnotherTest
This makes the keybindings that depend on `m_termios` (^W, ^U, etc) work.
2020-08-18LibLine: Allow the user to override (or add) keybinds in the config fileAnotherTest
2020-08-18LibLine: Make (almost) all key actions configurableAnotherTest
This moves all internal functions to a new file, and defines the old keybinds with register_key_input_callback().
2020-08-18LibLine: Read configuration from a config fileAnotherTest
2020-08-17LibLine: Add a getter for num_lines/num_colsAnotherTest
2020-08-17LibLine: Uninitialized members in Editor, found by CoverityBrian Gianforcaro
2020-08-09LibLine: Only write to the standard errorAnotherTest
This fixes `> asdf` and allows for all sorts of stdout redirections.
2020-08-07LibLine: Add Ctrl-k shortcutNico Weber
Only does the 'delete to end of line' bit for now. No yank ring support yet.