vamolessa / pepper

simple and opinionated modal code editor for your terminal
https://vamolessa.github.io/pepper/
370 stars 15 forks source link

Emacs mode #73

Open VarLad opened 1 year ago

VarLad commented 1 year ago

Hello, thanks for taking the time to make this! I was wondering if you could also implement an emacs/nano style mode (for people who don't want modal editing)

vamolessa commented 1 year ago

Hi! Thanks for taking interest in the project! However, a non-modal editing model is really outside of the scope. I also have very little expericence with emacs editing model (in the terminal).

However, should you want to edit the source, I can give you an overview on how to achieve it. There's mainly only two modes for editing: normal and insert. The work would be to collapse them into a single mode that does both navigation and editing.

Will close for now. But should you have questions on specifics, feel free to reopen.

Thanks again

VarLad commented 1 year ago

@vamolessa Just wondering, can this be done via a plugin, or will I have to fork it? If not, does a feature request to make the keybindings more extensible via plugins make sense?

VarLad commented 1 year ago

@vamolessa I've some interest in implementing this (although lack time). This is a good reference for what I want. https://www.nano-editor.org/dist/v7/nano.pdf#Editor%20Basics

vamolessa commented 1 year ago

Maybe it's possible to implement the bulk of the input logic in a plugin and then add a small patch to normal mode to always imediately switch to that plugin mode. If that works and the change to the modes system is minimal I think we could merge the patch.

VarLad commented 1 year ago

@vamolessa How can I start looking into this?

vamolessa commented 1 year ago

here is a small example of how to use the pepper lib crate to create your own binary together with how to register plugins you wish to use: https://github.com/vamolessa/pepper/blob/master/mine/src/main.rs (this is the binary that i use daily btw)

here you can see what the plugin struct is (and also the PluginDefinition struct): https://github.com/vamolessa/pepper/blob/master/pepper/src/plugin.rs#L22

there you can see that there is a function ptr for input keys you can provide: on_keys.

with this, you should be able to handle key inputs once you're in you plugin's mode.

however, for all of this to work, there are some changes that will be needed:

this is the highlevel view hope it helps!

vamolessa commented 1 year ago

will reopen this while you're trying to get this going :) it's easier to find this issue this way