mirror of
https://github.com/starship/starship.git
synced 2024-11-07 08:54:50 +01:00
refactor: replace term_size
with terminal_size
(#3087)
This commit is contained in:
parent
888a653c32
commit
b22c54fccc
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -1705,7 +1705,7 @@ dependencies = [
|
||||
"strsim 0.10.0",
|
||||
"sys-info",
|
||||
"tempfile",
|
||||
"term_size",
|
||||
"terminal_size",
|
||||
"toml",
|
||||
"unicode-segmentation",
|
||||
"unicode-width",
|
||||
@ -1815,10 +1815,10 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "term_size"
|
||||
version = "0.3.2"
|
||||
name = "terminal_size"
|
||||
version = "0.1.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9"
|
||||
checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
|
@ -58,7 +58,7 @@ os_info = "3.0.7"
|
||||
urlencoding = "2.1.0"
|
||||
open = "2.0.1"
|
||||
unicode-width = "0.1.9"
|
||||
term_size = "0.3.2"
|
||||
terminal_size = "0.1.17"
|
||||
quick-xml = "0.22.0"
|
||||
rand = "0.8.4"
|
||||
serde = { version = "1.0.130", features = ["derive"] }
|
||||
|
@ -15,6 +15,7 @@ use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::string::String;
|
||||
use std::time::{Duration, Instant};
|
||||
use terminal_size::terminal_size;
|
||||
|
||||
/// Context contains data or common methods that may be used by multiple modules.
|
||||
/// The data contained within Context will be relevant to this particular rendering
|
||||
@ -138,8 +139,8 @@ impl<'a> Context<'a> {
|
||||
repo: OnceCell::new(),
|
||||
shell,
|
||||
right,
|
||||
width: term_size::dimensions()
|
||||
.map(|(width, _)| width)
|
||||
width: terminal_size()
|
||||
.map(|(w, _)| w.0 as usize)
|
||||
.unwrap_or_default(),
|
||||
#[cfg(test)]
|
||||
env: HashMap::new(),
|
||||
|
@ -5,6 +5,7 @@ use std::collections::BTreeSet;
|
||||
use std::fmt::{self, Debug, Write as FmtWrite};
|
||||
use std::io::{self, Write};
|
||||
use std::time::Duration;
|
||||
use terminal_size::terminal_size;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
use unicode_width::UnicodeWidthChar;
|
||||
|
||||
@ -224,8 +225,8 @@ pub fn explain(args: ArgMatches) {
|
||||
// Overall a line looks like this: " "{module value}" ({xxxms}) - {description}".
|
||||
const PADDING_WIDTH: usize = 11;
|
||||
|
||||
let desc_width = term_size::dimensions()
|
||||
.map(|(w, _)| w)
|
||||
let desc_width = terminal_size()
|
||||
.map(|(w, _)| w.0 as usize)
|
||||
// Add padding length to module length to avoid text overflow. This line also assures desc_width >= 0.
|
||||
.map(|width| width - std::cmp::min(width, max_module_width + PADDING_WIDTH));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user