I am writing a text editor.
With 1049 (alternate screen) mode + 1000 (mouse tracking) mode enabled, the terminal is able to catch both mouse scroll events and click events. I do not need the click events.
This has the added disadvantage of not allowing other useful motions with your mouse (example: an external copy paste by highlighting text on the terminal screen).
I say vim
, because it has ideal mouse behavior, where with a scroll event the cursor position changes to reflect it, and click events seem not to affect it. In addition, it does so in a manner that does not lead to flickering.
The thing that tells me that it does not use 1049 + 1007 is that something like the external copy-paste (by highlighting text) is possible in vim
.
My question: How is vim
doing this?
I've scoured the source code and am unable to find it. I've also attempted to trace the escape sequences it writes to the screen. This holds true on 2 terminal emulators I've tried.
vim
(or whatever other utility) underscript
and then study the resultingtypescript
file to see the commands it sends to the terminal. Edit the file in various ways (e.g. keep just the part that corresponds to the startup only and not the shutdown of the app), or experiment in other ways (bisect etc.), replay withcat
and see if it provides the desired result.vim
, are you absolutely sure you're not confusingvim
's own text selection mechanisn with the terminals?