forked from speedie/spmenu
Oops, fix wacky highlighting, should be working perfectly now
This commit is contained in:
parent
7492eed0cf
commit
ad96d3fbb3
|
@ -89,7 +89,7 @@ void moveup(Arg *arg) {
|
||||||
void complete(Arg *arg) {
|
void complete(Arg *arg) {
|
||||||
if (hideitem) return;
|
if (hideitem) return;
|
||||||
|
|
||||||
strncpy(tx.text, sel->text, sizeof tx.text - 1);
|
strncpy(tx.text, sel->nsgrtext, sizeof tx.text - 1);
|
||||||
tx.text[sizeof tx.text - 1] = '\0';
|
tx.text[sizeof tx.text - 1] = '\0';
|
||||||
sp.cursor = strlen(tx.text);
|
sp.cursor = strlen(tx.text);
|
||||||
|
|
||||||
|
|
24
libs/draw.c
24
libs/draw.c
|
@ -40,7 +40,6 @@ void drawhighlights(struct item *item, int x, int y, int w, int p, const char *i
|
||||||
|
|
||||||
int drawitemtext(struct item *item, int x, int y, int w) {
|
int drawitemtext(struct item *item, int x, int y, int w) {
|
||||||
char buffer[MAXITEMLENGTH]; // buffer containing item text
|
char buffer[MAXITEMLENGTH]; // buffer containing item text
|
||||||
char *ttext;
|
|
||||||
int leftpadding = sp.lrpad / 2; // padding
|
int leftpadding = sp.lrpad / 2; // padding
|
||||||
int wr, rd; // character
|
int wr, rd; // character
|
||||||
int fg = 7; // foreground
|
int fg = 7; // foreground
|
||||||
|
@ -54,6 +53,10 @@ int drawitemtext(struct item *item, int x, int y, int w) {
|
||||||
int bga;
|
int bga;
|
||||||
int fga;
|
int fga;
|
||||||
|
|
||||||
|
int ox;
|
||||||
|
int oy;
|
||||||
|
int ow;
|
||||||
|
|
||||||
// memcpy the correct scheme
|
// memcpy the correct scheme
|
||||||
if (item == sel) {
|
if (item == sel) {
|
||||||
selitem = 1;
|
selitem = 1;
|
||||||
|
@ -137,8 +140,12 @@ int drawitemtext(struct item *item, int x, int y, int w) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ttext = malloc(sizeof(buffer));
|
ox = x;
|
||||||
ttext[0] = '\0';
|
oy = y;
|
||||||
|
ow = w;
|
||||||
|
|
||||||
|
item->nsgrtext = malloc(sizeof(buffer));
|
||||||
|
item->nsgrtext[0] = '\0';
|
||||||
|
|
||||||
// parse item text
|
// parse item text
|
||||||
for (wr = 0, rd = 0; item->text[rd]; rd++) {
|
for (wr = 0, rd = 0; item->text[rd]; rd++) {
|
||||||
|
@ -153,9 +160,8 @@ int drawitemtext(struct item *item, int x, int y, int w) {
|
||||||
|
|
||||||
apply_fribidi(buffer);
|
apply_fribidi(buffer);
|
||||||
draw_text(draw, x, y, MIN(w, TEXTW(buffer) - sp.lrpad) + leftpadding, sp.bh, leftpadding, isrtl ? fribidi_text : buffer, 0, pango_item ? True : False, fgcol, bgcol, fga, bga);
|
draw_text(draw, x, y, MIN(w, TEXTW(buffer) - sp.lrpad) + leftpadding, sp.bh, leftpadding, isrtl ? fribidi_text : buffer, 0, pango_item ? True : False, fgcol, bgcol, fga, bga);
|
||||||
drawhighlights(item, x, y, MIN(w, TEXTW(buffer) - sp.lrpad) + leftpadding, leftpadding, isrtl ? fribidi_text : buffer);
|
|
||||||
|
|
||||||
strcat(ttext, buffer);
|
strcat(item->nsgrtext, buffer);
|
||||||
|
|
||||||
// position and width
|
// position and width
|
||||||
x += MIN(w, TEXTW(buffer) - sp.lrpad) + leftpadding;
|
x += MIN(w, TEXTW(buffer) - sp.lrpad) + leftpadding;
|
||||||
|
@ -270,14 +276,14 @@ int drawitemtext(struct item *item, int x, int y, int w) {
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer[wr] = '\0';
|
buffer[wr] = '\0';
|
||||||
strcat(ttext, buffer);
|
strcat(item->nsgrtext, buffer);
|
||||||
|
|
||||||
item->text = ttext; // set item text to one without SGR sequences
|
|
||||||
|
|
||||||
// now draw any non-colored text
|
// now draw any non-colored text
|
||||||
apply_fribidi(buffer);
|
apply_fribidi(buffer);
|
||||||
int r = draw_text(draw, x, y, w, sp.bh, leftpadding, isrtl ? fribidi_text : buffer, 0, pango_item ? True : False, fgcol, bgcol, fga, bga);
|
int r = draw_text(draw, x, y, w, sp.bh, leftpadding, isrtl ? fribidi_text : buffer, 0, pango_item ? True : False, fgcol, bgcol, fga, bga);
|
||||||
if (!hidehighlight) drawhighlights(item, x, y, w, leftpadding, buffer);
|
|
||||||
|
if (!hidehighlight)
|
||||||
|
drawhighlights(item, ox, oy, ow, sp.lrpad / 2, item->nsgrtext);
|
||||||
|
|
||||||
if (!hidepowerline && powerlineitems && selitem) {
|
if (!hidepowerline && powerlineitems && selitem) {
|
||||||
if (itempwlstyle == 2) {
|
if (itempwlstyle == 2) {
|
||||||
|
|
Loading…
Reference in a new issue