📄 textsw_input.c
字号:
(delta > 0) ? delta : 0); } textsw_checkpoint(folio);}statictextsw_do_undo(view) Textsw_view view;{ extern Ev_finger_handle ev_add_finger(); extern int ev_remove_finger(); extern Es_index ev_get_insert(), textsw_set_insert(); register Textsw_folio folio = FOLIO_FOR_VIEW(view); register Ev_finger_handle saved_insert_finger; register Ev_chain views = folio->views; Ev_mark_object save_insert; if (!TXTSW_DO_UNDO(folio)) return; if (folio->undo[0] == es_get(views->esh, ES_UNDO_MARK)) { /* Undo followed immediately by another undo. * Note: textsw_set_internal guarantees that folio->undo_count != 1 */ bcopy((caddr_t)&folio->undo[1], (caddr_t)&folio->undo[0], (int)((folio->undo_count-2)*sizeof(folio->undo[0]))); folio->undo[folio->undo_count-1] = ES_NULL_UNDO_MARK; } if (folio->undo[0] == ES_NULL_UNDO_MARK) return; /* Undo the changes to the piece source. */ (void) ev_add_finger(&views->fingers, ev_get_insert(views), 0, &save_insert); ev_set(0, views, EV_CHAIN_DELAY_UPDATE, TRUE, 0); es_set(views->esh, ES_UNDO_NOTIFY_PAIR, textsw_undo_notify, (caddr_t)folio, ES_UNDO_MARK, folio->undo[0], 0); ev_set(0, views, EV_CHAIN_DELAY_UPDATE, FALSE, 0); ev_update_chain_display(views); saved_insert_finger = ev_find_finger(&views->fingers, save_insert); if AN_ERROR(saved_insert_finger == 0) { } else { (void) textsw_set_insert(folio, saved_insert_finger->pos); ev_remove_finger(&views->fingers, save_insert); } /* Get the new mark. */ folio->undo[0] = es_get(views->esh, ES_UNDO_MARK); /* Check to see if this has undone all edits to the folio. */ if (textsw_has_been_modified(VIEW_REP_TO_ABS(folio->first_view)) == 0) { char *name; if (textsw_file_name(folio, &name) == 0) { textsw_notify(view, TEXTSW_ACTION_LOADED_FILE, name, 0); } folio->state &= ~TXTSW_EDITED; }}extern inttextsw_undo(textsw) Textsw_folio textsw;{ textsw_begin_undo(textsw->first_view); textsw_end_undo(textsw->first_view);}static inttextsw_win_event(view, ie, caret_was_up) register Textsw_view view; register Event *ie; int caret_was_up;{ Textsw_folio folio = FOLIO_FOR_VIEW(view); int is_win_event = FALSE; extern void textsw_resize(); extern void textsw_repaint(); int action = event_action(ie); if (action == WIN_RESIZE) { is_win_event = TRUE; textsw_resize(view); } else if (action == WIN_REPAINT) { is_win_event = TRUE; ev_set(view->e_view, EV_NO_REPAINT_TIL_EVENT, FALSE, 0); textsw_repaint(view); /* if caret was up and we took it down, put it back */ if (caret_was_up && (folio->caret_state & TXTSW_CARET_ON) == 0) { textsw_remove_timer(folio); textsw_timer_expired(folio, 0); } } return(is_win_event);}static inttextsw_scroll_event(view, ie, arg) register Textsw_view view; register Event *ie; Notify_arg arg;{ Textsw_folio folio = FOLIO_FOR_VIEW(view); int is_scroll_event = FALSE; extern void textsw_scroll(); extern void textsw_update_scrollbars(); int action = event_action(ie); if (action == SCROLL_REQUEST) { is_scroll_event = TRUE; textsw_scroll((Scrollbar)arg); } else if (action == SCROLL_ENTER) { is_scroll_event = TRUE; textsw_update_scrollbars(folio, view); } return(is_scroll_event);}static inttextsw_function_key_event(view, ie, result) register Textsw_view view; register Event *ie; int *result;{ Textsw_folio folio = FOLIO_FOR_VIEW(view); int is_function_key_event = FALSE; int action = event_action(ie); if (action == TXTSW_AGAIN) { is_function_key_event = TRUE; if (win_inputposevent(ie)) { textsw_begin_again(view); } else if (folio->func_state & TXTSW_FUNC_AGAIN) { textsw_end_again(view, ie->ie_locx, ie->ie_locy); }#ifdef VT_100_HACK } else if (action == TXTSW_AGAIN) { is_function_key_event = TRUE; /* Bug in releases through K3 only generates down, no up */ if (win_inputposevent(ie)) { textsw_begin_again(view); textsw_end_again(view, ie->ie_locx, ie->ie_locy); } else if (folio->func_state & TXTSW_FUNC_AGAIN) { }#endif } else if (action == TXTSW_UNDO) { is_function_key_event = TRUE; if (TXTSW_IS_READ_ONLY(folio)) { *result |= TEXTSW_PE_READ_ONLY; } if (win_inputposevent(ie)) { textsw_begin_undo(view); } else if (folio->func_state & TXTSW_FUNC_UNDO) { textsw_end_undo(view); }#ifdef VT_100_HACK } else if (action == TXTSW_UNDO) { /* Bug in releases through K3 only generates down, no up */ is_function_key_event = TRUE; if (win_inputposevent(ie)) { textsw_begin_undo(view); textsw_end_undo(view); } else if (folio->func_state & TXTSW_FUNC_UNDO) { }#endif } else if ((action == TXTSW_TOP) || (action == TXTSW_BOTTOM) || (action == TXTSW_OPEN) || (action == TXTSW_PROPS)) { is_function_key_event = TRUE; /* These key should only work on up event */ if (!win_inputposevent(ie)) textsw_notify(view, TEXTSW_ACTION_TOOL_MGR, ie, 0); } else if ((action == TXTSW_FIND_FORWARD) || (action == TXTSW_FIND_BACKWARD) || (action == TXTSW_REPLACE)) { is_function_key_event = TRUE; if (win_inputposevent(ie)) { textsw_begin_find(view); folio->func_x = ie->ie_locx; folio->func_y = ie->ie_locy; folio->func_view = view; } else textsw_end_find(view, action, ie->ie_locx, ie->ie_locy); } return(is_function_key_event);}static inttextsw_mouse_event(view, ie) register Textsw_view view; register Event *ie;{ Textsw_folio folio = FOLIO_FOR_VIEW(view); int is_mouse_event = FALSE; int action = event_action(ie); if (action == TXTSW_POINT) { is_mouse_event = TRUE; if (win_inputposevent(ie)) {#ifdef VT_100_HACK if ((folio->state & TXTSW_SHIFT_DOWN) && (textsw->func_state & TXTSW_FUNC_ALL) == 0) { /* Hack for VT-100 keyboard until PIT is available. */ textsw_begin_get(view); folio->func_x = ie->ie_locx; folio->func_y = ie->ie_locy; folio->func_view = view; } else#endif start_selection_tracking(view, ie); } /* Discard negative events that get to here, as state is wrong. */ } else if (action == TXTSW_ADJUST) { is_mouse_event = TRUE; if (win_inputposevent(ie)) { start_selection_tracking(view, ie); } /* Discard negative events that get to here, as state is wrong. */ } else if (action == LOC_WINENTER) { /* extern int textsw_sync_with_seln_svc(); is_mouse_event = TRUE; textsw_sync_with_seln_svc(folio); */ /* This is done for performance improvment */ is_mouse_event = TRUE; folio->state |= TXTSW_DELAY_SEL_INQUIRE; } else if (action == LOC_WINEXIT || action == KBD_DONE) { is_mouse_event = TRUE; textsw_may_win_exit(folio); /* * Menus */ } else if (action == TXTSW_MENU) { is_mouse_event = TRUE; if (win_inputposevent(ie)) { extern textsw_do_menu(); textsw_flush_caches(view, TFC_STD); textsw_do_menu(view, ie); } } return(is_mouse_event);}static inttextsw_edit_function_key_event(view, ie, result) register Textsw_view view; register Event *ie; int *result;{ Textsw_folio folio = FOLIO_FOR_VIEW(view); int is_edit_function_key_event = FALSE; int action = event_action(ie); if (action == TXTSW_DELETE) { is_edit_function_key_event = TRUE; if (win_inputposevent(ie)) { textsw_begin_delete(view); folio->func_x = ie->ie_locx; folio->func_y = ie->ie_locy; folio->func_view = view; } else { *result |= textsw_end_delete(view); } } else if (action == TXTSW_GET) { is_edit_function_key_event = TRUE; if (win_inputposevent(ie)) { textsw_begin_get(view); folio->func_x = ie->ie_locx; folio->func_y = ie->ie_locy; folio->func_view = view; } else { *result |= textsw_end_get(view); } } else if (action == TXTSW_PUT) { is_edit_function_key_event = TRUE; if (win_inputposevent(ie)) { textsw_begin_put(view, TRUE); folio->func_x = ie->ie_locx; folio->func_y = ie->ie_locy; folio->func_view = view; } else { *result |= textsw_end_put(view); } } return(is_edit_function_key_event);} static inttextsw_caret_motion_event (view, ie, action) register Textsw_view view; register Event *ie; register int *action;{ short ch; int is_caret_motion_event = TRUE; pkg_private void textsw_move_down_a_line(); pkg_private void textsw_move_left_a_character(); pkg_private void textsw_move_right_a_character(); pkg_private void textsw_move_up_a_line(); pkg_private void textsw_move_forward_a_word(); pkg_private void textsw_move_backward_a_word(); pkg_private void textsw_move_to_line_end(); pkg_private void textsw_move_to_line_start(); pkg_private void textsw_move_caret(); switch (*action) { case TXTSW_MOVE_RIGHT: if (win_inputposevent(ie)) textsw_move_caret(view, TXTSW_CHAR_FORWARD); break; case TXTSW_MOVE_LEFT: if (win_inputposevent(ie)) textsw_move_caret(view, TXTSW_CHAR_BACKWARD); break; case TXTSW_MOVE_UP: if (win_inputposevent(ie)) textsw_move_caret(view, TXTSW_PREVIOUS_LINE); break; case TXTSW_MOVE_DOWN: if (win_inputposevent(ie)) textsw_move_caret(view, TXTSW_NEXT_LINE); break; case TXTSW_MOVE_WORD_BACKWARD: if (win_inputposevent(ie)) textsw_move_caret(view, TXTSW_WORD_BACKWARD); break; case TXTSW_MOVE_WORD_FORWARD: if (win_inputposevent(ie)) textsw_move_caret(view, TXTSW_WORD_FORWARD); break; case TXTSW_MOVE_WORD_END: if (win_inputposevent(ie)) textsw_move_caret(view, TXTSW_WORD_END); break; case TXTSW_MOVE_TO_LINE_START: if (win_inputposevent(ie)) textsw_move_caret(view, TXTSW_LINE_START); break; case TXTSW_MOVE_TO_LINE_END: if (win_inputposevent(ie)) textsw_move_caret(view, TXTSW_LINE_END); break; case TXTSW_MOVE_TO_NEXT_LINE_START: if (win_inputposevent(ie)) textsw_move_caret(view, TXTSW_NEXT_LINE_START); break; case TXTSW_MOVE_TO_DOC_START: if (win_inputposevent(ie)) { /* This is a gross hack to make sure control m is CR */ if (win_get_vuid_value(WIN_FD_FOR_VIEW(view), 'm') || win_get_vuid_value(WIN_FD_FOR_VIEW(view), 'M')) { is_caret_motion_event = FALSE; event_set_id(ie, 13); /* ASCII value of CR */ *action = 13; } else textsw_move_caret(view, TXTSW_DOCUMENT_START); } break; case TXTSW_MOVE_TO_DOC_END: if (win_inputposevent(ie)) { /* This is a gross hack to make sure control m is CR */ if (win_get_vuid_value(WIN_FD_FOR_VIEW(view), 'm') || win_get_vuid_value(WIN_FD_FOR_VIEW(view), 'M')) { is_caret_motion_event = FALSE; event_set_id(ie, 13); /* ASCII value of CR */ *action = 13; } else textsw_move_caret(view, TXTSW_DOCUMENT_END); } break; default: is_caret_motion_event = FALSE; break; } return(is_caret_motion_event);}static inttextsw_field_event(view, ie, action) register Textsw_view view; register Event *ie; register int *action;{ int is_field_event = FALSE; if (*action == TXTSW_NEXT_FIELD) { /* This is a gross hack to make sure control i is TAB */ if (win_get_vuid_value(WIN_FD_FOR_VIEW(view), 'i') || win_get_vuid_value(WIN_FD_FOR_VIEW(view), 'I')) { event_set_id(ie, 9); /* ASCII value of TAB */ *action = 9; } else { is_field_event = TRUE; if (win_inputposevent(ie)) { textsw_flush_caches(view, TFC_STD); (void) textsw_match_selection_and_normalize(view, "|>", TEXTSW_FIELD_FORWARD); } } } else if (*action == TXTSW_PREV_FIELD) { /* This is a gross hack to make sure control i is TAB */ if (win_get_vuid_value(WIN_FD_FOR_VIEW(view), 'i') || win_get_vuid_value(WIN_FD_FOR_VIEW(view), 'I')) { event_set_id(ie, 9); /* ASCII value of TAB */ *action = 9; } else { is_field_event = TRUE; if (win_inputposevent(ie)) { textsw_flush_caches(view, TFC_STD); (void) textsw_match_selection_and_normalize(view, "<|", TEXTSW_FIELD_BACKWARD); } } } else if (*action == TXTSW_MATCH_DELIMITER) { char *start_marker; is_field_event = TRUE; if (win_inputposevent(ie)) { textsw_flush_caches(view, TFC_STD); (void) textsw_match_selection_and_normalize(view, start_marker, TEXTSW_NOT_A_FIELD); } } return(is_field_event);}static inttextsw_file_operation(view, ie) register Textsw_view view; register Event *ie;{ int is_file_op_event = FALSE; register Textsw_folio folio = FOLIO_FOR_VIEW(view); int action = event_action(ie); if (action == TXTSW_LOAD_FILE_AS_MENU) { int no_cd; int result, dont_load_file = 0; if (win_inputposevent(ie)) { if (textsw_has_been_modified(VIEW_REP_TO_ABS(view))) { result = alert_prompt( (Frame)window_get(WINDOW_FROM_VIEW(view), WIN_OWNER), ie, ALERT_MESSAGE_STRINGS, "The text has been edited.", "Load File will discard these edits. Please confirm.", 0, ALERT_BUTTON_YES, "Confirm, discard edits", ALERT_BUTTON_NO, "Cancel", 0); if (result != ALERT_FAILED) { dont_load_file = (result == 1); } } no_cd = ((folio->state & TXTSW_NO_CD) || ((folio->state & TXTSW_LOAD_CAN_CD) == 0)); if (!dont_load_file) { if (textsw_load_selection( folio, ie->ie_locx, ie->ie_locy, no_cd) == 0) { } } is_file_op_event = TRUE; } } else if (action == TXTSW_STORE_FILE) { if (win_inputposevent(ie)) (void) textsw_store_to_selection(folio, ie->ie_locx, ie->ie_locy); is_file_op_event = TRUE; } return(is_file_op_event);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -