gyscos / cursive

A Text User Interface library for the Rust programming language
MIT License
4.22k stars 239 forks source link

Using this for an text editor? #220

Open mistakenelf opened 6 years ago

mistakenelf commented 6 years ago

Asking for help

Problem description

Im looking to start learning rust and I would like to build a simple text editor, this seems to be the most well maintained TUI library for rust and was wondering if its feasible to use this to make a simple terminal text editor?

Environment

gyscos commented 6 years ago

Hi!

It should be possible to implement a text editor using this library: the simplest version would just use a TextArea, and simply implement ways to open/save files.

However, this trivial solution is not ideal for a few reasons:

Note that those two points could be solved by writing your own EditorView; the core mechanism of cursive should be feature-sufficient for that.

matthiasbeyer commented 6 years ago

@knipferrc if you implement said EditorView I wouldn't mind a library for this! :smile:

Also, if you (by any chance) implement a "tab" functionality, I would love to see a library for this as well!


But, as you're learning: No pressure! :smile:

mistakenelf commented 6 years ago

I would definitely be interested in at least taking a swing at making an EditorView, could be a fun learning experience.

gyscos commented 6 years ago

You may be interested in xi-editor for the editor backend.

matthiasbeyer commented 6 years ago

Hell yeah, that is actually a freakin' nice idea! I will try to implemented a View using Xi tomorrow, I guess.

gyscos commented 6 years ago

I'd love to have a look! But it seems the project is not available - maybe it was removed? Or is not public?

njskalski commented 6 years ago

Yes, I have to ask my company for release permission. I already filed for it, waiting for answer.

dermetfan commented 6 years ago

Maybe the EditorView implementation I'm using in my text editor built on Cursive can serve as inspiration. There's no repo yet but you can view the sources on docs.rs.

njskalski commented 6 years ago

finally got clearance to share my code. The editor is sly_text_view.rs. It's a bit complicated (separate model from view, multiple cursors, some events bound to configurable input), but can be used as reference. Just make sure you know the license (Apache 2.0).

https://github.com/njskalski/sly-editor