liner (the readline library used by ion) rewrites the entire line when a character is typed. At least on my machine, this makes using ion in qemu very painful and slow.
I'd like to change this. I have experience with terminal rendering from building 3mux.
To do this, I think we'd maintain state of the current terminal line. We'd need some sort of struct keeping track of colors and attributes (e.g. bold, dim).
I think the biggest difficulty would be the way that highlighting is done. Currently, the highlighter returns a string with ecma48 syntax (e.g.
Hello \e[91mdodo\e[m world). Parsing ecma48 is a lot of work. Possible solutions:
- Have syntax highlighters directly modify a copy of the line state. For example, we could have a helper function to bold characters from index X to Y in the line (best option imo)
- Write some easier-to-parse-than-ecma48 syntax, possibly borrowing prompt code from
ion(okay-ish option imo)
Just build an ecma48 parser (worst option imo)Use https://gitlab.redox-os.org/redox-os/ransid for parsing ecma48
I understand this would break
redox_liner API compatibility. But as far as I can tell, only
ion depends on
ion doesn't currently do syntax highlighting, we could change the syntax highlighting API here without breaking