Skip to content

Commit

Permalink
add votes indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
Toni500github committed Apr 26, 2024
1 parent 1bf8caa commit c5cdf22
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions include/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ struct _color_t {
fmt::rgb others;
fmt::rgb version;
fmt::rgb popularity;
fmt::rgb votes;
fmt::rgb installed;
fmt::rgb index;
};
Expand Down Expand Up @@ -173,6 +174,7 @@ gray = "#5a5a5a"
#version = "#00ff00"
#popularity = "#00ffff"
#votes = "#00ffff"
#installed = "#5a5a5a"
#index = "#ff11cc"
)#";
Expand Down
1 change: 1 addition & 0 deletions include/taur.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct TaurPkg_t {
string url;
string desc;
float popularity = 1; // normal
float votes;
vector<string> depends;
bool installed = false;
string db_name = "aur";
Expand Down
1 change: 1 addition & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ void Config::initColors() {
color.others = this->getThemeValue("others", "#ff11cc");
color.version = this->getThemeValue("version", "#00ff00");
color.popularity = this->getThemeValue("popularity", "#00ffff");
color.votes = this->getThemeValue("votes", "#00ffff");
color.installed = this->getThemeValue("installed", "#5a5a5a");
color.index = this->getThemeValue("index", "#ff11cc");
}
Expand Down
2 changes: 2 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void test_colors() {
.version = VERSION,
.desc = "A customizable and lightweight AUR helper, designed to be simple but powerful.",
.popularity = 100,
.votes = 34.1,
.installed = true,
.db_name = "aur",
};
Expand Down Expand Up @@ -88,6 +89,7 @@ void test_colors() {

fmt::println(BOLD_TEXT(color.version), "\n(bold) version " VERSION);
fmt::println(fg(color.popularity), "Popularity: {} ({})", pkg.popularity, getTitleForPopularity(pkg.popularity));
fmt::println(fg(color.votes), "Votes: {}", pkg.votes);
fmt::println(fg(color.index), "index [1]");
fmt::println(fg(color.installed), "indicator [Installed]");

Expand Down
1 change: 1 addition & 0 deletions src/taur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ TaurPkg_t parsePkg(rapidjson::Value& pkgJson, bool returnGit = false) {
getUrl(pkgJson, returnGit), // url
pkgJson["Description"].IsString() ? pkgJson["Description"].GetString() : "", // description
pkgJson["Popularity"].GetFloat(), // popularity
pkgJson["NumVotes"].GetFloat(), // votes
depends, // depends
alpm_db_get_pkg(alpm_get_localdb(config->handle), pkgJson["Name"].GetString()) != nullptr, // installed
};
Expand Down
7 changes: 4 additions & 3 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,12 @@ void printPkgInfo(TaurPkg_t& pkg, string db_name, int index) {
fmt::print(fmt::fg(color.index), "[{}] ", index);

fmt::print(getColorFromDBName(db_name), "{}/", db_name);
fmt::print(fmt::emphasis::bold, "{} ", pkg.name);
fmt::print(BOLD, "{} ", pkg.name);
fmt::print(BOLD_TEXT(color.version), "{} ", pkg.version);
fmt::print(fmt::fg(color.popularity), " Popularity: {} ({}) ", pkg.popularity, getTitleForPopularity(pkg.popularity));
fmt::print(fg(color.popularity), " Popularity: {:.2f} ({}) ", pkg.popularity, getTitleForPopularity(pkg.popularity));
fmt::print(fg(color.votes), "Votes: {} ", pkg.votes);
if (pkg.installed)
fmt::println(fmt::fg(color.installed), "[Installed]");
fmt::println(fg(color.installed), "[Installed]");
else
fmt::print("\n");
fmt::println(" {}", pkg.desc);
Expand Down

0 comments on commit c5cdf22

Please sign in to comment.