Skip to content
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

Use as a library? #150

Open
mentalisttraceur opened this issue May 13, 2023 · 0 comments
Open

Use as a library? #150

mentalisttraceur opened this issue May 13, 2023 · 0 comments

Comments

@mentalisttraceur
Copy link

I was recently thinking about adding vi-style editing to some software written in Python.

Naturally I start searching for "vi"/"vim"/etc on PyPI, and I find this - looks promising, I'm super excited, etc.

At a glance, it looks like the focus of this project is the full interactive TUI of vi. Does it have a core that can be reused as a library? So that for example a GUI written in Python could easily add vi-style editing to a command line that it has? If not, is there interest in a PR to refactor things to make it that happen?

[click to expand some design thoughts]

I'm hoping for a library that's more like a state machine of sorts: off the top of my head, I imagine/design

  1. a class representing a thing being edited,
  2. we construct/initialize it with one argument - a string, bytes, or bytearray object, or something similarly sensible,
  3. it has a method which takes inputs (a string representing key strokes, probably) and returns something to indicate if further inputs are needed (for example, the user hit "d" and the second "d" or motion hasn't come in yet) and what vi mode this instance of the object is in, and
  4. another method that returns the current string/bytearray/whatever after all the edits/input up to this point (perhaps this could/should also return the current vi mode, for convenience).

(A full vi replacement use-case would probably need to layer in optimizations with this - which could be done by for example creating an object that fulfills a relevant editable interface - but this seems like a sufficient minimal interface for basic use-cases.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant