Sublime Forum

Pressing home key two or three times in succession

#1

I originally posted the following in the General Discussion forum, but in hindsight I think I should have posed it here.

Back in the 1980s there was an MS-DOS text editor called B.R.I.E.F. (Basic Reconfigurable Interactive Editing Facility — published by UnderWare). A behavior of that editor was when the home key was pressed once, the cursor would go to the beginning of the line it as on. Pressing it a second time (without any intervening key press) would take the cursor to the top of the screen, and pressing it a third time would take the cursor to the beginning of the file. Similar behavior existed for the end button.

The more general form of the above question is, when writing a ST plugin in Python, how do you keep track of what the most recent previous keystroke was? In the context of the home-home-home key sequence, when the home is pressed, how can I know that the previous keystroke was for the home key, and the one immediately preceding that keystroke was also for the home key (in the case of the three key sequence of home keystrokes)?

Would it be possible to mirror this behavior in ST, and if so, how?

Thanks,

Roger Alexander

0 Likes

#2

Not directly answering your question, but have you also considered a slightly different approach where each time the command is invoked it inspects the current position of the cursor and uses that to decide what to do next?

0 Likes