diff --git a/TODO b/TODO index fa29592..98bc29b 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ # TODO for spmenu -- Tab currently broken for SGR sequences - Mouse bind array (mouse.h) - Add configuration file using (probably) libconfig diff --git a/libs/arg.c b/libs/arg.c index 07d163b..899f0d5 100644 --- a/libs/arg.c +++ b/libs/arg.c @@ -109,7 +109,7 @@ complete(const Arg *arg) { if (!sel) return; - strncpy(text, sel->text, sizeof text - 1); + strncpy(text, sel->clntext, sizeof text - 1); text[sizeof text - 1] = '\0'; cursor = strlen(text); match(); diff --git a/libs/draw.c b/libs/draw.c index 0856e48..412cddc 100644 --- a/libs/draw.c +++ b/libs/draw.c @@ -69,8 +69,7 @@ drawitem(struct item *item, int x, int y, int w) // parse item text for (wr = 0, rd = 0; item->text[rd]; rd++) { if (item->text[rd] == '' && item->text[rd + 1] == '[') { - size_t alen = strspn(item->text + rd + 2, - "0123456789;"); + size_t alen = strspn(item->text + rd + 2, "0123456789;"); if (item->text[rd + alen + 2] == 'm') { // last character in sequence is always 'm' buffer[wr] = '\0'; @@ -144,6 +143,10 @@ drawitem(struct item *item, int x, int y, int w) int r = drw_text(drw, x, y, w, bh, lp, isrtl ? fribidi_text : buffer, 0, pango_item ? True : False); if (!hidehighlight && !ib) drawhighlights(item, x, y, w); + // this should allow us to use it for tab completion + item->clntext = malloc(sizeof(buffer)); + memcpy(item->clntext, buffer, sizeof(buffer)); + return r; } diff --git a/spmenu.c b/spmenu.c index b82d8db..737e599 100644 --- a/spmenu.c +++ b/spmenu.c @@ -137,6 +137,7 @@ static int screen; // item struct struct item { char *text; + char *clntext; #if USEIMAGE char *image; #endif