From 52caedc1f1fed8507c6e986f02d6a3e771537347 Mon Sep 17 00:00:00 2001 From: Renzix <31043283+Renzix@users.noreply.github.com> Date: Tue, 29 Mar 2022 20:35:51 -0400 Subject: [PATCH 1/2] feat: delete key on st and fix: delete key crash on xterm (#131) * fix: delete key on st * fix: delete key crash on xterm Co-authored-by: Renzix --- readline/codes.go | 1 + readline/readline.go | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/readline/codes.go b/readline/codes.go index 680aa79..6ec0a99 100644 --- a/readline/codes.go +++ b/readline/codes.go @@ -48,6 +48,7 @@ var ( seqEnd = string([]byte{27, 91, 70}) seqEndSc = string([]byte{27, 91, 52, 126}) seqDelete = string([]byte{27, 91, 51, 126}) + seqDelete2 = string([]byte{27, 91, 80}) seqShiftTab = string([]byte{27, 91, 90}) seqAltQuote = string([]byte{27, 34}) // Added for showing registers ^[" seqAltR = string([]byte{27, 114}) // Used for alternative history diff --git a/readline/readline.go b/readline/readline.go index aa752b5..651a4ca 100644 --- a/readline/readline.go +++ b/readline/readline.go @@ -712,12 +712,15 @@ func (rl *Instance) escapeSeq(r []rune) { rl.updateHelpers() return - case seqDelete: + case seqDelete,seqDelete2: if rl.modeTabFind { rl.backspaceTabFind() } else { - rl.deleteBackspace(true) + if (rl.pos < len(rl.line)) { + rl.deleteBackspace(true) + } } + case seqHome, seqHomeSc: if rl.modeTabCompletion { return From 0ebd8d9035083e7a290a620af8ba444f0ac0b006 Mon Sep 17 00:00:00 2001 From: Renzix <31043283+Renzix@users.noreply.github.com> Date: Tue, 29 Mar 2022 22:15:23 -0400 Subject: [PATCH 2/2] feat: added alt backspace keybinding (#132) Co-authored-by: Renzix --- readline/codes.go | 27 ++++++++++++++------------- readline/readline.go | 13 +++++++++++++ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/readline/codes.go b/readline/codes.go index 6ec0a99..e524bc6 100644 --- a/readline/codes.go +++ b/readline/codes.go @@ -39,19 +39,20 @@ const ( // Escape sequences var ( - seqUp = string([]byte{27, 91, 65}) - seqDown = string([]byte{27, 91, 66}) - seqForwards = string([]byte{27, 91, 67}) - seqBackwards = string([]byte{27, 91, 68}) - seqHome = string([]byte{27, 91, 72}) - seqHomeSc = string([]byte{27, 91, 49, 126}) - seqEnd = string([]byte{27, 91, 70}) - seqEndSc = string([]byte{27, 91, 52, 126}) - seqDelete = string([]byte{27, 91, 51, 126}) - seqDelete2 = string([]byte{27, 91, 80}) - seqShiftTab = string([]byte{27, 91, 90}) - seqAltQuote = string([]byte{27, 34}) // Added for showing registers ^[" - seqAltR = string([]byte{27, 114}) // Used for alternative history + seqUp = string([]byte{27, 91, 65}) + seqDown = string([]byte{27, 91, 66}) + seqForwards = string([]byte{27, 91, 67}) + seqBackwards = string([]byte{27, 91, 68}) + seqHome = string([]byte{27, 91, 72}) + seqHomeSc = string([]byte{27, 91, 49, 126}) + seqEnd = string([]byte{27, 91, 70}) + seqEndSc = string([]byte{27, 91, 52, 126}) + seqDelete = string([]byte{27, 91, 51, 126}) + seqDelete2 = string([]byte{27, 91, 80}) + seqShiftTab = string([]byte{27, 91, 90}) + seqAltQuote = string([]byte{27, 34}) // Added for showing registers ^[" + seqAltR = string([]byte{27, 114}) // Used for alternative history + seqAltBackspace = string([]byte{27, 127}) ) const ( diff --git a/readline/readline.go b/readline/readline.go index 651a4ca..ddb0104 100644 --- a/readline/readline.go +++ b/readline/readline.go @@ -755,6 +755,19 @@ func (rl *Instance) escapeSeq(r []rune) { rl.updateTabFind([]rune{}) rl.viUndoSkipAppend = true + case seqAltBackspace: + if rl.modeTabCompletion { + rl.resetVirtualComp(false) + } + // This is only available in Insert mode + if rl.modeViMode != VimInsert { + return + } + + rl.saveToRegister(rl.viJumpB(tokeniseLine)) + rl.viDeleteByAdjust(rl.viJumpB(tokeniseLine)) + rl.updateHelpers() + default: if rl.modeTabFind { return