📄 ttysw_main.c
字号:
cmdsw->pty_owes_newline = TRUE; /* avoid extra newline */ ttysw_input(ttysw, p, len); /* shelltool, local cmdtool */ } return(len);}/* #ifndef CMDSW */ttysw_handle_itimer(ttysw) register struct ttysubwindow *ttysw;{ if (ttysw->ttysw_primary.sel_made) { ttysel_deselect(&ttysw->ttysw_primary, SELN_PRIMARY); } if (ttysw->ttysw_secondary.sel_made) { ttysel_deselect(&ttysw->ttysw_secondary, SELN_SECONDARY); } pw_batch(csr_pixwin, PW_ALL); (void)pdisplayscreen(0); pw_batch(csr_pixwin, PW_NONE);}/* * handle standard events. * Note that KBD_USE, KBD_DONE cheat and assume that the * ttysw_client of the ttysw is a ttytoolsubwindow. */intttysw_eventstd(ttysw, ie) register struct ttysubwindow *ttysw; register struct inputevent *ie;{ struct tool *tool; tool = NULL; if (ttysw->ttysw_client) tool = ((struct ttytoolsubwindow *)LINT_CAST( ttysw->ttysw_client))->tool; switch (event_id(ie)) { case KBD_REQUEST: { extern Seln_rank ttysel_mode(); /* Refuse kbd focus if in secondary selection mode */ if (ttysel_mode(ttysw) == SELN_SECONDARY) (void)win_refuse_kbd_focus(ttysw->ttysw_wfd); return TTY_DONE; } case KBD_USE: (void)ttysw_restore_cursor(); if (tool) (void)tool_kbd_use(tool, (char *)(LINT_CAST(ttysw))); return TTY_DONE; case KBD_DONE: ttysw_lighten_cursor(); if (tool) (void)tool_kbd_done(tool, (char *)(LINT_CAST(ttysw))); return TTY_DONE; case MS_LEFT: return ttysw_process_point(ttysw, ie); case MS_MIDDLE: return ttysw_process_adjust(ttysw, ie); case MS_RIGHT: return ttysw_process_menu(ttysw, ie); case LOC_WINEXIT: return ttysw_process_exit(ttysw, ie); case LOC_MOVEWHILEBUTDOWN: return ttysw_process_motion(ttysw, ie); default: return ttysw_process_keyboard(ttysw, ie); }}static intttysw_process_point(ttysw, ie) register struct ttysubwindow *ttysw; register struct inputevent *ie;{ register int wfd = ttysw->ttysw_wfd; struct inputmask im; if (win_inputposevent(ie)) { ttysw->ttysw_butdown = MS_LEFT; ttysel_make(ttysw, ie, 1); (void)win_get_pick_mask(wfd, &im); win_setinputcodebit(&im, LOC_MOVEWHILEBUTDOWN); win_unsetinputcodebit(&im, LOC_WINEXIT); (void)win_set_pick_mask(wfd, &im); } else { if (ttysw->ttysw_butdown == MS_LEFT) { (void)ttysel_adjust(ttysw, ie, 0); ttysetselection(ttysw); (void)win_get_pick_mask(wfd, &im); win_unsetinputcodebit(&im, LOC_MOVEWHILEBUTDOWN); win_setinputcodebit(&im, LOC_WINEXIT); (void)win_set_pick_mask(wfd, &im); } ttysw->ttysw_butdown = 0; } return TTY_DONE;}static intttysw_process_adjust(ttysw, ie) register struct ttysubwindow *ttysw; register struct inputevent *ie;{ register int wfd = ttysw->ttysw_wfd; struct inputmask im; if (win_inputposevent(ie)) { ttysw->ttysw_butdown = MS_MIDDLE; (void)ttysel_adjust(ttysw, ie, 1); (void)win_get_pick_mask(wfd, &im); win_setinputcodebit(&im, LOC_MOVEWHILEBUTDOWN); win_unsetinputcodebit(&im, LOC_WINEXIT); (void)win_set_pick_mask(wfd, &im); } else { if (ttysw->ttysw_butdown == MS_MIDDLE) { (void)ttysel_adjust(ttysw, ie, 0); ttysetselection(ttysw); (void)win_get_pick_mask(wfd, &im); win_unsetinputcodebit(&im, LOC_MOVEWHILEBUTDOWN); win_setinputcodebit(&im, LOC_WINEXIT); (void)win_set_pick_mask(wfd, &im); } ttysw->ttysw_butdown = 0; } return TTY_DONE;}static intttysw_process_motion(ttysw, ie) register struct ttysubwindow *ttysw; register struct inputevent *ie;{#ifdef wipethrough (void)ttysel_adjust(ttysw, ie, 0);#else if (ttysw->ttysw_butdown == MS_LEFT) ttysel_move(ttysw, ie); else (void)ttysel_adjust(ttysw, ie, 0);#endif return TTY_DONE;}/* ARGSUSED */static intttysw_process_exit(ttysw, ie) struct ttysubwindow *ttysw; struct inputevent *ie;{ register int wfd = ttysw->ttysw_wfd; struct inputmask im; (void)win_get_pick_mask(wfd, &im); win_unsetinputcodebit(&im, LOC_WINEXIT); (void)win_set_pick_mask(wfd, &im); return TTY_DONE;}static intttysw_process_keyboard(ttysw, ie) struct ttysubwindow *ttysw; struct inputevent *ie;{ register int action = event_action(ie); register int unmapped_key = event_id(ie); if ((action >= EUC_FIRST && action <= EUC_LAST) && (win_inputposevent(ie))) { char c = (char) action; /* * State machine for handling logical caps lock, ``F1'' key. * Capitalize characters except when an ESC goes by. Then go * into a state where characters are passed uncapitalized until * an alphabetic character is passed. We presume that all ESC * sequences end with an alphabetic character. * * Used to solve the function key problem where the final `z' is * is being capitalized. (Bug id: 1005033) */ if (ttysw->ttysw_capslocked & TTYSW_CAPSLOCKED) { if (ttysw->ttysw_capslocked & TTYSW_CAPSSAWESC) { if (isalpha(c)) ttysw->ttysw_capslocked &= ~TTYSW_CAPSSAWESC; } else { if (islower(c)) c = toupper(c); else if (c == '\033') ttysw->ttysw_capslocked |= TTYSW_CAPSSAWESC; } } (void) ttysw_input((caddr_t) ttysw, &c, 1);#ifdef TTY_ACQUIRE_CARET if (!ttysw->ttysw_caret.sel_made) { ttysel_acquire(ttysw, SELN_CARET); }#endif return TTY_DONE; /* * else if this is a meta-c, meta-v, meta-f, meta-x, or some * permutation with shift or cntl, pass * it through to ttysw_input without going through ttysw_domap. * bugid 1026817 */ } else if ((unmapped_key == 227) || (unmapped_key == 246) || (unmapped_key == 230) || (unmapped_key == 248) || (unmapped_key == 198)|| (unmapped_key == 216)|| (unmapped_key == 152)|| (unmapped_key == 195)|| (unmapped_key == 131)|| (unmapped_key == 214)|| (unmapped_key == 150)) { if (event_is_down(ie)) { char c = (char) unmapped_key; (void) ttysw_input((caddr_t) ttysw, &c, 1); } } else if (action > META_LAST) { return ttysw_domap(ttysw, ie); } return TTY_OK;}/* #endif CMDSW *//* * Pty size setter. Called from ttyimage imagealloc. */ttynewsize(cols, lines) int cols, lines;{ struct ttysize ts; extern struct ttysubwindow *_ttysw; ts.ts_lines = lines; ts.ts_cols = cols; /* XXX - ttysw should be passed */ if ((ioctl(_ttysw->ttysw_tty, TIOCSSIZE, &ts)) == -1) perror("ttysw-TIOCSSIZE");}/* * A stop sign cursor, for when output is stopped. */static short stop_data[16] = { 0x07C0, 0x0FE0, 0x1FF0, 0x1FF0, 0x1FF0, 0x1FF0, 0x1FF0, 0x0FE0, 0x07C0, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0FE0};static mpr_static(stop_mpr, 16, 16, 1, stop_data);static struct cursor stop_cursor = {7, 5, PIX_SRC | PIX_DST, &stop_mpr};/* * Freeze tty output. */ttysw_freeze(ttysw, on) struct ttysubwindow *ttysw; int on;{ extern struct cursor ttysw_cursor; if (!ttysw->ttysw_frozen && on) { struct sgttyb sgttyb; (void) ioctl(ttysw->ttysw_tty, TIOCGETP, (char *) &sgttyb); if ((sgttyb.sg_flags & (RAW | CBREAK)) == 0) { (void)win_setcursor(ttysw->ttysw_wfd, &stop_cursor); ttysw->ttysw_frozen = 1; } else ttysw->ttysw_lpp = 0; } else if (ttysw->ttysw_frozen && !on) { (void)win_setcursor(ttysw->ttysw_wfd, &ttysw_cursor); ttysw->ttysw_frozen = 0; ttysw->ttysw_lpp = 0; } return (ttysw->ttysw_frozen);}/* * Set (or reset) the specified option number. */ttysw_setopt(ttysw0, opt, on) caddr_t ttysw0; int opt, on;{ struct ttysubwindow *ttysw = (struct ttysubwindow *) LINT_CAST(ttysw0); int result = 0; switch (opt) { case TTYOPT_HISTORY: /* tty history */#ifdef TTYHIST if (on) ttyhist_on(ttysw); else ttyhist_off(ttysw);#endif break; case TTYOPT_TEXT: /* cmdsw */ if (on) result = ttysw_be_cmdsw(ttysw); else result = ttysw_be_ttysw(ttysw);#ifdef DEBUG break; case 5: /* HACK */ result = ttysw_getp(ttysw);#endif DEBUG } if (result != -1) if (on) ttysw->ttysw_opt |= 1 << opt; else ttysw->ttysw_opt &= ~(1 << opt);}ttysw_getopt(ttysw0, opt) caddr_t ttysw0; int opt;{ struct ttysubwindow *ttysw = (struct ttysubwindow *) LINT_CAST(ttysw0); return ((ttysw->ttysw_opt & (1 << opt)) != 0);}ttysw_flush_input(ttysw0) caddr_t ttysw0;{ struct ttysubwindow *ttysw = (struct ttysubwindow *) LINT_CAST(ttysw0); struct sigvec vec, ovec; /* int (*presigval) () = signal(SIGTTOU, SIG_IGN); */ vec.sv_handler = SIG_IGN; vec.sv_mask = vec.sv_onstack = 0; (void) sigvec(SIGTTOU, &vec, &ovec); /* Flush tty input buffer */ if (ioctl(ttysw->ttysw_tty, TIOCFLUSH, 0)) perror("TIOCFLUSH"); /* (void) signal(SIGTTOU, presigval); */ (void) sigvec(SIGTTOU, &ovec, (struct sigvec *)0); /* Flush ttysw input pending buffer */ irbp = iwbp = ibuf;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -