index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Dan McGee <dan@archlinux.org> | 2011-06-13 17:04:35 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-06-13 17:04:35 -0500 |
commit | 895a88886525dd3e6d2d0db996cedb7e73455fbb (patch) | |
tree | eefe31eb84bd330b5bd18cf3dbf5bf5fa5096456 /src | |
parent | b0590400111c04e1c6a42052d3f03986b4ad31aa (diff) |
-rw-r--r-- | src/pacman/util.c | 19 |
diff --git a/src/pacman/util.c b/src/pacman/util.c index 508cc89f..a6d150fc 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -216,8 +216,9 @@ void indentprint(const char *str, int indent) return; } - /* if we're not a tty, print without indenting */ - if(cols == 0) { + /* if we're not a tty, or our tty is not wide enough that wrapping even makes + * sense, print without indenting */ + if(cols == 0 || indent > cols) { printf("%s", str); return; } @@ -450,12 +451,16 @@ void list_display(const char *title, const alpm_list_t *list) if(!list) { printf("%s\n", _("None")); } else { - int cols; - const int maxcols = getcols(80); - for(i = list, cols = len; i; i = alpm_list_next(i)) { - char *str = alpm_list_getdata(i); + const int maxcols = getcols(0); + int cols = len; + const char *str = alpm_list_getdata(list); + printf("%s", str); + cols += string_length(str); + for(i = alpm_list_next(list), cols = len; i; i = alpm_list_next(i)) { + const char *str = alpm_list_getdata(i); int s = string_length(str); - if(cols + s + 2 >= maxcols) { + /* wrap only if we have enough usable column space */ + if(maxcols > len && cols + s + 2 >= maxcols) { int j; cols = len; printf("\n"); |