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

📄 tool_support.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
		0);}voidmt_update_info(s)	char           *s;{	char           *p;	if (*s == '\0')		return;	/* FOR NOW */	else if (p = index(s, '\n'))		*p = '\0';	if (mt_info_item != NULL) 		(void) panel_set_value(mt_info_item, s);}/* * Makes the message number in the indicated message be the primary selection  */voidmt_set_curselmsg(msg)	int             msg;{	int             spos, epos;	extern int      mt_last_sel_msg;	epos = mt_message[msg].m_start + 5;	if (msg < 10)		spos = epos - 1;	else if (msg < 100)		spos = epos - 2;	else		spos = epos - 3;	(void) textsw_set_selection(mt_headersw, spos, epos, SEL_PRIMARY);	mt_last_sel_msg = msg;}/* * Delete characters in the header subwindow. */voidmt_del_header(from, to)	int             from, to;{	mt_replace_header(from, to, "");}/* * Insert characters in the header subwindow. */ voidmt_ins_header(start, s)	int             start;	char           *s;{	mt_replace_header(start, start, s);}/* * replace characters in the header subwindow. */voidmt_replace_header(from, to, s)	int             from, to;	char           *s;{	(void) window_set(mt_headersw, TEXTSW_READ_ONLY, FALSE, 0);	mt_replace_bytes(from, to, s);	(void) window_set(mt_headersw,		TEXTSW_READ_ONLY, TRUE,		TEXTSW_UPDATE_SCROLLBAR,		0);}static voidmt_replace_bytes(from, to, s)	int             from, to;	char           *s;{	if ((textsw_replace_bytes(mt_headersw, from, to, s, strlen(s)) == 0)		&& (from != 0))		/* replace failed */		return;	return;}/* * Temporarily set the namestripe while tool is busy doing something. * Does not affect the value of the buffers mt_namestripe_left or * mt_namestripe_right */voidmt_set_namestripe_temp(s)	char           *s;{	if (!mt_frame) {}	else 		(void) window_set(mt_frame, FRAME_LABEL, s, 0);}/* * Set the left side of the namestripe to message of the form %s - folder: %s %s */voidmt_set_namestripe_left(folder, status, update)	char           *folder, *status;	int		update;{	if (!mt_frame) {}	else {		*mt_namestripe_left = '\0';		(void) sprintf(mt_namestripe_left, "%s - %s%s %s",			mt_cmdname,			(mt_panel_style != mt_Old && mt_system_mail_box) ? "" : "folder: ",			/* to save some space in namestripe */			folder, status);		if (update)			mt_set_namestripe_both();	} }/* * Set the "right side" of the namestripe */voidmt_set_namestripe_right(s, update)	char           *s;{	if (!mt_frame) {}	else {		*mt_namestripe_right = '\0';		if (mt_panel_style != mt_Old)			(void) strcpy(mt_namestripe_right, s);		if (update)			mt_set_namestripe_both();	}}/* * set the name stripe with all of the left side and as much of the right * side as will fit. Take right most characters of right side if not all will * fit.  */voidmt_set_namestripe_both(){	register int	i, j, lenl, lenr;	int		dots = 0;	lenl = strlen(mt_namestripe_left);	lenr = strlen(mt_namestripe_right);	*mt_namestripe = '\0';	j = lenl + lenr + 3 - mt_namestripe_width;		/* take right most characters */	if (j <= 0)		/* all will fit */		j = 0;	else		dots = 3;	for (i = 0; i < mt_namestripe_width; i++ ) {		if (i < lenl)			mt_namestripe[i] = mt_namestripe_left[i];		else if (i < lenl + 3)			mt_namestripe[i] = ' ';	/* the -3 to make sure at						 * least three spaces between						 * two sides */		else if (i < mt_namestripe_width - lenr)			mt_namestripe[i] = ' ';		else if (dots > 0) {			mt_namestripe[i] = '.';			dots--;			j++;		} else			mt_namestripe[i] = mt_namestripe_right[j++];	}	mt_namestripe[i] = '\0';	if (strcmp(window_get(mt_frame, FRAME_LABEL), mt_namestripe) != 0)		/*		 * to avoid multiple repainting of name stripe. Should be		 * handled in SunView libraries 		 */		(void) window_set(mt_frame, FRAME_LABEL, mt_namestripe, 0);}/* * restores name stripe to previous value. */voidmt_restore_namestripe(){	(void) window_set(mt_frame, FRAME_LABEL, mt_namestripe, 0);}/* * Set the icon. */voidmt_set_icon(ic)	struct icon    *ic;{	(void) window_set(mt_frame, FRAME_ICON, ic, 0);}/* * Announce the arrival of new mail. */voidmt_announce_mail(){	static struct timeval tv = {0, 300000};	int             bells, flashes, fd; 	Pixwin		*pw;	bells = mt_bells;	flashes = mt_flashes;	if (bells <= 0 && flashes <= 0)		return;	fd = (int)window_get(mt_frame, WIN_FD);	pw = (Pixwin *)window_get(mt_frame, WIN_PIXWIN);	for (;;) {		win_bell(bells-- > 0 ? fd : -1, tv, flashes-- > 0 ? pw : 0);		if (bells > 0 || flashes > 0)			/* pause between bells */			select(0, 0, 0, 0, &tv);		else			break;	}}/* * Request confirmation from the user. Use alerts.   *//* VARARGS1 */intmt_confirm(frame, beep, optional, button1, button2, va_alist)	Frame		frame;	int		beep, optional;	char		*button1, *button2;	va_dcl{	va_list         args;	Event           ie;	char		*p;	int		status, i;	char		*array[100];	if (mt_value("expert"))		return(TRUE);	i = 0;	va_start(args);	while ((p = va_arg(args, char *)) != (char *) 0) 		array[i++] = p;	va_end(args);	array[i] = (char *) 0;	status = alert_prompt(frame,		&ie,		ALERT_MESSAGE_STRINGS_ARRAY_PTR, array,		ALERT_BUTTON_YES, button1,		ALERT_BUTTON_NO, button2,		ALERT_OPTIONAL, optional,		ALERT_NO_BEEPING, (mt_bells == 0 || beep == 0),		0);	switch (status) {		case ALERT_YES: return (TRUE);		case ALERT_NO: return(FALSE);		case ALERT_FAILED: mt_alert_failed("Could not put up alert to request confirmation of the following operation:\n",			array,			"\nProceeding by assuming that this operation was NOT confirmed\n");			return(FALSE);	}}/* * Warn the user about an error. *//* VARARGS1 */voidmt_warn(frame, va_alist)	Frame		frame;	va_dcl{	va_list         args;	Event           ie;	char		*p;	int		status, i;	char		*array[100];	i = 0;	va_start(args);	while ((p = va_arg(args, char *)) != (char *) 0) 		array[i++] = p;	va_end(args);	array[i] = (char *) 0;	status = alert_prompt(frame,		&ie,		ALERT_MESSAGE_STRINGS_ARRAY_PTR, array,		ALERT_BUTTON_YES, "Continue",		ALERT_NO_BEEPING, (mt_bells == 0),		ALERT_TRIGGER, ACTION_STOP, 		0);	switch (status) {		case ALERT_YES: return;		case ALERT_TRIGGERED: return; 		case ALERT_FAILED: mt_alert_failed("Could not put up alert to warn user of the following condition:\n",		array, "");			return;	}}static voidmt_alert_failed(str1, array, str2)	char	*str1, *str2;	char	*array[];{	int	i = 0;	(void) fprintf(stderr, str1);	for (i = 0; array[i] != (char *) 0; i++)		(void) fprintf(stderr, array[i]);	(void) fprintf(stderr, str2);}/*  * Change cursor to hourglass */voidmt_waitcursor(){	int             fd, i;	static          index;	while (index < numWindows)		cursor[index++] = cursor_create((char *)0);	for (i = 0; i < numWindows; i++) {		fd = (int) window_get(window[i], WIN_FD);		(void) win_getcursor(fd, cursor[i]);		(void) win_setcursor(fd, &hourglasscursor);	}}/*  * Restore cursor */voidmt_restorecursor(){	int             i, fd;	for (i = 0; i < numWindows; i++) {		fd = (int) window_get(window[i], WIN_FD);		(void) win_setcursor(fd, cursor[i]);	}}/* * stores w in window[], an array of all subwindows. window[] is used for * setting cursor in mt_waitcursor and restoring it in mt_restore_cursor  */voidmt_add_window(w, type)	Window          w;	enum mt_Window_Type type;{	window[numWindows++] = w;}/* takes care of removing w from the window array */voidmt_remove_window(w)	Window          w;{	int             i;	for (i = 1; i < numWindows; i++)		if (window[i] == w)			for (; i < numWindows; i++)				window[i] = window[i+1];	numWindows--;}/* installed on all subwindows in the tool *//* not used - halastatic Notify_value mt_subwindow_event_proc(client, event, arg, when)	Notify_client   client;	Event          *event;	Notify_arg      arg;	Notify_event_type when;{	mt_log_event(event);	return (notify_next_event_func(client, event, arg, when));}*/FILE           *mt_fopen(filename, type)	char           *filename, *type;{	FILE           *f;	if (filename == NULL)		return(NULL);	if (!(f = fopen(filename, type))) {		char            s[128];		(void) strcpy(s, "couldn't open ");		(void) strcat(s, filename);		mt_warn(mt_frame, s, 0);	}	return(f);}

⌨️ 快捷键说明

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