cleanup item drawing, this means we can now disable any item we want at
any time (just don't forget to call drawmenu)
This commit is contained in:
parent
327636b0ee
commit
d455c3a3f2
|
@ -58,10 +58,6 @@ spmenu.type: 1
|
|||
spmenu.class: spmenu
|
||||
spmenu.leftarrow: <
|
||||
spmenu.rightarrow: >
|
||||
spmenu.hidematchcount: 0
|
||||
spmenu.hidehighlight: 0
|
||||
spmenu.hidemode: 0
|
||||
spmenu.hideimage: 0
|
||||
spmenu.imagewidth: 86
|
||||
spmenu.imageheight: 86
|
||||
spmenu.imagegaps: 0
|
||||
|
@ -69,6 +65,14 @@ spmenu.imageposition: 0
|
|||
spmenu.generatecache: 0
|
||||
spmenu.mode: 0
|
||||
spmenu.fast: 0
|
||||
spmenu.hidematchcount: 0
|
||||
spmenu.hidemode: 0
|
||||
spmenu.hidelarrow: 0
|
||||
spmenu.hiderarrow: 0
|
||||
spmenu.hideprompt: 0
|
||||
spmenu.hidecursor: 0
|
||||
spmenu.hidehighlight: 0
|
||||
spmenu.hideimage: 0
|
||||
spmenu.normtext: Normal
|
||||
spmenu.instext: Insert
|
||||
spmenu.pango_item: 1
|
||||
|
|
44
libs/draw.c
44
libs/draw.c
|
@ -126,8 +126,8 @@ drawmenu(void)
|
|||
int modeWidth = 0;
|
||||
int larrowWidth = 0;
|
||||
int rarrowWidth = 0;
|
||||
int itemWidth = 0;
|
||||
|
||||
if (!hidematchcount) numberWidth = TEXTW(numbers);
|
||||
if (!hidemode) modeWidth = TEXTW(modetext);
|
||||
if (!hidelarrow) larrowWidth = TEXTW(leftarrow);
|
||||
if (!hiderarrow) rarrowWidth = TEXTW(rightarrow);
|
||||
|
@ -142,7 +142,7 @@ drawmenu(void)
|
|||
/* draw input field */
|
||||
w = (lines > 0 || !matches) ? mw - x : inputw;
|
||||
drw_setscheme(drw, scheme[SchemeInput]);
|
||||
if (passwd) {
|
||||
if (passwd && !hideprompt) {
|
||||
censort = ecalloc(1, sizeof(text));
|
||||
memset(censort, '.', strlen(text));
|
||||
|
||||
|
@ -151,28 +151,36 @@ drawmenu(void)
|
|||
|
||||
curpos = TEXTW(censort) - TEXTW(&text[cursor]);
|
||||
free(censort);
|
||||
} else if (!passwd) {
|
||||
} else if (!passwd && !hideprompt) {
|
||||
apply_fribidi(text);
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, isrtl ? fribidi_text : text, 0, pango_input ? True : False);
|
||||
curpos = TEXTW(text) - TEXTW(&text[cursor]);
|
||||
}
|
||||
|
||||
if ((curpos += lrpad / 2 - 1) < w) {
|
||||
if ((curpos += lrpad / 2 - 1) < w && !hidecursor && !hideprompt) {
|
||||
drw_setscheme(drw, scheme[SchemeCaret]);
|
||||
drw_rect(drw, x + curpos, 2 + (bh - fh) / 2, 2, fh - 4, 1, 0);
|
||||
}
|
||||
|
||||
/* get match count */
|
||||
if (!hidematchcount) recalculatenumbers();
|
||||
if (!hidematchcount) {
|
||||
recalculatenumbers();
|
||||
numberWidth = TEXTW(numbers);
|
||||
}
|
||||
|
||||
/* draw stuff */
|
||||
if (lines > 0) {
|
||||
|
||||
/* draw image first */
|
||||
#if USEIMAGE
|
||||
if (!hideimage && longestedge != 0) {
|
||||
x += imagegaps + imagewidth;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* draw grid */
|
||||
int i = 0;
|
||||
|
||||
for (item = curr; item != next; item = item->right, i++)
|
||||
drawitem(
|
||||
item,
|
||||
|
@ -183,38 +191,36 @@ drawmenu(void)
|
|||
} else if (matches) {
|
||||
/* draw horizontal list */
|
||||
x += inputw;
|
||||
w = TEXTW(leftarrow);
|
||||
w = larrowWidth;
|
||||
|
||||
itemWidth = TEXTWM(item->text);
|
||||
|
||||
if (curr->left) {
|
||||
drw_setscheme(drw, scheme[SchemeLArrow]);
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, leftarrow, 0, pango_leftarrow ? True : False);
|
||||
}
|
||||
|
||||
x += w;
|
||||
|
||||
for (item = curr; item != next; item = item->right)
|
||||
if (hidematchcount) {
|
||||
x = drawitem(item, x, 0, MIN(TEXTWM(item->text), mw - x - TEXTW(rightarrow) - TEXTW(modetext)));
|
||||
} else {
|
||||
x = drawitem(item, x, 0, MIN(TEXTWM(item->text), mw - x - TEXTW(rightarrow) - TEXTW(numbers) - TEXTW(modetext)));
|
||||
}
|
||||
x = drawitem(item, x, 0, MIN(itemWidth, mw - x - rarrowWidth - numberWidth - modeWidth));
|
||||
|
||||
if (next) {
|
||||
w = TEXTW(rightarrow);
|
||||
w = rarrowWidth;
|
||||
drw_setscheme(drw, scheme[SchemeRArrow]);
|
||||
|
||||
if (hidematchcount) {
|
||||
drw_text(drw, mw - w - TEXTW(modetext), 0, w, bh, lrpad / 2, rightarrow, 0, pango_rightarrow ? True : False);
|
||||
} else {
|
||||
drw_text(drw, mw - w - TEXTW(numbers) - TEXTW(modetext), 0, w, bh, lrpad / 2, rightarrow, 0, pango_rightarrow ? True : False);
|
||||
}
|
||||
drw_text(drw, mw - w - numberWidth - modeWidth, 0, w, bh, lrpad / 2, rightarrow, 0, pango_rightarrow ? True : False);
|
||||
}
|
||||
}
|
||||
|
||||
if (!hidematchcount) {
|
||||
drw_setscheme(drw, scheme[SchemeNumber]);
|
||||
drw_text(drw, mw - TEXTW(numbers) - TEXTW(modetext), 0, TEXTW(numbers), bh, lrpad / 2, numbers, 0, pango_numbers ? True : False);
|
||||
drw_text(drw, mw - numberWidth - modeWidth, 0, numberWidth, bh, lrpad / 2, numbers, 0, pango_numbers ? True : False);
|
||||
}
|
||||
|
||||
if (!hidemode) {
|
||||
drw_setscheme(drw, scheme[SchemeMode]);
|
||||
drw_text(drw, mw - TEXTW(modetext), 0, TEXTW(modetext), bh, lrpad / 2, modetext, 0, pango_mode ? True : False);
|
||||
drw_text(drw, mw - modeWidth, 0, modeWidth, bh, lrpad / 2, modetext, 0, pango_mode ? True : False);
|
||||
}
|
||||
|
||||
drw_map(drw, win, 0, 0, mw, mh);
|
||||
|
|
|
@ -67,6 +67,8 @@ static int hidematchcount = 0; /* Hide match count (0/1) */
|
|||
static int hidemode = 0; /* Hide mode (0/1) */
|
||||
static int hidelarrow = 0; /* Hide left arrow (0/1) */
|
||||
static int hiderarrow = 0; /* Hide right arrow (0/1) */
|
||||
static int hideprompt = 0; /* Hide prompt (0/1) */
|
||||
static int hidecursor = 0; /* Hide cursor (0/1) */
|
||||
static int hidehighlight = 0; /* Hide highlight (0/1) */
|
||||
static int hideimage = 0; /* Hide image (0/1) */
|
||||
|
||||
|
|
|
@ -114,6 +114,10 @@ ResourcePref resources[] = {
|
|||
{ "hidehighlight", INTEGER, &hidehighlight },
|
||||
{ "hidemode", INTEGER, &hidemode },
|
||||
{ "hideimage", INTEGER, &hideimage },
|
||||
{ "hidelarrow", INTEGER, &hidelarrow },
|
||||
{ "hiderarrow", INTEGER, &hiderarrow },
|
||||
{ "hideprompt", INTEGER, &hideprompt },
|
||||
{ "hidecursor", INTEGER, &hidecursor },
|
||||
{ "histnodup", INTEGER, &histnodup },
|
||||
{ "casesensitive", INTEGER, &casesensitive },
|
||||
{ "imagewidth", INTEGER, &imagewidth },
|
||||
|
|
Loading…
Reference in a new issue