mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-15 01:17:45 +00:00
termsize.rs: export Termsize
This commit is contained in:
parent
d073b7140b
commit
b64c3eb79b
1 changed files with 4 additions and 8 deletions
|
@ -32,7 +32,7 @@ mod termsize_ffi {
|
||||||
pub fn termsize_handle_winch();
|
pub fn termsize_handle_winch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
use termsize_ffi::Termsize;
|
pub use termsize_ffi::Termsize;
|
||||||
|
|
||||||
// A counter which is incremented every SIGWINCH, or when the tty is otherwise invalidated.
|
// A counter which is incremented every SIGWINCH, or when the tty is otherwise invalidated.
|
||||||
static TTY_TERMSIZE_GEN_COUNT: AtomicU32 = AtomicU32::new(0);
|
static TTY_TERMSIZE_GEN_COUNT: AtomicU32 = AtomicU32::new(0);
|
||||||
|
@ -121,13 +121,9 @@ impl TermsizeData {
|
||||||
fn current(&self) -> Termsize {
|
fn current(&self) -> Termsize {
|
||||||
// This encapsulates our ordering logic. If we have a termsize from a tty, use it; otherwise use
|
// This encapsulates our ordering logic. If we have a termsize from a tty, use it; otherwise use
|
||||||
// what we have seen from the environment.
|
// what we have seen from the environment.
|
||||||
if let Some(ts) = self.last_from_tty {
|
self.last_from_tty
|
||||||
ts
|
.or(self.last_from_env)
|
||||||
} else if let Some(ts) = self.last_from_env {
|
.unwrap_or_else(Termsize::defaults)
|
||||||
ts
|
|
||||||
} else {
|
|
||||||
Termsize::defaults()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mark that our termsize is (for the time being) from the environment, not the tty.
|
/// Mark that our termsize is (for the time being) from the environment, not the tty.
|
||||||
|
|
Loading…
Reference in a new issue