make csi sequences available as &str or String
Created by: little-dude
All the CSI sequences are implemented as structs that implement Display
.
This is good when you directly write them in a formatter.
However, I'd like to build String
s that contain CSI sequences.
For now, my only option is to use format!
and do things like
let mut line: String::from("some text, ");
line.push_str(&format!("{}", termion::style::Invert));
line.push_str("some selected text");
line.push_str(&format!("{}", termion::style::Reset));
Instread, I'd like to be able to do something like:
let mut line: String::from("some text, ");
line.push_str(termion::style::Invert::as_str());
line.push_str("some selected text");
line.push_str(termion::style::Reset::as_str()));
For dynamic sequences, like RGB colors, we cannot have &str
of course, but we could have String
.
If you think you'd accept a PR for this, please let me know, I'll give it a shot.