-
Notifications
You must be signed in to change notification settings - Fork 120
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
Add utility function ansi::slice_ansi_str
#206
base: main
Are you sure you want to change the base?
Conversation
3811bcc
to
3324138
Compare
src/unix_term.rs
Outdated
@@ -56,7 +56,7 @@ pub fn terminal_size(out: &Term) -> Option<(u16, u16)> { | |||
#[allow(clippy::useless_conversion)] | |||
libc::ioctl(out.as_raw_fd(), libc::TIOCGWINSZ.into(), &mut winsize); | |||
if winsize.ws_row > 0 && winsize.ws_col > 0 { | |||
Some((winsize.ws_row as u16, winsize.ws_col as u16)) | |||
Some((winsize.ws_row, winsize.ws_col)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just a random (new?) clippy lint : these are already u16 🤷
src/utils.rs
Outdated
AnsiCodeIterator::new(s) | ||
.filter(|(_, is_ansi)| !is_ansi) | ||
.map(|(sub, _)| str_width(sub)) | ||
.sum() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to the MR, but while implementing a less optimized draft of my fix I thought this could spare a few allocs. This is probably not something to care about so I wouldn't mind if you want to revert this for the sake of simplification.
0f33b85
to
ce77cc5
Compare
ansi::slice_ansi_str
ansi::slice_ansi_str
Can you avoid |
Indeed, that should be good now 👍 |
And format is also a recent-is feature, on it 😬 I'll try to build on 1.56, it didn't work last time I tried it because it fails to resolve EDIT : Ok, got it |
Should be good, |
97b3716
to
66bb444
Compare
Hi! I bumped into this while doing some cleanup and I think it might still be useful. So I've rebased it on latest main! |
I definitely don't want to accept a semver-incompatible change for this. Is there a way to make this compatible? |
Hi! You're right that it would be a shame. Although I think I made a mistake with semver : I only added a new function without affecting the behavior of the existing, as we're still on unstable scheme 0.x.y this should only affect the last (y) component. I changed the target version to 0.15.12 and made sure that I didn't modify previously existing test cases 👍 |
Okay, this doesn't currently pass the MSRV jobs in CI, so that's something that will have to be fixed. I'd like a cleaner set of changes for review, with separate commits or PRs for each of these changes:
Please avoid unrelated changes as much as possible (as such, keep functions/logic in the place as much as possible to minimize the diffs). You can leave the version bumping and changelog to me (note that the |
3740c3f
to
1599bf9
Compare
Hello mon ami ! 🥖 Those are super relevant comments 👍
|
d662074
to
c0e5ff2
Compare
I'm putting this in draft until #250 is solved. |
Rebased & ready for review again! 😄 |
Hi!
While working on a bug of
indicatif
(cf. console-rs/indicatif#627), I needed an ANSI-aware slicing method. I think it made more sense to add it in this crate.This is a generalisation of
truncate_str
😃