-static void output_draw_screen(Output *o, term_screen *s) {
- unsigned int i, j;
- bool first = true;
-
- assert(o);
- assert(s);
-
- for (j = 0; j < s->page->height && j < o->in_height; ++j) {
- if (!first)
- output_printf(o, "\e[m\r\n" BORDER_VERT);
- first = false;
-
- for (i = 0; i < s->page->width && i < o->in_width; ++i) {
- term_charbuf_t buf;
- term_cell *cell = &s->page->lines[j]->cells[i];
- size_t k, len, ulen;
- const uint32_t *str;
- char utf8[4];
-
- switch (cell->attr.fg.ccode) {
- case TERM_CCODE_DEFAULT:
- output_printf(o, "\e[39m");
- break;
- case TERM_CCODE_256:
- output_printf(o, "\e[38;5;%um", cell->attr.fg.c256);
- break;
- case TERM_CCODE_RGB:
- output_printf(o, "\e[38;2;%u;%u;%um", cell->attr.fg.red, cell->attr.fg.green, cell->attr.fg.blue);
- break;
- case TERM_CCODE_BLACK ... TERM_CCODE_WHITE:
- if (cell->attr.bold)
- output_printf(o, "\e[%um", cell->attr.fg.ccode - TERM_CCODE_BLACK + 90);
- else
- output_printf(o, "\e[%um", cell->attr.fg.ccode - TERM_CCODE_BLACK + 30);
- break;
- case TERM_CCODE_LIGHT_BLACK ... TERM_CCODE_LIGHT_WHITE:
- output_printf(o, "\e[%um", cell->attr.fg.ccode - TERM_CCODE_LIGHT_BLACK + 90);
- break;
- }
+static int output_draw_cell_fn(term_screen *screen,
+ void *userdata,
+ unsigned int x,
+ unsigned int y,
+ const term_attr *attr,
+ const uint32_t *ch,
+ size_t n_ch,
+ unsigned int ch_width) {
+ Output *o = userdata;
+ size_t k, ulen;
+ char utf8[4];
+
+ if (x >= o->in_width || y >= o->in_height)
+ return 0;