mirror of
https://github.com/felixangell/phi.git
synced 2024-08-16 11:10:37 +03:00
clamp camera fixes panic when trying to scroll out of bounds
This commit is contained in:
parent
2012c04a10
commit
a7ce51cac2
@ -1092,6 +1092,14 @@ func (b *Buffer) OnUpdate() bool {
|
||||
b.cam.y = b.cam.dy
|
||||
}
|
||||
|
||||
// clamp camera
|
||||
if b.cam.y <= 0 {
|
||||
b.cam.y = 0
|
||||
}
|
||||
if b.cam.x <= 0 {
|
||||
b.cam.x = 0
|
||||
}
|
||||
|
||||
switch strife.MouseButtonsState() {
|
||||
case strife.LeftMouseButton:
|
||||
b.processLeftClick()
|
||||
@ -1268,6 +1276,7 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) {
|
||||
if start > len(b.table.Lines) {
|
||||
start = len(b.table.Lines)
|
||||
}
|
||||
|
||||
if upper > len(b.table.Lines) {
|
||||
upper = len(b.table.Lines)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user