magiblot / turbo

An experimental text editor based on Scintilla and Turbo Vision.
Other
461 stars 35 forks source link

configurable Home key behavoir #16

Open unxed opened 3 years ago

unxed commented 3 years ago

In most editors, Home key means "go to the 1st character of a string". In turbo, Home key means "go to the 1st non-space character of a string if pressed once, and go to the 1st character of a string if pressed for the second time".

Can this behavior be made configurable to make turbo react on Home key just like all other editors? Thanks!

magiblot commented 3 years ago

Hey unxed,

I'm all for customization, although this is easier said than done. This issue is similar to #9: most of the work lies in integrating a configuration system and designing the interface to choose the settings. This project is a hobby, so all I can promise is: I'll do it some day. But I acknowledge that being useful and making users feel comfortable is a top priority, so getting this done would be a great accomplishment.

I am surprised, though, that your experience with text editors is so different from mine. The Home key behaviour in Turbo is the same as in:

unxed commented 3 years ago

Can you please suggest where to look for Home key behavior definition in the code? Hardcode will suit my personal needs for the near future :)

magiblot commented 3 years ago

Okay :). The default key bindings are defined in scintilla/src/Editor.cxx. But the Home key binding is concidentally overriden in src/editwindow.cc. Apply the following change near line 132:

-   editor.WndProc(SCI_ASSIGNCMDKEY, SCK_HOME | (SCI_NORM << 16), SCI_VCHOMEWRAP);
-   editor.WndProc(SCI_ASSIGNCMDKEY, SCK_HOME | (SCI_SHIFT << 16), SCI_VCHOMEWRAPEXTEND);
+   editor.WndProc(SCI_ASSIGNCMDKEY, SCK_HOME | (SCI_NORM << 16), SCI_HOMEWRAP);
+   editor.WndProc(SCI_ASSIGNCMDKEY, SCK_HOME | (SCI_SHIFT << 16), SCI_HOMEWRAPEXTEND);

Cheers.

unxed commented 3 years ago

Thank you very much! Indeed, the configuration interface is not so important to me as the ability to customize the behavior to suit my (perhaps a little bit strange) habits. Now it has become quite good for me to use turbo instead of the tilde, and I like it!