From d91a17c74bc6557e18b7e096f221d9e2b78bb7ae Mon Sep 17 00:00:00 2001 From: rrrooommmaaa Date: Tue, 19 Feb 2019 22:42:32 +0300 Subject: [PATCH] ESC key for vi (#227) * #225 ESC press doesn't work as expected under vi * fix: BEL OSC terminator for Windows * bug fix: correcte DA2 handling --- gui/input.go | 14 +++----------- platform/winpty.go | 2 +- terminal/csi.go | 21 ++++++--------------- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/gui/input.go b/gui/input.go index ab97d68..0357d62 100644 --- a/gui/input.go +++ b/gui/input.go @@ -196,17 +196,9 @@ func (gui *GUI) key(w *glfw.Window, key glfw.Key, scancode int, action glfw.Acti gui.terminal.Write([]byte(fmt.Sprintf("\x1b[6;%s~", modStr))) } case glfw.KeyEscape: - if gui.terminal.IsApplicationCursorKeysModeEnabled() { - gui.terminal.Write([]byte{ - 0x1b, - }) - } else { - gui.terminal.Write([]byte{ - 0x1b, - '[', - 0x1b, - }) - } + gui.terminal.Write([]byte{ + 0x1b, + }) case glfw.KeyTab: gui.terminal.Write([]byte{ 0x09, diff --git a/platform/winpty.go b/platform/winpty.go index ebeeec2..d330745 100644 --- a/platform/winpty.go +++ b/platform/winpty.go @@ -223,7 +223,7 @@ func NewPty(x, y int) (pty Pty, err error) { innerOutPipe: outputWriteSide, hcon: uintptr(hc), platformDependentSettings: PlatformDependentSettings{ - OSCTerminators: map[rune]struct{}{0x00: {}}, + OSCTerminators: map[rune]struct{}{0x00: {}, 0x07: {}}, }, } diff --git a/terminal/csi.go b/terminal/csi.go index c749951..8756ff2 100644 --- a/terminal/csi.go +++ b/terminal/csi.go @@ -114,25 +114,16 @@ func csiHandler(pty chan rune, terminal *Terminal) error { func csiSendDeviceAttributesHandler(params []string, terminal *Terminal) error { // we are VT100 - // for DA1 we'll respond 1;2 - // for DA2 we'll respond 0;0;0 + // for DA1 we'll respond ?1;2 + // for DA2 we'll respond >0;0;0 - response := "1;2" + response := "?1;2" - if len(params) > 0 { - param, err := strconv.Atoi(params[0]) - - if err != nil { - return fmt.Errorf("Invalid parameter in DA request: %s", params[0]) - } - - if param > 0 { - // DA2 - response = "0;0;0" - } + if len(params) > 0 && len(params[0]) > 0 && params[0][0] == '>' { + response = ">0;0;0" } - _ = terminal.Write([]byte("\x1b[?" + response + "c")) + _ = terminal.Write([]byte("\x1b[" + response + "c")) return nil }