From 7052982d32f709ff664cff78ff8e064b5b807b23 Mon Sep 17 00:00:00 2001 From: Liam Galvin Date: Sun, 28 Oct 2018 16:36:26 +0000 Subject: [PATCH] Fix for zsh --- config.go | 1 + config/config.go | 1 + gui/input.go | 28 +++++++++++++++++++++++++++- main.go | 4 ++++ terminal/csi.go | 2 +- 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/config.go b/config.go index 86a4bac..07f5d09 100644 --- a/config.go +++ b/config.go @@ -18,6 +18,7 @@ func getConfig() *config.Config { conf := loadConfigFile() + flag.StringVar(&conf.Shell, "shell", conf.Shell, "Specify the shell to use") flag.BoolVar(&conf.DebugMode, "debug", conf.DebugMode, "Enable debug logging") flag.BoolVar(&conf.Slomo, "slomo", conf.Slomo, "Render in slow motion (useful for debugging)") flag.BoolVar(&conf.Rendering.AlwaysRepaint, "always-repaint", conf.Rendering.AlwaysRepaint, "Always repaint the window, even when no changes have occurred") diff --git a/config/config.go b/config/config.go index 0c98cdf..24ee94e 100644 --- a/config/config.go +++ b/config/config.go @@ -11,6 +11,7 @@ type Config struct { Rendering RenderingConfig `toml:"rendering"` Slomo bool `toml:"slomo"` ColourScheme ColourScheme `toml:"colours"` + Shell string `toml:"shell"` } type RenderingConfig struct { diff --git a/gui/input.go b/gui/input.go index 347cae2..b5ebc62 100644 --- a/gui/input.go +++ b/gui/input.go @@ -55,6 +55,26 @@ func (gui *GUI) key(w *glfw.Window, key glfw.Key, scancode int, action glfw.Acti gui.logger.Debugf("Sending CTRL^C") gui.terminal.Write([]byte{0x3}) // send EOT return + case glfw.KeyD: + gui.logger.Debugf("Sending CTRL^D") + gui.terminal.Write([]byte{0x4}) // send EOT + return + case glfw.KeyH: + gui.logger.Debugf("Sending CTRL^H") + gui.terminal.Write([]byte{0x08}) + return + case glfw.KeyJ: + gui.logger.Debugf("Sending CTRL^J") + gui.terminal.Write([]byte{0x0a}) + return + case glfw.KeyM: + gui.logger.Debugf("Sending CTRL^M") + gui.terminal.Write([]byte{0x0d}) + return + case glfw.KeyX: + gui.logger.Debugf("Sending CTRL^X") + gui.terminal.Write([]byte{0x18}) + return } case modsPressed(mods, glfw.ModAlt, glfw.ModShift): modStr = "4" @@ -199,6 +219,10 @@ func (gui *GUI) key(w *glfw.Window, key glfw.Key, scancode int, action glfw.Acti }) } case glfw.KeyEnter: + gui.terminal.Write([]byte{ + 0x0d, + }) + case glfw.KeyKPEnter: if gui.terminal.IsApplicationCursorKeysModeEnabled() { gui.terminal.Write([]byte{ 0x1b, @@ -206,7 +230,9 @@ func (gui *GUI) key(w *glfw.Window, key glfw.Key, scancode int, action glfw.Acti 'M', }) } else { - gui.terminal.Write([]byte{0x0d}) + gui.terminal.Write([]byte{ + 0x0d, + }) } case glfw.KeyBackspace: gui.terminal.Write([]byte{0x08}) diff --git a/main.go b/main.go index 15501f9..b101720 100644 --- a/main.go +++ b/main.go @@ -33,6 +33,10 @@ func main() { logger.Fatalf("Failed to ascertain your shell: %s", err) } + if conf.Shell != "" { + shellStr = conf.Shell + } + os.Setenv("TERM", "xterm-256color") // contraversial! easier than installing terminfo everywhere, but obviously going to be slightly different to xterm functionality, so we'll see... os.Setenv("COLORTERM", "truecolor") diff --git a/terminal/csi.go b/terminal/csi.go index d1e8b1f..7ead116 100644 --- a/terminal/csi.go +++ b/terminal/csi.go @@ -395,7 +395,7 @@ func csiEraseInDisplayHandler(params []string, intermediate string, terminal *Te terminal.ActiveBuffer().EraseDisplayFromCursor() case "1": terminal.ActiveBuffer().EraseDisplayToCursor() - case "2": + case "2", "3": terminal.ActiveBuffer().EraseDisplay() default: return fmt.Errorf("Unsupported ED: CSI %s J", n)