-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New View.SetCursor() - problem/question #77
Comments
I ran into the same issue, i'm currently fixing /optimizing other stuff as well, also it potentially ran into a len(v.lines[y]) failing on a nil slice. I think they changed it to implement a logic where it is only possible to set the cursor to a position where a line is existing and allowing to set x outside of maxX when there is content in the line , or outside of the line content, when its below maxX. a little wired logic.. But in my opinion a .Clear() should also reset the cursor position to 0, so there shouldn't be the need for setting it extra. I'm new to Go, so i'm not sure if chaning it from:
to somehting like this would fix it (always let 0 values pass)
|
Seems like setting the
I've probably made those change 😅, I think we cannot go back to the old code here as it works fundamentally different. In the past the cursor position was based on the visible lines and now it's based on the buffer lines.
We could do i'm ok with either tough as we might introduce some unexpected behaviour into code bases i would suggest keeping it like it as is currently.
I'm not sure if we should exactly do that but your point is right i think we indeed should allow setting the cursor position to 0,0 on empty buffers as it's a common action after |
I was looking thru it to understand the problem a bit more and here is what I learned (feel free to correct me). For this I would suggest solution in a way, to basically check the cursor, and if it's not in the However, there is still one problem as expected :) and that is mouse position. Mouse set cursor position to |
Why check if it's inside the view range? |
Hmmm... so you mean anywhere in limit of |
It's relative to the buffer not to the view. I made this change because i don't know of any situation where you would have scrollable text and want to place the cursor relative to the view and not relative to the buffer. |
I think setting it on the buffer makes more sense, but it should work when the buffer is nil. I also discovered an offset bug: When clearing a buffer the view offsets are not getting reset to 0 which leads to a missing first character in an single line input prompt which got scrolled recently. I also set v.ox and v.oy to 0 on a v.Clear() in my current patched version. |
Hmm you're right maybe we should reset everything in the clear function. |
I've checked it. I think that should "clear" most of the problem with |
I've merged the PR to fix the issue and created a new release v1.0.0-beta-3 |
I found this problem when I was trying to update my application to use gocui version
v1.0.0-beta-2
.I had there code like this (where
v
is referencinggocui.View
):The
View
which is there, is 1 line in height. It's basically a command prompt and after hitting enter, the prompt will be cleared and cursor set to the beginning.I know that I don't have error checks :) but the point is, that after the upgrade the function
SetCursor
was changed like this:gocui/view.go
Line 239 in a0f5add
Now after
View.Clear
(which setsv.lines = nil
) I can't really runView.SetCursors(0, 0)
. Easy fix for me in this situation is just to moveSetCursor
aboveClear
, but I'm just wondering if this shouldn't be fixed ingocui
too.@mjarkk I think you did these changes regarding the line buffer. So I would like to hear your opinion. Before the check was like this:
Which makes it work, because the
maxY
is 1 in my case. And it kinda makes sense, because you could point anywhere into the view this way.So I'm curious about the reason to limit the
SetCursor
this way, as it appears that before it was possible to set it in the range of theView
dimension while after the change the limitation is to the lines in the line buffer.The text was updated successfully, but these errors were encountered: