Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ctrl-H support to delete input text #135

Merged
merged 1 commit into from
Sep 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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