1 /* $MirOS: contrib/code/jupp/qw.c,v 1.5 2017/01/10 19:16:27 tg Exp $ */
5 * (C) 1992 Joseph H. Allen
7 * This file is part of JOE (Joe's Own Editor)
21 static void dispqw(QW *qw)
25 /* Scroll buffer and position prompt */
26 if (qw->promptlen > w->w / 2 + w->w / 4)
27 qw->promptofst = qw->promptlen - w->w / 2;
31 /* Set cursor position */
32 w->curx = qw->promptlen - qw->promptofst;
36 w->t->t->updtab[w->y] = 1;
38 w->t->t->scrn + w->y * w->t->t->co + w->x,
39 w->t->t->attr + w->y * w->t->t->co + w->x,
51 static void dispqwn(QW *qw)
55 /* Scroll buffer and position prompt */
56 if (qw->promptlen > w->w / 2 + w->w / 4)
57 qw->promptofst = qw->promptlen - w->w / 2;
61 /* Set cursor position */
62 if (w->win->watom->follow && w->win->object)
63 w->win->watom->follow(w->win->object);
64 if (w->win->watom->disp && w->win->object)
65 w->win->watom->disp(w->win->object);
66 w->curx = w->win->curx;
67 w->cury = w->win->cury + w->win->y - w->y;
70 w->t->t->updtab[w->y] = 1;
72 w->t->t->scrn + w->y * w->t->t->co + w->x,
73 w->t->t->attr + w->y * w->t->t->co + w->x,
85 /* When user hits a key in a query window */
89 static int utypeqw(QW *qw, int c)
93 int *notify = w->notify;
95 void *object = qw->object;
97 if (locale_map->type) {
98 c = utf8_decode(&qw_sm, c);
103 win = qw->parent->win;
111 return func(win->object, c, object, notify);
115 static int abortqw(QW *qw)
117 W *win = qw->parent->win;
118 void *object = qw->object;
119 int (*abrt) () = qw->abrt;
124 return abrt(win->object, object);
129 static WATOM watomqw = {
143 static WATOM watqwn = {
157 static WATOM watqwsr = {
171 /* Create a query window */
173 QW *mkqw(W *w, unsigned char *prompt, int len, int (*func) (/* ??? */), int (*abrt) (/* ??? */), void *object, int *notify)
178 new = wcreate(w->t, &watomqw, w, w, w->main, 1, NULL, notify);
185 new->object = (void *) (qw = (QW *) joe_malloc(sizeof(QW)));
187 qw->prompt = vsncpy(NULL, 0, prompt, len);
197 /* Same as above, but cursor is left in original window */
198 /* For Ctrl-Meta thing */
200 QW *mkqwna(W *w, unsigned char *prompt, int len, int (*func) (/* ??? */), int (*abrt) (/* ??? */), void *object, int *notify)
205 new = wcreate(w->t, &watqwn, w, w, w->main, 1, NULL, notify);
212 new->object = (void *) (qw = (QW *) joe_malloc(sizeof(QW)));
214 qw->prompt = vsncpy(NULL, 0, prompt, len);
224 /* Same as above, but cursor is left in original window */
225 /* For search and replace thing */
227 QW *mkqwnsr(W *w, unsigned char *prompt, int len, int (*func) (/* ??? */), int (*abrt) (/* ??? */), void *object, int *notify)
232 new = wcreate(w->t, &watqwsr, w, w, w->main, 1, NULL, notify);
239 new->object = (void *) (qw = (QW *) joe_malloc(sizeof(QW)));
241 qw->prompt = vsncpy(NULL, 0, prompt, len);