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)
```
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().
And move canonicalized_path() to a static method on LexicalPath.
This is to make it clear that FileSystemPath/canonicalized_path() only
perform *lexical* canonicalization.
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
To achieve this, the API was tweaked a bit to allow for easier tracking
of completions.
This API change is non-disruptive to any application that does not use
anchored styles.
This commit also adds the concept of "anchored" styles, which are
applied to a specific part of the line, and are tracked to always stay
applied to that specific part.
Inserting text in the middle of an anchored style extends it, and
removing the styled substring causes the style to be removed as well.
LibLine should ultimately not care about what a "token" means in the
context of its user, so force the user to split the buffer itself.
This also allows the users to pick up contextual clues as well, since
they have to lex the line themselves.
This commit pacthes Shell and the JS repl to better handle completions,
so certain wrong behaviours are now corrected as well:
- JS repl can now complete "Object . getOw<tab>"
- Shell can now complete "echo | ca<tab>" and paths inside strings
We can now cycle pages of suggestions when there are more suggestions
than we can fit on one screen.
This does not inculude a visual indicator that more pages exist,
however.
This patchset fixes incorrect handling of escaped tokens (`a\ b`) in
Shell autocompletion and LibLine.
The users of LibLine can now choose between two token splitting modes,
either taking into account escapes, or ignoring them.
It does not make much sense to receive an interrupt and process it
*much later*.
Also patches Userland/js to only create exceptions while some code is
actually running.
These strings would be applied when inserted into the buffer, but are
not shown as part of the suggestion.
This commit also patches up Userland/js and Shell to use this
functionality
On the first tab, only complete the token without suggesting extra
stuff, and on further tabs, show suggestions.
Except in one case where the completion is all in the buffer, then
we show the suggestions, but do no completion.