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

📄 textsw_attr.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
#ifndef lint#ifdef sccsstatic  char sccsid[] = "@(#)textsw_attr.c 1.1 92/07/30";#endif#endif/* * Copyright (c) 1986, 1987 by Sun Microsystems, Inc. *//* * Attribute set/get routines for text subwindows. */#include <suntool/primal.h>#include <suntool/textsw_impl.h>#include <suntool/ev_impl.h>#include <varargs.h>#include <sys/dir.h>#include <pixrect/pixfont.h>#include <suntool/window.h>#include <suntool/walkmenu.h>#include <suntool/alert.h>#include <suntool/frame.h>#include <sunwindow/defaults.h>extern void			ev_line_info();extern Es_handle		es_file_create(), es_mem_create();pkg_private Es_handle		textsw_add_scrollbar_to_view();pkg_private Es_handle		textsw_create_ps();pkg_private void		textsw_display_view_margins();pkg_private void		textsw_init_again(), textsw_init_undo();pkg_private Es_status		textsw_load_file_internal();extern Textsw_index		textsw_position_for_physical_line();pkg_private Textsw_index	textsw_replace();pkg_private Es_index		textsw_get_contents();#ifndef CTRL#define CTRL(c)		('c' & 037)#endif#define	DEL		0x7f#define SET_BOOL_FLAG(flags, to_test, flag)			\	if ((unsigned)(to_test) != 0) (flags) |= (flag);	\	else (flags) &= ~(flag)#define BOOL_FLAG_VALUE(flags, flag)				\	((flags & flag) ? TRUE : FALSE)static int	TEXTSW_count;		/* = 0 for -A-R */static Textsw_statusset_first(view, error_msg, filename, reset_mode, first, first_line, all_views)	register Textsw_view	 view;	char			*error_msg;	char			*filename;	int			 reset_mode;	Es_index		 first;	int			 first_line;	int			 all_views;{	char			 msg_buf[MAXNAMLEN+100];	char			*msg;	Es_status		 load_status;	Textsw_status		 result = TEXTSW_STATUS_OKAY;	register Textsw_folio	 folio = FOLIO_FOR_VIEW(view);	extern void		 textsw_normalize_view();	msg = (error_msg) ? error_msg : msg_buf;	if (filename) {	    char		 scratch_name[MAXNAMLEN];	    Es_handle		 new_esh;	    /* Ensure no caret turds will leave behind */	    textsw_take_down_caret(folio);	    load_status =		textsw_load_file_internal(		    folio, filename, scratch_name, &new_esh, ES_CANNOT_SET,		    1);	    if (load_status == ES_SUCCESS) {		if (first_line > -1) {		    first = textsw_position_for_physical_line(				VIEW_REP_TO_ABS(view), first_line+1);		}		if (reset_mode != TEXTSW_LRSS_CURRENT) {		    Textsw_view   view_ptr;		    (void) ev_set(view->e_view,				  EV_FOR_ALL_VIEWS,				  EV_DISPLAY_LEVEL, EV_DISPLAY_NONE,				  EV_DISPLAY_START, first,				  EV_DISPLAY_LEVEL, EV_DISPLAY,				  0);		    for (view_ptr = folio->first_view; view_ptr;			view_ptr = view_ptr->next) {			textsw_set_scroll_mark(VIEW_REP_TO_ABS(view_ptr));		    }		  		}		textsw_notify(view,			      TEXTSW_ACTION_LOADED_FILE, filename,			      0);	    } else {		textsw_format_load_error(msg, load_status,					 filename, scratch_name);		if (error_msg == NULL) {                    Event   alert_event;                     (void) alert_prompt(                       	    (Frame)window_get(WINDOW_FROM_VIEW(folio), WIN_OWNER),                            &alert_event,                            ALERT_MESSAGE_STRINGS, msg,                            ALERT_BUTTON_YES, "Continue",                            0);                }		result = TEXTSW_STATUS_OTHER_ERROR;	    }	} else {	    if (first_line > -1) {		first = textsw_position_for_physical_line(				VIEW_REP_TO_ABS(view), first_line+1);	    }	    if (first != ES_CANNOT_SET) {	       if (all_views) {		 Textsw_view   view_ptr;		 for (view_ptr = folio->first_view; view_ptr; view_ptr = view_ptr->next) {		 	textsw_normalize_internal(view_ptr, first, first, 0, 0,				  TXTSW_NI_DEFAULT);     		 };	      } else		 textsw_normalize_view(VIEW_REP_TO_ABS(view), first);     	    } else {		result = TEXTSW_STATUS_OTHER_ERROR;	    }	}	return(result);}pkg_private Textsw_statustextsw_set_internal(view, attrs)	Textsw_view			 view;	register Attr_avlist		 attrs;{	Textsw_status			 status, status_dummy;	Textsw_status			*status_ptr = &status_dummy;	Textsw_view			 next;	char				 expand_attr[100];	char				 error_dummy[256];	char				*error_msg = error_dummy;	char				*file = NULL;	int				 reset_mode = -1;	register int			 temp;	int				 all_views = 0;	int				 display_views = 0;	int				 update_scrollbar = 0;	int				 ceased_read_only = 0;	int				 set_read_only_esh = 0;	int				 str_length = 0;	Es_handle			 ps_esh, scratch_esh, mem_esh;	Es_status			 es_status;	Es_index			 old_insert_pos, old_length;	register int			 consume_attrs = 0;	register Textsw_folio		 textsw = FOLIO_FOR_VIEW(view);	status = TEXTSW_STATUS_OKAY;	for (; *attrs; attrs = attr_next(attrs)) {	    if (consume_attrs & 1) consume_attrs |= 0x10000; 	    switch ((Textsw_attribute)(*attrs)) {	      case TEXTSW_FOR_ALL_VIEWS:		all_views = TRUE;		break;	      case TEXTSW_END_ALL_VIEWS:		all_views = FALSE;		break;	      case TEXTSW_ADJUST_IS_PENDING_DELETE:		SET_BOOL_FLAG(textsw->state, attrs[1], TXTSW_ADJUST_IS_PD);		break;	      case TEXTSW_AGAIN_LIMIT:		/* Internally we want one more again slot that client does.  */		temp = (int)(attrs[1]);		temp = (temp > 0) ? temp+1 : 0;		textsw_init_again(textsw, temp);		break;	      case TEXTSW_AGAIN_RECORDING:		SET_BOOL_FLAG(textsw->state, !attrs[1],			      TXTSW_NO_AGAIN_RECORDING);		break;	      case TEXTSW_AUTO_INDENT:		SET_BOOL_FLAG(textsw->state, attrs[1], TXTSW_AUTO_INDENT);		break;	      case TEXTSW_AUTO_SCROLL_BY:		(void) ev_set(view->e_view,			      EV_CHAIN_AUTO_SCROLL_BY, (int)(attrs[1]),			      0);		break;	      case TEXTSW_BLINK_CARET:		SET_BOOL_FLAG(textsw->caret_state, attrs[1],			      TXTSW_CARET_FLASHING);		break;	      case TEXTSW_BROWSING:		temp = TXTSW_IS_READ_ONLY(textsw);		SET_BOOL_FLAG(textsw->state, attrs[1], TXTSW_READ_ONLY_SW);		ceased_read_only = (temp && !TXTSW_IS_READ_ONLY(textsw));		break;	      case TEXTSW_CLIENT_DATA:		textsw->client_data = attrs[1];		break;	      case HELP_DATA:		textsw->help_data = attrs[1];		break;	      case TEXTSW_COALESCE_WITH:		/* Get only */		break;	      case TEXTSW_CONFIRM_OVERWRITE:		SET_BOOL_FLAG(textsw->state, attrs[1],			      TXTSW_CONFIRM_OVERWRITE);		break;	      case TEXTSW_CONTENTS:		temp = (textsw->state & TXTSW_NO_AGAIN_RECORDING);		if (!(textsw->state & TXTSW_INITIALIZED))		    textsw->state |= TXTSW_NO_AGAIN_RECORDING;		(void) textsw_replace(VIEW_REP_TO_ABS(view), 0,				 TEXTSW_INFINITY, attrs[1], strlen(attrs[1]));		if (!(textsw->state & TXTSW_INITIALIZED))		    SET_BOOL_FLAG(textsw->state, temp,				  TXTSW_NO_AGAIN_RECORDING);		break;	      case TEXTSW_CONTROL_CHARS_USE_FONT:		(void) ei_set(textsw->views->eih,			      EI_CONTROL_CHARS_USE_FONT, attrs[1], 0);		break;	      case TEXTSW_DESTROY_ALL_VIEWS:		SET_BOOL_FLAG(textsw->state, attrs[1],			      TXTSW_DESTROY_ALL_VIEWS);		break;	      case TEXTSW_DISABLE_CD:		SET_BOOL_FLAG(textsw->state, attrs[1], TXTSW_NO_CD);		break;	      case TEXTSW_DISABLE_LOAD:		SET_BOOL_FLAG(textsw->state, attrs[1], TXTSW_NO_LOAD);		break;	      case TEXTSW_STORE_CHANGES_FILE:		SET_BOOL_FLAG(textsw->state, attrs[1],			      TXTSW_STORE_CHANGES_FILE);		break;	      case TEXTSW_EDIT_BACK_CHAR:		textsw->edit_bk_char = (char)(attrs[1]);		break;	      case TEXTSW_EDIT_BACK_WORD:		textsw->edit_bk_word = (char)(attrs[1]);		break;	      case TEXTSW_EDIT_BACK_LINE:		textsw->edit_bk_line = (char)(attrs[1]);		break;	      case TEXTSW_ERROR_MSG:		error_msg = (char *)(attrs[1]);		error_msg[0] = '\0';		break;	      case TEXTSW_ES_CREATE_PROC:		textsw->es_create = (Es_handle (*)())LINT_CAST(attrs[1]);		break;	      case TEXTSW_FILE:		file = (char *)(attrs[1]);		break;	      case TEXTSW_FILE_CONTENTS: 	      	        textsw_flush_caches(view, TFC_PD_SEL);		 		ps_esh = ES_NULL;		str_length = (attrs[1] ? strlen(attrs[1]) : 0);				if (!file) {    		    if (str_length > 0) {		        scratch_esh = es_file_create(attrs[1], 0, &es_status);		        /* Ensure no caret turds will leave behind */	    		textsw_take_down_caret(textsw);			    } else		        scratch_esh = textsw->views->esh;		    		    if (scratch_esh) {		        mem_esh = es_mem_create(es_get_length(scratch_esh) + 1, "");		        if (mem_esh) {			    if (es_copy(scratch_esh, mem_esh, FALSE) != ES_SUCCESS) {				es_destroy(mem_esh);				mem_esh = ES_NULL;			    }		        }		        if (str_length > 0)  {			    es_destroy(scratch_esh);		        }			if (mem_esh) {			    scratch_esh = es_mem_create(textsw->es_mem_maximum, "");			    if (scratch_esh) {				ps_esh = textsw_create_ps(textsw, mem_esh, scratch_esh,							  &es_status);			    } else {				es_destroy(mem_esh);			    }			}		    }		}		if (ps_esh) {	    		    textsw_replace_esh(textsw, ps_esh);		    		    if (str_length > 0)  {		        Ev_handle		ev_next;		        Ev_impl_line_seq	seq;		        			(void) ev_set_insert(textsw->views, es_get_length(ps_esh));						FORALLVIEWS(textsw->views, ev_next) {			    seq = (Ev_impl_line_seq) ev_next->line_table.seq;			    seq[0].damaged = 0;  /* Set damage bit in line table to force redisplay  */		        }		        display_views = 2;  /* TEXTSW_FIRST will set it to 0 to avoid repaint */		        all_views = TRUE; /*  For TEXTSW_FIRST, or TEXTSW_FIRST_LINE */	                        /* bug 1009822 unecessary painting of caret			textsw_invert_caret(textsw);		                                  */ 		    }		} else {		    *status_ptr = TEXTSW_STATUS_OTHER_ERROR;		}				break;	      case TEXTSW_FIRST:		*status_ptr = set_first(view, error_msg, file, reset_mode,					(Es_index)(attrs[1]), -1,					all_views);		/*		 *  Make sure the scrollbar get updated,		 *  when this attribute is called with TEXT_FIRST.		 */		if (file && !update_scrollbar) 			update_scrollbar = 2;		file = NULL;		display_views = 0;		break;	      case TEXTSW_FIRST_LINE:		*status_ptr = set_first(view, error_msg, file, reset_mode,					ES_CANNOT_SET, (int)(attrs[1]),					all_views);		/*		 *  Make sure the scrollbar get updated,		 *  when this attribute is called with TEXT_FIRST.		 */		if (file && !update_scrollbar) 			update_scrollbar = 2;

⌨️ 快捷键说明

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