Skip to content

Gtk Port: New editor implementation #1419

@TheJackiMonster

Description

@TheJackiMonster

I think the new implementation of the editor (which is probably the most important GUI element in Manuskript) has a lot of potential to improve things for a lot of users. As far as I'm aware there have been requests in the past to allow more features in terms of formatting text, making it WYSIWYG and improving performance for spell or grammar checking.

However this makes it kind of complicated to implement. For one reason because GTK only provides a rather basic GtkTextView which utilizes a GtkTextBuffer that allows certain formatting options but not everything you could think of. So I think before doing anything abnormal in terms of features, we should focus on getting existing features done and having better performance as well as integration for plugins like spellcheckers.

Using a GtkTextBuffer provides two major options doing formatting like for example underlining spelling mistakes:

  • You can create a table of GtkTextTag objects defining specific formatting attributes that apply to a selected portion of the text. You can think of it as abstracting a markup language. However this comes with disadvantages of loosing fine control and mixing attributes gets more difficult.
  • You can insert markup directly into the buffer which allows full usage of Pango markup. It is still limited in terms of features but you have very much control and it allows mixing attributes however you like (as long as you implement some own function to apply it properly). The disadvantage is that you have only the insert_markup() method to do everything.

I personally think for the best experience we pretty much have to use the Pango markup option. Because even though I tried using the tag system first, I ran into issues very fast that could not really be solved without extremely ugly workarounds.

Still I think this will cost quite some time and effort to get everything right. Mostly because of the ability to edit text in the editor. Not just that but also editing text that belongs to different scenes or chapters while being displaying as a complete document. Spellcheckers need to process singular words which implies we have to split the whole text into pieces, process each piece, stitch them together with proper markup added between and compile it into one complete string to insert.

In current state I've started by appending scenes one for one into the buffer and I think this approach should even go further. Ideally we want a system that can stream text from the scene files into the spellchecker into some sort of queue that puts everything together into the buffer. So the user would be able to edit the text while the format corrects itself according to changes and while we are potentially loading additional text pieces into the buffer at another position. We would also need to convert each change in the buffer again removing formatting from spellcheckers into local changes of scene text to then store it at the right place when a user saves the project.

In other words the representation of text in the buffer needs to be treated as completely different instance than the actual data model with some sort of translation unit between that while update local changes in either of them into local changes of the other. It's gonna be a beast to implement but probably worth it. Because if we do that right, we can probably deal with a lot of feature requests way easier down the line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions