static void screpeat(Tk *tk, void *v, int cancelled) { char *e, *pos; int repeat; TkScale *tks = TKobj(TkScale, tk); pos = v; if (cancelled) { tks->flag &= ~Autorepeat; return; } e = stepscale(tk, pos, &repeat); if(e != nil || !repeat) { tks->flag &= ~Autorepeat; tkcancelrepeat(tk); } tk->dirty = tkrect(tk, 1); tkupdate(tk->env->top); }
static void sbrepeat(Tk *tk, void *v, int cancelled) { char *e, buf[Tkmaxitem]; TkScroll *tks = TKobj(TkScroll, tk); char *fmt = (char *)v; if (cancelled) { tks->flag &= ~Autorepeat; return; } if(tks->cmd != nil && fmt != nil) { snprint(buf, sizeof(buf), fmt, tks->cmd); e = tkexec(tk->env->top, buf, nil); if (e != nil) { tks->flag &= ~Autorepeat; tkcancelrepeat(tk); } else tkupdate(tk->env->top); } }
static void autoselect(Tk *tk, void *v, int cancelled) { TkEntry *tke = TKobj(TkEntry, tk); Rectangle hitr; char buf[32]; Point p; USED(v); if (cancelled) return; p = tkscrn2local(tk, Pt(tke->oldx, 0)); p.y = 0; if (tkvisiblerect(tk, &hitr) && ptinrect(p, hitr)) return; snprint(buf, sizeof(buf), "to @%d", p.x); tkentryselect(tk, buf, nil); tkdirty(tk); tkupdate(tk->env->top); }