mirror of
https://github.com/starship/starship.git
synced 2026-06-23 02:05:51 +07:00
refactor: replace term_size with terminal_size (#3087)
This commit is contained in:
+3
-2
@@ -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(),
|
||||
|
||||
+3
-2
@@ -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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user