fixed resize issues at last

This commit is contained in:
Liam Galvin 2018-07-03 16:53:36 +01:00
parent af62fef8d5
commit 6fbcc3003e
1 changed files with 13 additions and 2 deletions

View File

@ -291,7 +291,7 @@ func (terminal *Terminal) SetSize(newCols int, newLines int) error {
terminal.position.Line++ terminal.position.Line++
} else if terminal.getPosition().Line == l { } else if terminal.getPosition().Line == l {
if terminal.getPosition().Col >= newCols { if terminal.getPosition().Col >= newCols {
terminal.position.Line++ //terminal.position.Line++
} }
} }
} }
@ -309,7 +309,7 @@ func (terminal *Terminal) SetSize(newCols int, newLines int) error {
// remove line // remove line
terminal.lines = append(terminal.lines[:l+1], terminal.lines[l+2:]...) terminal.lines = append(terminal.lines[:l+1], terminal.lines[l+2:]...)
if terminal.getPosition().Line >= l+1 { if terminal.getPosition().Line >= l+1 {
terminal.position.Line-- //terminal.position.Line--
} }
} }
} }
@ -318,6 +318,17 @@ func (terminal *Terminal) SetSize(newCols int, newLines int) error {
} }
} }
if terminal.position.Line >= newLines {
terminal.position.Line = newLines - 1
} else {
linesFromEnd := oldLines - terminal.position.Line
terminal.position.Line = newLines - linesFromEnd
if terminal.position.Line >= len(terminal.lines) {
terminal.position.Line = len(terminal.lines) - 1
}
}
} }
terminal.size.Width = uint16(newCols) terminal.size.Width = uint16(newCols)