emoji: add one-shot candidate search
This commit is contained in:
23
win.c
23
win.c
@@ -90,16 +90,18 @@ fill(u32int *buf, int n, u32int color)
|
||||
static void
|
||||
drawkouho(Drawcmd *dc, int first, int n, int w, int h)
|
||||
{
|
||||
int sely, y, i;
|
||||
int npre, sely, y, i;
|
||||
Str *s;
|
||||
|
||||
fill(img, w * h, Colbg);
|
||||
drawstr(img, 0, 0, dc->pre.r, dc->pre.n, w, h);
|
||||
if(dc->sel >= 0){
|
||||
sely = Fontsz + dc->sel * Fontsz;
|
||||
npre = dc->pre.n != 0;
|
||||
if(npre)
|
||||
drawstr(img, 0, 0, dc->pre.r, dc->pre.n, w, h);
|
||||
if(dc->sel >= 0 && dc->sel < n){
|
||||
sely = (npre + dc->sel) * Fontsz;
|
||||
fill(img + sely * w, Fontsz * w, Colsel);
|
||||
}
|
||||
for(i = 0, y = Fontsz; i < n; i++, y += Fontsz){
|
||||
for(i = 0, y = npre * Fontsz; i < n; i++, y += Fontsz){
|
||||
s = &dc->kouho[first+i];
|
||||
putfont(img, w, h, 0, y, '1' + i + Asciitofull);
|
||||
drawstr(img, 2*Fontsz, y, s->r, s->n, w, h);
|
||||
@@ -124,13 +126,18 @@ winhide(void)
|
||||
static void
|
||||
winshow(Drawcmd *dc)
|
||||
{
|
||||
int px, py, w, h, i, n, maxw;
|
||||
int npre, px, py, w, h, i, n, maxw;
|
||||
u32int vals[4];
|
||||
xcb_query_pointer_reply_t *ptr;
|
||||
xcb_query_pointer_cookie_t cookie;
|
||||
|
||||
n = min(max(dc->nkouho, 0), Maxdisp);
|
||||
npre = dc->pre.n != 0;
|
||||
if(n == 0 && npre == 0){
|
||||
winhide();
|
||||
return;
|
||||
}
|
||||
cookie = xcb_query_pointer(conn, scr->root);
|
||||
n = dc->nkouho;
|
||||
maxw = dc->pre.n;
|
||||
for(i = 0; i < n; i++)
|
||||
maxw = max(maxw, dc->kouho[i].n);
|
||||
@@ -140,7 +147,7 @@ winshow(Drawcmd *dc)
|
||||
px = ptr->root_x + 10;
|
||||
py = ptr->root_y + 10;
|
||||
free(ptr);
|
||||
vals[3] = h = (n + 1) * Fontsz;
|
||||
vals[3] = h = (n + npre) * Fontsz;
|
||||
vals[2] = w = (maxw + 3) * Fontsz;
|
||||
vals[1] = py = max(0, min(py, scr->height_in_pixels - h));
|
||||
vals[0] = px = max(0, min(px, scr->width_in_pixels - w));
|
||||
|
||||
Reference in New Issue
Block a user