Skip to content
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
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nutmeg"
version = "0.1.5"
version = "0.1.6"
edition = "2021"
description = "An unopinionated progress bar library"
license = "MIT"
Expand All @@ -12,7 +12,7 @@ rust-version = "1.75" # Could perhaps be even older, but this is 2 years at tim

[dependencies]
atty = "0.2"
terminal_size = "0.2"
terminal_size = "0.4"
yansi = "0.5"

[dev-dependencies]
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Nutmeg Changelog

## 0.1.6

Released 2026-03-07

- Updated `terminal_size` dependency.

## 0.1.5

Released 2025-10-05
Expand Down
25 changes: 6 additions & 19 deletions src/width.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
// Copyright 2022-2023 Martin Pool
// Copyright 2022-2026 Martin Pool

//! Measure terminal width.

use terminal_size::Width;
#[cfg(unix)]
pub(crate) fn stdout_width() -> Option<usize> {
terminal_size::terminal_size_using_fd(1).map(|(Width(w), _)| w as usize)
}

#[cfg(windows)]
pub(crate) fn stdout_width() -> Option<usize> {
// TODO: We could get the handle for stderr to make this more precise...
terminal_size::terminal_size().map(|(Width(w), _)| w as usize)
}

mod unix;
#[cfg(unix)]
pub(crate) fn stderr_width() -> Option<usize> {
terminal_size::terminal_size_using_fd(2).map(|(Width(w), _)| w as usize)
}
pub(crate) use unix::{stderr_width, stdout_width};

#[cfg(windows)]
pub(crate) fn stderr_width() -> Option<usize> {
// TODO: We could get the handle for stderr to make this more precise...
terminal_size::terminal_size().map(|(Width(w), _)| w as usize)
}
mod windows;
#[cfg(windows)]
pub(crate) use windows::{stderr_width, stdout_width};
14 changes: 14 additions & 0 deletions src/width/unix.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use std::{
io::{stderr, stdout},
os::fd::AsFd,
};

use terminal_size::{terminal_size_of, Width};

pub(crate) fn stdout_width() -> Option<usize> {
terminal_size_of(stdout().as_fd()).map(|(Width(w), _)| w as usize)
}

pub(crate) fn stderr_width() -> Option<usize> {
terminal_size_of(stderr().as_fd()).map(|(Width(w), _)| w as usize)
}
14 changes: 14 additions & 0 deletions src/width/windows.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use std::{
io::{stderr, stdout},
os::windows::io::AsHandle,
};

use terminal_size::{terminal_size_of, Width};

pub(crate) fn stdout_width() -> Option<usize> {
terminal_size_of(stdout().as_handle()).map(|(Width(w), _)| w as usize)
}

pub(crate) fn stderr_width() -> Option<usize> {
terminal_size_of(stderr().as_handle()).map(|(Width(w), _)| w as usize)
}