From 73fd6ba00b3eff804a6ee87c730c6047c21318b3 Mon Sep 17 00:00:00 2001 From: Liam Galvin Date: Thu, 5 Jul 2018 09:29:01 +0100 Subject: [PATCH] top working --- gui/gui.go | 4 +--- terminal/escapes.go | 26 +++++++++----------------- terminal/terminal.go | 6 +++++- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/gui/gui.go b/gui/gui.go index ad07e6c..4edad55 100644 --- a/gui/gui.go +++ b/gui/gui.go @@ -248,15 +248,13 @@ func (gui *GUI) Render() error { case <-updateChan: updateRequired = 2 case <-ticker.C: - ca := gui.terminal.GetCellAttributes() text.SetString( fmt.Sprintf( - "%dx%d@%d,%d reverse=%t", + "%dx%d@%d,%d", gui.cols, gui.rows, gui.terminal.GetPosition().Col, gui.terminal.GetPosition().Line, - ca.Reverse, ), ) updateRequired = 2 diff --git a/terminal/escapes.go b/terminal/escapes.go index 435d85f..f41f1dc 100644 --- a/terminal/escapes.go +++ b/terminal/escapes.go @@ -1,7 +1,6 @@ package terminal import ( - "fmt" "strconv" "strings" ) @@ -10,13 +9,6 @@ import ( type TerminalCharSet int -const ( - C0 TerminalCharSet = iota - C1 - C2 - C3 -) - func (terminal *Terminal) processInput(buffer chan rune) { // https://en.wikipedia.org/wiki/ANSI_escape_code @@ -411,33 +403,33 @@ func (terminal *Terminal) processInput(buffer chan rune) { b = <-buffer switch b { case 'A': //uk @todo handle these? - terminal.charSet = C0 + //terminal.charSet = C0 case 'B': //us - terminal.charSet = C0 + //terminal.charSet = C0 } case ')': b = <-buffer switch b { case 'A': //uk @todo handle these? - terminal.charSet = C1 + //terminal.charSet = C1 case 'B': //us - terminal.charSet = C1 + //terminal.charSet = C1 } case '*': b = <-buffer switch b { case 'A': //uk @todo handle these? - terminal.charSet = C2 + //terminal.charSet = C2 case 'B': //us - terminal.charSet = C2 + //terminal.charSet = C2 } case '+': b = <-buffer switch b { case 'A': //uk @todo handle these? - terminal.charSet = C3 + //terminal.charSet = C3 case 'B': //us - terminal.charSet = C3 + //terminal.charSet = C3 } case '>': // numeric char selection @todo @@ -467,7 +459,7 @@ func (terminal *Terminal) processInput(buffer chan rune) { } } else { - fmt.Printf("%s", string(b)) + //fmt.Printf("%s", string(b)) if b != 0x0d { lineOverflow = false diff --git a/terminal/terminal.go b/terminal/terminal.go index 41ce999..e3e7fc1 100644 --- a/terminal/terminal.go +++ b/terminal/terminal.go @@ -24,7 +24,6 @@ type Terminal struct { cellAttr CellAttributes defaultCellAttr CellAttributes cursorVisible bool - charSet TerminalCharSet } type Line struct { @@ -209,6 +208,11 @@ func (terminal *Terminal) writeRune(r rune) { line.wrapped = true terminal.lines = append(terminal.lines, line) } + } else { + for terminal.position.Line >= h { + terminal.position.Line-- + //terminal.lines = append(terminal.lines, NewLine()) + } } terminal.setRuneAtPos(terminal.position, r, wrap) terminal.incrementPosition()