commit: e75a1a31fa0d05ab0db3548d848ddb602038ce01
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 13 08:36:53 2019 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jun 13 08:36:53 2019 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e75a1a31
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 <AT> gentoo.org>
applets.h | 1 +
main.c | 8 ++++++++
qmanifest.c | 7 -------
quse.c | 40 +++++++++++++++++++++++++++++++++++++---
4 files changed, 46 insertions(+), 10 deletions(-)
diff --git a/applets.h b/applets.h
index fbb21aa..acc85da 100644
--- a/applets.h
+++ b/applets.h
@@ -165,6 +165,7 @@ extern char *install_mask;
extern DEFINE_ARRAY(overlays);
extern DEFINE_ARRAY(overlay_names);
extern char *main_overlay;
+extern int twidth;
void no_colors(void);
void setup_quiet(void);
diff --git a/main.c b/main.c
index 1f51542..8325c44 100644
--- a/main.c
+++ b/main.c
@@ -16,6 +16,7 @@
#include <ctype.h>
#include <sys/time.h>
#include <limits.h>
+#include <termios.h>
#include "eat_file.h"
#include "rmspace.h"
@@ -27,6 +28,7 @@ char *main_overlay;
char *module_name = NULL;
int verbose = 0;
int quiet = 0;
+int twidth;
char pretend = 0;
char *portroot;
char *config_protect;
@@ -772,6 +774,12 @@ initialize_portage_env(void)
int main(int argc, char **argv)
{
struct stat st;
+ struct winsize winsz;
+
+ ioctl(0, TIOCGWINSZ, &winsz);
+ if (winsz.ws_col > 0)
+ twidth = winsz.ws_col > 0 ? (int)winsz.ws_col : 80;
+
warnout = stderr;
IF_DEBUG(init_coredumps());
argv0 = argv[0];
diff --git a/qmanifest.c b/qmanifest.c
index de68569..d7f90b8 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -25,7 +25,6 @@
#include <dirent.h>
#include <time.h>
#include <errno.h>
-#include <termios.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
@@ -1531,12 +1530,6 @@ process_dir_vrfy(void)
verify_msg topmsg;
verify_msg *walk = &topmsg;
gpg_sig *gs;
- struct winsize winsz;
- int twidth = 80;
-
- ioctl(0, TIOCGWINSZ, &winsz);
- if (winsz.ws_col > 0)
- twidth = (int)winsz.ws_col;
gettimeofday(&startt, NULL);
diff --git a/quse.c b/quse.c
index 751f767..f1d52ae 100644
--- a/quse.c
+++ b/quse.c
@@ -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]);
}