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

📄 srch_rep.c

📁 aee是一种易使用的文本编辑器。你可以不用说明书来使用它。它提供终端接口和本地的X-windows接口。它的特性包括即弹的菜单
💻 C
📖 第 1 页 / 共 2 页
字号:
/* |	srch_rep.c | |	$Header: /home/hugh/sources/aee/RCS/srch_rep.c,v 1.7 1996/12/01 23:07:50 hugh Exp hugh $ *//* | |	Copyright (c) 1986 - 1988, 1991 - 1996 Hugh Mahon. | */#include "aee.h"int search(move_cursor, start_line, offset, pointer, s_str_off, srch_short, disp)	/* search for srch_str in file after cursor	*/int move_cursor;/* should the cursor be moved by search to the found string */struct text *start_line;/* these parameters allow for better meta handling */int offset;char *pointer;int s_str_off;int srch_short;int disp;		/* boolean for whether or not to display message */{	int end_of_line;	int iter;	/* position in line of start of suspect string	*/	int found;	int found2;	int iter2;	/* position in line of end of suspect string	*/	int increment;	int moved_lines;	char x;	char x1, x2;	char *direction;	char *srch_1;		/* pointer to start of suspect string	*/	char *srch_2;		/* pointer to next character of string	*/	char *srch_3;	repl_length = 0;	if (forward)		direction = "d";	else		direction = "u";	end_of_line = FALSE;	if ((srch_str == NULL) || (*srch_str == (char) NULL))		return(FALSE);	if ((move_cursor) && (disp))	{		wmove(com_win,0,0);		wclrtoeol(com_win);		waddstr(com_win, searching_msg);		if (forward)			waddstr(com_win, fwd_srch_msg);		else			waddstr(com_win, rev_srch_msg);		wrefresh(com_win);		clr_cmd_line = TRUE;	}	moved_lines = 0;	found = FALSE;	srch_line = start_line;	srch_1 = pointer;	iter = offset;	if (!srch_short)	{		if ((offset < start_line->line_length) && (forward))		{			srch_1++;			iter = offset + 1;		}		else if ((offset > 1) && (!forward))		{			srch_1--;			iter = offset - 1;		}		else			end_of_line = TRUE;	}	while ((!found) && (srch_line != NULL))	{		while ((!end_of_line) && (!found))		{			srch_2 = srch_1;			iter2 = iter;			if (literal)			{				if (case_sen)	/* if case sensitive	*/				{					srch_3 = srch_str;					while ((*srch_2 == *srch_3) && (*srch_3 != (char) NULL) && (iter2 < srch_line->line_length))					{						found = TRUE;						srch_2++;						srch_3++;						iter2++;					}	/* end while	*/				}				else		/* if not case sensitive */				{					srch_3 = u_srch_str;					while ((toupper(*srch_2) == *srch_3) && (*srch_3 != (char) NULL) && (iter2 < srch_line->line_length))					{						found = TRUE;						srch_2++;						srch_3++;						iter2++;					}				}	/* end else	*/			}			else			{				if (case_sen)					srch_3 = srch_str;				else					srch_3 = u_srch_str;				do				{					found2 = FALSE;					if (srch_3[s_str_off] == '$')					{						if (iter2 == srch_line->line_length)						{							s_str_off++;							found2 = TRUE;						}					}					else if (srch_3[s_str_off] == '.')					{						if (iter2 < srch_line->line_length)						{							s_str_off++;							iter2++;							if (iter2 <= srch_line->line_length)								srch_2++;							found2 = TRUE;						}					}					else if (srch_3[s_str_off] == '*')					{						if (iter2 < srch_line->line_length)						{							increment = 1;							if ((srch_3[s_str_off+increment] != '$') && (srch_3[s_str_off+increment] != '['))							{								if (search(FALSE, srch_line, iter2, srch_2, (s_str_off+increment), TRUE, disp))								{									while (srch_3[s_str_off] != (char) NULL)										s_str_off++;									found2 = TRUE;								}							}							found2 = TRUE;							iter2++;							if (iter2 <= srch_line->line_length)								srch_2++;							else	/* if at end of line, increment srch_3 to exit do...while loop	*/								s_str_off++;						}						else if ((iter2 == srch_line->line_length) && ((srch_3[s_str_off+1] == '$') || (srch_3[s_str_off+1] == (char) NULL)))						{							s_str_off++;							found2 = TRUE;						}					}					else if (srch_3[s_str_off] == '^')					{						if (iter == 1)						{							found2 = TRUE;							s_str_off++;						}					}					else if (srch_3[s_str_off] == '[')					{						s_str_off++;						x = (char) NULL;						if (srch_3[s_str_off] == '^')						{							x = '^';							s_str_off++;						}						else if (srch_3[s_str_off] == '\\')							s_str_off++;						found2 = FALSE;						while ((srch_3[s_str_off] != (char) NULL) && (srch_3[s_str_off] != ']') && (!found2))						{							if (srch_3[s_str_off] == '\\')								s_str_off++;							x1 = srch_3[s_str_off];							s_str_off++;							if (srch_3[s_str_off] == '-')							{								s_str_off++;								if (srch_3[s_str_off] == '\\')									s_str_off++;								x2 = srch_3[s_str_off];								s_str_off++;								if (case_sen)								{									if ((*srch_2 >= x1) && (*srch_2 <= x2))										found2 = TRUE;								}								else								{									if ((toupper(*srch_2) >= x1) && (toupper(*srch_2) <= x2))										found2 = TRUE;								}							}							else if (case_sen)							{								if (x1 == *srch_2)									found2 = TRUE;							}							else							{								if (x1 == toupper(*srch_2))									found2 = TRUE;							}						}						if (x == '^')							found2 = !found2;						if (found2)						{							iter2++;							if (iter2 <= srch_line->line_length)								srch_2++;						}						while ((srch_3[s_str_off] != ']') && (srch_3[s_str_off] != (char) NULL))						{							if (srch_3[s_str_off] == '\\')								s_str_off++;							s_str_off++;						}						if (srch_3[s_str_off] != (char) NULL)							s_str_off++;					}					else					{						if (srch_3[s_str_off] == '\\')							s_str_off++;						if (case_sen)						{							if (srch_3[s_str_off] == *srch_2)								found2 = TRUE;						}						else						{							if (srch_3[s_str_off] == toupper(*srch_2))								found2 = TRUE;						}						s_str_off++;						iter2++;						if (iter2 <= srch_line->line_length)							srch_2++;					}				} while ((srch_3[s_str_off] != (char) NULL) && (found2));				found = found2;			}			if (srch_short)			{				if (found)					repl_length = (iter2 - iter) - 1;				return(found);			}			if (!((srch_3[s_str_off] == (char) NULL) && (found)))			{				s_str_off = 0;				found = FALSE;				if (forward)				{					if (iter < srch_line->line_length)						srch_1++;					else						end_of_line = TRUE;					iter++;				}				else				{					if (iter > 1)						srch_1--;					else						end_of_line = TRUE;					iter--;				}			}		}		if (!found)		{			if (forward)			{				srch_line = srch_line->next_line;				if (srch_line != NULL)					srch_1 = srch_line->line;				iter = 1;			}			else			{				srch_line = srch_line->prev_line;				if (srch_line != NULL)				{					srch_1 = srch_line->line;					iter = 1;					while (iter < srch_line->line_length)					{						iter++;						srch_1++;					}				}			}			end_of_line = FALSE;			moved_lines++;		}	}	start_of_string = srch_1;	lines_moved = moved_lines;	if (found)	{		repl_length += 1 + (iter2 - iter);		if (move_cursor)		{			if (disp)			{				wmove(com_win, 0, 0);				wclrtoeol(com_win);				wrefresh(com_win);			}			if (lines_moved != 0)				move_rel(direction, lines_moved);			if ((lines_moved != 0) || (forward))			{				while (curr_buff->position < iter)					right(TRUE);			}			else if ((lines_moved == 0) && (!forward))			{				while (curr_buff->position > iter)					left(TRUE);			}		}		else			tmp_pos = iter;	}	else	{		if (disp)		{			wmove(com_win,0,0);			wclrtoeol(com_win);			wprintw(com_win, str_str);			iter2 = curr_buff->scr_horz;	 		for (srch_3 = srch_str; *srch_3 != (char) NULL; srch_3++)			{				if ((*srch_3 >= 32) && (*srch_3 < 127))				{					iter2++;					waddch(com_win, *srch_3);				}				else					iter2 += out_char(com_win, *srch_3, iter2, 0, 0);			}			wprintw(com_win, not_fnd_str);			wrefresh(com_win);			wmove(curr_buff->win, curr_buff->scr_vert,curr_buff->scr_horz);		}	}	return(found);}int upper(value)		/* convert character to upper case		*/char value;{	char value2;	if ((value >= 'a') && (value <= 'z'))

⌨️ 快捷键说明

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