-
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
Make some helpers for views navigate #70
base: master
Are you sure you want to change the base?
Make some helpers for views navigate #70
Conversation
Thanks for the pr! Ill test your code tomorrow, so far it looks good! |
Ok!) |
Okay so i havent gotten around to it... I'm a bit busy right now so ill try to get around to it. Maybe @mjarkk can take a look at it |
fixed delete of rune when navigating with the mouse
When i run your example, on [3] the cursor value changes, but the cursor does not move. Is this the intended behaviour? |
Yes, this is an example with a wrap line that allows you to correctly display in view "props". The cursor has moved to a new line in the view array, but it is on the same line in the buffer array. |
I mean that would of course be the expected result, however I fear that the tools that rely on Gocui are now expecting it to work wrong and would be confused if suddenly it worked right I have been less active in the dev world since I'm very busy with university right now, so replies can take longer than expected |
@sinkevichmm thank you for this PR. @glvr182 any progress on the review? |
Going to ask @mjarkk to take this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah was gone for a while but here i am :)
Have a few questions and suggested changes.
Also can you fix the merge conflict
@@ -225,6 +236,27 @@ func (v *View) SetCursor(x, y int) error { | |||
return nil | |||
} | |||
|
|||
// SetViewLineUp sets the cursor position of the view at the one line up | |||
func (v *View) SetViewLineUp() { | |||
if v.cy > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should'd we add an extra v.Editable check here?
func (v *View) SetViewLineDown() { | ||
_, maxY := v.Size() | ||
if v.cy+v.oy < v.ViewLinesHeight()-1 { | ||
if v.cy >= maxY-1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should'd we add an extra v.Editable check here?
// SetViewLineDown sets the cursor position of the view at the one line down | ||
func (v *View) SetViewLineDown() { | ||
_, maxY := v.Size() | ||
if v.cy+v.oy < v.ViewLinesHeight()-1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change this code to be like this, so we don't have nested ifs:
if v.cy+v.oy < v.ViewLinesHeight()-1 { | |
if v.cy+v.oy >= v.ViewLinesHeight()-1 { | |
return | |
} |
} | ||
|
||
} | ||
v.lines[y] = append(v.lines[y][:x], v.lines[y][x+1:]...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tested this with half width characters?
For example:
半角
added functions BufferLinePosition, SetViewLineUp, SetViewLineDown and example.