mirror of
https://github.com/golang/term.git
synced 2026-02-08 19:56:05 +03:00
go.crypto/ssh/terminal: Allow ^A and ^E as synonyms for Home and End.
I understand that ssh/terminal can't implement everybodys favorite keyboard shortcuts, but I think these are very widespread. They exist not only in Emacs or Readline, but also in Acme and Sam. Also they almost come for free. R=golang-dev CC=agl, golang-dev https://golang.org/cl/13839047
This commit is contained in:
committed by
Adam Langley
parent
4986295c47
commit
879e955024
@@ -132,6 +132,10 @@ func bytesToKey(b []byte) (rune, []byte) {
|
||||
}
|
||||
|
||||
switch b[0] {
|
||||
case 1: // ^A
|
||||
return keyHome, b[1:]
|
||||
case 5: // ^E
|
||||
return keyEnd, b[1:]
|
||||
case 8: // ^H
|
||||
return keyBackspace, b[1:]
|
||||
case 11: // ^K
|
||||
|
||||
@@ -101,6 +101,18 @@ var keyPressTests = []struct {
|
||||
line: "line1xxx",
|
||||
throwAwayLines: 2,
|
||||
},
|
||||
{
|
||||
// Ctrl-A to move to beginning of line followed by ^K to kill
|
||||
// line.
|
||||
in: "a b \001\013\r",
|
||||
line: "",
|
||||
},
|
||||
{
|
||||
// Ctrl-A to move to beginning of line, Ctrl-E to move to end,
|
||||
// finally ^K to kill nothing.
|
||||
in: "a b \001\005\013\r",
|
||||
line: "a b ",
|
||||
},
|
||||
{
|
||||
in: "\027\r",
|
||||
line: "",
|
||||
|
||||
Reference in New Issue
Block a user