google / ci_edit

A terminal text editor with mouse support and ctrl+Q to quit.
Apache License 2.0
222 stars 53 forks source link

Scrolling up while cursor is on the message line or status line #58

Open aaxu opened 7 years ago

aaxu commented 7 years ago

This can be reproduced by the following steps:

  1. Start a new document
  2. Hold enter until you have enough lines to make the text buffer scroll up
  3. Scroll up and place the cursor back on the first line.
  4. Put your mouse over either the message line or status line
  5. Scroll up using the mouse wheel

Expected behavior: Text buffer scrolls down Actual behavior: Text buffer scrolls up, cursor moves down and all text in between is highlighted.

aaxu commented 7 years ago

Also a question: when I scroll the mouse wheel down (towards me), I expect the text buffer to scroll upward so I can see what is below my current view. Thus, I expect mouseWheelDown and scrollUp to be called. Is this not the case for you? The naming always confuses me LOL and I just want to make sure what's happening.

aaxu commented 7 years ago

A few more questions:

dschuyler commented 7 years ago

Interesting effect/bug.

Which way is up

What is up vs. down is a long time debate in computer UI's. I've heard there were debates on it in Xerox PARC and Apple back when scrolling UIs were first done. With mouse wheels and touchpads the debate continued. IIUC, at the heart of the debate is whether the user is scrolling the cursor (focus) or whether they are scrolling the document. Now with touchpads, imo, a self evident decision has arrived because it's more intuitive for the screen to follow the user's finger (i.e. scrolling the document) when moving (rather than going the other way). Mac (and maybe others) have an OS option to reverse the scroll direction of a mouse wheel/trackpad. (Any of the above could be wrong, that's my memory of it off the top of my head).

Maybe app.prefs.editor['scrollDirection']

Maybe we should include an option to reverse the scroll direction.

Captive Cursor

Other console editors, such as vi, keep the cursor on the screen when scrolling. So if the window is scrolled away from the cursor, the cursor gets 'caught' by the window border and dragged along so that it stays on-screen* (what I call captive**). GUI editors don't tend to do that, they leave the cursor in-place within the document while the window scrolls.

ci initially acted more like a console editor

So when I started ci_edit, I kept the cursor on the screen and added a marker feature. After some time, I began to ask myself why, why was doing what had been done before and whether that was really the most intuitive design. When I made the cursor behave more like a GUI editor I decided not to remove the code that held the cursor 'captive' on the screen, so I put it behind a preference setting. I suspect (bet on) someone in the future having a desire for the captive cursor behavior, and thought it would be nice to offer it.

*For this reason a 'marker' feature is necessary to specify ranges of text for acting upon (like cut, or copy). Leaving the cursor in-place to mark a position doesn't work if the user wants to act on more than a screen full of text. Since GUI editors that leave the cursor in-place within the document, the cursor itself acts as the 'marker' so a separate marker concept/feature is not needed.

**I don't think 'captive' is an official term, I just needed something to call it and 'captive' filled the need for a name.

dschuyler commented 7 years ago

Also, confusingly (unless ya don't think about it, then it's fine)* a click-and-drag action actually reverses the scrolling behavior. This is because the scrolling paradigm changes from scrolling the document to scrolling the cursor (focus).

*UI scrolling is like walking. It's all fine unless ya think about it too much, then it becomes a complicated mess :).

aaxu commented 6 years ago

Update: I think the main point of this PR is that scrolling when on the status line makes the textbuffer go in the opposite direction than if you scroll with the mouse on the main text buffer.

Edit: By default, we have natural scrolling turned OFF, so scrolling up should show earlier lines. Currently, scrolling up with the mouse on the message line/stats line makes the textbuffer scroll down (as if natural scrolling is turned ON) Scrolling down with the mouse at this area makes the cursor go to the bottom of the document and all text in between gets highlighted.