AnotherTest
da1b080935
LibLine: Make ^R search match the input anywhere in a given line
...
This is closer to what other line editors (and shells) do, and makes ^R
actually useful.
2020-09-07 11:42:56 +02:00
AnotherTest
39d14c22d1
LibLine: Treat ^D as EOF only when the buffer is empty
...
As opposed to when the cursor is at the start of the buffer.
Fixes #3421 .
2020-09-07 11:21:28 +02:00
AnotherTest
521475dc01
LibLine: Do not reset suggestion state immediately when encountering esc
...
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-09-06 13:00:02 +02:00
AnotherTest
084a5c6a90
LibLine: Reset suggestion state on any non-tab key
...
This fixes the following (and more!):
```sh
$ /bin/dis<tab><tab><backspace><backspace><backspace><backspace><tab>
$ /bink_benchmark
```
2020-08-31 23:06:07 +02:00
AnotherTest
f0ef283f3c
LibLine: Correct weird arrow up/down behaviour
...
Fixes #3270 .
Also removes a parameter from search(), as it had no effect.
2020-08-23 15:36:11 +02:00
AnotherTest
cf4870c93e
LibLine: Do not ignore Ctrl-C when buffer is empty
...
I am told that this is how people test their shells.
That's bizarre to me, but sure :^)
2020-08-21 17:09:41 +02:00
AnotherTest
30554c969c
LibLine: Handle interrupts/window size changes internally
2020-08-21 16:10:51 +02:00
AnotherTest
238e87de4e
LibLine: Handle Ctrl-C and Ctrl-D in a way similar to other line editors
...
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-21 16:10:51 +02:00
AnotherTest
ae9211037e
LibLine: Make actual_rendered_string_metrics() static
...
This function didn't depend on the editor itself.
2020-08-18 16:58:17 +02:00
AnotherTest
bda1d7fd7b
LibLine: Setup the keybindings after initialisation
...
This makes the keybindings that depend on `m_termios` (^W, ^U, etc) work.
2020-08-18 13:40:44 +02:00
AnotherTest
5b9d563b4b
LibLine: Allow the user to override (or add) keybinds in the config file
2020-08-18 12:07:32 +02:00
AnotherTest
32839d40e3
LibLine: Make (almost) all key actions configurable
...
This moves all internal functions to a new file, and defines the old
keybinds with register_key_input_callback().
2020-08-18 12:07:32 +02:00
AnotherTest
d0aab41628
LibLine: Read configuration from a config file
2020-08-18 12:07:32 +02:00
AnotherTest
4409cb88c9
LibLine: Only write to the standard error
...
This fixes `> asdf` and allows for all sorts of stdout redirections.
2020-08-09 21:50:33 +02:00
Nico Weber
f008e83eae
LibLine: Add Ctrl-k shortcut
...
Only does the 'delete to end of line' bit for now.
No yank ring support yet.
2020-08-07 09:07:30 +02:00
Nico Weber
530fb7eb82
LibLine: Add Alt-t shortcut for transposing words
2020-08-07 09:04:28 +02:00
Nico Weber
c1fb5263a5
LibLine: Add binding for Alt-backspace
...
It backward-deletes a word like Ctrl-W, but it has a slightly
different definition of what a word is. For example, with the
caret behind `gcc -fsanitize=address`, Ctrl-W would delete
'-fsanitize=address' but Alt-backspace would only delete 'address'.
2020-08-06 21:06:14 +02:00
Nico Weber
2051d690d5
LibLine: Fix "word" handling for alt-d/u/l/c/f/b and ctrl-left/right
...
All these shortcuts treat consecutive alnums as a word, not consecutive
non-spaces.
For example, `alias KILL='kill -9'` can now be written by typing it
out lowercase, then hitting ctrl-a alt-f alt-u.
Ctrl-W still treats a word as a sequence of non-spaces. Alt-backspace
in a future patch will add the ability to backward-delete a word
that's a sequence of alnums.
2020-08-06 20:55:27 +02:00
Nico Weber
3cc9e8ba41
LibLine+Shell: Remove unused split_mechanism
...
It was only read in should_break_token(), which had no callers.
should_break_token() also got `foo\\ bar` and `"foo bar"` wrong.
2020-08-06 20:37:39 +02:00
Nico Weber
7f7dd3cf9c
LibLine: Add binding for Alt-.
2020-08-06 20:37:17 +02:00
Nico Weber
90efba95c1
LibLine: Add bindings for Alt-u, Alt-l, Alt-c
2020-08-06 19:48:30 +02:00
Nico Weber
5d343e1c29
LibLine: Add comments for which keys trigger VWERASE and VKILL
2020-08-06 19:03:06 +02:00
Nico Weber
f29c5c3a41
LibLine: Add Alt-d binding to forward-delete a word
2020-08-06 19:03:06 +02:00
Nico Weber
4d9d054386
Shell: Start adding some alt shortcuts
...
This adds Alt-f to go forward by a word, and Alt-b to go backward
by a word (like ctrl-arrow-left / ctrl-arrow-right already do).
Behind the scenes, alt-key is implemented by sending <esc> followed
by that key, and typing <esc> f/b for moving by a word hence works
too (in all other shells too, not just in Serenity's).
While here, rename some InputState enum values to make the slightly
expanded use of <esc> clearer, and expand a few comments.
2020-08-06 17:45:31 +02:00
Nico Weber
ce95628b7f
Unicode: Try s/codepoint/code_point/g again
...
This time, without trailing 's'. Ran:
git grep -l 'codepoint' | xargs sed -ie 's/codepoint/code_point/g
2020-08-05 22:33:42 +02:00
Nico Weber
19ac1f6368
Revert "Unicode: s/codepoint/code_point/g"
...
This reverts commit ea9ac3155d
.
It replaced "codepoint" with "code_points", not "code_point".
2020-08-05 22:33:42 +02:00
AnotherTest
70eb7aa627
LibLine: Check if operating on a TTY before using TTY features
...
This makes the line editor behave well when input is passed in from
pipes as well.
2020-08-05 17:30:31 +02:00
Nico Weber
d0ad82f5c0
LibLine: Removed unused private field m_prompt_metrics
2020-08-04 17:42:08 +02:00
Andreas Kling
ea9ac3155d
Unicode: s/codepoint/code_point/g
...
Unicode calls them "code points" so let's follow their style.
2020-08-03 19:06:41 +02:00
Nico Weber
0e10a92ebc
LibLine: Add Ctrl-N/P as history next/previous shortcuts
2020-07-13 19:48:53 +02:00
Nico Weber
b0384bb1bb
LibLine: Move search-related updates into do_cursor_left/right
...
This way, arrow-left and arrow-right behave consistently with ctrl-b/ctrl-f.
2020-07-13 19:48:53 +02:00
Nico Weber
6105f063cb
LibLine: Add ctrl-t shortcut for transposing characters
2020-07-07 23:13:25 +02:00
Nico Weber
ad8e784938
LibEdit: Make Ctrl-d on an empty line mean EOD again
2020-07-07 18:43:09 +02:00
Nico Weber
f27e5ac68d
LibLine: Support Ctrl-b/f and Ctrl-d
...
And make the existing cltr-h handler easier to see.
2020-07-06 22:41:35 +02:00
Nico Weber
72f8b3d185
LibLine: Extract lambdas for cursor-left, cursor-right, delete
...
Also move the existing backspace lambda out of the loop.
The do_delete() extraction fixes a minor bug where
InputState::ExpectTerminator wasn't entered if delete was pressed at the
very end of a line. Now that this is fixed, there's no more
"LibLine: Unhandled final: 7e (~)" when hitting delete at the end of the
line.
2020-07-06 22:41:35 +02:00
Nico Weber
8c82138b22
LibLine: Put ctrl-key handlers in alphabetical order
2020-07-06 22:41:35 +02:00
Nico Weber
4726966ad7
LibLine: Replace some magic numbers with a magic function
2020-07-06 22:41:35 +02:00
AnotherTest
5fedf90bf9
LibLine: Avoid refreshing the display when resizing
...
This allows was_resized() to be called while the editor is not active
(i.e. get_line() is not in frame).
2020-07-06 22:39:32 +02:00
AnotherTest
f20becf71b
LibLine: Correctly display suggestions on multiline prompts
2020-06-30 18:21:44 +02:00
AnotherTest
a6fd969d93
LibLine: Support multiline editing
...
This commit also updates Shell, which uses actual_rendered_length.
2020-06-27 15:39:03 +02:00
Andreas Kling
fdfda6dec2
AK: Make string-to-number conversion helpers return Optional
...
Get rid of the weird old signature:
- int StringType::to_int(bool& ok) const
And replace it with sensible new signature:
- Optional<int> StringType::to_int() const
2020-06-12 21:28:55 +02:00
AnotherTest
492df51e70
LibLine: Correctly handle line content overflow when on last line
...
Fixes #2525
2020-06-07 23:54:21 +02:00
AnotherTest
aa3e440a58
LibLine: Use more descriptive names for row/column
...
The names x and y caused confusion because of their typical use as
horiz/vert.
2020-06-07 23:54:21 +02:00
AnotherTest
889a8e7d0f
LibLine: Handle interrupts again
...
This commit makes LibLine handle interrupts (as reported via
interrupted() and resized()) again.
There is a little catch with the shell:
```
$ ls |
pipe> <C-c> (prompt stays here until a key is pressed)
```
2020-06-01 19:52:20 +02:00
AnotherTest
e75f7ddb1b
LibLine: Send over some properties when being inspected
2020-05-27 11:13:02 +02:00
AnotherTest
70a213a6ec
LibLine: Use Core::EventLoop for outer read loop
...
This commit changes LibLine's internal structure to work in an event
loop, and as a result, also switches it to being a Core::Object.
2020-05-27 11:13:02 +02:00
AnotherTest
8b3eb4535d
LibLine: Use LibC's getline() when the terminal claims no support for escape sequences
...
We just look at $TERM and refuse to emit any escape sequences if it
doesn't start with "xterm".
This could be made much better, at detecting, and at not caling
getline().
2020-05-26 21:09:59 +02:00
Linus Groh
4e607192c7
LibLine: Don't add empty lines to history
2020-05-26 00:50:49 +02:00
AnotherTest
bc9013f706
LibLine: Change get_line to return a Result<String, Error>
...
This fixes a bunch of FIXME's in LibLine.
Also handles the case where read() would read zero bytes in vt_dsr() and
effectively block forever by erroring out.
Fixes #2370
2020-05-25 21:36:51 +02:00
AnotherTest
679a84d44c
LibLine: Default to resetting styles when a cell has no styles set
2020-05-23 17:05:18 +02:00