small software-rendered rust tty
add SGR 7 invert
bendn 9 months ago
parent 9fdfff7 · commit 970f7a3
-rw-r--r--src/main.rs4
-rw-r--r--src/term.rs14
2 files changed, 15 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index e1c06b5..de5cd0f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -34,7 +34,7 @@ fn spawn(shell: &str) -> Result<OwnedFd> {
match x {
ForkptyResult::Child => {
let sh =
- Command::new(shell).env("TERM", "xterm").spawn()?.wait();
+ Command::new(shell).env("TERM", "vt100").spawn()?.wait();
// std::thread::sleep(Duration::from_millis(5000));
// exit(0);
@@ -225,7 +225,7 @@ fn main() -> Result<()> {
fn tpaxrse() {
println!("-------------------");
let mut x = TerminalInputParser::new();
- for c in "\x1b[?2004l\nbash".as_bytes() {
+ for c in "[?2004h(B)0[?7h[?1h=[?1h= GNU nano 8.4 New Buffer [ Welcome to nano. For basic help, type Ctrl+G. ]".as_bytes() {
use ctlfun::TerminalInput::*;
match x.parse_byte(*c) {
Char(x) => {
diff --git a/src/term.rs b/src/term.rs
index ebfa3ce..125fca4 100644
--- a/src/term.rs
+++ b/src/term.rs
@@ -75,7 +75,7 @@ impl Terminal {
self.cells[self.row * self.size.0 as usize..].len()
== self.size.0 as usize * self.size.1 as usize
);
- dbg!(self.cursor);
+ // dbg!(self.cursor);
let c = &mut self.cells[self.row * self.size.0 as usize..]
// y*w+x
[(self.cursor.1 * self.size.0 + self.cursor.0)
@@ -117,8 +117,13 @@ impl Terminal {
ModeSet(2) => self.style.flags |= DIM,
ModeSet(3) => self.style.flags |= ITALIC,
ModeSet(4) => self.style.flags |= UNDERLINE,
+ ModeSet(7) => std::mem::swap(
+ &mut self.style.bg,
+ &mut self.style.color,
+ ),
ModeSet(9) => self.style.flags |= STRIKETHROUGH,
ModeSet(22) => self.style.flags &= !(BOLD | DIM),
+
_ => {}
}
}
@@ -187,6 +192,13 @@ impl Terminal {
}) => {
self.cursor.1 += 1;
}
+ Control(ControlFunction {
+ start: b'\x1b',
+ params: [],
+ bytes: [b'('],
+ end: b'B',
+ ..
+ }) => {}
Control(x) => {
dbg!(x);
println!(