zigalenarcic / mangl

An enhanced man page viewer for linux and BSD systems based on OpenGL and mandoc libraries
Other
39 stars 7 forks source link

Feature request: some Emacs-style key bindings #3

Closed omar-polo closed 2 years ago

omar-polo commented 2 years ago

Hi,

I hope you don't mind feature requests. I haven't tried it myself because of my ignorance with OpenGL, but I could eventually try to implement it myself.

I'd really like if mangl allowed to scroll up and down with Alt-v and Control-v (respectively). These are the standard Emacs keys for scrolling that are also supported by less(1) by default (at least, and probably by more applications.) Muscle memory is hard to defeat :)

zigalenarcic commented 2 years ago

Hi,

all standard key commands are welcome. I only implemented the set I'm more familiar with.

Key handling, mouse input and window opening is not directly part of OpenGL but rather a library that abstracts various windowing systems such as X11, wayland, Win32, Cocoa (since these all use different APIs). In this case the library used is GLFW.

Please look at main.c: key_func() and char_func(). Both are callbacks that handle key input but a bit differently - char_func works on the higher level of character input (such as typing - where key modifiers like shift or alt are already translated into character code), while key_func() works at a lower level. I think this could be implemented in either but I would start with key_func(). Please check if key repeat works correctly. Scrolling for a full page can be seen in case of the spacebar key.

zigalenarcic commented 2 years ago

Key commands Alt-v and Ctrl-v have beend added in commit b48e599c22ad99d164411277d7a3a90498074bcb

omar-polo commented 2 years ago

I was a bit stuck with how GLFW input works (locale vs. non-locale keys). I think I've sorted it out and also finally got why some keybindings advertised in the manpage didn't work for me (but this is for another PR.)

Thanks!