Skip to content

Commit

Permalink
Merge pull request #135 from micnncim/add-ctrl-h-support
Browse files Browse the repository at this point in the history
Add Ctrl-H support to delete input text
  • Loading branch information
jbowes committed Sep 28, 2020
2 parents e15db71 + 289685b commit 85345fc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (c *Cursor) Listen(line []rune, pos int, key rune) ([]rune, int, bool) {
case 0: // empty
case KeyEnter:
return []rune(c.Get()), c.Position, false
case KeyBackspace:
case KeyBackspace, KeyCtrlH:
if c.erase {
c.erase = false
c.Replace("")
Expand Down
3 changes: 3 additions & 0 deletions keycodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ var (
// KeyBackspace is the default key for deleting input text.
KeyBackspace rune = readline.CharBackspace

// KeyCtrlH is the key for deleting input text.
KeyCtrlH rune = readline.CharCtrlH

// KeyPrev is the default key to go up during selection.
KeyPrev rune = readline.CharPrev
KeyPrevDisplay = "↑"
Expand Down
2 changes: 1 addition & 1 deletion select.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (s *Select) innerRun(cursorPos, scroll int, top rune) (int, string, error)
} else {
searchMode = true
}
case key == KeyBackspace:
case key == KeyBackspace || key == KeyCtrlH:
if !canSearch || !searchMode {
break
}
Expand Down

0 comments on commit 85345fc

Please sign in to comment.