top working

This commit is contained in:
Liam Galvin 2018-07-05 09:29:01 +01:00
parent 702811507e
commit 73fd6ba00b
3 changed files with 15 additions and 21 deletions

View File

@ -248,15 +248,13 @@ func (gui *GUI) Render() error {
case <-updateChan: case <-updateChan:
updateRequired = 2 updateRequired = 2
case <-ticker.C: case <-ticker.C:
ca := gui.terminal.GetCellAttributes()
text.SetString( text.SetString(
fmt.Sprintf( fmt.Sprintf(
"%dx%d@%d,%d reverse=%t", "%dx%d@%d,%d",
gui.cols, gui.cols,
gui.rows, gui.rows,
gui.terminal.GetPosition().Col, gui.terminal.GetPosition().Col,
gui.terminal.GetPosition().Line, gui.terminal.GetPosition().Line,
ca.Reverse,
), ),
) )
updateRequired = 2 updateRequired = 2

View File

@ -1,7 +1,6 @@
package terminal package terminal
import ( import (
"fmt"
"strconv" "strconv"
"strings" "strings"
) )
@ -10,13 +9,6 @@ import (
type TerminalCharSet int type TerminalCharSet int
const (
C0 TerminalCharSet = iota
C1
C2
C3
)
func (terminal *Terminal) processInput(buffer chan rune) { func (terminal *Terminal) processInput(buffer chan rune) {
// https://en.wikipedia.org/wiki/ANSI_escape_code // https://en.wikipedia.org/wiki/ANSI_escape_code
@ -411,33 +403,33 @@ func (terminal *Terminal) processInput(buffer chan rune) {
b = <-buffer b = <-buffer
switch b { switch b {
case 'A': //uk @todo handle these? case 'A': //uk @todo handle these?
terminal.charSet = C0 //terminal.charSet = C0
case 'B': //us case 'B': //us
terminal.charSet = C0 //terminal.charSet = C0
} }
case ')': case ')':
b = <-buffer b = <-buffer
switch b { switch b {
case 'A': //uk @todo handle these? case 'A': //uk @todo handle these?
terminal.charSet = C1 //terminal.charSet = C1
case 'B': //us case 'B': //us
terminal.charSet = C1 //terminal.charSet = C1
} }
case '*': case '*':
b = <-buffer b = <-buffer
switch b { switch b {
case 'A': //uk @todo handle these? case 'A': //uk @todo handle these?
terminal.charSet = C2 //terminal.charSet = C2
case 'B': //us case 'B': //us
terminal.charSet = C2 //terminal.charSet = C2
} }
case '+': case '+':
b = <-buffer b = <-buffer
switch b { switch b {
case 'A': //uk @todo handle these? case 'A': //uk @todo handle these?
terminal.charSet = C3 //terminal.charSet = C3
case 'B': //us case 'B': //us
terminal.charSet = C3 //terminal.charSet = C3
} }
case '>': case '>':
// numeric char selection @todo // numeric char selection @todo
@ -467,7 +459,7 @@ func (terminal *Terminal) processInput(buffer chan rune) {
} }
} else { } else {
fmt.Printf("%s", string(b)) //fmt.Printf("%s", string(b))
if b != 0x0d { if b != 0x0d {
lineOverflow = false lineOverflow = false

View File

@ -24,7 +24,6 @@ type Terminal struct {
cellAttr CellAttributes cellAttr CellAttributes
defaultCellAttr CellAttributes defaultCellAttr CellAttributes
cursorVisible bool cursorVisible bool
charSet TerminalCharSet
} }
type Line struct { type Line struct {
@ -209,6 +208,11 @@ func (terminal *Terminal) writeRune(r rune) {
line.wrapped = true line.wrapped = true
terminal.lines = append(terminal.lines, line) 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.setRuneAtPos(terminal.position, r, wrap)
terminal.incrementPosition() terminal.incrementPosition()