fixed: tab completion with sgr sequences

This commit is contained in:
speedie 2023-03-24 03:48:56 +01:00
parent 316000a4fc
commit 1c6c041f5e
4 changed files with 7 additions and 4 deletions

1
TODO
View file

@ -1,5 +1,4 @@
# TODO for spmenu # TODO for spmenu
- Tab currently broken for SGR sequences
- Mouse bind array (mouse.h) - Mouse bind array (mouse.h)
- Add configuration file using (probably) libconfig - Add configuration file using (probably) libconfig

View file

@ -109,7 +109,7 @@ complete(const Arg *arg)
{ {
if (!sel) return; if (!sel) return;
strncpy(text, sel->text, sizeof text - 1); strncpy(text, sel->clntext, sizeof text - 1);
text[sizeof text - 1] = '\0'; text[sizeof text - 1] = '\0';
cursor = strlen(text); cursor = strlen(text);
match(); match();

View file

@ -69,8 +69,7 @@ drawitem(struct item *item, int x, int y, int w)
// parse item text // parse item text
for (wr = 0, rd = 0; item->text[rd]; rd++) { for (wr = 0, rd = 0; item->text[rd]; rd++) {
if (item->text[rd] == '' && item->text[rd + 1] == '[') { if (item->text[rd] == '' && item->text[rd + 1] == '[') {
size_t alen = strspn(item->text + rd + 2, size_t alen = strspn(item->text + rd + 2, "0123456789;");
"0123456789;");
if (item->text[rd + alen + 2] == 'm') { // last character in sequence is always 'm' if (item->text[rd + alen + 2] == 'm') { // last character in sequence is always 'm'
buffer[wr] = '\0'; 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); 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); 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; return r;
} }

View file

@ -137,6 +137,7 @@ static int screen;
// item struct // item struct
struct item { struct item {
char *text; char *text;
char *clntext;
#if USEIMAGE #if USEIMAGE
char *image; char *image;
#endif #endif