mirror of
https://github.com/gdamore/tcell.git
synced 2025-04-27 13:48:50 +08:00
views: fix corner case for limitCursor()
If m.width and m.height have not been initialized yet m.x and m.y would be set to -1. Changing the order fixes that.
This commit is contained in:
parent
440aba81dc
commit
b87161466d
@ -57,19 +57,20 @@ func (m *linesModel) GetBounds() (int, int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *linesModel) limitCursor() {
|
func (m *linesModel) limitCursor() {
|
||||||
if m.x < 0 {
|
|
||||||
m.x = 0
|
|
||||||
}
|
|
||||||
if m.y < 0 {
|
|
||||||
m.y = 0
|
|
||||||
}
|
|
||||||
if m.x > m.width-1 {
|
if m.x > m.width-1 {
|
||||||
m.x = m.width - 1
|
m.x = m.width - 1
|
||||||
}
|
}
|
||||||
if m.y > m.height-1 {
|
if m.y > m.height-1 {
|
||||||
m.y = m.height - 1
|
m.y = m.height - 1
|
||||||
}
|
}
|
||||||
|
if m.x < 0 {
|
||||||
|
m.x = 0
|
||||||
|
}
|
||||||
|
if m.y < 0 {
|
||||||
|
m.y = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *linesModel) SetCursor(x, y int) {
|
func (m *linesModel) SetCursor(x, y int) {
|
||||||
m.x = x
|
m.x = x
|
||||||
m.y = y
|
m.y = y
|
||||||
|
Loading…
x
Reference in New Issue
Block a user