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

📄 mark.c

📁 aee是一种易使用的文本编辑器。你可以不用说明书来使用它。它提供终端接口和本地的X-windows接口。它的特性包括即弹的菜单
💻 C
📖 第 1 页 / 共 2 页
字号:
/* |	mark.c | |	$Header: /home/hugh/sources/aee/RCS/mark.c,v 1.10 1996/05/07 03:10:31 hugh Exp $ *//* |	Copyright (c) 1986 - 1988, 1991 - 1996 Hugh Mahon. */#include "aee.h"void copy()			/* copy selected (marked) text into paste buffer */{	struct text *tmp_pste;	if (mark_text)	{		if ((paste_buff != NULL) && (mark_text == Mark))		{			tmp_pste = paste_buff;			while (tmp_pste->next_line != NULL)			{				free(tmp_pste->line);				tmp_pste = tmp_pste->next_line;				free(tmp_pste->prev_line);			}			free(tmp_pste->line);			free(tmp_pste);		}		if ((mark_text == Mark) || (paste_buff == NULL))			paste_buff = fpste_line;		else if (mark_text == Append)		{			tmp_pste = paste_buff;			while (tmp_pste->next_line != NULL)				tmp_pste = tmp_pste->next_line;			fpste_line->prev_line = tmp_pste;			tmp_pste->next_line = fpste_line;		}		else if (mark_text == Prefix)		{			tmp_pste = fpste_line;			while (tmp_pste->next_line != NULL)				tmp_pste = tmp_pste->next_line;			tmp_pste->next_line = paste_buff;			paste_buff->prev_line = tmp_pste;			paste_buff = fpste_line;		}		mark_text = FALSE;		midscreen(curr_buff->scr_vert, curr_buff->position);	}	else	{		wmove(com_win, 0,0);		werase(com_win);		wprintw(com_win, mark_not_actv_str);		wrefresh(com_win);		clr_cmd_line = TRUE;	}}void paste()		/* insert text from paste buffer into current buffer	*/{	int vert;	int tposit;	int ppos;	int temp_flag1;	int temp_flag2;	int temp_abs_line;	int temp_left_margin;	temp_abs_line = curr_buff->absolute_lin;	temp_flag1 = overstrike;	temp_flag2 = indent;	temp_left_margin = left_margin;	overstrike = FALSE;	indent = FALSE;	left_margin = 0;	if ((!mark_text) && (paste_buff != NULL))	{		vert = curr_buff->scr_vert;		tmp_line = curr_buff->curr_line;		ppos = curr_buff->scr_pos;		cpste_line = paste_buff;		tposit = curr_buff->position;		while (cpste_line != NULL)		{			pst_pos = 1;			pst_pnt = pst_line = cpste_line->line;			insert_line(FALSE);			left(FALSE);			curr_buff->pointer = resiz_line(cpste_line->line_length,curr_buff->curr_line,curr_buff->position);			while (pst_pos < cpste_line->line_length)			{				*curr_buff->pointer = *pst_pnt;				curr_buff->pointer++;				pst_pnt++;				curr_buff->position++;				curr_buff->curr_line->line_length++;				pst_pos++;			}			curr_buff->curr_line->changed = TRUE;			curr_buff->changed = TRUE;			*curr_buff->pointer = (char) NULL;			curr_buff->curr_line->vert_len = (scanline(curr_buff->curr_line, curr_buff->curr_line->line_length) / COLS) + 1;			cpste_line = cpste_line->next_line;			right(FALSE);		}		delete(FALSE);		if (curr_buff->journalling)			write_journal(curr_buff, curr_buff->curr_line);		curr_buff->abs_pos = curr_buff->scr_pos = ppos;		curr_buff->scr_vert = vert;		curr_buff->absolute_lin = temp_abs_line;		curr_buff->curr_line = tmp_line;		curr_buff->pointer = curr_buff->curr_line->line;		curr_buff->position = 1;		while (curr_buff->position < tposit)		{			curr_buff->pointer++;			curr_buff->position++;		}/*		curr_buff->scr_pos = curr_buff->abs_pos = scanline(curr_buff->curr_line, curr_buff->curr_line->line_length);*/		midscreen(curr_buff->scr_vert, curr_buff->position);	}	else if (mark_text)	{		wmove(com_win,0,0);		wclrtoeol(com_win);		wprintw(com_win, mark_active_str);		wrefresh(com_win);		clr_cmd_line = TRUE;		wmove(curr_buff->win, curr_buff->scr_vert, curr_buff->scr_horz);	}	overstrike = temp_flag1;	indent = temp_flag2;	left_margin = temp_left_margin;}void unmark_text()	/* unmark text and do not change contents of paste buffer */{	if (mark_text)	{		mark_text = FALSE;		while (cpste_line->prev_line != NULL)			cpste_line = cpste_line->prev_line;		while (cpste_line->next_line != NULL)		{			if (cpste_line->line != NULL)				free(cpste_line->line);			cpste_line = cpste_line->next_line;			free(cpste_line->prev_line);		}		free(cpste_line->line);		free(cpste_line);		midscreen(curr_buff->scr_vert, curr_buff->position);	}	else	{		wmove(com_win,0,0);		wclrtoeol(com_win);		wprintw(com_win, mark_not_actv_str);		wrefresh(com_win);		wmove(curr_buff->win, curr_buff->scr_vert, curr_buff->scr_horz);		clr_cmd_line = TRUE;	}}void cut()	/* cut selected (marked) text out of current buffer	*/{	int vert;	int temp_slct;	char tmp_char;	if (mark_text)	{		temp_slct = mark_text;		mark_text = FALSE;		tmp_char = d_char;		vert = curr_buff->scr_vert;		if (cpste_line->next_line != NULL)			cut_down();		else if (cpste_line->prev_line != NULL)			cut_up();		else 			cut_line();		cpste_line = fpste_line;		while (cpste_line != NULL)		{			pst_pos = 1;			pst_pnt = cpste_line->line;			while (pst_pos < cpste_line->line_length)			{				pst_pos++;				pst_pnt++;			}			if (*pst_pnt == -1)				*pst_pnt = (char) NULL;			cpste_line = cpste_line->next_line;		}		curr_buff->scr_vert = vert;		midscreen(curr_buff->scr_vert, curr_buff->position);		d_char = tmp_char;		mark_text = temp_slct;		copy();	}	else	{		wmove(com_win,0,0);		wclrtoeol(com_win);		wprintw(com_win, mark_not_actv_str);		wrefresh(com_win);		wmove(curr_buff->win, curr_buff->scr_vert, curr_buff->scr_horz);		clr_cmd_line = TRUE;	}}	void cut_up()	/* cut text above current cursor position	*/{	cut_line();	left(FALSE);	cpste_line = cpste_line->prev_line;	while (cpste_line->prev_line != NULL)	{		cpste_line = cpste_line->prev_line;		curr_buff->pointer = curr_buff->curr_line->line;		*curr_buff->pointer = (char) NULL;		curr_buff->position = curr_buff->curr_line->line_length = 1;		delete(FALSE);	}	pst_pnt = pst_line = cpste_line->line;	pst_pos = 1;	while (pst_pos < cpste_line->line_length)	{		pst_pos++;		pst_pnt++;	}	cut_line();	right(FALSE);	delete(FALSE);}void cut_down()		/* cut text below current cursor position	*/{	if (((pst_pos == 1) && (pst_pos < cpste_line->line_length)) ||	 ((pst_pos != 1) && (pst_pos == cpste_line->line_length)))	{		cut_line();		right(FALSE);	}	else		curr_buff->curr_line = curr_buff->curr_line->next_line;	cpste_line = cpste_line->next_line;	while (cpste_line->next_line != NULL)	{		cpste_line = cpste_line->next_line;		curr_buff->pointer = curr_buff->curr_line->line;		*curr_buff->pointer = (char) NULL;		curr_buff->position = curr_buff->curr_line->line_length = 1;		delete(FALSE);		right(FALSE);	}	pst_pnt = pst_line = cpste_line->line;	pst_pos = 1;	cut_line();	delete(FALSE);}void cut_line()		/* cut text in current line			*/{	if (((pst_pos == 1) && (pst_pos < cpste_line->line_length)) || ((pst_pos != 1) && (pst_pos == cpste_line->line_length)))	{		if (pst_pos == cpste_line->line_length)		{			while (pst_pos > 1)			{				pst_pos--;				delete(FALSE);			}		}		else		{			while (pst_pos < cpste_line->line_length)			{				right(FALSE);				delete(FALSE);				pst_pos++;			}		}	}}void fast_left()	/* move left one character while selecting (marking) text but not displaying on screen	*/{	int tpst_pos;	if ((curr_buff->position == 1) && (curr_buff->curr_line->prev_line != NULL))	{		if (curr_buff->curr_line->changed && curr_buff->journalling)			write_journal(curr_buff, curr_buff->curr_line);		curr_buff->curr_line = curr_buff->curr_line->prev_line;		curr_buff->pointer = curr_buff->curr_line->line;		curr_buff->position = 1;		while (curr_buff->position < curr_buff->curr_line->line_length)		{			curr_buff->position++;			curr_buff->pointer++;		}		curr_buff->scr_pos = scanline(curr_buff->curr_line, curr_buff->position);	}	else if (curr_buff->position > 1)	{		curr_buff->pointer--;		curr_buff->position--;		if (*curr_buff->pointer == '\t')			curr_buff->scr_pos = scanline(curr_buff->curr_line, curr_buff->position);		else			curr_buff->scr_pos -= len_char(*curr_buff->pointer, curr_buff->scr_pos);

⌨️ 快捷键说明

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