Print highlighted input text only on single match a4053bc4
When the input text fully matches a single item, do not draw the item
and highlight the input text to show that it matches an item in
opposition to regular input text not matching anything.
Quentin Rameau · 2016-07-26 12:48 1 file(s) · +13 −3
dmenu.c +13 −3
130 130
{
131 131
	unsigned int curpos;
132 132
	struct item *item;
133 -
	int x = 0, y = 0, w;
133 +
	int x = 0, y = 0, w, inputscheme;
134 134
135 135
	drw_setscheme(drw, scheme[SchemeNorm]);
136 136
	drw_rect(drw, 0, 0, mw, mh, 1, 1);
138 138
	if (prompt && *prompt) {
139 139
		drw_setscheme(drw, scheme[SchemeSel]);
140 140
		x = drw_text(drw, x, 0, promptw, bh, lrpad / 2, prompt, 0);
141 +
		x += 2;
141 142
	}
142 143
	/* draw input field */
143 144
	w = (lines > 0 || !matches) ? mw - x : inputw;
144 -
	drw_setscheme(drw, scheme[SchemeNorm]);
145 +
	if (matches && !strcmp(text, curr->text))
146 +
		inputscheme = SchemeSel;
147 +
	else
148 +
		inputscheme = SchemeNorm;
149 +
	drw_setscheme(drw, scheme[inputscheme]);
150 +
145 151
	drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
146 152
147 153
	drw_font_getexts(drw->fonts, text, cursor, &curpos, NULL);
148 154
	if ((curpos += lrpad / 2 - 1) < w) {
149 -
		drw_setscheme(drw, scheme[SchemeNorm]);
155 +
		drw_setscheme(drw, scheme[inputscheme]);
150 156
		drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0);
151 157
	}
158 +
159 +
	if (inputscheme == SchemeSel)
160 +
		goto drawmap;
152 161
153 162
	if (lines > 0) {
154 163
		/* draw vertical list */
171 180
			drw_text(drw, mw - w, 0, w, bh, lrpad / 2, ">", 0);
172 181
		}
173 182
	}
183 +
drawmap:
174 184
	drw_map(drw, win, 0, 0, mw, mh);
175 185
}
176 186