diff options
author | Fabian Groffen <grobian@gentoo.org> | 2019-06-13 10:36:53 +0200 |
---|---|---|
committer | Fabian Groffen <grobian@gentoo.org> | 2019-06-13 10:36:53 +0200 |
commit | e75a1a31fa0d05ab0db3548d848ddb602038ce01 (patch) | |
tree | d0f714687de9052d12469da1ed984dbca8462e06 /quse.c | |
parent | quse: add mode for querying installed packages (only) (diff) | |
download | portage-utils-e75a1a31fa0d05ab0db3548d848ddb602038ce01.tar.gz portage-utils-e75a1a31fa0d05ab0db3548d848ddb602038ce01.tar.bz2 portage-utils-e75a1a31fa0d05ab0db3548d848ddb602038ce01.zip |
quse: improve per package USE-flag output somewhat
- add asterisk at the end of USE-flag instead of at the start of the
line to mark currently enabled flag (installed package)
- colour such enabled flags green so they stand out better
- wrap descriptions when they don't fit on the terminal screen
example:
app-portage/portage-utils-0.80_pre20190610
nls* Add Native Language Support (using gettext - GNU locale utilities)
static !!do not set this during bootstrap!! Causes binaries to be
statically linked instead of dynamically
openmp Build support for the OpenMP (support parallel computing),
requires >=sys-devel/gcc-4.2 built with USE="openmp"
+qmanifest* Build qmanifest applet, this adds additional dependencies for GPG,
OpenSSL and BLAKE2B hashing
libressl* Use dev-libs/libressl instead of dev-libs/openssl when applicable
(see also the ssl useflag)
Bug: https://bugs.gentoo.org/656550
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Diffstat (limited to 'quse.c')
-rw-r--r-- | quse.c | 40 |
1 files changed, 37 insertions, 3 deletions
@@ -559,6 +559,7 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv) printf("%s\n", atom_format(qfmt, atom, 0)); } else if (verbose && !state->do_licence) { /* multi-line result, printing USE-flags with their descs */ + size_t desclen; struct quse_state us = { .do_regex = false, .do_describe = false, @@ -598,17 +599,50 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv) if (!quse_search_use_desc(portdirfd, &us)) quse_search_profiles_desc(portdirfd, &us); + /* calculate available space in the terminal to print + * descriptions */ + len = twidth - maxlen - 2 - 1 - 2; + for (i = 0; i < cnt; i++) { match = use != NULL && contains_set(us.argv[i], use); - printf("%s%c%s%s%s%*s %s\n", - match ? "*" : " ", + desclen = us.retv[i] != NULL ? strlen(us.retv[i]) : 0; + p = NULL; + if (desclen > (size_t)len) { /* need to wrap */ + for (p = &us.retv[i][len]; p > us.retv[i]; p--) + if (isspace((int)*p)) + break; + if (p > us.retv[i]) { + *p++ = '\0'; + desclen -= p - us.retv[i]; + } else { + p = NULL; + } + } + printf(" %c%s%s%s%c%*s %s\n", us.argv[i][-1], - /* selected ? RED : NORM */ MAGENTA, + match ? GREEN : MAGENTA, us.argv[i], NORM, + match ? '*' : ' ', (int)(maxlen - strlen(us.argv[i])), "", us.retv[i] == NULL ? "<no description found>" : us.retv[i]); + while (p != NULL) { /* continue wrapped description */ + q = p; + p = NULL; + if ((size_t)len < desclen) { + for (p = q + len; p > q; p--) + if (isspace((int)*p)) + break; + if (p > q) { + *p++ = '\0'; + desclen -= p - q; + } else { + p = NULL; + } + } + printf(" %*s %s\n", maxlen, "", q); + } if (us.retv[i] != NULL) free(us.retv[i]); } |