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

📄 textsw_once.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
    if (needmetamask(i)) {        if (needctrlmask(i)) return ctrlshiftmetamasks;        else return stdshiftmetamasks;    } else {        if (needctrlmask(i)) return ctrlshiftmasks;        else return stdshiftmasks;    }}static voidtextsw_adjust_keymap(fd)	int fd;{	Event	e;	int		x;	char *def_str;	char *def_str2;	char erase_char, erase_word, erase_line;		def_str = defaults_get_string("/Text/Edit_back_char", "\177", NULL);	erase_char = *def_str;	def_str = defaults_get_string("/Text/Edit_back_word", "\027", NULL);	erase_word = *def_str;	def_str = defaults_get_string("/Text/Edit_back_line", "\025", NULL);	erase_line = *def_str;		/*	 * Make entries for erase_char, erase_word, and	 * erase_line in the keymap tables. Do this even	 * if these are the default characters.	 */	win_keymap_map_code_and_mask(erase_char,			setmask(erase_char),			ACTION_ERASE_CHAR_BACKWARD, fd);	win_keymap_map_code_and_mask(erase_word,			setmask(erase_word),			ACTION_ERASE_WORD_BACKWARD, fd);	win_keymap_map_code_and_mask(erase_line,			setmask(erase_line),			ACTION_ERASE_LINE_BACKWARD, fd);/* *  Much of the code below has become obsolete since it was decided not to *  use keymapping for the arrow keys (R8, R10, R12, R14) since this was *  incompatible with the vi (and emacs?) notion of arrow keys as escape *  sequences.  These escape sequences are generated directly by the *  kernel keymap.  When they are enabled via /Input/Arrow_Keys = "Yes", *  the R8, etc. keys disappear--replaced by escape sequences which the *  text subwindow recognizes in textsw_event.c. * *  The code for document top (R7) and bottom (R8) along with line forward *  (R11) is still needed. */	def_str = defaults_get_string("/Input/Arrow_Keys", "Yes", NULL);	def_str2 = defaults_get_string(		"/Compatibility/New_keyboard_accelerators", "Enabled", NULL);#ifdef ecd        if (/* !strcmp(def_str, "Yes") && */ !strcmp(def_str2, "Enabled")) {#else	if (!strcmp(def_str, "Yes") && !strcmp(def_str2, "Enabled")) {#endif	    Inputmask mask;            def_str = defaults_get_string("/Input/Left_Handed", "No", NULL);            if (strcmp(def_str, "Yes")) {#ifdef ecd	    (void)win_keymap_map_code_and_mask(KEY_RIGHT(8),	                stdmasks, ACTION_GO_COLUMN_BACKWARD, fd);	    (void)win_keymap_map_code_and_mask(KEY_RIGHT(12),	                stdmasks, ACTION_GO_CHAR_FORWARD, fd);	    (void)win_keymap_map_code_and_mask(KEY_RIGHT(14),	                stdmasks, ACTION_GO_COLUMN_FORWARD, fd);	    (void)win_keymap_map_code_and_mask(KEY_RIGHT(10),	                stdmasks, ACTION_GO_CHAR_BACKWARD, fd);#endif	    win_setinputcodebit(&mask, KEY_RIGHT(11));	    win_setinputcodebit(&mask, KEY_RIGHT(7));	    win_setinputcodebit(&mask, KEY_RIGHT(13));	    win_keymap_set_smask(fd,KEY_RIGHT(11));	    win_keymap_set_smask(fd,KEY_RIGHT(7));	    win_keymap_set_smask(fd,KEY_RIGHT(13));	    win_get_kbd_mask(fd, &mask);#ifdef ecd	    win_setinputcodebit(&mask, KEY_RIGHT(8));	    win_setinputcodebit(&mask, KEY_RIGHT(12));	    win_setinputcodebit(&mask, KEY_RIGHT(14));	    win_setinputcodebit(&mask, KEY_RIGHT(10));#endif	    win_setinputcodebit(&mask, KEY_RIGHT(7));	    win_setinputcodebit(&mask, KEY_RIGHT(13));	    win_set_kbd_mask(fd, &mask);	    } else {#ifdef ecd	    (void)win_keymap_map_code_and_mask(KEY_RIGHT(8),	                stdmasks, ACTION_GO_COLUMN_BACKWARD, fd);	    (void)win_keymap_map_code_and_mask(KEY_RIGHT(5),	                stdmasks, ACTION_GO_CHAR_FORWARD, fd);	    (void)win_keymap_map_code_and_mask(KEY_RIGHT(14),	                stdmasks, ACTION_GO_COLUMN_FORWARD, fd);	    (void)win_keymap_map_code_and_mask(KEY_RIGHT(2),	                stdmasks, ACTION_GO_CHAR_BACKWARD, fd);	    win_get_kbd_mask(fd, &mask);	    win_setinputcodebit(&mask, KEY_RIGHT(8));	    win_setinputcodebit(&mask, KEY_RIGHT(5));	    win_setinputcodebit(&mask, KEY_RIGHT(14));	    win_setinputcodebit(&mask, KEY_RIGHT(2));	    win_set_kbd_mask(fd, &mask);#endif	    }	}}	static Pixwin *textsw_init_view_internal(view)	register Textsw_view	 view;{	Pixwin			*pw = pw_open_monochrome(view->window_fd);	if (pw) {	    win_getsize(view->window_fd, &view->rect);	    win_setcursor(view->window_fd, &textsw_cursor);	    textsw_set_base_mask(view->window_fd);	    	    /* Make some defaults inspired adjustments */	    textsw_adjust_keymap(view->window_fd);	}	return(pw);}static Textsw_statustextsw_register_view(view)	register Textsw_view	view;{	extern Notify_value	textsw_notify_destroy();	extern Notify_value	textsw_event();	extern Notify_value	textsw_input_func();       	if (0 != win_register((Notify_client)view, PIXWIN_FOR_VIEW(view),		    textsw_event, textsw_notify_destroy,		    (unsigned)(PW_INPUT_DEFAULT | (		        (FOLIO_FOR_VIEW(view)->state & TXTSW_RETAINED)		        ? (PW_RETAIN | PW_REPAINT_ALL)		        : 0 )) ))	    return(TEXTSW_STATUS_OTHER_ERROR);	(void) notify_set_input_func((Notify_client)view, textsw_input_func,	    view->window_fd);	(void) fcntl(view->window_fd, F_SETFL, FNDELAY);	return(TEXTSW_STATUS_OKAY);}static voidtextsw_unregister_view(view)	register Textsw_view	view;{	(void) notify_set_input_func((Notify_client)view, NOTIFY_FUNC_NULL,	    view->window_fd);	win_unregister((Notify_client)view);}#define	TXTSW_NEED_SELN_CLIENT	(Seln_client)1pkg_private Textsw_viewtextsw_init_internal(view, status, default_notify_proc, attrs)	Textsw_view	  view;	Textsw_status	 *status;	int		(*default_notify_proc)();	caddr_t		 *attrs;{	extern Menu		  textsw_menu_init();	caddr_t			  defaults_array[ATTR_STANDARD_SIZE];	Attr_avlist		  defaults = defaults_array;	Attr_avlist		  attr_font;	Es_handle		  ps_esh;	Ei_handle		  plain_text_eih;	Pixwin			 *pw;	char			 *name = 0, scratch_name[MAXNAMLEN];	Es_status		  es_status;	register Textsw_folio	  folio = NEW(Text_object);	if (folio == 0) {	    *status = TEXTSW_STATUS_CANNOT_ALLOCATE;	    goto Error_Return;	}	*status = TEXTSW_STATUS_OTHER_ERROR;	folio->magic = TEXTSW_MAGIC;	folio->first_view = view;	view->folio = folio;	pw = textsw_init_view_internal(view);	if (pw == 0)	    goto Error_Return;	plain_text_eih = ei_plain_text_create();	if (plain_text_eih == 0)	    goto Error_Return;	(void) textsw_menu_init(folio);	/*	 * The following go through the standard textsw_set mechanism	 * (eventually) because they rely on all of the side-effects that	 * accompany textsw_set calls.	 */	*defaults++ = (caddr_t)TEXTSW_NOTIFY_PROC;	*defaults++ = (caddr_t)LINT_CAST(default_notify_proc);	*defaults++ = (caddr_t)TEXTSW_INSERTION_POINT;	*defaults++ = (caddr_t)0;	*defaults = 0;	/* MAS: Work-around to fix bug 1005729.	 * Pre-scan client attrs looking for either TEXTSW_FONT or WIN_FONT.	 */	attr_font = attr_find(attrs, TEXTSW_FONT);	if (*attr_font == 0) attr_font = attr_find(attrs, WIN_FONT);	if (*attr_font) attr_font++;		/* Move over attribute to value */	textsw_read_defaults(folio, defaults, *attr_font);	/*	 *   Special case the initial attributes that must be handled as	 * part of the initial set up.  Optimizing out creating a memory	 * entity_stream and then replacing it with a file causes most of	 * the following complications.	 */	defaults = attr_find(defaults_array, TEXTSW_FONT); /* Must be there! */	(void) ei_set(plain_text_eih, EI_FONT, defaults[1], 0);	ATTR_CONSUME(*defaults);	if (*attr_font == 0) folio->state |= TXTSW_OPENED_FONT;	/*	 * Look for client provided entity_stream creation proc, and client	 * provided data, which must be passed to the creation proc.	 */	defaults = attr_find(attrs, TEXTSW_ES_CREATE_PROC);	if (*defaults) {	    ATTR_CONSUME(*defaults);	    folio->es_create = (Es_handle (*)())LINT_CAST(defaults[1]);	} else	    folio->es_create = ps_create;	defaults = attr_find(attrs, TEXTSW_CLIENT_DATA);	if (*defaults) {	    ATTR_CONSUME(*defaults);	    folio->client_data = defaults[1];	}		defaults = attr_find(attrs, TEXTSW_MEMORY_MAXIMUM);	if (*defaults) {	    folio->es_mem_maximum = (unsigned)defaults[1];	}		(void) textsw_set(VIEW_REP_TO_ABS(view),			  TEXTSW_MEMORY_MAXIMUM, folio->es_mem_maximum, 0);	defaults = attr_find(attrs, TEXTSW_FILE);	if (*defaults) {	    ATTR_CONSUME(*defaults);	    name = defaults[1];	}	if (name) {	    ps_esh = textsw_create_file_ps(folio, name,					   scratch_name, &es_status);	    if (es_status != ES_SUCCESS) {		/* BUG ALERT: a few diagnostics might be appreciated. */		*status = TEXTSW_STATUS_CANNOT_OPEN_INPUT;	    }	} else {	    Attr_avlist		 attr = (Attr_avlist)attrs;	    int			 have_file_contents;	    char		*initial_greeting;	    	    attr = attr_find(attrs, TEXTSW_FILE_CONTENTS);	    have_file_contents = (*attr != 0);	    /* Always look for TEXTSW_CONTENTS in defaults_array so that it	     * is freed, even if it is not used, to avoid storage leak.	     * Similarly, always consume TEXTSW_CONTENTS from attrs.	     */	    defaults = attr_find(defaults_array, TEXTSW_CONTENTS);	    attr = attr_find(attrs, TEXTSW_CONTENTS);	    initial_greeting =		(have_file_contents) ? ""		: ((*attr) ? attr[1]		: ((*defaults) ? defaults[1]		: "" ));	    ps_esh = es_mem_create((unsigned)strlen(initial_greeting),				   initial_greeting);	    ps_esh = textsw_create_mem_ps(folio, ps_esh);	    if (*defaults) {		ATTR_CONSUME(*defaults);		free(defaults[1]);	    }	    if (*attr) {		ATTR_CONSUME(*attr);	    }	}	if (ps_esh == ES_NULL)		goto Error_Return;	/*	 * Make the view chain and the initial view(s).	 */	folio->views = ev_create_chain(ps_esh, plain_text_eih);	(void) ev_set((Ev_handle)0, folio->views,		      EV_CHAIN_DATA, folio, 		      EV_CHAIN_NOTIFY_PROC, textsw_view_chain_notify,		      EV_CHAIN_NOTIFY_LEVEL, EV_NOTIFY_ALL,		      0);	view->e_view = ev_create_view(folio->views, pw, &view->rect);	if (view->e_view == EV_NULL)	    goto Error_Return;	/*	 * Register procedures with the central notifier.	 */	if (textsw_register_view(view) != TEXTSW_STATUS_OKAY)	    goto Error_Return;	/*	 * Set the default help attribute.	 */	folio->help_data = "textsw:textsw";	/*	 * Set the default, and then the client's, attributes.	 */	(void) textsw_set_internal(view, defaults_array);	(void) textsw_set_internal(view, attrs);	/*	 * Make last_point/_adjust/_ie_time close (but not too close) to	 *   current time to avoid overflow in tests for multi-click.	 */	(void) gettimeofday(&folio->last_point, (struct timezone *)0);	folio->last_point.tv_sec -= 1000;	folio->last_adjust = folio->last_point;	folio->last_ie_time = folio->last_point;	/*	 * Final touchups.	 */	folio->trash = ES_NULL;	folio->to_insert_next_free = folio->to_insert;	folio->to_insert_counter = 0;	folio->span_level = EI_SPAN_CHAR;	SET_TEXTSW_TIMER(&folio->timer);	(void) ev_init_mark(&folio->save_insert);	folio->owed_by_filter = 0;	/*	 * Get the user filters in the ~/.textswrc file.	 * Note that their description is read only once per process, and	 *   shared among all of the folios in each process.	 */

⌨️ 快捷键说明

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