diff --git a/terminal.go b/terminal.go index 66439cf..86853d6 100644 --- a/terminal.go +++ b/terminal.go @@ -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 diff --git a/terminal_test.go b/terminal_test.go index 7fbf0e6..641576c 100644 --- a/terminal_test.go +++ b/terminal_test.go @@ -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: "",