⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 textsw_search.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
	if (base_frame = (Frame) window_get(win, WIN_OWNER))	    frame = (window_get(base_frame, FRAME_CLOSED)) ? base_frame : win;	else	    frame = win;			pw = (struct pixwin *)(LINT_CAST(window_get(frame, WIN_PIXWIN)));	h = (int)window_get(frame, WIN_HEIGHT);	w = (int)window_get(frame, WIN_WIDTH); 	              for (i = 0; i < num_of_blink; i++) {            (void)pw_writebackground(pw, 0, 0, w, h, PIX_NOT(PIX_DST));            slp(2);            (void)pw_writebackground(pw, 0, 0, w, h, PIX_NOT(PIX_DST));        }}	static voidcmd_proc(item, event)	Panel_item	item;    	Event		*event;{	Textsw_view	view = view_from_panel_item(item);	Textsw_folio 	folio = FOLIO_FOR_VIEW(view);        int             wrapping_off = (int)panel_get(panel_items[(int)WRAP_ITEM], PANEL_VALUE);		if (item == panel_items[(int)FIND_ITEM]) {	    (void) do_search_proc(view, EV_FIND_DEFAULT, (RING_IF_NOT_FOUND | RING_IF_ONLY_ONE), wrapping_off);	    	} else if (item == panel_items[(int)REPLACE_ITEM]) {	    if (TXTSW_IS_READ_ONLY(folio) || !do_replace_proc(view)) {	       (void) window_bell(VIEW_REP_TO_ABS(view));	    }	} else if (item == panel_items[(int)FIND_THEN_REPLACE_ITEM]) {	    if (!TXTSW_IS_READ_ONLY(folio)) {	        if (do_search_proc(view, EV_FIND_DEFAULT, RING_IF_NOT_FOUND, wrapping_off) != ES_CANNOT_SET)                    (void) do_replace_proc(view);	    }	} else if (item == panel_items[(int)REPLACE_THEN_FIND_ITEM]) {	    if (!TXTSW_IS_READ_ONLY(folio)) {                (void) do_replace_proc(view);                (void) do_search_proc(view, EV_FIND_DEFAULT, RING_IF_NOT_FOUND, wrapping_off);	    }	} else if (item == panel_items[(int)DONE_ITEM]) {	    (void) do_destroy_proc(folio->search_frame);	    	} else if (item == panel_items[(int)REPLACE_ALL_ITEM]) {	    (void) replace_all_proc(view, FALSE, EV_FIND_DEFAULT);	    	} else if (item == panel_items[(int)BLINK_PARENT_ITEM]) {	    (void) blink_window(VIEW_REP_TO_ABS(view), 3);	}	}    		static voidcreate_search_item(panel, view)   	Panel		panel;  	Textsw_view	view;{	static char		*search = "Find";	static char		*replace = "Replace";	static char		*all    = "Replace All";	static char		*search_replace = "Find then Replace";	static char		*replace_search = "Replace then Find";	static char		*done = "Done";	static char		*backward = "Backward";	static char		*forward = "Forward";	static char		*blink_parent = "Blink Owner";	char			search_string[MAX_STR_LENGTH];	int			dummy;				direction_menu = menu_create(		MENU_ITEM,		    MENU_STRING, forward,		    MENU_VALUE, 1,		    HELP_INFO("textsw:mdirforward")		    0,		MENU_ITEM,		    MENU_STRING, backward,		    MENU_VALUE, 2,		    HELP_INFO("textsw:mdirbackward")		    0,		HELP_INFO("textsw:mdirection")		0);		panel_items[(int)FIND_ITEM] = panel_create_item(panel,PANEL_BUTTON,            PANEL_LABEL_IMAGE,                        panel_button_image(panel, search, 7, NULL),            PANEL_NOTIFY_PROC, cmd_proc,            PANEL_EVENT_PROC,  search_event_proc,	    HELP_INFO("textsw:find")            0);                search_string[0] = NULL;	(void) textsw_get_selection(view, &dummy, &dummy, search_string, MAX_STR_LENGTH);	                                                 panel_items[(int)FIND_STRING_ITEM] =  panel_create_item(panel, PANEL_TEXT,            PANEL_LABEL_Y,                 ATTR_ROW(0),            PANEL_VALUE_DISPLAY_LENGTH,    MAX_DISPLAY_LENGTH,            PANEL_VALUE_STORED_LENGTH,     MAX_STR_LENGTH,            PANEL_LABEL_STRING,            ":",            PANEL_VALUE, 		   search_string,	    HELP_INFO("textsw:findstring")            0);                panel_items[(int)DONE_ITEM] =   panel_create_item(panel,PANEL_BUTTON,            PANEL_LABEL_Y,                 ATTR_ROW(0),            PANEL_LABEL_IMAGE,                        panel_button_image(panel, done, 7, NULL),            PANEL_NOTIFY_PROC,		   cmd_proc,	    HELP_INFO("textsw:done")	    0);                panel_items[(int)REPLACE_ITEM] = panel_create_item(panel,PANEL_BUTTON,            PANEL_LABEL_X,                 ATTR_COL(0),            PANEL_LABEL_Y,                 ATTR_ROW(1),            PANEL_LABEL_IMAGE,                        panel_button_image(panel, replace, 7, NULL),            PANEL_NOTIFY_PROC,		   cmd_proc,	    HELP_INFO("textsw:replace")	    0);                  panel_items[(int)REPLACE_STRING_ITEM] = panel_create_item(panel, PANEL_TEXT,            PANEL_LABEL_Y,                 ATTR_ROW(1),            PANEL_VALUE_DISPLAY_LENGTH,    MAX_DISPLAY_LENGTH,            PANEL_VALUE_STORED_LENGTH,     MAX_STR_LENGTH,            PANEL_LABEL_STRING,            ":",	    HELP_INFO("textsw:replacestring")            0);                 panel_items[(int)WRAP_ITEM] = panel_create_item(panel, PANEL_CYCLE,            PANEL_LABEL_Y,                 ATTR_ROW(1),                       PANEL_CHOICE_STRINGS, 	   "All Text", "To End", 0,	    HELP_INFO("textsw:wrap")            0);                        panel_items[(int)FIND_THEN_REPLACE_ITEM] =  panel_create_item(panel,PANEL_BUTTON,            PANEL_LABEL_X,                 ATTR_COL(0),            PANEL_LABEL_Y,                 ATTR_ROW(2),	    PANEL_LABEL_IMAGE,                        panel_button_image(panel, search_replace, 0, NULL),            PANEL_NOTIFY_PROC,  	cmd_proc,	    HELP_INFO("textsw:findreplace")            0);                     panel_items[(int)REPLACE_THEN_FIND_ITEM] =  panel_create_item(panel,PANEL_BUTTON,                        PANEL_LABEL_IMAGE,                        panel_button_image(panel, replace_search, 0, NULL),            PANEL_NOTIFY_PROC, 		   cmd_proc,	    HELP_INFO("textsw:replacefind")            0);                     panel_items[(int)REPLACE_ALL_ITEM] =  panel_create_item(panel,PANEL_BUTTON,                        PANEL_LABEL_IMAGE,                        panel_button_image(panel, all, 0, NULL),            PANEL_NOTIFY_PROC, 		   cmd_proc,	    HELP_INFO("textsw:replaceall")            0);                     panel_items[(int)BLINK_PARENT_ITEM] =  panel_create_item(panel,PANEL_BUTTON,            PANEL_LABEL_X,                 ATTR_COL(59),            PANEL_LABEL_IMAGE,                        panel_button_image(panel, blink_parent, 0, NULL),            PANEL_NOTIFY_PROC, 		   cmd_proc,	    HELP_INFO("textsw:blinkparent")            0);                           if (search_string[0] != NULL)            window_set(panel, PANEL_CARET_ITEM, panel_items[(int)REPLACE_STRING_ITEM], 0);	                                                     }extern Paneltextsw_create_search_panel(frame, view)	Frame		frame;	Textsw_view	view;{	Panel		panel;		panel = (Panel)(LINT_CAST(	    window_create((Window)frame, PANEL,			  HELP_INFO("textsw:searchpanel")			  0)));	create_search_item(panel, view);  		return(panel);  }static Notify_valueabort_search_proc (frame, signal, when)	int			*frame;	int			signal;	Notify_signal_mode	when;{	if ((when == NOTIFY_ASYNC) && (signal == SIGURG))	    process_aborted = TRUE;	    	return(NOTIFY_DONE);}	static Notify_valuebase_frame_event_proc(base_frame, event, arg, type)    Frame 	 base_frame;    Event 	 *event;    Notify_arg 	 arg;    Notify_event_type type;{    Notify_value value = notify_next_event_func(base_frame, event, arg, type);    switch (event_action(event)) {      case WIN_REPAINT:      case TXTSW_OPEN:      case MS_RIGHT:        if (search_frame != NULL) {	    if (window_get(base_frame, FRAME_CLOSED)) {	         if (window_get(search_frame, WIN_SHOW))	             window_set(search_frame, WIN_SHOW, FALSE, 0);	    } else {	        if (!window_get(search_frame, WIN_SHOW))	             window_set(search_frame, WIN_SHOW, TRUE, 0);	    }	}	break;    }    return value;}					pkg_private voidtextsw_set_pop_up_location (base_frame, pop_up_frame)	Frame		base_frame, pop_up_frame;{/* base_frame and pop_up_frame has to be created with window_create not tool_create */#define MY_OFFSET		4		Rect		base_rect, pop_up_rect, screen_rect;	short		new_x, new_y;	int		max_cover_area;	int		win_fd;	struct screen	screen;		if (!base_frame || !pop_up_frame)	    return;	    		screen_rect = *((Rect *) (LINT_CAST(window_get(base_frame, WIN_SCREEN_RECT))));	base_rect = *((Rect *) (LINT_CAST(window_get(base_frame, WIN_RECT))));	pop_up_rect = *((Rect *) (LINT_CAST(window_get(pop_up_frame, WIN_RECT))));	    		new_x = pop_up_rect.r_left;	new_y = pop_up_rect.r_top;	max_cover_area = base_rect.r_width / 3;		if ((base_rect.r_top - (pop_up_rect.r_height + MY_OFFSET)) >= 0)	    new_y = base_rect.r_top - (pop_up_rect.r_height + MY_OFFSET);	else if ((base_rect.r_left - pop_up_rect.r_width + MY_OFFSET) >= 0)	    new_x = base_rect.r_left - (pop_up_rect.r_width + MY_OFFSET);	else if ((base_rect.r_left + base_rect.r_width + pop_up_rect.r_width + MY_OFFSET) <= 	         screen_rect.r_width)	    new_x = base_rect.r_left + base_rect.r_width;	else if ((pop_up_rect.r_width + MY_OFFSET - base_rect.r_left) <= max_cover_area)	    new_x = 0;	else if ((base_rect.r_left + base_rect.r_width - max_cover_area) <= (screen_rect.r_width - (pop_up_rect.r_width + MY_OFFSET)))	    new_x = screen_rect.r_width - (pop_up_rect.r_width + MY_OFFSET);                if (new_y < 0) new_y = 0;	    	pop_up_rect.r_left = new_x;                pop_up_rect.r_top = new_y;                       win_setrect((int)window_get(pop_up_frame, WIN_FD), &pop_up_rect);#undef MY_OFFSET	}	extern voidtextsw_create_search_frame(view)	Textsw_view	view;{                register Textsw_folio	folio = FOLIO_FOR_VIEW(view);        Frame			base_frame = (Frame) window_get(view, WIN_OWNER);	Panel			panel;	char			*label = "Find and Replace";	static int		already_interposed;		if (!base_frame) {	    (void)textsw_alert_for_old_interface(view);	    return;	}		if (search_frame) {	    register int	search_frame_fd = (int) window_fd(search_frame, WIN_FD);    	    register int	root_fd;	    char		str[MAX_STR_LENGTH];	    int			dummy;	    	    folio->search_frame = search_frame;  /* In case the popup is for a different textsw */	    window_set(folio->search_frame, WIN_CLIENT_DATA, view, 0);	    	    str[0] = NULL;	    (void) textsw_get_selection(view, &dummy, &dummy, str, MAX_STR_LENGTH);	    	    if (strlen(str) > 0) {	        panel = panel_get(panel_items[(int)FIND_STRING_ITEM], PANEL_PARENT_PANEL, 0);	        (void) panel_set_value(panel_items[(int)FIND_STRING_ITEM], str);	        (void) window_set(panel, PANEL_CARET_ITEM, panel_items[(int)REPLACE_STRING_ITEM], 0);	    }	    	    if (win_getlink(search_frame_fd, WL_COVERING) == WIN_NULLLINK) {	       (void) blink_window(folio->search_frame, 5);	    } else {	        root_fd = rootfd_for_toolfd(search_frame_fd);	        wmgr_top(search_frame_fd, root_fd);	        (void)close (root_fd);	    }	    	    return;	}	    	  	search_frame = folio->search_frame = window_create(base_frame, FRAME,			FRAME_SHOW_LABEL, 	TRUE,			FRAME_DONE_PROC, 	do_destroy_proc,			WIN_CLIENT_DATA, 	view,			0);		if (!search_frame)	    return;	    			panel = textsw_create_search_panel(folio->search_frame, view);		(void) notify_set_signal_func(folio->search_frame, abort_search_proc, SIGURG,  NOTIFY_ASYNC);		if (!already_interposed) {	    notify_interpose_event_func(base_frame, base_frame_event_proc, NOTIFY_SAFE);	    already_interposed = TRUE;	}		(void) window_fit(panel);	(void) window_fit(folio->search_frame);	(void) textsw_set_pop_up_location(base_frame, folio->search_frame);	(void) window_set(folio->search_frame, FRAME_LABEL, label, WIN_SHOW, TRUE, 0);	}		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -