Easiest Way to get a simple cross-platform, GUI Text Editor running?

I'm working on a little music live coding environment, and I'd like to integrate a text editor (currently it's just a REPL and I use VSCode to send text to it).

It doesn't need to do much for now, "just" run on all platforms and allow me to use Ctrl+Return to evaluate code.

I've thought about terminal text editors like Kiro, but reliably getting the Ctrl+Return key combination to work on a variety of terminal editors seems non-trivial. Plus, I'm not sure how they'd perform on MS Windows.

I saw that Nannou has a TextEdit widget, but I only looked into it briefly and haven't seen a working example so far.

So, does anyone have an idea what one could use here ? All hints appreciated !

1 Like

I'm working on a little music live coding environment, and I'd like to
integrate a text editor (currently it's just a REPL and I use VSCode
to send text to it).

It doesn't need to do much for now, "just" run on all platforms and
allow me to use Ctrl+Return to evaluate code.

I've thought about terminal text editors like Kiro, but reliably
getting the Ctrl+Return key combination to work on a variety of
terminal editors seems non-trivial. Plus, I'm not sure how they'd
perform on MS Windows.

Have you considered Emacs?

I'm looking for an editor (written in Rust) that I can integrate directly into my program, not an external editor.

EDIT: Maybe I should say a text editor widget, to be clearer ...

I'm out of my depth here but perhaps gtk-rs would do the job?

nannou exports the TextEdit widget from conrod_core. If you are interested in going this route, there is an example in the glium backend project: https://github.com/PistonDevelopers/conrod/blob/23629f26de1a217f3f35a5f71e0566a8054d4d38/backends/conrod_glium/examples/text_edit.rs

Conrod is just one of several attempts to provide cross-platform GUI in Rust. One of the more popular options right now is iced.

If you would rather have the editor in a terminal, you can use something like cursive, which has a TextArea widget for simple multi-line text editing: https://github.com/gyscos/cursive/blob/40efcc67271506c0f78227d0cc9a6cbac9ce02fe/examples/src/bin/text_area.rs

I don't know if any of these qualify as the "easiest way" in your view. There are currently a lot of options, and they are all experimental.

1 Like

Thanks for the input :slight_smile: I tried the conrod widget yesterday ... while it seems promising it doesn't currently allow to access the cursor positions/selections etc.

If I say "easy" I guess i mean "takes as much or less time than creating a custom mode for VSCode/Emacs/?". Not sure if that's realistic ...

Seems like Iced doesn't have a multi-line text editor widget yet: https://github.com/hecrj/iced/issues/320

Hmm the easiest way I found so far is FLTK-RS ... even comes with a working, notepad-like editor example.
Looks a bit dated and well ... bindings. But I guess there's always some compromise.

Thanks for the hint (and for the FLTK bindings :D).

I don't think it's inherently bad to rely on bindings either, especially if it's low-overhead ones like FLTK.

But especially bloatier ones tend to leave a stale aftertaste ...

1 Like

How about monitoring a file (with notify) for changes?

Hmm that'd lack a selection feature too ... otherwise definitely something to think about.

egui also does. The demo can run in the browser: egui – An immediate mode GUI written in Rust

1 Like

In case anyone is interested, I started playing around with egui and found that the text edit widget can be customized to my needs easily enough (right now still working with a fork).

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.