I want to build an emacs-like text editor as a hobby project. To do this, I need some kind of text view window, and I’d like to spend as little effort on this part as possible since it’s not the important part of the project. So ideally I’d want some kind of prebuilt GTK(4) widget that would handle showing the text. Then I’d just write code that modifies the text contents programmatically, and bind this code to various keys, and that should allow me to make a jank little editor.
Just for purposes of quickly prototyping, I decided to start out with PyGObject, and maybe move to C or something else later. I first checked out Gtk.TextView. The problem is that it’s designed to be a moderately featureful text editor, and I don’t want my view to support things like clicking on the text and entering additional text. I want to implement those things myself. I can set my Gtk.TextView’s editable prop to False, but it still has tons of keys bound, and I don’t see any way to unbind them.
So basically, Gtk.TextView seems like a mediocre candidate as a thing to just drop in and use, and instead something that would require a lot of fixing up to get it to do what I want. GtkSourceView would probably be even worse since it sounds like it’s everything that I don’t want from Gtk.TextView plus more.
In this thread:
the author (who has similar needs to me) speculates that his best option is to go through the code of Gtk.TextView and basically implement a version without all the extra stuff he doesn’t need. That sounds both like it might be his best option and also an awful option I’d really prefer not to have to go with.
Someone suggested that the author check out Scintilla/SciTE. I’m not totally sure why; was this supposed to be something to look at as a simple-version analogous to the hypothetical stripped-down version of Gtk.TextView? I looked at the code and didn’t see any other obvious way to make use of it. I also looked at the Custom Widgets blog posts mentioned, which wasn’t particularly helpful.
Can anyone give me any advice about how to proceed? Is there a better way forward than implementing a stripped-down TextView from scratch? It occurs to me that, at least within the GTK/Gnome ecosystem, there might not be; GTK widgets seem like they’re supposed to provide a lot of Gnome-standard look/feel/workflow features, or at least that this is a far higher priority than being maximally configurable. Am I just making a mistake by trying to solve my problem by looking for a standard GTK widget? I figured that I’d rather use GTK since if I ever wanted to make a real editor, I’d definitely want to use GTK, so I might as well use it for my jank hobby editor too. But maybe it’s just the wrong way to go.
Just in case anyone can actually help, here are some desiderata:
- I really would rather not use something like Electron for this. I’d much rather use a conventional UI toolkit.
- I use (Arch) Linux, so while ideally I’d be learning something cross-platform while doing this, it needs to work well on Linux more than anything.
- I’d rather not do this as a terminal application unless it’s substantially easier to do it that way and there’s no good way to do it as an X application.
- Although I eventually want to learn whatever UI toolkit I’d be working with well enough to make good custom applications, the more I can put off learning it and just start messing around with the parts relevant to this particular project, the better.
Thoughts?