Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: Switch from unmaintained term_size to terminal_size #4538

Merged
merged 5 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion lib/wasix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ serde_json = { version = "^1" }
serde_yaml = { version = "^0.9" }
weezl = { version = "^0.1" }
hex = { version = "^0.4" }
term_size = { version = "0.3" }
linked_hash_set = { version = "0.1" }
http = "0.2.8"
heapless = "0.7.16"
Expand Down Expand Up @@ -121,6 +120,9 @@ termios = { version = "0.3" }
[target.'cfg(windows)'.dependencies]
winapi = "0.3"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
terminal_size = { version = "0.3.0" }

[dev-dependencies]
wasmer = { path = "../api", version = "=4.2.8", default-features = false, features = ["wat", "js-serializable-module"] }
tokio = { version = "1", features = [ "sync", "macros", "rt" ], default_features = false }
Expand Down
60 changes: 33 additions & 27 deletions lib/wasix/src/os/tty/tty_sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,19 @@ impl TtyBridge for SysTty {
let stdin_tty = sys::is_stdin_tty();
let stdout_tty = sys::is_stdout_tty();
let stderr_tty = sys::is_stderr_tty();

if let Some((w, h)) = term_size::dimensions() {
WasiTtyState {
cols: w as u32,
rows: h as u32,
width: 800,
height: 600,
stdin_tty,
stdout_tty,
stderr_tty,
echo,
line_buffered,
line_feeds,
}
} else {
WasiTtyState {
rows: 80,
cols: 25,
width: 800,
height: 600,
stdin_tty,
stdout_tty,
stderr_tty,
echo,
line_buffered,
line_feeds,
}
let (cols, rows) = sys_terminal_size::get_terminal_size();

WasiTtyState {
cols,
rows,
width: 800,
height: 600,
stdin_tty,
stdout_tty,
stderr_tty,
echo,
line_buffered,
line_feeds,
}
}

Expand All @@ -66,6 +52,26 @@ impl TtyBridge for SysTty {
}
}

mod sys_terminal_size {
static DEFAULT_SIZE: (u32, u32) = (80, 25);

#[cfg(not(target_arch = "wasm32"))]
pub fn get_terminal_size() -> (u32, u32) {
if let Some((terminal_size::Width(width), terminal_size::Height(height))) =
terminal_size::terminal_size()
{
(width.into(), height.into())
} else {
DEFAULT_SIZE
}
}

#[cfg(target_arch = "wasm32")]
pub fn get_terminal_size() -> (u32, u32) {
DEFAULT_SIZE
}
}

#[allow(unused_mut)]
#[cfg(all(unix, not(target_os = "ios")))]
mod sys {
Expand Down
Loading