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

📄 aee.c

📁 aee是一种易使用的文本编辑器。你可以不用说明书来使用它。它提供终端接口和本地的X-windows接口。它的特性包括即弹的菜单
💻 C
📖 第 1 页 / 共 5 页
字号:
			{				curr_buff->curr_line = curr_buff->curr_line->next_line;				cpste_line = cpste_line->next_line;				curr_buff->pointer = curr_buff->curr_line->line;				pst_pos = 1;				while ((i <= curr_buff->last_line) && (cpste_line != NULL))				{					draw_line(i, 0, curr_buff->pointer, 1, curr_buff->curr_line);					i += curr_buff->curr_line->vert_len;					if (curr_buff->curr_line->next_line != NULL)					{						curr_buff->curr_line = curr_buff->curr_line->next_line;						cpste_line = cpste_line->next_line;						curr_buff->pointer = curr_buff->curr_line->line;					}				}			}		}		pst_pos = tppos;		curr_buff->curr_line = a_line;		cpste_line = b_line;	}	curr_buff->pointer = curr_buff->curr_line->line;	for (value = 1; value < count; value++)		curr_buff->pointer ++;	curr_buff->abs_pos = curr_buff->scr_pos = scanline(curr_buff->curr_line, count);	curr_buff->scr_horz = curr_buff->scr_pos % COLS;	wmove(curr_buff->win, curr_buff->scr_vert, curr_buff->scr_horz);}#ifndef xae11void get_options(numargs, arguments)	/* get arguments from original command line	*/int numargs;char *arguments[];{	char *buff;	char *extens;	int count;	struct files *temp_names;	buff = ae_basename(arguments[0]);	if (!strcmp(buff, "rae"))	{		restricted = TRUE;		change_dir_allowed = FALSE;	}	count = 1;	while (count < numargs)	{		buff = arguments[count];		if (*buff == '-')	/* options	*/		{			++buff;			if (*buff == 'j')	/* turn off recover file */				journ_on = FALSE;			else if (*buff == 'r')	/* recover from bad exit */				recover = TRUE;			else if (*buff == 'e')	/* turn off echo in init file */				echo_flag = FALSE;			else if (*buff == 'i')	/* turn off info window	*/				info_window = FALSE;			else if (!strcmp(arguments[count], "-text"))			{				text_only = TRUE;			}			else if (!strcmp(arguments[count], "-binary"))			{				text_only = FALSE;			}			else if (!strcmp(arguments[count], "-tab"))						/* expand tabs to spaces */				expand = TRUE;			else if (*buff == 'n')	/* turn off highlighting on menus*/				nohighlight = TRUE;#ifdef XAE			else if (*buff == 'h')	/* get height of window	*/			{				buff++;				if (*buff == (char) NULL)				{					count++;					buff = arguments[count];				}				win_height = atoi(buff);			}			else if (*buff == 'w')	/* get width of window	*/			{				buff++;				if (*buff == (char) NULL)				{					count++;					buff = arguments[count];				}				win_width = atoi(buff);			}#endif		}		else if (*buff == '+')		{			buff++;			start_at_line = buff;		}		else	/* if the argument wasn't an option, must be a file name, right?	*/		{			if (top_of_stack == NULL)				temp_names = top_of_stack = name_alloc();			else			{				temp_names->next_name = name_alloc();				temp_names = temp_names->next_name;			}			temp_names->next_name = NULL;			extens = temp_names->name = xalloc(strlen(buff) + 1);			while (*buff != (char) NULL)			{				*extens = *buff;				buff++;				extens++;			}			*extens = (char) NULL;			input_file = TRUE;			recv_file = TRUE;		}		count++;	}}#endif /* xae11	*/void finish(string)	/* prepare to EXIT edit session, write out file	*/char *string;{	char *query;	int leave;	leave = TRUE;	if (mark_text)	{		copy();	}	if ((num_of_bufs > 1) && (top_of_stack == NULL))	{		do			query = get_string(other_buffs_exist_msg, TRUE);		while ((toupper(*query) != toupper(*yes_char)) && 			(toupper(*query) != toupper(*no_char)));		if (toupper(*query) != toupper(*yes_char))			leave = FALSE;		else		{			leave = delete_all_buffers();		}	}	if (leave)	{		if (!curr_buff->main_buffer)			chng_buf(main_buffer_name);		if (file_op(SAVE_FILE) == 0)		{			change = FALSE;			quit(string);		}	}}int delete_all_buffers(){	int success = TRUE;	t_buff = first_buff->next_buff;	while ((t_buff != NULL) && (success))	{		chng_buf(t_buff->name);		success = del_buf();		t_buff = first_buff->next_buff;	}	return(success);}void quit(string)		/* leave editor, or if other files specified in invoking command line, edit next in sequence	*/char *string;{	char *query;	char *ans;	int editable_buffs = 0;	if (num_of_bufs > 1)	{		t_buff = first_buff;		while (t_buff != NULL)		{			if (t_buff->edit_buffer)				editable_buffs++;			t_buff = t_buff->next_buff;		}	}	if ((num_of_bufs > 1) && (top_of_stack == NULL))	{		do			query = get_string(other_buffs_exist_msg, TRUE);		while ((toupper(*query) != toupper(*yes_char)) && 			(toupper(*query) != toupper(*no_char)));		if (toupper(*query) != toupper(*yes_char))			return;		else		{			if (mark_text)				copy();			chng_buf(main_buffer_name);		}		if (!delete_all_buffers())			return;	}	if (first_buff->changed) /* if changes have been made in the file */	{		ans = get_string(changes_made_prompt, TRUE);		if (toupper(*ans) != toupper(*yes_char))			return;	}	if (mark_text)	{		copy();	}	chng_buf(main_buffer_name);	if (curr_buff->journalling)			/* if recover file in use, delete it */	{		remove_journal_file(curr_buff);	}	while ((string != NULL) && (*string != (char) NULL) && (*string != '!'))		string++;	if ((string != NULL) && (*string == '!'))		top_of_stack = NULL;	if (top_of_stack == NULL)	/* no other files to edit */	{		edit = FALSE;		wrefresh(com_win);		echo();		nl();		resetty();		resetterm();		noraw();		endwin();#ifndef XAE		putchar('\n');#endif	/* XAE */		exit(0);	}	else	/* prepare to edit next file	*/	{		change = FALSE;		curr_buff->curr_line = curr_buff->first_line;		while (curr_buff->curr_line->next_line != NULL)		{			free(curr_buff->curr_line->line);			curr_buff->curr_line = curr_buff->curr_line->next_line;			free(curr_buff->curr_line->prev_line);		}		curr_buff->num_of_lines = 1;		curr_buff->absolute_lin = 1;		free(curr_buff->curr_line->line);		free(curr_buff->curr_line);		curr_buff->scr_vert = curr_buff->scr_horz = 0;		curr_buff->curr_line = curr_buff->first_line = txtalloc();		curr_buff->curr_line->line = curr_buff->pointer = xalloc(10);		curr_buff->curr_line->line_length = 1;		curr_buff->curr_line->max_length = 10;		curr_buff->curr_line->prev_line = NULL;		curr_buff->curr_line->next_line = NULL;		curr_buff->curr_line->line_number = 1;		curr_buff->position = 1;		curr_buff->scr_pos = curr_buff->abs_pos = curr_buff->scr_horz = curr_buff->scr_vert = 0;		free(curr_buff->journal_file);		free(curr_buff->full_name);		curr_buff->journal_file = NULL;		curr_buff->file_name = NULL;		curr_buff->full_name = "";		werase(curr_buff->win);		recv_file = TRUE;		input_file = TRUE;		tmp_file = top_of_stack->name;		top_of_stack = top_of_stack->next_name;		value = check_fp();	}}void abort_edit(foo)	/* handle interrupt signal (break key) gracefully	*/int foo;{	wrefresh(com_win);	echo();	nl();	resetty();	resetterm();	noraw();	endwin();	putchar('\n');	exit(0);}void sh_command(string)	/* execute shell command			*/char *string;		/* string containing user command		*/{	char *temp_point;	char *last_slash;	char *path;		/* directory path to executable		*/	int parent;		/* zero if child, child's pid if parent	*/	struct text *line_holder;	struct bufr *tmp;	/* pointer to buffer structure		*/	if (restrict_mode())	{		return;	}	if (!(path = getenv("SHELL")))		path = "/bin/sh";	last_slash = temp_point = path;	while (*temp_point != (char) NULL)	{		if (*temp_point == '/')			last_slash = ++temp_point;		else			temp_point++;	}	keypad(curr_buff->win, FALSE);	echo();	nl();	noraw();	resetty();	if (in_pipe)	{		pipe(pipe_in);		/* create a pipe	*/		parent = fork();		if (!parent)		/* if the child		*/		{/* |  child process which will fork and exec shell command (if shell output is |  to be read by editor) */			in_pipe = FALSE;/* |  redirect stdout to pipe */			temp_stdout = dup(1);			close(1);			dup(pipe_in[1]);/* |  redirect stderr to pipe */			temp_stderr = dup(2);			close(2);			dup(pipe_in[1]);			close(pipe_in[1]);		}		else  /* if the parent	*/		{/* |  prepare editor to read from the pipe */			signal(SIGCHLD, SIG_IGN);			chng_buf(in_buff_name);			line_holder = curr_buff->curr_line;			tmp_vert = curr_buff->scr_vert;			close(pipe_in[1]);			get_fd = pipe_in[0];			get_file("");			close(pipe_in[0]);			curr_buff->scr_vert = tmp_vert;			curr_buff->scr_horz = curr_buff->scr_pos = curr_buff->abs_pos = 0;			curr_buff->position = 1;			curr_buff->curr_line = line_holder;			curr_buff->pointer = curr_buff->curr_line->line;			midscreen(curr_buff->scr_vert, 1);			out_pipe = FALSE;			signal(SIGCHLD, SIG_DFL);/* |  since flag "in_pipe" is still TRUE, do not even wait for child to complete |  (the pipe is closed, no more output can be expected) */		}	}	if (!in_pipe)	{		signal(SIGINT, SIG_IGN);		if (out_pipe)		{			pipe(pipe_out);		}/* |  fork process which will exec command */		parent = fork();   		if (!parent)		/* if the child	*/		{			if (shell_fork)				putchar('\n');			if (out_pipe)			{/* |  prepare the child process (soon to exec a shell command) to read from the  |  pipe (which will be output from the editor's buffer) */				close(0);				dup(pipe_out[0]);				close(pipe_out[0]);				close(pipe_out[1]);			}			for (value = 1; value < 24; value++)				signal(value, SIG_DFL);			execl(path, last_slash, "-c", string, NULL);			printf("could not exec %s\n", path);			exit(-1);		}		else	/* if the parent	*/		{			if (out_pipe)			{/* |  output the contents of the buffer to the pipe (to be read by the  |  process forked and exec'd above as stdin) */				close(pipe_out[0]);				tmp = first_buff;				while ((tmp != NULL) && (strcmp(out_buff_name, tmp->name)))					tmp = tmp->next_buff;				if (tmp != NULL)				{					line_holder = tmp->first_line;					while (line_holder != NULL)					{						write(pipe_out[1], line_holder->line, (line_holder->line_length-1));						write(pipe_out[1], "\n", 1);						line_holder = line_holder->next_line;					}				}				else					printf(no_buff_named_str, out_buff_name);				close(pipe_out[1]);				out_pipe = FALSE;			}			wait(&parent);			signal(SIGINT, abort_edit);/* |  if this process is actually the child of the editor, exit |  The editor forks a process.  If output must be sent to the command to be  |  exec'd another process is forked, and that process (the child's child)  |  will exec the command.  In this case, "shell_fork" will be FALSE.  If no  |  output is to be performed to the shell command, "shell_fork" will be TRUE. */			if (!shell_fork)				exit(0);		}	}	if (shell_fork)	{		printf(press_ret_to_cont_str);		fflush(stdout);		while (((in = getchar()) != '\n') && (in != '\r'))			;#ifdef XAE		raise_window();#endif	}	fixterm();	noecho();	nonl();	raw();	keypad(curr_buff->win, TRUE);	curr_buff->win = curr_buff->win;	clearok(curr_buff->win, TRUE);	redraw();}void redraw()		/* redraw screen			*/{	repaint_screen();}void repaint_screen(){	struct bufr *t_bu

⌨️ 快捷键说明

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