/* u2_term_io_loja(): release console from fprintf. */ void u2_term_io_loja(int x) { u2_utty* uty_u = _term_main(); if ( uty_u ) { if ( uty_u->fid_i > 2 ) { // We *should* in fact, produce some kind of fake FILE* for // non-console terminals. If we use this interface enough... // c3_assert(0); } else { if ( u2_yes == u2_Host.ops_u.dem ) { fflush(stdout); } else { if ( 0 != tcsetattr(1, TCSADRAIN, &uty_u->raw_u) ) { c3_assert(!"loja-tcsetattr"); } if ( -1 == fcntl(1, F_SETFL, uty_u->nob_i) ) { c3_assert(!"loja-fcntl"); } if ( 0 != tcsetattr(0, TCSADRAIN, &uty_u->raw_u) ) { c3_assert(!"loja-tcsetattr"); } if ( -1 == fcntl(0, F_SETFL, uty_u->nob_i) ) { c3_assert(!"loja-fcntl"); } _term_it_refresh_line(uty_u); } } } }
/* _term_ef_blit(): send blit to terminal. */ static void _term_ef_blit(u2_utty* uty_u, u2_noun blt) { switch ( u2h(blt) ) { default: break; case c3__bel: { if ( u2_no == u2_Host.ops_u.dem ) { _term_it_write_txt(uty_u, uty_u->ufo_u.out.bel_y); } } break; case c3__clr: { if ( u2_no == u2_Host.ops_u.dem ) { _term_it_show_blank(uty_u); _term_it_refresh_line(uty_u); } } break; case c3__hop: { if ( u2_no == u2_Host.ops_u.dem ) { _term_it_show_cursor(uty_u, u2t(blt)); } } break; case c3__lin: { u2_noun lin = u2t(blt); c3_w len_w = u2_ckb_lent(u2k(lin)); c3_w* lin_w = malloc(4 * len_w); { c3_w i_w; for ( i_w = 0; u2_nul != lin; i_w++, lin = u2t(lin) ) { lin_w[i_w] = u2_cr_word(0, u2h(lin)); } } if ( u2_no == u2_Host.ops_u.dem ) { _term_it_show_clear(uty_u); _term_it_show_line(uty_u, lin_w, len_w); } else { while ( uty_u->out_u ) { u2_ubuf* out_u = uty_u->out_u; uty_u->out_u = uty_u->out_u->nex_u; if ( 0 == uty_u->out_u ) { c3_assert(out_u == uty_u->tou_u); uty_u->tou_u = 0; } free(out_u); } _term_it_show_line(uty_u, lin_w, len_w); } } break; case c3__mor: { if ( u2_no == u2_Host.ops_u.dem ) { _term_it_show_more(uty_u); } else { _term_it_show_more(uty_u); _term_it_do_writes(uty_u); } } break; case c3__sav: { _term_it_save(u2k(u2h(u2t(blt))), u2k(u2t(u2t(blt)))); } break; } u2z(blt); return; }
/* _term_ef_blit(): send blit to terminal. */ static void _term_ef_blit(u3_utty* uty_u, u3_noun blt) { switch ( u3h(blt) ) { default: break; case c3__bel: { if ( c3n == u3_Host.ops_u.dem ) { _term_it_write_txt(uty_u, uty_u->ufo_u.out.bel_y); } } break; case c3__clr: { if ( c3n == u3_Host.ops_u.dem ) { _term_it_show_blank(uty_u); _term_it_refresh_line(uty_u); } } break; case c3__hop: { if ( c3n == u3_Host.ops_u.dem ) { _term_it_show_cursor(uty_u, u3t(blt)); } } break; case c3__lin: { u3_noun lin = u3t(blt); c3_w len_w = u3kb_lent(u3k(lin)); c3_w* lin_w = c3_malloc(4 * len_w); { c3_w i_w; for ( i_w = 0; u3_nul != lin; i_w++, lin = u3t(lin) ) { lin_w[i_w] = u3r_word(0, u3h(lin)); } } if ( c3n == u3_Host.ops_u.dem ) { _term_it_show_clear(uty_u); _term_it_show_line(uty_u, lin_w, len_w); } else { _term_it_show_line(uty_u, lin_w, len_w); } } break; case c3__mor: { _term_it_show_more(uty_u); } break; case c3__sav: { _term_it_save(u3k(u3h(u3t(blt))), u3k(u3t(u3t(blt)))); } break; case c3__sag: { u3_noun pib = u3k(u3t(u3t(blt))); u3_noun jam; fprintf(stderr, "jamming...\r\n"); jam = u3ke_jam(pib); fprintf(stderr, "jammed.\r\n"); _term_it_save(u3k(u3h(u3t(blt))), jam); } break; } u3z(blt); return; }