Closed mjarkk closed 3 years ago
Looks good. I like the unrestricted
method too :)
Btw... I found one more bug, with the EditNewLine()
... it has moveCursor(0, 1)
which shouldn't probably be there. This is what worked for me:
func (v *View) EditNewLine() {
v.breakLine(v.cx, v.cy)
v.ox = 0
v.cy = v.cy + 1
v.cx = 0
// v.moveCursor(0, 1)
}
The bug is visible in demo.go
example. Or any example with editable text. If you come to a line with a text and hit Enter, you will move the line one below but the cursor will move one more line below. Hope it makes sense, what I said.
Note: I know this bug is not related to this PR, so if necessary I can create a new PR.
@dankox Merged it and fixed also fixed the issue you pointed out above
Fixes #81
This makes it so the SetCursor defaults to nearest buffer location if the x and y are not available in the buffer.
Also added
SetCursorUnrestricted
a function that doesn't check if the location is a valid buffer location.