summaryrefslogtreecommitdiffstats
path: root/src/tui
diff options
context:
space:
mode:
authorSyphdias <syphdias+git@gmail.com>2023-05-21 11:40:05 +0200
committerGitHub <noreply@github.com>2023-05-21 18:40:05 +0900
commit37f258b1bf863633205548e7b8194776daab463b (patch)
tree307c214a985ffe24441aec0a0169a5e661783900 /src/tui
parente2dd2a133e780dbc9184ecf04892edaa98115e8a (diff)
Add key combinations for ctrl-delete and shift-delete (#3284)
Currently there is not option to bind ctrl-delete and shift-delete. As suggested by issue #3240, shift-delete could be used to bind "delete entry from history" as it is a common way to do so in other applications, e.g. browsers. This, however, does only implement to use the key combination itself and does not assign a default action to any of them. This does enable to call one's all predefined actions. With the exec action this can expanded like the issue #3240 suggested. If desirable, the key combinations could later get a default behavior. Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
Diffstat (limited to 'src/tui')
-rw-r--r--src/tui/light.go14
-rw-r--r--src/tui/tcell.go6
-rw-r--r--src/tui/tui.go2
3 files changed, 21 insertions, 1 deletions
diff --git a/src/tui/light.go b/src/tui/light.go
index bc44b4f8..8356eb50 100644
--- a/src/tui/light.go
+++ b/src/tui/light.go
@@ -430,7 +430,19 @@ func (r *LightRenderer) escSequence(sz *int) Event {
}
return Event{Invalid, 0, nil} // INS
case '3':
- return Event{Del, 0, nil}
+ if r.buffer[3] == '~' {
+ return Event{Del, 0, nil}
+ }
+ if len(r.buffer) == 6 && r.buffer[5] == '~' {
+ *sz = 6
+ switch r.buffer[4] {
+ case '5':
+ return Event{CtrlDelete, 0, nil}
+ case '2':
+ return Event{SDelete, 0, nil}
+ }
+ }
+ return Event{Invalid, 0, nil}
case '4':
return Event{End, 0, nil}
case '5':
diff --git a/src/tui/tcell.go b/src/tui/tcell.go
index f82482d7..f815df07 100644
--- a/src/tui/tcell.go
+++ b/src/tui/tcell.go
@@ -413,6 +413,12 @@ func (r *FullscreenRenderer) GetChar() Event {
case tcell.KeyHome:
return Event{Home, 0, nil}
case tcell.KeyDelete:
+ if ctrl {
+ return Event{CtrlDelete, 0, nil}
+ }
+ if shift {
+ return Event{SDelete, 0, nil}
+ }
return Event{Del, 0, nil}
case tcell.KeyEnd:
return Event{End, 0, nil}
diff --git a/src/tui/tui.go b/src/tui/tui.go
index 63bdfa83..55fbe771 100644
--- a/src/tui/tui.go
+++ b/src/tui/tui.go
@@ -41,6 +41,7 @@ const (
CtrlZ
ESC
CtrlSpace
+ CtrlDelete
// https://apple.stackexchange.com/questions/24261/how-do-i-send-c-that-is-control-slash-to-the-terminal
CtrlBackSlash
@@ -74,6 +75,7 @@ const (
SDown
SLeft
SRight
+ SDelete
F1
F2