engine: redraw when the picture changes, not when the state might have
Every key copied the whole Im and Search rune by rune, compared them after the transition, and combined the answer with 'eaten', a commit count that is always zero, and a force flag for caret and owner changes, while redraw() kept a separate 'visible' bit to know when to send an empty popup. redraw() now compares the snapshot with the last one sent and treats two empty popups as equal, so imhandlekey just ends in redraw(). keystroke() was only a test entry point and moves there.
This commit is contained in:
@@ -10,6 +10,17 @@ Str shownpre(Im*);
|
||||
static int typekeys(struct ct*, char*, Str*);
|
||||
static int draindraw(Drawcmd*);
|
||||
|
||||
/* One key from the owner, as imhandlekey drives the engine. */
|
||||
static int
|
||||
keystroke(u32int ks, u32int mod, Str *com)
|
||||
{
|
||||
int eaten;
|
||||
|
||||
eaten = transition(ks, mod, com);
|
||||
redraw();
|
||||
return eaten;
|
||||
}
|
||||
|
||||
void
|
||||
testengineinit(int lang)
|
||||
{
|
||||
@@ -675,7 +686,7 @@ struct Searchfix
|
||||
Lang *dictlang;
|
||||
Trie *dict;
|
||||
int activecap;
|
||||
int visible;
|
||||
Drawcmd lastdraw;
|
||||
int candidatechosen;
|
||||
};
|
||||
|
||||
@@ -893,7 +904,7 @@ searchsave(Searchfix *f, int lang)
|
||||
f->dictlang = getlang(lang);
|
||||
f->dict = f->dictlang->dict;
|
||||
f->activecap = activecap;
|
||||
f->visible = visible;
|
||||
f->lastdraw = lastdraw;
|
||||
f->candidatechosen = candidatechosen;
|
||||
draindraw(nil);
|
||||
}
|
||||
@@ -936,7 +947,7 @@ searchend(Searchfix *f)
|
||||
im = f->im;
|
||||
search = f->search;
|
||||
activecap = f->activecap;
|
||||
visible = f->visible;
|
||||
lastdraw = f->lastdraw;
|
||||
candidatechosen = f->candidatechosen;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user