📄 vt100esc.c
字号:
default: break; }}/* * Erase in line. * erase_line(sp, pn) erases line from the cursor to the end, from the * beginning to the cursor or completely according to pn = 0, 1 or 2 * respectively. */erase_line(sp, pn) register SCREEN *sp; register int pn;{ register struct cursor *spc = &sp->s_csr; switch(pn) { case 0: clear_chars(spc->csr_x, spc->csr_y, rit_m - spc->csr_x + 1, sp->s_term_mode & DECSCNM, sp->s_plane, sp->s_bgcol); break; case 1: clear_chars(LFT_M, spc->csr_y, spc->csr_x - LFT_M + 1, sp->s_term_mode & DECSCNM, sp->s_plane, sp->s_bgcol); break; case 2: clear_lines(spc->csr_y, 1, sp->s_term_mode & DECSCNM, sp->s_plane, sp->s_bgcol); break; default: break; }}/* * Insert line. * insert_line(sp, pn) inserts pn lines in scroll region */insert_line(sp, pn) register SCREEN *sp; register int pn;{ register struct cursor *spc = &sp->s_csr; register struct region *spr = &sp->s_region; pn = max(pn, 1); if (spc->csr_y < spr->top_margin || spc->csr_y > spr->btm_margin) return; if (pn <= spr->btm_margin - spc->csr_y) { move_lines(spc->csr_y, spr->btm_margin - pn - spc->csr_y + 1, spc->csr_y + pn); } clear_lines(spc->csr_y, min(spc->csr_y + pn - 1, spr->btm_margin) - spc->csr_y + 1, sp->s_term_mode & DECSCNM, sp->s_plane, sp->s_bgcol); spc->csr_x = LFT_M; spc->csr_p.x = x_ofst;} /* * Delete line. * delete_line(sp, pn) deletes pn lines in scroll region */delete_line(sp, pn) register SCREEN *sp; register int pn;{ register struct cursor *spc = &sp->s_csr; register struct region *spr = &sp->s_region; register int aux; pn = max(pn, 1); if (spc->csr_y < spr->top_margin || spc->csr_y > spr->btm_margin) return; if (pn <= spr->btm_margin - spc->csr_y) { aux = spc->csr_y + pn; move_lines(aux, spr->btm_margin - aux + 1, spc->csr_y); } aux = max(spr->btm_margin - pn + 1, spc->csr_y); clear_lines(aux, spr->btm_margin - aux + 1, sp->s_term_mode & DECSCNM, sp->s_plane, sp->s_bgcol); spc->csr_x = LFT_M; spc->csr_p.x = x_ofst;}/* * Delete character. * delete_char(sp, pn) deletes pn characters right side of the cursor. */delete_char(sp, pn) register SCREEN *sp; register int pn;{ register struct cursor *spc = &sp->s_csr; register int aux; pn = max(pn, 1); if (pn < rit_m - spc->csr_x + 1) { move_chars(spc->csr_x + pn, spc->csr_y, rit_m - spc->csr_x - pn + 1 ,spc->csr_x); } aux = max(rit_m - pn + 1, spc->csr_x); clear_chars(aux, spc->csr_y, rit_m - aux + 1, sp->s_term_mode & DECSCNM, sp->s_plane, sp->s_bgcol);}/* * This escape control sequence begins `^[[?' and ends `h' or `l' */esc_csi_dec(sp, c) register SCREEN *sp; char c;{ register char *cp; if (in_str(c, sp->s_estp->terminators)) { if (esc_buf[0] != INVALID) { cursor_off(); switch (c) { case 'h': /* set mode */ for (cp = esc_buf; cp <= esc_bp; cp++) { switch (*cp) { case 1: /* cursor key application */ sp->s_term_mode |= DECCKM; change_csr_key_pad(APPLIC); break; case 3: /* 132 column mode */ sp->s_term_mode |= DECCOLM; break; case 4: /* jump scroll */ sp->s_term_mode |= DECSCLM; break; case 5: /* reverse */ if ((sp->s_term_mode & DECSCNM) == 0) reverse_rec(sp->s_bgcol, sp->s_plane); sp->s_term_mode |= DECSCNM; if (sp->s_csr.csr_attributes & REVERSE) { fcolor = sp->s_plane; bcolor = sp->s_bgcol; } else { fcolor = sp->s_bgcol; bcolor = sp->s_plane; } break; case 6: /* origin */ sp->s_term_mode |= DECOM; sp->s_csr.csr_x = LFT_M; sp->s_csr.csr_y = sp->s_region.top_margin; sp->s_csr.csr_p.x = x_ofst; sp->s_csr.csr_p.y = (sp->s_csr.csr_y - 1) * char_h + y_ofst; break; case 7: /* auto wrap */ sp->s_term_mode |= DECAWM; break; case 8: /* auto repeat */ if ((sp->s_term_mode & DECARM) == 0) { kbd_ioctl(SCC_KEYBOARD, KIOCREPT, (int *)0); } sp->s_term_mode |= DECARM; break; case 25: /* cursor active */ sp->s_term_mode |= DECCSR_ACTV; break; default: break; } } break; case 'l': /* reset mode */ for (cp = esc_buf; cp <= esc_bp; cp++) { switch (*cp) { case 1: /* cursor key application */ sp->s_term_mode &= ~DECCKM; change_csr_key_pad(NUMERIC); break; case 3: /* 132 column mode */ sp->s_term_mode &= ~DECCOLM; break; case 4: /* jump scroll */ sp->s_term_mode &= ~DECSCLM; break; case 5: /* reverse */ if (sp->s_term_mode & DECSCNM) reverse_rec(sp->s_plane, sp->s_bgcol); sp->s_term_mode &= ~DECSCNM; if (sp->s_csr.csr_attributes & REVERSE) { fcolor = sp->s_bgcol; bcolor = sp->s_plane; } else { fcolor = sp->s_plane; bcolor = sp->s_bgcol; } break; case 6: /* origin */ sp->s_term_mode &= ~DECOM; sp->s_csr.csr_x = LFT_M; sp->s_csr.csr_y = TOP_M; sp->s_csr.csr_p.x = x_ofst; sp->s_csr.csr_p.y = y_ofst; break; case 7: /* auto wrap */ sp->s_term_mode &= ~DECAWM; break; case 8: /* auto repeat */ if (sp->s_term_mode & DECARM) { kbd_ioctl(SCC_KEYBOARD, KIOCNRPT, (int *) 0); } sp->s_term_mode &= ~DECARM; break; case 25: /* cursor non-active */ sp->s_term_mode &= ~DECCSR_ACTV; break; default: break; } } break; default: break; } cursor_on(&sp->s_csr.csr_p); } sp->s_current_stat &= ~ESCAPE; } else { /* buffering arguments */ if (c >= '0' && c <= '9') { *esc_bp = *esc_bp * 10 + (c - '0'); } else if (c == ';') { esc_bp++; } else if (c == '?') { esc_buf[0] = INVALID; } else { sp->s_current_stat &= ~ESCAPE; } }}/* * changes cursor key pad to ansi_ctl */staticchange_csr_key_pad(applic) register int applic;{ char pad[4]; register Pfk_string *pfk = &pfk_str; register Key_string *kys = &pfk_str.pfk_string; register struct key_pad *kpd; register int i; kpd = &key_pad[UP-N0]; pad[0] = '\033'; pad[1] = (applic) ? 'O': '['; for (i = UP; i <= LEFT; i++) { pfk->pfk_num = i; kys->key_length = (applic) ? 3: 3; pad[2] = (applic) ? kpd->kpd_applic: kpd->kpd_numeric; kys->key_string = pad; kpd++; pfk->pfk_shift = PF_NORMAL; kbd_ioctl(SCC_KEYBOARD, KIOCSETS, pfk); pfk->pfk_shift = PF_SHIFT; kbd_ioctl(SCC_KEYBOARD, KIOCSETS, pfk); }}extern struct cursor inner_buf_csr;extern int inner_buf_tstat;/* * Store cursor position and attributes. * The SCREEN structure is stored inner structure. */esc_store_csr(sp) register SCREEN *sp;{ inner_buf_csr = sp->s_csr; inner_buf_tstat = (DECOM|DECAWM) & sp->s_term_mode;}/* * Restore cursor position and attributes. * The SCREEN structure is restored from inner structure. * Prevail error from unexpected use of this command, inner structure * must be initialized. */esc_restore_csr(sp) register SCREEN *sp;{ cursor_off(); sp->s_csr = inner_buf_csr; sp->s_term_mode = (sp->s_term_mode & ~(DECOM|DECAWM)) | inner_buf_tstat; cursor_on(&sp->s_csr.csr_p);}/* * index() * esc_index(sp) moves the cursor down if the cursor is not at * bottom margin. If the cursor is at the bottom margin then * scroll up. */esc_index(sp) register SCREEN *sp;{ cursor_off(); if (sp->s_csr.csr_y == sp->s_region.btm_margin) scroll_up(sp->s_region.top_margin, sp->s_region.btm_margin, sp->s_term_mode & DECSCNM, sp->s_plane, sp->s_bgcol); else { if (sp->s_csr.csr_y < btm_m) { sp->s_csr.csr_y += 1; sp->s_csr.csr_p.y += char_h; } } sp->s_current_stat &= ~WRAP; cursor_on(&sp->s_csr.csr_p);}/* * next line * esc_next_line(sp) moves the cursor down like index but the cursor * position is the beginning of the next line. */esc_next_line(sp) register SCREEN *sp;{ sp->s_csr.csr_x = LFT_M; sp->s_csr.csr_p.x = x_ofst; esc_index(sp);}/* * tabulation set * esc_tab_set(sp) sets tabulation stop at the current cursor point. */esc_tab_set(sp) register SCREEN *sp;{ sp->s_tab_pos[sp->s_csr.csr_x] = 1;}/* * reverse index * esc_rev_index(sp) moves the cursor up if the cursor is not at the top * margin. If the cursor is at the top margin then the screen takes place * scroll down. */esc_rev_index(sp) register SCREEN *sp;{ cursor_off(); if (sp->s_csr.csr_y == sp->s_region.top_margin) scroll_down(sp->s_region.top_margin, sp->s_region.btm_margin, sp->s_term_mode & DECSCNM, sp->s_plane, sp->s_bgcol); else { if (sp->s_csr.csr_y > TOP_M) { sp->s_csr.csr_y -= 1; sp->s_csr.csr_p.y -= char_h; } } sp->s_current_stat &= ~WRAP; cursor_on(&sp->s_csr.csr_p);}/* * numeric key pad * esc_numeric_kpad(sp) changes key pad of cursor to numeric one. * This sequence is used in vi. * currently not supported */esc_numeric_kpad(sp) register SCREEN *sp;{ change_aux_key_pad(NUMERIC); sp->s_current_stat &= ~ESCAPE;}/* * application key pad * esc_application_kpad(sp) changes key pad of cursor to application one. * This sequence is also used in vi. * currently not supported. */esc_application_kpad(sp) register SCREEN *sp;{ change_aux_key_pad(APPLIC); sp->s_current_stat &= ~ESCAPE;}/* * change auxiliary keypad */staticchange_aux_key_pad(applic) register int applic;{ char pad[4]; register Pfk_string *pfk = &pfk_str; register Key_string *kys = &pfk_str.pfk_string; register struct key_pad *kpd; register int i; kpd = &key_pad[0]; if (applic) { pad[0] = '\033'; pad[1] = 'O'; } for (i = N0; i <= NENTER; i++) { pfk->pfk_num = i; kys->key_length = (applic) ? 3: 1; if (applic) { pad[2] = kpd->kpd_applic; } else { pad[0] = kpd->kpd_numeric; } kys->key_string = pad; kpd++; pfk->pfk_shift = PF_NORMAL; kbd_ioctl(SCC_KEYBOARD, KIOCSETS, pfk); pfk->pfk_shift = PF_SHIFT; kbd_ioctl(SCC_KEYBOARD, KIOCSETS, pfk); } if (!applic) { pfk->pfk_shift = PF_SHIFT; kys->key_length = 1; pfk->pfk_num = MINUS; kys->key_string = "/"; kbd_ioctl(SCC_KEYBOARD, KIOCSETS, pfk); pfk->pfk_num = PLUS; kys->key_string = "*"; kbd_ioctl(SCC_KEYBOARD, KIOCSETS, pfk); pfk->pfk_num = COMMA; kys->key_string = "="; kbd_ioctl(SCC_KEYBOARD, KIOCSETS, pfk); }}extern struct csr_buf local_csr_buf;/* * change line size * esc_line_size(sp, pn) changes line size. * c = `3' double side double height(top half) * c = `4' double side double height(bottom half) * c = `5' sigle width line * c = `6' double width line * currently not supported */esc_line_size(sp, c) register SCREEN *sp; char c;{ register int i; register int j; int save_f, save_b; cursor_off(); switch (c) { case '5': local_csr_buf.csr_number = 1; break; case '6': local_csr_buf.csr_number = 2; break; case '8': sp->s_region.top_margin = TOP_M; sp->s_region.btm_margin = btm_m; save_f = fcolor; save_b = bcolor; fcolor = sp->s_bgcol; bcolor = sp->s_plane; sp->s_csr.csr_p.y = y_ofst; for (i = TOP_M; i <= btm_m; i++) { sp->s_csr.csr_p.x = x_ofst; sp->s_csr.csr_y = i; for (j = LFT_M; j <= rit_m; j++) { sp->s_csr.csr_x = j; copy_char(sp, 'E', 0); sp->s_csr.csr_p.x += char_w; } sp->s_csr.csr_p.y += char_h; } sp->s_csr.csr_x = LFT_M; sp->s_csr.csr_y = TOP_M; sp->s_csr.csr_p.x = x_ofst; sp->s_csr.csr_p.y = y_ofst; fcolor = save_f; bcolor = save_b; break; default: break; } cursor_on(&sp->s_csr.csr_p); sp->s_current_stat &= ~ESCAPE;}/* * character set * esc_char_setr sets which character set you use in right graphic set. * currently not supported */esc_char_setr(sp, c) register SCREEN *sp; int c;{#if defined(IPC_MRX) || defined(CPU_SINGLE) switch (c) { case 'J': case 'H': font_jisroman();#ifdef CPU_SINGLE font_jisroman24();#endif sp->s_current_stat &= ~JKANJI; break; case 'B': font_ascii();#ifdef CPU_SINGLE font_ascii24();#endif sp->s_current_stat &= ~JKANJI; break; }#else /* IPC_MRX || CPU_SINGLE */ if (c == 'B' || c == 'J' || c == 'H') { sp->s_current_stat &= ~JKANJI; }#endif /* IPC_MRX || CPU_SINGLE */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -