cursive
cursive copied to clipboard
View for showing other TUI apps?
It would be nice if there was a View which can show other TUI apps... I particularly think about vim here, (but this is not related to #358 because in my case, vim would be opened inside of cursive, rather than replacing cursive temporarily).
This could then be used to build a tmux-like UI, for example, or even something like aerc where vim is used for composing emails inside of the TUI application itself.
Just a brain-dump, really.
I think @IGBC has started experimenting with something a bit similar: https://github.com/igbc/cue Haven't looked much in there so I'm not sure how far the experiment went.
The brute-force solution I'm thinking about involves re-implementing a terminal emulator, forwarding events from cursive and printing the output as a View
. Doesn't sound super easy, but maybe terminal emulator libraries (like VTE or VT-100) are easier to use than I fear? For example https://crates.io/crates/terminal-emulator is unmaintained, but extracting the terminal emulation logic from alacritty sounds nice.
Correct, I started writing a 'desktop environment' in cursive. That was a stupid idea, but I did end up implementing a terminal emulator widget for cursive.
This was like 2 years ago and the first thing I wrote in rust, but I can check what state it is in and makeca PR to add the widget to cursive if people want it.
This hasn't been run in well over a year but this is the code for my terminal emulator view:
https://gitlab.com/IGBC/CUE/blob/master/cue/src/views/term.rs (xpost to Gitlab where I keep my bigger projects.)
It should still work. should.
Thank you for that! Pretty impressive to get something like that working with so few lines of code.
Note that a few edge cases may need some special effort to support properly:
- Wide characters (chinese/japanese/korean)
- Composed graphemes (more than one
char
per cell) - Right-to-left text (but that one is already broken in cursive, so...)
Wide characters (chinese/japanese/korean) Composed graphemes (more than one char per cell) Right-to-left text (but that one is already broken in cursive, so...)
FWIW I needed to do something similar (not the actual terminal emulation part, but needed a TextGrid
widget that could store an arbitrary combination of attributes and text in a grid), for this I re-used parts of https://github.com/agavrilov/cursive_buffered_backend/blob/master/src/lib.rs#L119
Each cell has a EnumSet<theme::Effect>
, a theme::ColorPair
and a SmallVec<[u8; 8]>
, but can also be empty. Maybe it's not the most memory efficient way possible but also I think this handles these cases besides right-to-left text.
Based of the idea listed in this issue, I am wondering how doable it is to make Cursive widgets
, which are individually compiled into dynamic libraries, that can be loaded by other main running Cursive applications.
The widgets will all implement something like _widget_create()
, and the view size and positioning management can be done akin to a tilling windows manager.
reference for myself
That would be nice, technically, but where's the actual benefit? Compiling everything into the binary that is shipped is less effort for the user and more security for the developer. So I don't see how this would yield any benefit.
But from a technical perspective, it would be nice, sure. Although I think that all plugins then need to be compiled with the same rustc version,...
Compiling everything into the binary that is shipped is less effort for the user and more security for the developer. So I don't see how this would yield any benefit.
This is basically the rust core's approach to dynamic linking in general.
Generally speaking dynamic libs on Rust are "Kinda supported" but there's not a lot of information about it floating around as its super not recommended.
Checkout https://github.com/deadpixi/mtm
. Here is simple terminal emulator in less than 1000 lines of code. A TTYView
can be added for handling nested TUI apps.