Skip to content

Commit

Permalink
output: Use short ANSI clr sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentdephily committed Apr 9, 2024
1 parent 8beaea1 commit 5426dab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ impl Conf {
unmerge: AnsiStr::from(if color { "\x1B[1;31m" } else { "<<< " }),
dur: AnsiStr::from(if color { "\x1B[1;35m" } else { "" }),
cnt: AnsiStr::from(if color { "\x1B[2;33m" } else { "" }),
clr: AnsiStr::from(if color { "\x1B[0m" } else { "" }),
lineend: if color { b"\x1B[0m\n" } else { b"\n" },
clr: AnsiStr::from(if color { "\x1B[m" } else { "" }),
lineend: if color { b"\x1B[m\n" } else { b"\n" },
header: sel!(cli, toml, header, (), false)?,
dur_t: sel!(cli, toml, duration, (), DurationStyle::Hms)?,
date_offset: offset,
Expand Down
4 changes: 2 additions & 2 deletions src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ mod test {
let mut t = Table::<2>::new(&conf).align_left(0);
t.row([&[&"123"], &[&1]]);
t.row([&[&conf.merge, &1, &conf.dur, &2, &conf.cnt, &3, &conf.clr], &[&1]]);
let res = "123 1\x1B[0m\n\
\x1B[1;32m1\x1B[1;35m2\x1B[2;33m3\x1B[0m 1\x1B[0m\n";
let res = "123 1\x1B[m\n\
\x1B[1;32m1\x1B[1;35m2\x1B[2;33m3\x1B[m 1\x1B[m\n";
let (l1, l2) = res.split_once('\n').expect("two lines");
assert_eq!(Ansi::strip(l1, 100), "123 1");
assert_eq!(Ansi::strip(l1, 100), Ansi::strip(l2, 100));
Expand Down

0 comments on commit 5426dab

Please sign in to comment.