This commit is contained in:
okan
2015-07-01 14:36:42 +00:00
parent 8efaf33cfb
commit cb900def7f
6 changed files with 18 additions and 42 deletions

View File

@ -134,7 +134,7 @@ search_print_cmd(struct menu *mi, int i)
special = 1;
(void)snprintf(mi->print, sizeof(mi->print),
(special) ? "[%s]" : "%s", cmd->name);
(special) ? "[%s]" : "%s", cmd->name);
}
void
@ -148,35 +148,12 @@ search_print_client(struct menu *mi, int list)
else if (cc->flags & CLIENT_HIDDEN)
flag = '&';
if (list)
if ((list) || (cc->matchname == cc->label))
cc->matchname = cc->name;
(void)snprintf(mi->print, sizeof(mi->print), "(%d) %c[%s] %s",
cc->group ? cc->group->num : 0, flag,
cc->label ? cc->label : "", cc->matchname);
if (!list && cc->matchname != cc->name &&
strlen(mi->print) < sizeof(mi->print) - 1) {
const char *marker = "";
char buf[MENU_MAXENTRY + 1];
int diff;
diff = sizeof(mi->print) - 1 - strlen(mi->print);
/* One for the ':' */
diff -= 1;
if (strlen(cc->name) > diff) {
marker = "..";
diff -= 2;
} else {
diff = strlen(cc->name);
}
(void)strlcpy(buf, mi->print, sizeof(buf));
(void)snprintf(mi->print, sizeof(mi->print),
"%s:%.*s%s", buf, diff, cc->name, marker);
}
(cc->group) ? cc->group->num : 0, flag,
(cc->label) ? cc->label : "", cc->matchname);
}
static void