Skip to content
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

Add Page Up and Page Down #1114

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kanishkarj
Copy link
Contributor

Addresses #698

  • Implement
  • Test if working
  • Write tests

I am not sure how to test this. Can someone guide me?

@scholtzan scholtzan self-assigned this Feb 9, 2019
Copy link
Member

@scholtzan scholtzan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking this on!

At the moment the core doesn't actually make the frontend scroll to the new position. So for now nothing is happening. I added some inline comments as to why that is.

I think the easiest way to test the functionality for now is to implement the page_up and page_down in the frontend your are using (or maybe they are already implemented?) and just manually test and play around with it. After that unit tests can be added to ensure that selections and the visible line ranges are correct.

One important thing that should be mentioned here is the distinction between PageUp/PageDown and ScrollPageUp/ScrollPageDown. In the case of scroll page the cursor position is not changed whereas for page up and page down the cursor position actually changes. To make this a bit more clear here some videos:

The following shows the case for ScrollPageUp and ScrollPageDown. Note that the cursor remains on scrollView the entire time while scrolling up and down.
scrollpage

The following is what you are going to implement in this PR, PageUp and PageDown. Note that the cursor actually changes while moving pages up and down.
pageupdown

So what you are currently missing is that the cursor needs to be changed. Another thing is that selection can get collapsed.
It might be interesting to see how different editors implement this behaviour. I looked at XCode and Sublime and there are some minor differences between them.

let scroll_height: i64 = self.scroll_height() as i64;
match movement {
Movement::DownPage => {
self.set_scroll(first_line - scroll_height, first_line);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now this only updates first_line and height in View but does not tell the frontend to actually scroll to that position. So for now nothing happens.
To make it scroll you have to set self.scroll_to = Some(<position>);
There are some functions in View where this is already used, for example in scroll_to_cursor, which might be helpful.

@scholtzan scholtzan removed their assignment Feb 9, 2019
@kanishkarj
Copy link
Contributor Author

But doesn't xi-editor already implement that? PageUp and PageDown are working on the GXI front-end. That's why I assumed I was supposed to implement ScrollPageUp/ScrollPageDown. I have attached a clip of what happens in GXI on PageUp and PageDown, take a look at it.

peek 2019-02-10 11-38

@scholtzan
Copy link
Member

Oh, I see. It seems that the xi-mac frontend doesn't implement it correctly. Yeah, then it makes sense to not change the selections when doing PageUp/PageDown. ScrollPage seems to move the cursor to the end/beginning of the visible line range.

@kanishkarj
Copy link
Contributor Author

Yes, so shall I go with implementing this properly ? Like without changing the selection.

@scholtzan
Copy link
Member

Yeah sure, go ahead.

@kanishkarj
Copy link
Contributor Author

I need some help with getting the cursor to not move. I tried messing around with selections and carets, but couldn't get much out of it.

@jansol
Copy link
Collaborator

jansol commented Mar 12, 2019

@scholtzan do you have any pointers for this?

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.

None yet

3 participants