[systemd-devel] [PATCH] Fix title positions for dynamic column widths.

David Strauss david at davidstrauss.net
Thu Jul 26 13:46:16 PDT 2012


This stacks on top of Zbyszek's patch to fix column title alignment.

On Thu, Jul 26, 2012 at 1:42 PM,  <david at davidstrauss.net> wrote:
> From: David Strauss <david at davidstrauss.net>
>
> ---
>  src/cgtop/cgtop.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c
> index fde31b9..33e78b0 100644
> --- a/src/cgtop/cgtop.c
> +++ b/src/cgtop/cgtop.c
> @@ -450,13 +450,13 @@ static int display(Hashmap *a) {
>          if (path_columns < 10)
>                  path_columns = 10;
>
> -        printf("%s%-37s%s %s%7s%s %s%6s%s %s%8s%s %s%8s%s %s%8s%s\n\n",
> -               arg_order == ORDER_PATH   ? ANSI_HIGHLIGHT_ON : "", "Path",     arg_order == ORDER_PATH   ? ANSI_HIGHLIGHT_OFF : "",
> -               arg_order == ORDER_TASKS  ? ANSI_HIGHLIGHT_ON : "", "Tasks",    arg_order == ORDER_TASKS  ? ANSI_HIGHLIGHT_OFF : "",
> -               arg_order == ORDER_CPU    ? ANSI_HIGHLIGHT_ON : "", "%CPU",     arg_order == ORDER_CPU    ? ANSI_HIGHLIGHT_OFF : "",
> -               arg_order == ORDER_MEMORY ? ANSI_HIGHLIGHT_ON : "", "Memory",   arg_order == ORDER_MEMORY ? ANSI_HIGHLIGHT_OFF : "",
> -               arg_order == ORDER_IO     ? ANSI_HIGHLIGHT_ON : "", "Input/s",  arg_order == ORDER_IO     ? ANSI_HIGHLIGHT_OFF : "",
> -               arg_order == ORDER_IO     ? ANSI_HIGHLIGHT_ON : "", "Output/s", arg_order == ORDER_IO     ? ANSI_HIGHLIGHT_OFF : "");
> +        printf("%s%-*s%s %s%7s%s %s%6s%s %s%8s%s %s%8s%s %s%8s%s\n\n",
> +               arg_order == ORDER_PATH   ? ANSI_HIGHLIGHT_ON : "", path_columns, "Path",     arg_order == ORDER_PATH   ? ANSI_HIGHLIGHT_OFF : "",
> +               arg_order == ORDER_TASKS  ? ANSI_HIGHLIGHT_ON : "",               "Tasks",    arg_order == ORDER_TASKS  ? ANSI_HIGHLIGHT_OFF : "",
> +               arg_order == ORDER_CPU    ? ANSI_HIGHLIGHT_ON : "",               "%CPU",     arg_order == ORDER_CPU    ? ANSI_HIGHLIGHT_OFF : "",
> +               arg_order == ORDER_MEMORY ? ANSI_HIGHLIGHT_ON : "",               "Memory",   arg_order == ORDER_MEMORY ? ANSI_HIGHLIGHT_OFF : "",
> +               arg_order == ORDER_IO     ? ANSI_HIGHLIGHT_ON : "",               "Input/s",  arg_order == ORDER_IO     ? ANSI_HIGHLIGHT_OFF : "",
> +               arg_order == ORDER_IO     ? ANSI_HIGHLIGHT_ON : "",               "Output/s", arg_order == ORDER_IO     ? ANSI_HIGHLIGHT_OFF : "");
>
>          for (j = 0; j < n; j++) {
>                  char *p;
> --
> 1.7.11.2
>



-- 
David Strauss
   | david at davidstrauss.net
   | +1 512 577 5827 [mobile]


More information about the systemd-devel mailing list