ronisbr / TerminalPager.jl

Pure Julia implementation of the command less
MIT License
116 stars 8 forks source link

[FR] Implement keybinding callbacks #18

Closed DhruvaSambrani closed 3 years ago

DhruvaSambrani commented 3 years ago

I would like to do some other computations when the user moves or triggers other keybindings. Is it possible to expose the pager events so as to customize them?

ronisbr commented 3 years ago

Hi @DhruvaSambrani

Can you please describe better what kind of computations do you want to perform? It should be easy to provide a callback, but I am not sure what kind of modifications in pager you want.

DhruvaSambrani commented 3 years ago

I wanted to build a 2D map scroller which would have a player character at the center and the map elements in ASCII. However, for the player to interact with map elements, I would need a way to check if there are any interactable elements at the present location, which would need to be called everytime the pager updates.

ronisbr commented 3 years ago

Hum, I think this will not work, because TerminalPager assumes the content does not change after the initialization.

I think this kind of application is not suitable for TerminalPager, which we need to keep as small as possible to avoid overhead to packages that will use it. However, it is a very good application for TextUserInterfaces.jl. The only problem is that I did not have time yet to stabilize the API...

DhruvaSambrani commented 3 years ago

Yeah, I thought so too. Awesome work nonetheless!!

ronisbr commented 3 years ago

Thanks! I will try to put some effort into TextUserInterfaces to have at least a stable API. Ah! BTW, by stable API I mean a Julian way to create TUI. If you want to uses raw ncurses functions, it should be working fine (just use master).