Skip to content
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 coloring to repo names and version diff #1292

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

romanstingler
Copy link

@romanstingler romanstingler commented Dec 15, 2024

closes #1291

I have also the cachyOS repositories installed
and the colors are too often the same.
Therefore, I changed to use the repo name length, which appears to be different for each repo.

I had to add some code to calculate the length without the ANSI, so the padding would still be working as intended.

2024-12-15-22:34:15

wait aur is missing

Copy link
Owner

@Morganamilo Morganamilo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure on this. It's a lot of code (though i think can be shrunk down considerably).

The main issue is paru's goal is to look like pacman and this breaks away from that. It's not too outlandish like the upgrade menu and other yay formatting so I''m just unsure at the moment.

Maybe if for the diffs we used the gray pacman does when printing versions it would fit in more.

@@ -114,15 +114,11 @@ pub fn color_repo(enabled: bool, name: &str) -> String {
return name.to_string();
}

let mut col: u32 = 5;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a small hash function. Meaning colours should be different for similar strings. As there's only 6 possibilities we're bound to get conflicts.

Maybe we can adjust it to avoid this known conflict but just using the length would be a big no.

@@ -443,13 +439,38 @@ pub fn print_install_verbose(config: &Config, actions: &Actions, devel: &HashSet
});

for pkg in &install {
println!(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if println is going to overpad by the amount of characters we added by colouring. Can't we just do package_len -= pkg_str.len() - pkg.pkg.db().unwrap().name().len() - pkg.pkg.name().len() - 1 to calculate the difference like you have but keep using the {:<package_len$} and similar formatters instead of repeating strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add colors for repo names and version differences
2 participants