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

📄 new_curse.c

📁 aee是一种易使用的文本编辑器。你可以不用说明书来使用它。它提供终端接口和本地的X-windows接口。它的特性包括即弹的菜单
💻 C
📖 第 1 页 / 共 5 页
字号:
		in_value = Get_key(in_value);	return(in_value);}#ifndef BSD_SELECTvoid Clear(arg)		/* notify that time out has occurred	*/int arg;{	Time_Out = TRUE;#ifdef DEBUGfprintf(stderr, "inside Clear()\n");fflush(stderr);#endif /* DEBUG */}#endif /* BSD_SELECT */int Get_key(first_char)			/* try to decode key sequence	*/int first_char;				/* first character of sequence	*/{	int in_char;	int Count;	char string[128];	char *Gtemp;	int Found;#ifdef SYS5	struct termio Gterminal;#else	struct sgttyb Gterminal;#endif	struct KEY_STACK *St_point;#if (!defined( BSD_SELECT)) || (!defined(SYS5))	int value;#endif /* BSD_SELECT */	Count = 0;	Gtemp = string;	string[Count++] = first_char;	string[Count] = (char) NULL;	Time_Out = FALSE;#ifndef BSD_SELECT	signal(SIGALRM, Clear);	value = alarm(1);#endif /* BSD_SELECT */	Noblock = TRUE;#ifdef SYS5	Gterminal.c_cc[VTIME] = 0;		/* timeout value	*/	Gterminal.c_lflag &= ~ICANON;	/* disable canonical operation	*/	Gterminal.c_lflag &= ~ECHO;		/* disable echo		*/#endif	Count = 1;	Found = FALSE;	while ((Count < Max_Key_len) && (!Time_Out) && (!Found))	{		in_char = wgetch(stdscr);#ifdef DEBUGfprintf(stderr, "back in GetKey()\n");fflush(stderr);#endif /* DEBUG */		if (in_char != -1)		{			string[Count++] = in_char;			string[Count] = (char) NULL;			St_point = KEY_TOS;			while ((St_point != NULL) && (!Found))			{				if (!strcmp(string, St_point->element->string))					Found = TRUE;				else					St_point = St_point->next;			}		}	}#ifndef BSD_SELECT	if (!Time_Out)		value = alarm(0);#endif /* BSD_SELECT */#ifdef SYS5/*	value = ioctl(0, TCSETA, &Terminal);*/#else	value = ioctl(0, TIOCSETP, &Terminal);/*	value = fcntl(0, F_SETFL, old_arg);*/#endif	Noblock = FALSE;	if (Found)	{		return(St_point->element->value);	}	else	{		while (Count > 1)		{			if ((string[--Count] != -1) && 					((unsigned char) (string[Count]) != 255))			{#ifdef DIAGfprintf(stderr, "ungetting character %d\n", string[Count]);fflush(stdout);#endif				ungetch(string[Count]);			}		}		return(first_char);	}}void waddch(window, c)	/* output the character in the specified window	*/WINDOW *window;int c;{	int column, j;	int shift;	/* number of spaces to shift if a tab		*/	struct _line *tmpline;#ifdef DIAG/*printf("starting waddch \n");fflush(stdout);*/#endif	column = window->LX;	if (c == '\t')	{		shift = (column + 1) % 8;		if (shift == 0)			shift++;		else			shift = 9 - shift;		while (shift > 0)		{			shift--;			waddch(window, ' ');		}	}	else if ((column < window->Num_cols) && (window->LY < window->Num_lines))	{		if ((c == '~') && (Booleans[hz__]))			c = '@';		if (( c != '\b') && (c != '\n') && (c != '\r'))		{			tmpline = window->line_array[window->LY];			tmpline->row[column] = c;			tmpline->attributes[column] = window->Attrib;			tmpline->changed = TRUE;			if (column >= tmpline->last_char)			{				if (column > tmpline->last_char)					for (j = tmpline->last_char; j < column; j++)					{						tmpline->row[j] = ' ';						tmpline->attributes[j] = (char) NULL;					}				tmpline->row[column + 1] = (char) NULL;				tmpline->attributes[column + 1] = (char) NULL;				tmpline->last_char = column + 1;			}		}		if (c == '\n')		{			wclrtoeol(window);			window->LX = window->Num_cols;		}		else if (c == '\r')			window->LX = 0;		else if (c == '\b')			window->LX--;		else			window->LX++;	}	if (window->LX >= window->Num_cols)	{		window->LX = 0;		window->LY++;		if (window->LY >= window->Num_lines)		{			window->LY = window->Num_lines - 1;/*			window->LY = row;			wmove(window, 0, 0);			wdeleteln(window);			wmove(window, row, 0);*/		}	}	window->SCROLL_CLEAR = CHANGE;}void winsertln(window)	/* insert a blank line into the specified window */WINDOW *window;{	int row, column;	struct _line *tmp;	struct _line *tmp1;	window->scroll_down += 1;	window->SCROLL_CLEAR = SCROLL;	column = window->LX;	row = window->LY;	for (row = 0, tmp = window->first_line; (row < window->Num_lines) && (tmp->next_screen != NULL); row++)		tmp = tmp->next_screen;	if (tmp->prev_screen != NULL)		tmp->prev_screen->next_screen = NULL;	tmp1 = tmp;	clear_line(tmp1, 0, window->Num_cols);	tmp1->number = -1;	for (row = 0, tmp = window->first_line; (row < window->LY) && (tmp->next_screen != NULL); row++)		tmp = tmp->next_screen;	if ((window->LY == (window->Num_lines - 1)) && (window->Num_lines > 1))	{		tmp1->next_screen = tmp->next_screen;		tmp->next_screen = tmp1;		tmp->changed = TRUE;		tmp->next_screen->prev_screen = tmp;	}	else if (window->Num_lines > 1)	{		if (tmp->prev_screen != NULL)			tmp->prev_screen->next_screen = tmp1;		tmp1->prev_screen = tmp->prev_screen;		tmp->prev_screen = tmp1;		tmp1->next_screen = tmp;		tmp->changed = TRUE;		tmp->scroll = DOWN;	}	if (window->LY == 0)		window->first_line = tmp1;	for (row = 0, tmp1 = window->first_line; 		row < window->Num_lines; row++)	{		window->line_array[row] = tmp1;		tmp1 = tmp1->next_screen;	}}void wdeleteln(window)	/* delete a line in the specified window */WINDOW *window;{	int row, column;	struct _line *tmp;	struct _line  *tmpline;	if (window->Num_lines > 1)	{		window->scroll_up += 1;		window->SCROLL_CLEAR = SCROLL;		column = window->LX;		row = window->LY;		for (row = 0, tmp = window->first_line; row < window->LY; row++)			tmp = tmp->next_screen;		if (window->LY == 0)			window->first_line = tmp->next_screen;		if (tmp->prev_screen != NULL)			tmp->prev_screen->next_screen = tmp->next_screen;		if (tmp->next_screen != NULL)		{			tmp->next_screen->changed = TRUE;			tmp->next_screen->scroll = UP;			tmp->next_screen->prev_screen = tmp->prev_screen;		}		tmpline = tmp;		clear_line(tmpline, 0, window->Num_cols);		tmpline->number = -1;		for (row = 0, tmp = window->first_line; tmp->next_screen != NULL; row++)			tmp = tmp->next_screen;		if (tmp != NULL)		{			tmp->next_screen = tmpline;			tmp->next_screen->prev_screen = tmp;			tmp->changed = TRUE;			tmp = tmp->next_screen;		}		else			tmp = tmpline;		tmp->next_screen = NULL;		for (row = 0, tmp = window->first_line; row < window->Num_lines; row++)		{			window->line_array[row] = tmp;			tmp = tmp->next_screen;		}	}	else	{		clear_line(window->first_line, 0, window->Num_cols);	}}void wclrtobot(window)	/* delete from current position to end of the window */WINDOW *window;{	int row, column;	struct _line *tmp;	window->SCROLL_CLEAR |= CLEAR;	column = window->LX;	row = window->LY;	for (row = 0, tmp = window->first_line; row < window->LY; row++)		tmp = tmp->next_screen;	clear_line(tmp, column, window->Num_cols);	for (row = (window->LY + 1); row < window->Num_lines; row++)	{		tmp = tmp->next_screen;		clear_line(tmp, 0, window->Num_cols);	}	wmove(window, row, column);}void wstandout(window)	/* begin standout mode in window	*/WINDOW *window;{	if (Numbers[sg__] < 1)	/* if not magic cookie glitch	*/		window->Attrib |= A_STANDOUT;}void wstandend(window)	/* end standout mode in window	*/WINDOW *window;{	window->Attrib &= ~A_STANDOUT;}void waddstr(window, string)	/* write 'string' in window	*/WINDOW *window;char *string;{	char *wstring;	for (wstring = string; *wstring != (char) NULL; wstring++)		waddch(window, *wstring);}void clearok(window, flag)	/* erase screen and redraw at next refresh	*/WINDOW *window;int flag;{	Repaint_screen = TRUE;}void echo()			/* turn on echoing				*/{	int value;#ifdef SYS5	Terminal.c_lflag |= ECHO;		/* enable echo		*/	value = ioctl(0, TCSETA, &Terminal);	/* set characteristics	*/#else	Terminal.sg_flags |= ECHO;		/* enable echo		*/	value = ioctl(0, TIOCSETP, &Terminal);	/* set characteristics	*/#endif}void noecho()		/* turn off echoing				*/{	int value;#ifdef SYS5	Terminal.c_lflag &= ~ECHO;		/* disable echo		*/	value = ioctl(0, TCSETA, &Terminal);	/* set characteristics	*/#else	Terminal.sg_flags &= ~ECHO;		/* disable echo		*/	value = ioctl(0, TIOCSETP, &Terminal);	/* set characteristics	*/#endif}void raw()			/* set to read characters immediately		*/{	int value;#ifdef SYS5	Intr = Terminal.c_cc[VINTR];	/* get the interrupt character	*/	Terminal.c_lflag &= ~ICANON;	/* disable canonical operation	*/	Terminal.c_lflag &= ~ISIG;	/* disable signal checking	*/#ifdef FLUSHO	Terminal.c_lflag &= ~FLUSHO;#endif#ifdef PENDIN	Terminal.c_lflag &= ~PENDIN;#endif#ifdef IEXTEN	Terminal.c_lflag &= ~IEXTEN;#endif	Terminal.c_cc[VMIN] = 1;		/* minimum of one character */	Terminal.c_cc[VTIME] = 255;		/* timeout value	*/	Terminal.c_cc[VINTR] = 0;		/* eliminate interrupt	*/	value = ioctl(0, TCSETA, &Terminal);	/* set characteristics	*/#else	Terminal.sg_flags |= RAW;	/* enable raw mode		*/	value = ioctl(0, TIOCSETP, &Terminal);	/* set characteristics	*/#endif}void noraw()			/* set to normal character read mode		*/{	int value;#ifdef SYS5	Terminal.c_lflag |= ICANON;	/* enable canonical operation	*/	Terminal.c_lflag |= ISIG;	/* enable signal checking	*/	Terminal.c_cc[VEOF] = 4;		/* EOF character = 4	*/	Terminal.c_cc[VEOL] = (char) NULL;	/* EOL = 0		*/	Terminal.c_cc[VINTR] = Intr;		/* reset interrupt char	*/	value = ioctl(0, TCSETA, &Terminal);	/* set characteristics	*/#else	Terminal.sg_flags &= ~RAW;	/* disable raw mode		*/	value = ioctl(0, TIOCSETP, &Terminal);	/* set characteristics	*//*	old_arg = fcntl(0, F_GETFL, 0);	value = fcntl(0, F_SETFL, old_arg & ~FNDELAY);*/#endif}void nl(){	int value;#ifdef SYS5	Terminal.c_iflag |= ICRNL;	/* enable carriage-return to line-feed mapping	*/	value = ioctl(0, TCSETA, &Terminal);	/* set characteristics	*/#endif}void nonl(){	int value;#ifdef SYS5	Terminal.c_iflag &= ~ICRNL;	/* disable carriage-return to line-feed mapping	*/	Terminal.c_iflag &= ~IGNCR;	/* do not ignore carriage-return	*/	value = ioctl(0, TCSETA, &Terminal);	/* set characteristics	*/#endif}void saveterm(){}void fixterm(){}void resetterm(){}void nodelay(window, flag)WINDOW *window;int flag;{}void idlok(window, flag)WINDOW *window;int flag;{}void keypad(window, flag)WINDOW *window;int flag;{	if (flag)		String_Out(String_table[ks__], NULL, 0);	else		String_Out(String_table[ke__], NULL, 0);}void savetty()		/* save current tty stats			*/{	int value;#ifdef SYS5	value = ioctl(0, TCGETA, &Saved_tty);	/* set characteristics	*/#else	value = ioctl(0, TIOCGETP, &Saved_tty);	/* set characteristics	*/#endif}void resetty()		/* restore previous tty stats			*/{	int value;#ifdef SYS5	value = ioctl(0, TCSETA, &Saved_tty);	/* set characteristics	*/#else	value = ioctl(0, TIOCSETP, &Saved_tty);	/* set characteristics	*/#endif}void endwin()		/* end windows					*/{	keypad(stdscr, FALSE);	initialized = FALSE;	delwin(curscr);	delwin(virtual_scr);	delwin(stdscr);#ifndef SYS5{	int old_arg, value;/*	old_arg = fcntl(0, F_GETFL, 0);	value = fcntl(0, F_SETFL, old_arg & ~FNDELAY);*/}#endif}void delwin(window)		/* delete the window structure			*/WINDOW *window;{	int i;	for (i = 1; (i < window->Num_lines) && (window->first_line->next_screen != NULL); i++)	{		window->first_line = window->first_line->next_screen;		free(window->first_line->prev_screen->row);		free(window->first_line->prev_screen->attributes);		free(window->first_line->prev_screen);	}	if (window == last_window_refreshed)		last_window_refreshed = 0;	if (window->first_line != NULL)	{		free(window->first_line->row);		free(window->first_line->attributes);		free(window->first_line);		free(window);	}}#ifndef __STDC__void wprintw(va_alist)va_dcl#else /* __STDC__ */void wprintw(WINDOW *window, const char *format, ...)#endif /* __STDC__ */{#ifndef __STDC__	WINDOW *window;	char *format;	va_list ap;#else	va_list ap;#endif	int value;	char *fpoint;	char *wtemp;#ifndef __STDC__	va_start(ap);	window = va_arg(ap, WINDOW *);	format = va_arg(ap, char *);#else /* __STDC__ */	va_start(a

⌨️ 快捷键说明

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