point, mark, and region, like in emacs

2012-03-01
2012-10-17
  • Kostas Oikonomou

    Is it possible to add to TeXstudio the concepts of point, mark, and region,
    like in GNU emacs?
    So that, for example, I can set the mark at the current point (cursor
    location) by some key combination like Ctrl-space, and then, when I move the
    cursor with the keyboard, the region between the mark and the current location
    (point) is highlighted.
    Then if I do a "cut", for example, the highlighted region is cut. And can be
    pasted wherever I move the point.

    Of course, it is possible right now to select a region with the mouse, and cut
    it, etc, but it would nice to be able to do it with the keyboard as well.

     
  • Tim Hoffmann

    Tim Hoffmann - 2012-03-12

    It would of course be possible, but I don't see the real benefit.

    1. I think outside emacs this is not a common paradigm.
    2. You can select text by keyboard, if you hold <Shift> while moving the cursor. That's pretty much the same as you want.
     
  • Kostas Oikonomou

    1. I agree, but if you are a long-time emacs user you really miss this way of marking regions. And TeXstudio already lets you define key bindings that make it behave like emacs, which is one of its most attractive features.
    2. Yes, I tried that, it works if you move the cursor with the arrow keys, but not if you move it with emacs-like commands, e.g. Ctrl+f.

    Anyhow, could you give some hints about how to implement this in Javascript?

    The first issue is how to set the "mark" (maybe "bookmark" in Texstudio
    terminology?) using the keyboard. Then how to emulate the "hold Shift key
    while moving cursor" behavior.

     
  • Tim Hoffmann

    Tim Hoffmann - 2012-03-12

    Sorry, I'm neither a Javascript expert nor have I looked into the scripting
    capabilities so far. Maybe the other developers can comment on your problem.

     
  • Benito van der Zander

    Anyhow, could you give some hints about how to implement this in Javascript?

    With cursor.lineNumber(), cursor.columnNumber() you can get the current
    cursor position.

    With setGlobal("name...", ...) you can save a value and retrieve it
    later with getGlobal("name...").

    And with cursor.select(line, column, lineTo, columnTo) you can select an
    area .

    So you could write a script to save the current position, and then
    another one to select
    everything from that saved position to the next current cursor position.

    On 03/12/12 23:20, SourceForge.net wrote:

     
  • Kostas Oikonomou

    Thanks. I wrote the two scripts, they seem to work. Two more questions:

    1. Can I bind the scripts to a key combination other than Shift-F1, Shift-F2?
    2. Say I run the first script, that saves the position of the cursor, or "sets the mark" in Emacs terms. Now can I somehow modify the 2nd script to "run continuously", so the region between the mark and the current cursor position is highlighted as the cursor moves?
     
  • Benito van der Zander

    1. Can I bind the scripts to a key combination other than Shift-F1,
      Shift-F2?
      On the shortcut config page, like all menu item keys
      Now can I somehow modify the 2nd script to "run
      continuously", so the region between the mark and the current cursor
      position
      is highlighted as the cursor moves?
      That's an interesting question.
      You can't do it in 2.3, but perhaps in the current svn version.
      And it is not possible to add an new highlighted area, but you could
      change the cursor selection everytime the cursor moves, by binding a
      function to the cursorPositionChanged signal of editor (see the new
      usermanual for signal scripting)...

    On 03/14/12 23:17, SourceForge.net wrote:

     
  • Kostas Oikonomou

    No, I don't want to add a new highlighted area. What I want is the following
    two functionalities:

    1. If I set the mark somewhere, and then I click somewhere else with the mouse, the region between the mark and the click is highlighted. (And then I can cut it, etc)
    2. If I set the mark somewhere, and then I start moving the cursor with the keyboard, e.g. with Ctrl-f (emacs key binding for "move right"), or Ctrl-n ("go down"), the highlight "follows" the region.
     
  • Benito van der Zander

    What I want is the following two functionalities:
    Then you can probably use the cursorPositionChanged-signal

    On 03/16/12 00:18, SourceForge.net wrote:

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks