Skip to content

Commit

Permalink
more responsive command display
Browse files Browse the repository at this point in the history
  • Loading branch information
justanhduc committed Jun 4, 2021
1 parent 7ca2cba commit c94c46e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions list.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ char *joblist_headers() {
}

static int max(int a, int b) {
if (a > b)
return a;
return b;
return a > b ? a : b;
}

static const char *ofilename_shown(const struct Job *p) {
Expand Down Expand Up @@ -124,7 +122,7 @@ static char *print_noresult(const struct Job *p) {
if (line == NULL)
error("Malloc for %i failed.\n", maxlen);

cmd_len = (term_width - maxlen) > 0 ? strlen(p->command) : 20;
cmd_len = max((strlen(p->command) + (term_width - maxlen)), 20);
if (p->label)
snprintf(line, maxlen, "%-4i %-10s %-20s %-8s %6s %-5d %s[%s]%s\n",
p->jobid,
Expand Down Expand Up @@ -205,7 +203,7 @@ static char *print_result(const struct Job *p) {
}
}

cmd_len = (term_width - maxlen) > 0 ? strlen(p->command) : 20;
cmd_len = max((strlen(p->command) + (term_width - maxlen)), 20);
if (p->label)
snprintf(line, maxlen, "%-4i %-10s %-20s %-8i %5.2f%s %-5d %s[%s]%s\n",
p->jobid,
Expand Down

0 comments on commit c94c46e

Please sign in to comment.