This commit is contained in:
Liam Galvin 2018-07-01 10:57:13 +01:00
parent db5b8be8cd
commit 726bfe6531
2 changed files with 18 additions and 13 deletions

View File

@ -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})

21
main.go
View File

@ -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
}