From 43eaece5ca4a25842759f61435b51f9d7b0576b0 Mon Sep 17 00:00:00 2001 From: Liam Galvin Date: Thu, 5 Jul 2018 09:31:07 +0100 Subject: [PATCH] top working --- terminal/terminal.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/terminal/terminal.go b/terminal/terminal.go index e3e7fc1..5c19973 100644 --- a/terminal/terminal.go +++ b/terminal/terminal.go @@ -140,13 +140,14 @@ func (terminal *Terminal) hideCursor() { } func (terminal *Terminal) incrementPosition() { - position := terminal.getPosition() - position.Col++ - terminal.SetPosition(position) + terminal.SetPosition(terminal.position.Col+1, terminal.position.Line) } -func (terminal *Terminal) SetPosition(position Position) { - terminal.position = position +func (terminal *Terminal) SetPosition(col int, line int) { + terminal.position = Position{ + Col: col, + Line: line, + } } func (terminal *Terminal) GetPosition() Position { @@ -224,7 +225,7 @@ func (terminal *Terminal) Clear() { for i := 0; i < int(terminal.size.Height); i++ { terminal.lines = append(terminal.lines, NewLine()) } - terminal.SetPosition(Position{Line: 0, Col: 0}) + terminal.SetPosition(0, 0) } func (terminal *Terminal) GetCellAtPos(pos Position) (*Cell, error) {