Add a utility for printing aligned

Add a new utility for printing

  TITLE: value

while properly handling Unicode wrt to alignment.

This will be shared between info and remote-info.

Closes: #2502
Approved by: alexlarsson
This commit is contained in:
Matthias Clasen
2018-12-28 23:24:19 -05:00
committed by Atomic Bot
parent d3447eb3fa
commit 90ade7ad96
2 changed files with 17 additions and 0 deletions

View File

@@ -1088,3 +1088,18 @@ as_store_find_app (AsStore *store,
return NULL;
}
void
print_aligned (int len, const char *title, const char *value)
{
const char *on = "";
const char *off = "";
if (flatpak_fancy_output ())
{
on = FLATPAK_ANSI_BOLD_ON;
off = FLATPAK_ANSI_BOLD_OFF;
}
g_print ("%s%*s%s%s %s\n", on, len - (int)g_utf8_strlen (title, -1), "", title, off, value);
}

View File

@@ -141,6 +141,8 @@ typedef enum {
char * ellipsize_string (const char *text, int len);
char * ellipsize_string_full (const char *text, int len, FlatpakEllipsizeMode mode);
void print_aligned (int len, const char *title, const char *value);
AsApp *as_store_find_app (AsStore *store,
const char *ref);
const char *as_app_get_localized_name (AsApp *app);