Skip to content

Commit

Permalink
use owo-colors, which is more pleasant
Browse files Browse the repository at this point in the history
  • Loading branch information
tshepang committed Jul 6, 2023
1 parent e850fdf commit 7169ae2
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 57 deletions.
175 changes: 128 additions & 47 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bindgen-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ prettyplease = { version = "0.2.7", features = ["verbatim"] }
syn = { version = "2.0" }
tempfile = "3"
similar = { version = "2.2.1", features = ["inline"] }
console = "0.15.7"
owo-colors = "3.5.0"

[features]
logging = ["bindgen/logging"]
Expand Down
18 changes: 9 additions & 9 deletions bindgen-tests/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extern crate env_logger;
extern crate shlex;

use bindgen::{clang_version, Builder};
use console::{style, Style};
use owo_colors::{OwoColorize, Style};
use similar::{ChangeTag, TextDiff};
use std::env;
use std::fmt;
Expand Down Expand Up @@ -95,27 +95,27 @@ fn show_diff(old: &str, new: &str) {
let diff = TextDiff::from_lines(old, new);
for (count, group) in diff.grouped_ops(3).iter().enumerate() {
if count > 0 {
let message= format!("(chunk {count}/n)");
println!("{}", style(message).cyan().dim());
let message = format!("(chunk {count}/n)");
println!("{}", message.cyan().dimmed());
}
for diff_op in group {
for change in diff.iter_inline_changes(diff_op) {
let (sign, styled) = match change.tag() {
let (sign, color) = match change.tag() {
ChangeTag::Delete => ("-", Style::new().red()),
ChangeTag::Insert => ("+", Style::new().green()),
ChangeTag::Equal => (" ", Style::new()),
};
print!(
"{}{}| {}",
style(Line(change.old_index())).dim(),
style(Line(change.new_index())).dim(),
styled.apply_to(sign).bold(),
Line(change.old_index()).style(color).dimmed(),
Line(change.new_index()).style(color).dimmed(),
sign.style(color).bold(),
);
for (emphasized, text) in change.iter_strings_lossy() {
if emphasized {
print!("{}", styled.apply_to(text).underlined());
print!("{}", text.style(color).underline());
} else {
print!("{}", styled.apply_to(text));
print!("{}", text.style(color));
}
}
if change.missing_newline() {
Expand Down

0 comments on commit 7169ae2

Please sign in to comment.