remove terminal_size crate everywhere it makes sense (#14423)

# Description

This PR removes the `terminal_size` crate everywhere that it made sense.
I replaced it with crossterm's version called `size`. The places I
didn't remove it were the places that did not have a dependency on
crossterm. So, I thought it was "cheaper" to have a dep on term_size vs
crossterm in those locations.
This commit is contained in:
Darren Schroeder
2024-11-23 21:37:12 -06:00
committed by GitHub
parent 83d8e936ad
commit dd3a3a2717
8 changed files with 13 additions and 23 deletions

View File

@ -1,5 +1,5 @@
use crossterm::terminal::size;
use nu_engine::command_prelude::*;
use terminal_size::{terminal_size, Height, Width};
#[derive(Clone)]
pub struct TermSize;
@ -51,15 +51,12 @@ impl Command for TermSize {
) -> Result<PipelineData, ShellError> {
let head = call.head;
let (cols, rows) = match terminal_size() {
Some((w, h)) => (Width(w.0), Height(h.0)),
None => (Width(0), Height(0)),
};
let (cols, rows) = size().unwrap_or((0, 0));
Ok(Value::record(
record! {
"columns" => Value::int(cols.0 as i64, head),
"rows" => Value::int(rows.0 as i64, head),
"columns" => Value::int(cols as i64, head),
"rows" => Value::int(rows as i64, head),
},
head,
)