void gli_windows_update() { window_t *win; for (win=gli_windowlist; win; win=win->next) { switch (win->type) { case wintype_TextGrid: win_textgrid_update(win); break; case wintype_TextBuffer: win_textbuffer_update(win); break; } } }
/* This constructs an update object for the library state. (It's in rgwindow.c because most of the work is window-related.) This clears all the dirty flags, constructs an update, sends it to stdout, and flushes. If special is provided, it goes into the update. It will be freed after sending. */ void gli_windows_update(data_specialreq_t *special, int newgeneration) { window_t *win; int ix; data_update_t *update = data_update_alloc(); if (newgeneration) generation++; update->gen = generation; if (geometry_changed) { geometry_changed = FALSE; update->usewindows = TRUE; for (win=gli_windowlist, ix=0; win; win=win->next, ix++) { if (win->type == wintype_Pair) continue; data_window_t *dat = data_window_alloc(win->updatetag, win->type, win->rock); dat->size = win->bbox; if (win->type == wintype_TextGrid) { window_textgrid_t *dwin = win->data; dat->gridwidth = dwin->width; dat->gridheight = dwin->height; } gen_list_append(&update->windows, dat); } } for (win=gli_windowlist; win; win=win->next) { data_content_t *dat = NULL; switch (win->type) { case wintype_TextGrid: dat = win_textgrid_update(win); break; case wintype_TextBuffer: dat = win_textbuffer_update(win); break; } if (dat) { gen_list_append(&update->contents, dat); } } for (win=gli_windowlist; win; win=win->next) { data_input_t *dat = NULL; if (win->char_request) { dat = data_input_alloc(win->updatetag, evtype_CharInput); dat->gen = win->inputgen; if (win->type == wintype_TextGrid) { window_textgrid_t *dwin = win->data; /* Canonicalize position first? */ dat->cursorpos = TRUE; dat->xpos = dwin->curx; dat->ypos = dwin->cury; } } else if (win->line_request) { dat = data_input_alloc(win->updatetag, evtype_LineInput); dat->gen = win->inputgen; if (win->type == wintype_TextBuffer) { window_textbuffer_t *dwin = win->data; dat->maxlen = dwin->inmax; if (dwin->incurpos) { dat->initlen = dwin->incurpos; dat->initstr = dup_buffer(dwin->inbuf, dwin->incurpos, dwin->inunicode); } } else if (win->type == wintype_TextGrid) { window_textgrid_t *dwin = win->data; /* Canonicalize position first? */ dat->cursorpos = TRUE; dat->xpos = dwin->curx; dat->ypos = dwin->cury; dat->maxlen = dwin->inmax; if (dwin->incurpos) { dat->initlen = dwin->incurpos; dat->initstr = dup_buffer(dwin->inbuf, dwin->incurpos, dwin->inunicode); } } } if (win->hyperlink_request) { if (!dat) dat = data_input_alloc(win->updatetag, evtype_None); dat->hyperlink = TRUE; } if (dat) { update->useinputs = TRUE; gen_list_append(&update->inputs, dat); } } glui32 timing_msec = 0; if (gli_timer_need_update(&timing_msec)) { update->includetimer = TRUE; update->timer = timing_msec; } update->specialreq = special; data_update_print(update); printf("\n"); /* blank line after stanza */ fflush(stdout); data_update_free(update); }