📄 textsw_menu.c
字号:
{ extern struct toolsw *tool_find_sw_with_client(); extern Textsw_view textsw_create_view(); extern caddr_t textsw_view_window_object(); register struct toolsw *toolsw; struct rect new_to_split_rect, new_view_rect; int left_margin, right_margin, start_line; register int to_split_ts_height, to_split_ts_width; Es_index start_pos; register Textsw_view new_view; register Textsw_view to_split = VIEW_ABS_TO_REP(abstract); Textsw_folio folio = FOLIO_FOR_VIEW(to_split); /* * Only split views that are large enough */ if ((locy < 0) || (to_split->rect.r_height < locy) || (textsw_screen_line_count(abstract) < 3)) { return(TEXTSW_NULL); } win_getrect(to_split->window_fd, &new_to_split_rect); new_view_rect.r_left = new_to_split_rect.r_left; new_view_rect.r_width = new_to_split_rect.r_width; new_view_rect.r_height = to_split->rect.r_height - locy; if (new_view_rect.r_height < ei_line_height(folio->views->eih)) new_view_rect.r_height = ei_line_height(folio->views->eih); new_view_rect.r_top = rect_bottom(&new_to_split_rect) + 1 - new_view_rect.r_height; /* * start_line/pos must be determined BEFORE adjusting to_split. */ start_line = ev_line_for_y(to_split->e_view, new_view_rect.r_top - new_to_split_rect.r_top); start_pos = ev_index_for_line(to_split->e_view, start_line); if (start_pos == ES_INFINITY) { start_pos = ev_index_for_line(to_split->e_view, 0); } new_to_split_rect.r_height -= new_view_rect.r_height + TOOL_SUBWINDOWSPACING; win_setrect(to_split->window_fd, &new_to_split_rect); toolsw = tool_find_sw_with_client((Tool *)LINT_CAST(folio->tool), (caddr_t)LINT_CAST(to_split)); if (toolsw) { to_split_ts_height = toolsw->ts_height; to_split_ts_width = toolsw->ts_width; toolsw->ts_height = new_to_split_rect.r_height; } left_margin = (int)ev_get(to_split->e_view, EV_LEFT_MARGIN); right_margin = (int)ev_get(to_split->e_view, EV_RIGHT_MARGIN); new_view = textsw_create_view(folio, new_view_rect, left_margin, right_margin); if (to_split_ts_height == TOOL_SWEXTENDTOEDGE || to_split_ts_width == TOOL_SWEXTENDTOEDGE) { toolsw = tool_find_sw_with_client((Tool *)LINT_CAST(folio->tool), (caddr_t)LINT_CAST(new_view)); if (toolsw) { if (to_split_ts_height == TOOL_SWEXTENDTOEDGE) toolsw->ts_height = TOOL_SWEXTENDTOEDGE; if (to_split_ts_width == TOOL_SWEXTENDTOEDGE) toolsw->ts_width = TOOL_SWEXTENDTOEDGE; } } if (SCROLLBAR_FOR_VIEW(to_split)) { extern void textsw_add_scrollbar_to_view(); textsw_add_scrollbar_to_view(new_view, TEXTSW_DEFAULT_SCROLLBAR); } (void) ev_set(new_view->e_view, EV_SAME_AS, to_split->e_view, 0); /* * Although this call to ev_set_start will cause an unnecessary * display of the newly created view, but it is necessary * to update the line table of the new view. */ ev_set_start(new_view->e_view, start_pos); window_create((Window)LINT_CAST(window_get(WINDOW_FROM_VIEW(to_split), WIN_OWNER)), textsw_view_window_object, WIN_COMPATIBILITY, WIN_OBJECT, new_view, 0); /* BUG ALERT - why isn't the system doing this for us? */ if (win_fdtonumber(to_split->window_fd) == win_get_kbd_focus(to_split->window_fd) && folio->tool != 0) tool_displaytoolonly(TOOL_FROM_FOLIO(folio)); if (folio->notify_level & TEXTSW_NOTIFY_SPLIT_VIEW) textsw_notify(to_split, TEXTSW_ACTION_SPLIT_VIEW, new_view, 0); ASSERT(allock()); return(VIEW_REP_TO_ABS(new_view));}static Textsw_viewtextsw_adjacent_view(view, coalesced_rect) register Textsw_view view; register Rect *coalesced_rect;{ Textsw_folio folio = FOLIO_FOR_VIEW(view); Textsw_view above = (Textsw_view)0; Textsw_view under = (Textsw_view)0; register Textsw_view other; Rect view_rect, other_rect; win_getrect(WIN_FD_FOR_VIEW(view), &view_rect); FORALL_TEXT_VIEWS(folio, other) { if (view == other) continue; win_getrect(WIN_FD_FOR_VIEW(other), &other_rect); if ((view_rect.r_left == other_rect.r_left) && (view_rect.r_width == other_rect.r_width)) { /* Possible vertical split */ if ((rect_bottom(&view_rect) + 1 + TOOL_SUBWINDOWSPACING) == other_rect.r_top) { under = other; *coalesced_rect = view_rect; coalesced_rect->r_height = rect_bottom(&other_rect) + 1 - coalesced_rect->r_top; } else if ((rect_bottom(&other_rect) + 1 + TOOL_SUBWINDOWSPACING) == view_rect.r_top) { above = other; *coalesced_rect = other_rect; coalesced_rect->r_height = rect_bottom(&view_rect) + 1 - coalesced_rect->r_top; break; } } } return((above) ? above : under);}static Textsw_viewtextsw_wrapped_adjacent_view(view, rect) register Textsw_view view; register Rect *rect;{ Textsw_view upper_view; Textsw_view coalesce_with = 0; coalesce_with = textsw_adjacent_view(view, rect); if (coalesce_with) { if ((int)window_get(WINDOW_FROM_VIEW(view), WIN_Y) < (int)window_get(WINDOW_FROM_VIEW(coalesce_with), WIN_Y)) { upper_view = view; } else { upper_view = coalesce_with; } rect->r_top = (int)LINT_CAST(window_get(WINDOW_FROM_VIEW(upper_view), WIN_Y)); rect->r_left = (int)LINT_CAST(window_get(WINDOW_FROM_VIEW(upper_view), WIN_X)); } else { win_getrect((int)window_get(WINDOW_FROM_VIEW(view), WIN_FD), rect); } return (coalesce_with);}static Notify_valuetextsw_menu_destroy_view(abstract, status) Textsw abstract; Destroy_status status;{ register Textsw_view view = VIEW_ABS_TO_REP(abstract); register Textsw_folio folio = FOLIO_FOR_VIEW(view); Rect rect; int win_show; int had_kbd_focus; Notify_value nv; int height, width; if (status != DESTROY_CLEANUP) { return (notify_next_destroy_func((Notify_client)abstract, status)); } /*-------------------------------------------------------------------- If the folio has any pop-up frame associated with it, see if that frame was created from the view we are about to destroy. You can tell by checking whether its WIN_CLIENT_DATA field contains a pointer to the view in question. Any such pop-up should be destroyed along with the view that owns it. ---------------------------------------------------------------------*/ if((folio->search_frame != NULL) && (view == (Textsw_view) window_get(folio->search_frame, WIN_CLIENT_DATA)) ) { /*------------------------------------------------------------------- search_frame is a global that represents the frame that the user can bring up to "find" operations on the text. If the view which owns it is destroyed it must also be destroyed and set NULL. -------------------------------------------------------------------*/ extern Frame search_frame; window_set(folio->search_frame, FRAME_NO_CONFIRM, TRUE, 0); window_destroy(folio->search_frame); search_frame = folio->search_frame = NULL; } /* Look to see if we can coalesce with one of our own views. */ folio->coalesce_with = textsw_wrapped_adjacent_view(view, &rect); textsw_get_extend_to_edge(view, &height, &width); win_show = (int)LINT_CAST(window_get(WINDOW_FROM_VIEW(view), WIN_SHOW)); had_kbd_focus = (int)LINT_CAST(window_get(WINDOW_FROM_VIEW(view), WIN_KBD_FOCUS)); /* Unlink view from everywhere and remove its storage */ nv = notify_next_destroy_func((Notify_client)abstract, status); if (folio->coalesce_with) { if ((int)LINT_CAST(window_get(WINDOW_FROM_VIEW(folio->coalesce_with), WIN_SHOW)) && !win_show) { window_set(WINDOW_FROM_VIEW(folio->coalesce_with), WIN_SHOW, win_show, 0); } else { if (had_kbd_focus) { window_set(folio->coalesce_with, WIN_KBD_FOCUS, TRUE, 0); } } window_set(WINDOW_FROM_VIEW(folio->coalesce_with), WIN_RECT, &rect, 0); textsw_set_extend_to_edge(folio->coalesce_with, height, width); if (win_fdtonumber(folio->coalesce_with->window_fd) == win_get_kbd_focus(folio->coalesce_with->window_fd)) { tool_displaytoolonly(TOOL_FROM_FOLIO(folio)); } } else if (folio->tool) { tool_expand_neighbors(TOOL_FROM_FOLIO(folio), TOOLSW_NULL, &rect); } folio->coalesce_with = 0; return (nv);}static Notify_valuetextsw_menu_destroy_first(abstract, status) Textsw abstract; Destroy_status status;{ register Textsw_view tagged_view = VIEW_ABS_TO_REP(abstract); register Textsw_view first_view; register Textsw_folio folio = FOLIO_FOR_VIEW(tagged_view); Rect rect; Rect empty_rect; Es_index tagged_view_first = ES_CANNOT_SET; int win_show; int had_kbd_focus; Notify_value nv; int height, width; if (status != DESTROY_CLEANUP) { return (notify_next_destroy_func((Notify_client)abstract, status)); } first_view = folio->first_view; /* Look to see if we can coalesce with one of our own views. */ folio->coalesce_with = textsw_wrapped_adjacent_view(first_view, &rect); if (folio->coalesce_with) { /* ASSERT(folio->coalesce_with == tagged_view); */ /* * At this point folio->coalesce_with should point to the first view. * tagged_view is pointing to the view going to be destroyed. */ textsw_get_extend_to_edge(folio->coalesce_with, &height, &width); folio->coalesce_with = first_view; } else { empty_rect = rect; rect = *((Rect *)LINT_CAST(window_get(WINDOW_FROM_VIEW(tagged_view), WIN_RECT))); textsw_get_extend_to_edge(tagged_view, &height, &width); } win_show = (int)LINT_CAST(window_get(WINDOW_FROM_VIEW(tagged_view), WIN_SHOW)); had_kbd_focus = (int)LINT_CAST(window_get(WINDOW_FROM_VIEW(tagged_view), WIN_KBD_FOCUS)); tagged_view_first = (Es_index)textsw_get(abstract, TEXTSW_FIRST); if (tagged_view_first == (Es_index)LINT_CAST(textsw_get( VIEW_REP_TO_ABS(first_view), TEXTSW_FIRST))) { tagged_view_first = ES_CANNOT_SET; } /* Unlink view from everywhere and remove its storage */ nv = notify_next_destroy_func((Notify_client)abstract, status); if ((int)LINT_CAST(window_get(WINDOW_FROM_VIEW(first_view), WIN_SHOW)) && !win_show) { window_set(WINDOW_FROM_VIEW(first_view), WIN_SHOW, win_show, 0); } else { if (had_kbd_focus) { window_set(first_view, WIN_KBD_FOCUS, TRUE, 0); } } if (tagged_view_first != ES_CANNOT_SET) { textsw_set(VIEW_REP_TO_ABS(first_view), TEXTSW_FIRST, tagged_view_first, 0); } window_set(WINDOW_FROM_VIEW(first_view), WIN_RECT, &rect, 0); textsw_set_extend_to_edge(first_view, height, width); if (win_fdtonumber(first_view->window_fd) == win_get_kbd_focus(first_view->window_fd)) { tool_displaytoolonly(TOOL_FROM_FOLIO(folio)); } if (folio->coalesce_with) { folio->coalesce_with = 0; } else { tool_expand_neighbors(TOOL_FROM_FOLIO(folio), TOOLSW_NULL,&empty_rect); } return (nv);}/* ARGSUSED */extern voidtextsw_destroy_split(abstract, locx, locy) Textsw abstract; int locx, locy; /* Currently unused */{ register Textsw_view designated_view = VIEW_ABS_TO_REP(abstract); register Textsw_view tagged_view; Textsw_view adjacent_view; register Textsw_folio folio = FOLIO_FOR_VIEW(designated_view); Rect rect; if (folio->first_view == designated_view) { if (!designated_view->next) return; adjacent_view = textsw_adjacent_view(designated_view, &rect); if (adjacent_view) { tagged_view = adjacent_view; } else { tagged_view = designated_view->next; } notify_interpose_destroy_func( (Notify_client)tagged_view, textsw_menu_destroy_first); } else { tagged_view = designated_view; notify_interpose_destroy_func( (Notify_client)tagged_view, textsw_menu_destroy_view); } window_destroy(WINDOW_FROM_VIEW(tagged_view));}pkg_private voidtextsw_set_extend_to_edge(view, height, width) Textsw_view view; int height, width; { Textsw_folio folio; register struct toolsw *toolsw; if (view) { folio = FOLIO_FOR_VIEW(view); toolsw = tool_find_sw_with_client((Tool *)LINT_CAST(folio->tool), (caddr_t)LINT_CAST(view)); if (toolsw) { if (height == TOOL_SWEXTENDTOEDGE) toolsw->ts_height = TOOL_SWEXTENDTOEDGE; if (width == TOOL_SWEXTENDTOEDGE) toolsw->ts_width = TOOL_SWEXTENDTOEDGE; } } }pkg_private voidtextsw_get_extend_to_edge(view, height, width) Textsw_view view; int *height, *width; { Textsw_folio folio; register struct toolsw *toolsw; *height = 0; *width = 0; if (view) { folio = FOLIO_FOR_VIEW(view); toolsw = tool_find_sw_with_client((Tool *)LINT_CAST(folio->tool), (caddr_t)LINT_CAST(view)); if (toolsw) { *height = toolsw->ts_height; *width = toolsw->ts_width; } }}pkg_private voidtextsw_alert_for_old_interface(view){ Event event; (void) alert_prompt(NULL, &event, ALERT_MESSAGE_STRINGS, "This feature is not available,", "due to the fact this text subwindow is created with", "pre SunView tool interface. In order to utilize", "the full text subwindow features, please upgrade the application.", 0, ALERT_BUTTON_YES, "Continue", ALERT_TRIGGER, ACTION_STOP, 0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -