Skip to content

Commit 85345fc

Browse files
authored
Merge pull request #135 from micnncim/add-ctrl-h-support
Add Ctrl-H support to delete input text
2 parents e15db71 + 289685b commit 85345fc

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

cursor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func (c *Cursor) Listen(line []rune, pos int, key rune) ([]rune, int, bool) {
195195
case 0: // empty
196196
case KeyEnter:
197197
return []rune(c.Get()), c.Position, false
198-
case KeyBackspace:
198+
case KeyBackspace, KeyCtrlH:
199199
if c.erase {
200200
c.erase = false
201201
c.Replace("")

keycodes.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ var (
1313
// KeyBackspace is the default key for deleting input text.
1414
KeyBackspace rune = readline.CharBackspace
1515

16+
// KeyCtrlH is the key for deleting input text.
17+
KeyCtrlH rune = readline.CharCtrlH
18+
1619
// KeyPrev is the default key to go up during selection.
1720
KeyPrev rune = readline.CharPrev
1821
KeyPrevDisplay = "↑"

select.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func (s *Select) innerRun(cursorPos, scroll int, top rune) (int, string, error)
273273
} else {
274274
searchMode = true
275275
}
276-
case key == KeyBackspace:
276+
case key == KeyBackspace || key == KeyCtrlH:
277277
if !canSearch || !searchMode {
278278
break
279279
}

0 commit comments

Comments
 (0)