Set terminal to raw mode

This commit is contained in:
Manfred Touron 2015-08-25 12:11:21 +02:00
parent f566b10f66
commit d3a30fd41c
No known key found for this signature in database
GPG Key ID: 0DCB9CE0CABAE1B5
1 changed files with 6 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import (
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"golang.org/x/crypto/ssh/terminal"
) )
// GetWebsocketURL transforms a GoTTY http URL to its WebSocket URL // GetWebsocketURL transforms a GoTTY http URL to its WebSocket URL
@ -71,6 +72,11 @@ func (c *Client) Loop() error {
} }
func (c *Client) writeLoop(done chan bool) { func (c *Client) writeLoop(done chan bool) {
oldState, err := terminal.MakeRaw(0)
if err == nil {
defer terminal.Restore(0, oldState)
}
reader := bufio.NewReader(os.Stdin) reader := bufio.NewReader(os.Stdin)
for { for {
x, size, err := reader.ReadRune() x, size, err := reader.ReadRune()