mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:07:34 +00:00
Shell: Be more smart with pasted stuff
Shell can now use LibLine's `on_paste` hook to more intelligently escape pasted data, with the following heuristics: - If the current command is invalid, just pile the pasted string on top - If the cursor is *after* a command node, escape the pasted data, whichever way yields a smaller encoding - If the cursor is at the start of or in the middle of a command name, paste the data as-is, assuming that the user wants to paste code - If the cursor is otherwise in some argument, escape the pasted data according to which kind of string the cursor is in the middle of (double-quoted, single-quoted or a simple bareword)
This commit is contained in:
parent
c4d9377477
commit
a76730823a
3 changed files with 148 additions and 66 deletions
|
@ -164,6 +164,7 @@ public:
|
|||
static String escape_token_for_double_quotes(StringView token);
|
||||
static String escape_token_for_single_quotes(StringView token);
|
||||
static String escape_token(StringView token, EscapeMode = EscapeMode::Bareword);
|
||||
static String escape_token(Utf32View token, EscapeMode = EscapeMode::Bareword);
|
||||
static String unescape_token(StringView token);
|
||||
enum class SpecialCharacterEscapeMode {
|
||||
Untouched,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue