mirror of
https://github.com/moparisthebest/pacman
synced 2024-10-31 15:45:03 -04:00
Add new list_display_linebreak function
list_display puts several members on the same line, which is not appropriate for optdepends: Optdepends: foo: feature1 bar: feature2 baz: feature3 The new list_display_linebreak function puts every member on its own line, which is much better with optdepends: Optdepends: foo: feature1 bar: feature2 baz: feature3 Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> [Xav: implement this new behavior as a new function rather than as a parameter of list_display] Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
9451b2e4f2
commit
e27a8c9ae3
@ -95,7 +95,7 @@ void dump_pkg_full(pmpkg_t *pkg, int level)
|
||||
list_display(_("Groups :"), alpm_pkg_get_groups(pkg));
|
||||
list_display(_("Provides :"), alpm_pkg_get_provides(pkg));
|
||||
list_display(_("Depends On :"), depstrings);
|
||||
list_display(_("Optional Deps :"), alpm_pkg_get_optdepends(pkg));
|
||||
list_display_linebreak(_("Optional Deps :"), alpm_pkg_get_optdepends(pkg));
|
||||
/* Only applicable if installed */
|
||||
if(level > 0) {
|
||||
list_display(_("Required By :"), requiredby);
|
||||
|
@ -461,38 +461,27 @@ void string_display(const char *title, const char *string)
|
||||
void list_display(const char *title, const alpm_list_t *list)
|
||||
{
|
||||
const alpm_list_t *i;
|
||||
int cols, len;
|
||||
wchar_t *wcstr;
|
||||
int cols, len = 0;
|
||||
|
||||
if(title) {
|
||||
/* len goes from # bytes -> # chars -> # cols */
|
||||
len = strlen(title) + 1;
|
||||
wcstr = calloc(len, sizeof(wchar_t));
|
||||
len = mbstowcs(wcstr, title, len);
|
||||
len = wcswidth(wcstr, len);
|
||||
free(wcstr);
|
||||
len = string_length(title) + 1;
|
||||
printf("%s ", title);
|
||||
} else {
|
||||
len = 0;
|
||||
}
|
||||
|
||||
if(list) {
|
||||
if(!list) {
|
||||
printf(_("None\n"));
|
||||
} else {
|
||||
for(i = list, cols = len; i; i = alpm_list_next(i)) {
|
||||
char *str = alpm_list_getdata(i);
|
||||
/* s goes from # bytes -> # chars -> # cols */
|
||||
int s = strlen(str) + 1;
|
||||
wcstr = calloc(s, sizeof(wchar_t));
|
||||
s = mbstowcs(wcstr, str, s);
|
||||
s = wcswidth(wcstr, s);
|
||||
free(wcstr);
|
||||
int s = string_length(str);
|
||||
/* two additional spaces are added to the length */
|
||||
s += 2;
|
||||
int maxcols = getcols();
|
||||
if(s + cols >= maxcols) {
|
||||
int i;
|
||||
if(s + cols > maxcols) {
|
||||
int j;
|
||||
cols = len;
|
||||
printf("\n");
|
||||
for (i = 0; i <= len; ++i) {
|
||||
for (j = 1; j <= len; j++) {
|
||||
printf(" ");
|
||||
}
|
||||
}
|
||||
@ -500,11 +489,36 @@ void list_display(const char *title, const alpm_list_t *list)
|
||||
cols += s;
|
||||
}
|
||||
printf("\n");
|
||||
} else {
|
||||
printf(_("None\n"));
|
||||
}
|
||||
}
|
||||
|
||||
void list_display_linebreak(const char *title, const alpm_list_t *list)
|
||||
{
|
||||
const alpm_list_t *i;
|
||||
int len = 0;
|
||||
|
||||
if(title) {
|
||||
len = string_length(title) + 1;
|
||||
printf("%s ", title);
|
||||
}
|
||||
|
||||
if(!list) {
|
||||
printf(_("None\n"));
|
||||
} else {
|
||||
/* Print the first element */
|
||||
indentprint((const char *) alpm_list_getdata(list), len);
|
||||
printf("\n");
|
||||
/* Print the rest */
|
||||
for(i = alpm_list_next(list); i; i = alpm_list_next(i)) {
|
||||
int j;
|
||||
for(j = 1; j <= len; j++) {
|
||||
printf(" ");
|
||||
}
|
||||
indentprint((const char *) alpm_list_getdata(i), len);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
/* prepare a list of pkgs to display */
|
||||
void display_targets(const alpm_list_t *pkgs, int install)
|
||||
{
|
||||
|
@ -51,6 +51,7 @@ char *strreplace(const char *str, const char *needle, const char *replace);
|
||||
alpm_list_t *strsplit(const char *str, const char splitchar);
|
||||
void string_display(const char *title, const char *string);
|
||||
void list_display(const char *title, const alpm_list_t *list);
|
||||
void list_display_linebreak(const char *title, const alpm_list_t *list);
|
||||
void display_targets(const alpm_list_t *pkgs, int install);
|
||||
void display_synctargets(const alpm_list_t *syncpkgs);
|
||||
int yesno(short preset, char *fmt, ...);
|
||||
|
Loading…
Reference in New Issue
Block a user