"Transient" mark mode?

Hi, I was wondering if it was possible to use something like Emacs's Transient Mark Mode.

Essentially, this makes the mark act a bit more like a standard text-highlighting feature that you would find in most modern text editors. Until you set the mark (with, say, CTRL+Space), the mark does not exist. Once you set the mark, all the text between the mark and your cursor is highlighted, and follows similar semantics to what you would expect (e.g., typing a character replaces the selection with that character and removes the mark, hitting backspace deletes the entire selection and removes the mark, etc.). Finally, you can un-set the mark (thereby un-selecting the current selection) by pressing escape.

I am a big fan of this paradigm, because it gives you all of the power and flexibility of having a mark+cursor, but lets you use all of the same commands that you are used to (e.g., using Backspace to delete a range instead of CTRL+d)... but as far as I can tell, 4coder does not support it (without me having to do some heavy lifting to implement it myself).

Edited by Andrew Smith on
Interesting! Supporting a range of paradigms is on my todo list but it's going to be a little while. I want to get the customization API feature complete first. In the upcoming build I am already planning to take the first step towards making this sort of feature easy to implement, by adding visual markers to the custom layer. (Markers are my generalization of cursors and marks.)

Unfortunately, I think a realistic timeline for when this will happen is sometime in 2019. In the mean time you could approximate it in the custom layer yourself, by adding the rules for auto-moving the mark onto of the cursor whenever it's not in the active mode. This could be accomplished in the command caller hook and a global variable. With the command caller hook, you'd just set the mark to the cursor in the active view whenever the global variable indicates that the mark isn't active, and then have the set mark command switch the global variable. Might have a bug or two, but I think that would pretty much work, if you're okay with patching over the problem for now.
I had not thought of implementing it that way... but it does seem like it could be made to work with an approach like that. Although it sounds like I would need to wait for visual markers in order to do something like visually "highlighting" the selection.
Yeah you'd be stuck living without a good highlight until the visible markers come out in the next build.

You might be able to hack that too with view_set_highlight but at some point why bother when the "more correct" way to do it is coming along so soon. Still it's up to you how much or how little you put into trying to make it work. If you do go for it, I'll happily help you locate APIs docs and whatever else you need along the way either here on the forums or at the 4coder email.