-
Notifications
You must be signed in to change notification settings - Fork 16
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
topic: text editor #8
Comments
👍 to a simple text editor - I found with the Python version that mapping various coordinate systems to each other and handling basic keyboard input was one chapter, while adding undo/redo was another. Don't know if it would be the same here? |
Got something minimal to share and seeking some direction - opening a file from arguments, rendering the text contents to a window. I've included a super simple implementation of a Piece table which looks to be the easiest way to build a text editor. I've also used the text segmentation from roc-lang/unicode to split the input file into graphemes so in theory this should support unicode out of the box 🤞 So far the demo only renders text, the editing and saving functionality hasn't been included yet. I'm pretty sure the undo/redo will be essentially free. The plan is to just keep a new copy of the Piece Table (sans buffers) on each significant user action (edits) in a list. This is just duplicating the indexes into the buffers and so shouldn't grow too significantly unless the user has very long editing session. We can always just keep the latest N edits or something if it becomes a problem. WIP code for this demo (I haven't removed any of the code from the menu example, just added the parts for editor) Questions
Demo |
This is a great start - well done! I based the editor in the Python book on the first few parts of Wasim Lorgat's tutorial https://wasimlorgat.com/posts/editor.html - I think we definitely want the line breaks, but modes and windows and what-not won't fit into the one-hour limit. |
Quick update on progress this weekend.
I've had to make a few changes to the roc-ansi package, so this has been good to flush those issues out and resolve them. I've also been adding a lot of inline comments and thinking about the dot points for the chapter content. Demo |
this is great work - thank you very much. I think you may already have an hour's worth of teachable material - if you'd like to grab some time with me ([email protected]) I'd be happy to talk you through next steps. |
Sounds good. I sent you a meeting request via email. Just took a guess at a suitable time re timezones. Apologies if it's too short notice, I could find a time next week. I'd like to implement text deletion to close out the Piece table basics. Also I'll need to make a release for the unicode and ansi dependencies before this will be usable more generally. If you don't mind I'd love to write something up about this for my blog and share in the online meetup this weekend, it won't be the same content as the book more my experience. |
Blogging about this would be great, and no worries about overlap with whatever you're going to write for the book: you own the rights to your blog posts, so you can decide to recycle them. |
I would like to work on the test editor chapter. I have a package for handling ANSI escape sequences which are supported in most modern terminals, and is most useful when working with the basic-cli platform.
Here is an illustration of an app using this package, and the code for the tui-menu example.
I think I can expand this example to include opening, editing, and saving files. The main limitation I can think of is limiting this to ASCII and not supporting full unicode.
The text was updated successfully, but these errors were encountered: