diff --git a/gui/input.go b/gui/input.go index 64bc177..c1aa5c7 100644 --- a/gui/input.go +++ b/gui/input.go @@ -2,6 +2,7 @@ package gui import "github.com/go-gl/glfw/v3.2/glfw" +// send typed runes straight through to the pty func (gui *GUI) char(w *glfw.Window, r rune) { gui.terminal.Write([]byte(string(r))) } @@ -11,6 +12,15 @@ func (gui *GUI) key(w *glfw.Window, key glfw.Key, scancode int, action glfw.Acti gui.logger.Debugf("KEY PRESS: key=0x%X scan=0x%X", key, scancode) + switch true { + case mods&glfw.ModControl > 0: + switch key { + case glfw.KeyC: // ctrl^c + gui.logger.Debugf("Sending CTRL^C") + gui.terminal.Write([]byte{0x3}) // send EOT + } + } + switch key { case glfw.KeyEnter: gui.terminal.Write([]byte{0x0a}) diff --git a/main.go b/main.go index 24e42d5..990040e 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,6 @@ package main import ( "fmt" "os" - "time" "gitlab.com/liamg/raft/config" "gitlab.com/liamg/raft/gui" @@ -34,25 +33,21 @@ func main() { sugaredLogger.Infof("Allocationg pty...") pty, err := pty.NewPtyWithShell() if err != nil { - panic(err) + sugaredLogger.Fatalf("Failed to allocate pty: %s", err) } sugaredLogger.Infof("Creating terminal...") terminal := terminal.New(pty, sugaredLogger) - - go func() { - time.Sleep(time.Second * 1) - terminal.Write([]byte("tput cols && tput lines\n")) - terminal.Write([]byte("ls -la\n")) - }() + /* + go func() { + time.Sleep(time.Second * 1) + terminal.Write([]byte("tput cols && tput lines\n")) + terminal.Write([]byte("ls -la\n")) + }() + */ g := gui.New(conf, terminal, sugaredLogger) if err := g.Render(); err != nil { sugaredLogger.Fatalf("Render error: %s", err) } - - //go io.Copy(pty, os.Stdin) - //io.Copy(os.Stdout, pty) - - // return pty, err }