mirror of
https://github.com/moparisthebest/pacman
synced 2025-02-28 17:31:52 -05:00
* 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
@ -76,12 +76,13 @@ int pacman_add(alpm_list_t *targets)
|
||||
MSG(NL, _("loading package data... "));
|
||||
for(i = targets; i; i = i->next) {
|
||||
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));
|
||||
retval = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
MSG(CL, _("done."));
|
||||
MSG(CL, _("done.\n"));
|
||||
|
||||
/* 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);
|
||||
lst = alpm_list_add(lst, strdup(alpm_pkg_get_name(pkg)));
|
||||
}
|
||||
list_display(_("\nTargets:"), lst);
|
||||
MSG(NL, "\n");
|
||||
list_display(_("Targets:"), lst);
|
||||
FREELIST(lst);
|
||||
/* get confirmation */
|
||||
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);
|
||||
|
||||
if(grp) {
|
||||
/* TODO this should be a lot cleaner, why two outputs? */
|
||||
MSG(NL, "%s\n", (char *)alpm_grp_get_name(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);
|
||||
}
|
||||
if(list_remove) {
|
||||
MSG(NL, _("\nRemove: "));
|
||||
str = buildstring(list_remove);
|
||||
indentprint(str, 9);
|
||||
MSG(CL, "\n");
|
||||
MSG(NL, "\n"); /* TODO ugly hack. printing a single NL should be easy */
|
||||
list_display(_("Remove:"), list_remove);
|
||||
FREELIST(list_remove);
|
||||
FREE(str);
|
||||
}
|
||||
mb = (double)(totalsize / 1048576.0);
|
||||
umb = (double)(totalisize / 1048576.0);
|
||||
@ -675,15 +673,13 @@ int pacman_sync(alpm_list_t *targets)
|
||||
if(umb > 0 && umb < 0.1) {
|
||||
umb = 0.1;
|
||||
}
|
||||
MSG(NL, _("\nTargets: "));
|
||||
str = buildstring(list_install);
|
||||
indentprint(str, 9);
|
||||
MSG(NL, "\n");
|
||||
list_display(_("Targets:"), list_install);
|
||||
MSG(NL, _("\nTotal Package Size: %.1f MB\n"), mb);
|
||||
if(umb > 0) {
|
||||
MSG(NL, _("Total Installed Size: %.1f MB\n"), umb);
|
||||
}
|
||||
FREELIST(list_install);
|
||||
FREE(str);
|
||||
|
||||
if(config->op_s_downloadonly) {
|
||||
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
|
||||
*/
|
||||
char *strtoupper(char *str)
|
||||
@ -265,17 +239,17 @@ void list_display(const char *title, alpm_list_t *list)
|
||||
if(list) {
|
||||
for(i = list, cols = len; i; i = alpm_list_next(i)) {
|
||||
char *str = alpm_list_getdata(i);
|
||||
int s = strlen(str)+1;
|
||||
int s = strlen(str) + 2;
|
||||
unsigned int maxcols = getcols();
|
||||
if(s + cols >= maxcols) {
|
||||
int i;
|
||||
cols = len;
|
||||
printf("\n");
|
||||
for (i = 0; i < len+1; ++i) {
|
||||
for (i = 0; i <= len; ++i) {
|
||||
printf(" ");
|
||||
}
|
||||
}
|
||||
printf("%s ", str);
|
||||
printf("%s ", str);
|
||||
cols += s;
|
||||
}
|
||||
printf("\n");
|
||||
|
@ -52,7 +52,6 @@ unsigned int getcols();
|
||||
int makepath(char *path);
|
||||
int rmrf(char *path);
|
||||
void indentprint(const char *str, unsigned int indent);
|
||||
char *buildstring(alpm_list_t *strlist);
|
||||
char *strtoupper(char *str);
|
||||
char *strtrim(char *str);
|
||||
int reg_match(char *string, char *pattern);
|
||||
|
Loading…
x
Reference in New Issue
Block a user