You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug EnterAlternateScreen does not overwrite what is already on TTY/VT
To Reproduce
Run echo "hi" on Linux tty
Run this program:
use std::{
io::{self, stdout},
time::Duration,};use crossterm::{
cursor::position,
event::{poll, read,Event,KeyCode},
execute,
terminal::{disable_raw_mode, enable_raw_mode,EnterAlternateScreen},};fnmain(){enable_raw_mode().unwrap();execute!(stdout(), EnterAlternateScreen).unwrap();ifletErr(e) = print_events(){println!("Error: {:?}\r", e);}disable_raw_mode().unwrap();}fnprint_events() -> io::Result<()>{loop{// Wait up to 1s for another eventifpoll(Duration::from_millis(1_000))? {// It's guaranteed that read() won't block if `poll` returns `Ok(true)`let event = read()?;println!("Event::{:?}\r", event);if event == Event::Key(KeyCode::Char('c').into()){println!("Cursor position: {:?}\r", position());}if event == Event::Key(KeyCode::Esc.into()){break;}}else{// Timeout expired, no event for 1sprintln!(".\r");}}Ok(())}
On tty, it seems that EnterAlternateScreen doesn't take effect (you can see the hi output directly), whereas on the terminal emulator it does.
Expected behavior EnterAlternateScreen has the same behavior as other terminal emulators under tty
OS
Linux
Terminal/Console
tty
The text was updated successfully, but these errors were encountered:
eatradish
changed the title
EnterAlternateScreen does not overwrite what is already on ttyEnterAlternateScreen does not overwrite what is already on TTY/VT
Sep 23, 2024
Try running tput smcup to switch to the alt screen and tput rmcup to restore. If this does nothing, then your tty doesn't support the alternate screen (or it's disabled by config), and there's likely nothing we can do here. If it does then your tty likely has some alternative escape code to make this change. You'll need to dig into the termcap / terminfo to work out what's going on.
Describe the bug
EnterAlternateScreen
does not overwrite what is already on TTY/VTTo Reproduce
echo "hi"
on Linux ttyEnterAlternateScreen
doesn't take effect (you can see the hi output directly), whereas on the terminal emulator it does.Expected behavior
EnterAlternateScreen
has the same behavior as other terminal emulators under ttyOS
Linux
Terminal/Console
The text was updated successfully, but these errors were encountered: