mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
fix(tui): skip alternate scroll on Apple Terminal
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use std::env;
|
||||
use std::io::Result;
|
||||
use std::io::Stdout;
|
||||
use std::io::stdout;
|
||||
@@ -317,6 +318,9 @@ pub fn enter_alt_screen_only(theme_fg: ratatui::style::Color, theme_bg: ratatui:
|
||||
}
|
||||
|
||||
fn enable_alternate_scroll_mode() -> Result<()> {
|
||||
if !should_enable_alternate_scroll_mode() {
|
||||
return Ok(());
|
||||
}
|
||||
let mut handle = stdout();
|
||||
handle.write_all(b"\x1b[?1007h")?;
|
||||
handle.flush()?;
|
||||
@@ -324,12 +328,21 @@ fn enable_alternate_scroll_mode() -> Result<()> {
|
||||
}
|
||||
|
||||
fn disable_alternate_scroll_mode() -> Result<()> {
|
||||
if !should_enable_alternate_scroll_mode() {
|
||||
return Ok(());
|
||||
}
|
||||
let mut handle = stdout();
|
||||
handle.write_all(b"\x1b[?1007l")?;
|
||||
handle.flush()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn should_enable_alternate_scroll_mode() -> bool {
|
||||
// macOS Terminal hijacks scrolling when 1007h is set without also enabling
|
||||
// mouse reporting, so skip the escape in that environment.
|
||||
!matches!(env::var("TERM_PROGRAM"), Ok(value) if value.eq_ignore_ascii_case("Apple_Terminal"))
|
||||
}
|
||||
|
||||
/// Clear the current screen (normal buffer) with the theme background and reset cursor.
|
||||
// Removed: clear_screen_with_theme — we no longer hard-clear the normal buffer in terminal mode.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user