Hacker News new | ask | show | jobs
by amelius 4066 days ago
Why not decouple the following things:

- Core editor (internal representation, etc.)

- Key bindings (so you could easily create an emacs instead of a vi)

- Rendering

- Scripting language (for customized behavior)

Finally, make sure you thoroughly document these building blocks, so others can create really cool stuff with it. Also, think of possible use-cases when defining the modules. A smart architecture could allow for a collaborative editor, for example.

2 comments

Hi, thanks for the suggestions! Actually, the internal representation, is completely separate from the layout. It's not in another repository, but it's decoupled.

The key bindings are also separate. Getting emacs bindings is not much more than changing this line [0]. Only adding the bindings for the window management and emacs command line is still to be done. (I know that emacs is actually much more than only its key bindings, but you know what I mean.)

The rendering is also independent. There are two backends: vt100 terminals and the windows console. (Honesly, my main focus is vt100, but any render back-end is possible. I think even graphical)

The same for the event loops by the way, it can run on a couple of event loops. For instance asyncio.

Documentation will follow. prompt-toolkit has already quite a lot of examples, and there's a lot of documentation in the code itself. But I agree that we should keep improving.

Cheers!

[0] https://github.com/jonathanslenders/pyvim/blob/master/pyvim/...

I want to compliment you on your code. It's so rare to see clean python code. I am almost never able to be able to jump into a file in a module and understand exactly what's happening, but you fucking nailed it. Well done!
I believe he follows pep8 ;)
The prompt_toolkit (core library) which is the basis for pyvim (same author), is well structured and modular. https://github.com/jonathanslenders/python-prompt-toolkit

There are plenty of examples in the repo that cover most of the features in the library. The awesome thing is all of the examples fit in a single page, a testament to the power and simplicity of the library.

I built pgcli (https://github.com/dbcli/pgcli) almost entirely by reading the examples.

Will you please make pgcli compatible with the most recent prompt_toolkit release?
@amjith: we should do that indeed. If you don't have the time, I'll help you doing it later on.