Skip to content

Make some helpers for views navigate#70

Open
sinkevichmm wants to merge 2 commits into
awesome-gocui:masterfrom
sinkevichmm:feature-view-helpers
Open

Make some helpers for views navigate#70
sinkevichmm wants to merge 2 commits into
awesome-gocui:masterfrom
sinkevichmm:feature-view-helpers

Conversation

@sinkevichmm

Copy link
Copy Markdown

added functions BufferLinePosition, SetViewLineUp, SetViewLineDown and example.

@sinkevichmm sinkevichmm changed the title make some helpers for views navigate Make some helpers for views navigate Sep 9, 2020
@glvr182

glvr182 commented Sep 10, 2020

Copy link
Copy Markdown

Thanks for the pr! Ill test your code tomorrow, so far it looks good!

@sinkevichmm

Copy link
Copy Markdown
Author

Thanks for the pr! Ill test your code tomorrow, so far it looks good!

Ok!)

@glvr182

glvr182 commented Sep 16, 2020

Copy link
Copy Markdown

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
@glvr182

glvr182 commented Sep 26, 2020

Copy link
Copy Markdown

When i run your example, on [3] the cursor value changes, but the cursor does not move. Is this the intended behaviour?

@sinkevichmm

Copy link
Copy Markdown
Author

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.

@glvr182

glvr182 commented Oct 27, 2020

Copy link
Copy Markdown

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

@aliakseiz

Copy link
Copy Markdown

@sinkevichmm thank you for this PR.
Your functions SetViewLineUp and SetViewLineDown helped me to make the scrolling work again, as it was in the forked gocui.
awesome-gocui spoiled it completely.

@glvr182 any progress on the review?

@glvr182

glvr182 commented Jun 7, 2021

Copy link
Copy Markdown

Going to ask @mjarkk to take this

@mjarkk mjarkk left a comment

Copy link
Copy Markdown
Member

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

Comment thread view.go

// SetViewLineUp sets the cursor position of the view at the one line up
func (v *View) SetViewLineUp() {
if v.cy > 0 {

Copy link
Copy Markdown
Member

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?

Comment thread view.go
func (v *View) SetViewLineDown() {
_, maxY := v.Size()
if v.cy+v.oy < v.ViewLinesHeight()-1 {
if v.cy >= maxY-1 {

Copy link
Copy Markdown
Member

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?

Comment thread view.go
// 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 {

Copy link
Copy Markdown
Member

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:

Suggested change
if v.cy+v.oy < v.ViewLinesHeight()-1 {
if v.cy+v.oy >= v.ViewLinesHeight()-1 {
return
}

Comment thread edit.go
}

}
v.lines[y] = append(v.lines[y][:x], v.lines[y][x+1:]...)

Copy link
Copy Markdown
Member

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:

半角

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants