-
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
[BUG] Arrows not moving cursor properly #47
Comments
Thanks for reporting this, I hope i can find some time this week to fix the issue seems like something important to fix. |
That's the same issue I'm having, except I can move where the chars are sent using the arrow keys. But it seems like the up/down arrow keys just do left/right. Thanks for looking into it! |
Looked into this yesterday and it seems there is a fix for this build into gocui but it's supper crappy. Right now when you are typing at the end of a sentence and you reach the end of a line it just insert a new line in-staid of adding a char to the end of the current line. (just star typing something till it line wraps and then resize the window) It seems like the first wired behavior was build as fix for the second one but the solution doesn't seems to work at all. |
I've put up a pr to fix you issue #48 can you test it on your repo and see if it fixes the issue because the pr has quite a bit of changes and i'm not sure if i may have accidentally have broken something? |
Sorry! I didn't see this, give me one sec and I'll build it in |
Seems like this doesn't fix the issue we were having with input, it actually makes it a little worse now as we can't scroll horizontally to the part of the string we want to edit. What it does now is it seems to lock the cursor to a specific point, unless we edit after a newline |
Thanks for the feedback i'll see if i can fix it. |
I think it's fixed now, can you try it again? Also you might already know this but gocui also has a nice view argument called |
I can't seem to pull your branch due to merge conflicts. As for |
I don't think is a merge conflict, |
Still no dice, for some reason the insert is happening at cursorY - 1 instead of cursorY so when the cursor is at (8,1) the insert happens at (8,0) instead of under the cursor. However if I move the cursor to be normalY+1, it inserts at the proper spot - which isn't a part of the previous string and breaks backspace. To get up to the string I have to arrow key up, which then the input jumps back up to cursorY-1. Is there some logic that interferes with when the cursor is at (X,1)? Since it works when Y=2, or if I move up so Y=0. If I manually move the cursor up to Y=0, the input aligns with the cursor. The moment I back down to Y=1, the input still happens at Y=0, if I cursor down again to Y=2, which is out of the string, it prints on the proper line and appends to the string with no newline or space |
Can you maybe provide a working go file with the problem, |
I'm not sure how to, it's the same project as last time https://github.com/Rudi9719/kbtui - the exact code that is being run is
|
Can you try this: func moveCursorToEnd(viewName string) {
g.Update(func(g *gocui.Gui) error {
inputView, err := g.View(viewName)
if err != nil {
return err
}
inputView.SetCursor(0, 0)
inputView.SetOrigin(0, 0)
lines := v.ViewBufferLines()
x := len(lines[len(lines)-1])
y := len(lines)-1
// If this gives a compile error you don't have the latest changes
inputView.MoveCursor(x, y)
return nil
})
} |
That causes some interesting behavior, now it flat out ignores up and down unless there are newlines, so navigating a string works however there is no way to jump up or down at all |
This is how an editor should behave right? |
Yes and no, this fixes the issue by removing the ability to cause it in the first place. Most editors allow you to (like here in github you can test this in a comment) just hit the up arrow to go to the line above. Before the fix, you could do that however the insert wasn't happening at the cursor. Now the insert does always happen at the cursor, at the loss of being able to use the up and down arrows. Either way, it works now :) |
Ah yes i think i see what you mean.. If for example this is the text:
And this is on screen:
If the cursor is |
Changed the way text is rendered (Fixes: #47)
Describe the bug
Arrow keys aren't moving cursor properly in view?
To Reproduce
Steps to reproduce the behavior:
On a view with editable text in it
Expected behavior
Text should be entered under the cursor. It seems like the left and right arrows work properly, however up and down arrows move cursor either left or right by one char rather than up or down.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
Additional context
Trying to pop up a view, clear it of any cruft, populate it with a string, and move the cursor to the end of the string. I tried making a func moveCursorToEnd() to try and move the cursor to the end of a view to get around this, however the func is also causing the same issue
https://github.com/Rudi9719/kbtui/tree/bugs/edit-cursor
The text was updated successfully, but these errors were encountered: