Skip to content

Commit

Permalink
Attempt to exit the alternate buffer at close
Browse files Browse the repository at this point in the history
  • Loading branch information
lif committed Feb 8, 2024
1 parent 29cf54e commit 76d5a8d
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 2 deletions.
135 changes: 133 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
futures = "0.3.28"
libc = "0.2"
regex = "1"
terminfo = "0.8.0"
thiserror = "1"
tokio = { version = "1", features = ["io-std", "io-util", "macros", "rt", "rt-multi-thread", "signal", "sync", "time"] }
tokio-tungstenite = "0.20.1"
Expand Down
7 changes: 7 additions & 0 deletions src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ mod platform_impl {
if r == -1 {
Err::<(), _>(std::io::Error::last_os_error()).unwrap();
}
// if we have a terminfo database and this terminal is in it,
// try to exit the alternate buffer in case we were left there.
if let Ok(info) = terminfo::Database::from_env() {
if let Some(rmcup) = info.get::<terminfo::capability::ExitCaMode>() {
rmcup.expand().to(std::io::stdout()).unwrap();
}
}
}
}
}

0 comments on commit 76d5a8d

Please sign in to comment.