Git Product home page Git Product logo

Comments (3)

dschuyler avatar dschuyler commented on May 7, 2024

Awesome. That is a good first project. (From a learning the code perspective).

I've wondered about using ctrl+L to select line too. There are a couple reasons I haven't committed it.

  • after pressing ctrl+L and the line is selected; should pressing ctrl+L again perform some action (like extending the selection to the next line or toggle the selection so that the line is no longer selected or just leave the current line selected)
  • there are limited ctrl combinations in a curses app (compared to a GUI). Some are used for regular keys (ctrl+j for return, ctrl+m for enter, ctrl+i for tab, ctrl-h for backspace). A home row ctrl key is really valuable
  • there is currently a key sequence to select a row that is only one key longer: press Home then shift+cursorDown. This also leaves an intuitive way of extending the selection (continue to hold shift and press cursor down)

Good news: ci_edit was intentionally designed to allow switching between keyboard layouts. Some preliminary work was done to allow swapping layouts on the fly so that ci keys or emacs-like or vim-like controls can be used. Making a custom layout should be doable. The sad news on this front is that code is a bit rusty. I'll make a point to improve that, so that custom layouts are better supported.

Oh also there are some mouse methods of selecting a line (I realize that going to the mouse is not acceptable to so some, but thought I mention for completeness): triple click on a line will select the line; single click on a line number will select the line (and click drag on the line numbers to select several lines); and of course click and drag down at the first character in the line will select the line.

If you'd like an example of adding ctrl+L to select a line, please let me know. I haven't mentioned it yet because it would be a bit of a spoiler, if you wanted to work it out on your own.

from ci_edit.

aaxu avatar aaxu commented on May 7, 2024

Thanks for the feedback! I really appreciate the help.

Maybe it was just because I use CTRL + L a lot that I felt it was missing. Although it is on the home row, do you have another shortcut in mind that would be more appropriate as the default? I was thinking that CTRL+L could select the current line and further use of the shortcut would extend the selection and pick up subsequent lines. The user can simply use the arrow keys to break out of this selection. I currently have it in the initCommandSet function so that all controllers would have access to the line selection (since currently there is no line number to select when you're in the InteractiveFind or InteractiveGoTo controller).

I did realize that there are a few workarounds like using the mouse or pressing HOME into SHIFT + DOWN/UP, but it just seems a lot more inconvenient.

I have a basic implementation of the shortcut right now, but I just want to make sure I am getting the meaning of the variables correct.

  • What does penRow and markerRow stand for?
  • Is scrollRow + paneRow equivalent to penRow?

from ci_edit.

dschuyler avatar dschuyler commented on May 7, 2024

Cool.

Having subsequent ctrl+L expand the selection to the next line sounds good.

Which Variables are Which

###Short version

The Row/Col of Cursor, Scroll, and Pane relate to the window's view of the buffer.
The Row/Col of Pen and Marker relate to the undo/redo mutations within the buffer.

###Long version

Cursor (Row or Col) is where the blinking text insert is in the window. Two windows (or panes) can have different cursor positions on the same buffer. The cursor will be shown to the user with a graphical indicator (a blinking block, beam, or underbar are common).

Pen (Row or Col) is where the undo/redo mutator will operate. Often, cursor and pen will be the same, but will be able to become different (I haven't finished that work yet). E.g. if there are two windows looking at the same buffer and you alternate edits in each window, the pen will move to 'where the action is', it will move to where there edits are happening.

Marker (Row or Col) cooperates with the pen to specify a span of selection. E.g. if a word is being deleted, the marker will be on one side of the word and the pen will be on the other side. I'm considering changing the name of Marker by adding more components to the pen instead (like penStartRow and penEndRow), but I haven't done that yet.

scroll (Row or Col) is the place in the buffer that corresponds to the upper left cell in the window. E.g. moving the mouse will changes the scrollRow. The scrollRow is zero when the window is scrolled to the top of the buffer. A scrollRow of five means that the first five rows of the buffer are scrolled 'off the top' of the window (and are not shown on the screen).

pane (Row Col) is a place (coordinates) of a character cell in the window. E.g. a mouse click can be partially described with pan coordinates. So scrollRow + paneRow is the place in the buffer where the mouse clicked (if the click landed on text).

Here are some relationships to make the concepts more solid

  • The penCol will not go past the end of the line it is on, while the paneCol could.
  • If scrollRow is greater than len(textBuffer.lines) then the window will be blank, so scrollRow is generally kept to something less than the number of lines in the buffer.
  • The pen and marker represent the start and end of a mutation operation, but which is the start and which is the end is not consistent (which is something I'd like to change)
  • At the moment, the cursor is simply set to the pen value, but this is a hack. There are a couple reasons that I'd like them to be able to diverge, such as multiple windows viewing the same buffer and moving the cursor after an undo.
  • Other than mouse event handling the paneRow/Col is not widely used.

Is scrollRow + paneRow equivalent to penRow?
If the mouse was just clicked within a text line, then that would hold true. i.e. I used something like that to set the pen row from a mouse click. Though they would quickly diverge so it's not a mathematical equivalence. (A bit like a broken clock being correct twice a day, sometimes things line up that way).

from ci_edit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.