* Tried to clean up newline display a bit in the frontend.
* Removed useless buildstring function from util.h; replaced all calls of it with list_display. * Made list_display output 2 spaces instead of 1 between each item.
This commit is contained in:
parent
8c0a8ddc5b
commit
cdaed9221d
5 changed files with 12 additions and 41 deletions
|
@ -76,12 +76,13 @@ int pacman_add(alpm_list_t *targets)
|
||||||
MSG(NL, _("loading package data... "));
|
MSG(NL, _("loading package data... "));
|
||||||
for(i = targets; i; i = i->next) {
|
for(i = targets; i; i = i->next) {
|
||||||
if(alpm_trans_addtarget(i->data) == -1) {
|
if(alpm_trans_addtarget(i->data) == -1) {
|
||||||
|
MSG(NL, "\n");
|
||||||
ERR(NL, _("failed to add target '%s' (%s)\n"), (char *)i->data, alpm_strerror(pm_errno));
|
ERR(NL, _("failed to add target '%s' (%s)\n"), (char *)i->data, alpm_strerror(pm_errno));
|
||||||
retval = 1;
|
retval = 1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MSG(CL, _("done."));
|
MSG(CL, _("done.\n"));
|
||||||
|
|
||||||
/* Step 2: "compute" the transaction based on targets and flags
|
/* Step 2: "compute" the transaction based on targets and flags
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -121,7 +121,8 @@ int pacman_remove(alpm_list_t *targets)
|
||||||
pmpkg_t *pkg = alpm_list_getdata(i);
|
pmpkg_t *pkg = alpm_list_getdata(i);
|
||||||
lst = alpm_list_add(lst, strdup(alpm_pkg_get_name(pkg)));
|
lst = alpm_list_add(lst, strdup(alpm_pkg_get_name(pkg)));
|
||||||
}
|
}
|
||||||
list_display(_("\nTargets:"), lst);
|
MSG(NL, "\n");
|
||||||
|
list_display(_("Targets:"), lst);
|
||||||
FREELIST(lst);
|
FREELIST(lst);
|
||||||
/* get confirmation */
|
/* get confirmation */
|
||||||
if(yesno(_("\nDo you want to remove these packages? [Y/n] ")) == 0) {
|
if(yesno(_("\nDo you want to remove these packages? [Y/n] ")) == 0) {
|
||||||
|
|
|
@ -292,6 +292,7 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets)
|
||||||
pmgrp_t *grp = alpm_db_readgrp(db, grpname);
|
pmgrp_t *grp = alpm_db_readgrp(db, grpname);
|
||||||
|
|
||||||
if(grp) {
|
if(grp) {
|
||||||
|
/* TODO this should be a lot cleaner, why two outputs? */
|
||||||
MSG(NL, "%s\n", (char *)alpm_grp_get_name(grp));
|
MSG(NL, "%s\n", (char *)alpm_grp_get_name(grp));
|
||||||
list_display(" ", alpm_grp_get_packages(grp));
|
list_display(" ", alpm_grp_get_packages(grp));
|
||||||
}
|
}
|
||||||
|
@ -659,12 +660,9 @@ int pacman_sync(alpm_list_t *targets)
|
||||||
list_install = alpm_list_add(list_install, str);
|
list_install = alpm_list_add(list_install, str);
|
||||||
}
|
}
|
||||||
if(list_remove) {
|
if(list_remove) {
|
||||||
MSG(NL, _("\nRemove: "));
|
MSG(NL, "\n"); /* TODO ugly hack. printing a single NL should be easy */
|
||||||
str = buildstring(list_remove);
|
list_display(_("Remove:"), list_remove);
|
||||||
indentprint(str, 9);
|
|
||||||
MSG(CL, "\n");
|
|
||||||
FREELIST(list_remove);
|
FREELIST(list_remove);
|
||||||
FREE(str);
|
|
||||||
}
|
}
|
||||||
mb = (double)(totalsize / 1048576.0);
|
mb = (double)(totalsize / 1048576.0);
|
||||||
umb = (double)(totalisize / 1048576.0);
|
umb = (double)(totalisize / 1048576.0);
|
||||||
|
@ -675,15 +673,13 @@ int pacman_sync(alpm_list_t *targets)
|
||||||
if(umb > 0 && umb < 0.1) {
|
if(umb > 0 && umb < 0.1) {
|
||||||
umb = 0.1;
|
umb = 0.1;
|
||||||
}
|
}
|
||||||
MSG(NL, _("\nTargets: "));
|
MSG(NL, "\n");
|
||||||
str = buildstring(list_install);
|
list_display(_("Targets:"), list_install);
|
||||||
indentprint(str, 9);
|
|
||||||
MSG(NL, _("\nTotal Package Size: %.1f MB\n"), mb);
|
MSG(NL, _("\nTotal Package Size: %.1f MB\n"), mb);
|
||||||
if(umb > 0) {
|
if(umb > 0) {
|
||||||
MSG(NL, _("Total Installed Size: %.1f MB\n"), umb);
|
MSG(NL, _("Total Installed Size: %.1f MB\n"), umb);
|
||||||
}
|
}
|
||||||
FREELIST(list_install);
|
FREELIST(list_install);
|
||||||
FREE(str);
|
|
||||||
|
|
||||||
if(config->op_s_downloadonly) {
|
if(config->op_s_downloadonly) {
|
||||||
if(config->noconfirm) {
|
if(config->noconfirm) {
|
||||||
|
|
|
@ -194,32 +194,6 @@ void indentprint(const char *str, unsigned int indent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Condense a list of strings into one long (space-delimited) string
|
|
||||||
*/
|
|
||||||
char *buildstring(alpm_list_t *strlist)
|
|
||||||
{
|
|
||||||
char *str;
|
|
||||||
size_t size = 1;
|
|
||||||
alpm_list_t *i;
|
|
||||||
|
|
||||||
for(i = strlist; i; i = alpm_list_next(i)) {
|
|
||||||
size += strlen(alpm_list_getdata(i)) + 1;
|
|
||||||
}
|
|
||||||
str = (char *)malloc(size);
|
|
||||||
if(str == NULL) {
|
|
||||||
ERR(NL, _("failed to allocate %d bytes\n"), size);
|
|
||||||
}
|
|
||||||
str[0] = '\0';
|
|
||||||
for(i = strlist; i; i = alpm_list_next(i)) {
|
|
||||||
strcat(str, alpm_list_getdata(i));
|
|
||||||
strcat(str, " ");
|
|
||||||
}
|
|
||||||
/* shave off the last space */
|
|
||||||
str[strlen(str)-1] = '\0';
|
|
||||||
|
|
||||||
return(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Convert a string to uppercase
|
/* Convert a string to uppercase
|
||||||
*/
|
*/
|
||||||
char *strtoupper(char *str)
|
char *strtoupper(char *str)
|
||||||
|
@ -265,13 +239,13 @@ void list_display(const char *title, alpm_list_t *list)
|
||||||
if(list) {
|
if(list) {
|
||||||
for(i = list, cols = len; i; i = alpm_list_next(i)) {
|
for(i = list, cols = len; i; i = alpm_list_next(i)) {
|
||||||
char *str = alpm_list_getdata(i);
|
char *str = alpm_list_getdata(i);
|
||||||
int s = strlen(str)+1;
|
int s = strlen(str) + 2;
|
||||||
unsigned int maxcols = getcols();
|
unsigned int maxcols = getcols();
|
||||||
if(s + cols >= maxcols) {
|
if(s + cols >= maxcols) {
|
||||||
int i;
|
int i;
|
||||||
cols = len;
|
cols = len;
|
||||||
printf("\n");
|
printf("\n");
|
||||||
for (i = 0; i < len+1; ++i) {
|
for (i = 0; i <= len; ++i) {
|
||||||
printf(" ");
|
printf(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,6 @@ unsigned int getcols();
|
||||||
int makepath(char *path);
|
int makepath(char *path);
|
||||||
int rmrf(char *path);
|
int rmrf(char *path);
|
||||||
void indentprint(const char *str, unsigned int indent);
|
void indentprint(const char *str, unsigned int indent);
|
||||||
char *buildstring(alpm_list_t *strlist);
|
|
||||||
char *strtoupper(char *str);
|
char *strtoupper(char *str);
|
||||||
char *strtrim(char *str);
|
char *strtrim(char *str);
|
||||||
int reg_match(char *string, char *pattern);
|
int reg_match(char *string, char *pattern);
|
||||||
|
|
Loading…
Add table
Reference in a new issue