Open VarLad opened 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
@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?
@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
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.
@vamolessa How can I start looking into this?
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:
change_to_plugin
fn to impl Mode
in pepper/src/mode.rs
that changes kind
to ModeKind::Plugin
and sets plugin_handle
to your plugin handle
instantiate
fn that you provide in your PluginDefinition
)on_exit
on the old mode and on_enter
on the new one (just see the src of Mode::change_to
)Mode::change_to_plugin(editor, plugin_handle)
which lets you manually change to your emacs mode; or you can change peppe/src/mode/normal.rs
to call Mode::change_to_plugin(editor, plugin_handle)
automatically inside its on_enter
(going this way you would either to put your plugin_handle in a global or also add it as a field to Editor
structpepper/src/mode/normal.rs
and pepper/src/mode/insert.rs
to inside your on_keys
plugin function
on_client_keys_with_buffer_view
fn; the way it's implemented is a really big match on keys from the editor KeysIterator
this is the highlevel view hope it helps!
will reopen this while you're trying to get this going :) it's easier to find this issue this way
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)