-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code Organisation/Design Discussion: Making Editing Mode do more work #61
Comments
@sherubthakur - thanks for the detailed design! So it seems like the way this would work would be kind of "pluggable" logic that where some part of the Engine as we have it today lives in a separate part of the code. We did a little of this in the last stream with ViEngine, but this sounds like a deeper change that would also move the emacs logic into its own engine as well. If I understand correctly, they would still use a similar EditCommand, though maybe that is something that's also changed a bit? Something related is that I think you mention is that other parts of the engine should also be pluggable. @fdncred mentioned to me the other day how we should make sure to make completions pluggable, so that we could design new completion popups and widgets without having to change a bunch of the code in reedline. This makes sense, and is another good area we could make more generic with clever use of traits. I'd say if it sounds like I understand the gist of what you're suggesting, let's go for it! |
Some things I will just throw around to think about:
|
@jonathandturner I tried to codify my very high level thoughts here about |
When I pulled this abstraction out, a lot of what it was doing is something that the line-buffer should do (IMO). The way I have structured it currently, it has more than a few responsibilities which I don't like. |
The following PRs together achieved this --
There are some other PRs that help with some minor fixes. These are the major ones that help in achieving the vision outlined in this issue. |
And.... Done |
Hey
Firstly, love the work you are doing on nushell and I hope one day this would be my primary shell. One of the things that are stopping me is the vi-mode. If I am correct you are experimenting with reedline to see if we can have something better for the end-user. I have a bit of interest in this particular project.
I was playing around with the idea - where we make the core part of reedline as a library that an edit mode plugin/module can make use of. Initially, I wanted to do break the
Reedline
struct in the following manner.where the components would have had the following responsibilities
Painter
: Handles all painting interactions.EditMode
: This should parse theKeyEvent
s that we get into aVec<EditCommand>
. This is more than an enum in this designPrompt
: -EditingEngine
: Handles the list ofEditCommand
.The primary motivation was to have
EditMode
structured in a way whereemcas
andvi
stuff can reside in a completely separate struct. Where they do not know about each other. The metric for code design that I was using was "how easy is it to get rid of this feature (vi editing mode or emacs editing mode)".Eventually, I figured that the edit mode controls more stuff than just translation of
KeyEvent
s toVec<EditCommand>
, like deciding on how to paint the prompt (VI: Normal, Visual, Insert), etc. So I thought of making a trait that will define the interface we will need from a line editor with an editing mode.ViReedline
(orEmacsReedline
).Here is the trait in question. We can get a
Painter
object using a methond and all the methods can then have a default so we will not need to focus on stuff other thanread_line
function in it's implementorsand the (VI) struct that will eventually implement it.
The emacs counterpart would be less complex than this (as far as I can see)
Let me know if this is a direction that makes sense to you, or if you would like to see how the codebase would look like if we chase this direction. I can then cook up a PR and share the same with you.
The text was updated successfully, but these errors were encountered: