mirror of https://github.com/liamg/aminal.git
ctrl^c
This commit is contained in:
parent
db5b8be8cd
commit
726bfe6531
10
gui/input.go
10
gui/input.go
|
@ -2,6 +2,7 @@ package gui
|
||||||
|
|
||||||
import "github.com/go-gl/glfw/v3.2/glfw"
|
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) {
|
func (gui *GUI) char(w *glfw.Window, r rune) {
|
||||||
gui.terminal.Write([]byte(string(r)))
|
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)
|
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 {
|
switch key {
|
||||||
case glfw.KeyEnter:
|
case glfw.KeyEnter:
|
||||||
gui.terminal.Write([]byte{0x0a})
|
gui.terminal.Write([]byte{0x0a})
|
||||||
|
|
21
main.go
21
main.go
|
@ -3,7 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
|
||||||
|
|
||||||
"gitlab.com/liamg/raft/config"
|
"gitlab.com/liamg/raft/config"
|
||||||
"gitlab.com/liamg/raft/gui"
|
"gitlab.com/liamg/raft/gui"
|
||||||
|
@ -34,25 +33,21 @@ func main() {
|
||||||
sugaredLogger.Infof("Allocationg pty...")
|
sugaredLogger.Infof("Allocationg pty...")
|
||||||
pty, err := pty.NewPtyWithShell()
|
pty, err := pty.NewPtyWithShell()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
sugaredLogger.Fatalf("Failed to allocate pty: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sugaredLogger.Infof("Creating terminal...")
|
sugaredLogger.Infof("Creating terminal...")
|
||||||
terminal := terminal.New(pty, sugaredLogger)
|
terminal := terminal.New(pty, sugaredLogger)
|
||||||
|
/*
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(time.Second * 1)
|
time.Sleep(time.Second * 1)
|
||||||
terminal.Write([]byte("tput cols && tput lines\n"))
|
terminal.Write([]byte("tput cols && tput lines\n"))
|
||||||
terminal.Write([]byte("ls -la\n"))
|
terminal.Write([]byte("ls -la\n"))
|
||||||
}()
|
}()
|
||||||
|
*/
|
||||||
|
|
||||||
g := gui.New(conf, terminal, sugaredLogger)
|
g := gui.New(conf, terminal, sugaredLogger)
|
||||||
if err := g.Render(); err != nil {
|
if err := g.Render(); err != nil {
|
||||||
sugaredLogger.Fatalf("Render error: %s", err)
|
sugaredLogger.Fatalf("Render error: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
//go io.Copy(pty, os.Stdin)
|
|
||||||
//io.Copy(os.Stdout, pty)
|
|
||||||
|
|
||||||
// return pty, err
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue