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

📄 ee.c

📁 EE Text Editor in standard UNIX
💻 C
📖 第 1 页 / 共 5 页
字号:
			right(TRUE);	}	else		left(TRUE);}void control()			/* use control for commands		*/{	char *string;	if (in == 1)		/* control a	*/	{		string = get_string(ascii_code_str, TRUE);		if (*string != (char) NULL)		{			in = atoi(string);			wmove(text_win, scr_vert, (scr_horz - horiz_offset));			insert(in);		}		free(string);	}	else if (in == 2)	/* control b	*/		bottom();	else if (in == 3)	/* control c	*/	{		command_prompt();	}	else if (in == 4)	/* control d	*/		down();	else if (in == 5)	/* control e	*/		search_prompt();	else if (in == 6)	/* control f	*/		undel_char();	else if (in == 7)	/* control g	*/		bol();	else if (in == 8)	/* control h	*/		delete(TRUE);	else if (in == 9)	/* control i	*/		;	else if (in == 10)	/* control j	*/		insert_line(TRUE);	else if (in == 11)	/* control k	*/		del_char();	else if (in == 12)	/* control l	*/		left(TRUE);	else if (in == 13)	/* control m	*/		insert_line(TRUE);	else if (in == 14)	/* control n	*/		move_rel("d", max(5, (last_line - 5)));	else if (in == 15)	/* control o	*/		eol();	else if (in == 16)	/* control p	*/		move_rel("u", max(5, (last_line - 5)));	else if (in == 17)	/* control q	*/		;	else if (in == 18)	/* control r	*/		right(TRUE);	else if (in == 19)	/* control s	*/		;	else if (in == 20)	/* control t	*/		top();	else if (in == 21)	/* control u	*/		up();	else if (in == 22)	/* control v	*/		undel_word();	else if (in == 23)	/* control w	*/		del_word();	else if (in == 24)	/* control x	*/		search(TRUE);	else if (in == 25)	/* control y	*/		del_line();	else if (in == 26)	/* control z	*/		undel_line();	else if (in == 27)	/* control [ (escape)	*/	{		menu_op(main_menu);	}	}/* |	Emacs control-key bindings */void emacs_control(){	char *string;	if (in == 1)		/* control a	*/		bol();	else if (in == 2)	/* control b	*/		left(TRUE);	else if (in == 3)	/* control c	*/	{		command_prompt();	}	else if (in == 4)	/* control d	*/		del_char();	else if (in == 5)	/* control e	*/		eol();	else if (in == 6)	/* control f	*/		right(TRUE);	else if (in == 7)	/* control g	*/		move_rel("u", max(5, (last_line - 5)));	else if (in == 8)	/* control h	*/		delete(TRUE);	else if (in == 9)	/* control i	*/		;	else if (in == 10)	/* control j	*/		undel_char();	else if (in == 11)	/* control k	*/		del_line();	else if (in == 12)	/* control l	*/		undel_line();	else if (in == 13)	/* control m	*/		insert_line(TRUE);	else if (in == 14)	/* control n	*/		down();	else if (in == 15)	/* control o	*/	{		string = get_string(ascii_code_str, TRUE);		if (*string != (char) NULL)		{			in = atoi(string);			wmove(text_win, scr_vert, (scr_horz - horiz_offset));			insert(in);		}		free(string);	}	else if (in == 16)	/* control p	*/		up();	else if (in == 17)	/* control q	*/		;	else if (in == 18)	/* control r	*/		undel_word();	else if (in == 19)	/* control s	*/		;	else if (in == 20)	/* control t	*/		top();	else if (in == 21)	/* control u	*/		bottom();	else if (in == 22)	/* control v	*/		move_rel("d", max(5, (last_line - 5)));	else if (in == 23)	/* control w	*/		del_word();	else if (in == 24)	/* control x	*/		search(TRUE);	else if (in == 25)	/* control y	*/		search_prompt();	else if (in == 26)	/* control z	*/		adv_word();	else if (in == 27)	/* control [ (escape)	*/	{		menu_op(main_menu);	}	}void bottom()			/* go to bottom of file			*/{	while (curr_line->next_line != NULL)		curr_line = curr_line->next_line;	point = curr_line->line;	if (horiz_offset)		horiz_offset = 0;	position = 1;	midscreen(last_line, point);	scr_pos = scr_horz;}void top()				/* go to top of file			*/{	while (curr_line->prev_line != NULL)		curr_line = curr_line->prev_line;	point = curr_line->line;	if (horiz_offset)		horiz_offset = 0;	position = 1;	midscreen(0, point);	scr_pos = scr_horz;}void nextline()			/* move pointers to start of next line	*/{	curr_line = curr_line->next_line;	point = curr_line->line;	position = 1;	if (scr_vert == last_line)	{		wmove(text_win, 0,0);		wdeleteln(text_win);		wmove(text_win, last_line,0);		wclrtobot(text_win);		draw_line(last_line,0,point,1,curr_line->line_length);	}	else		scr_vert++;}void prevline()			/* move pointers to start of previous line*/{	curr_line = curr_line->prev_line;	point = curr_line->line;	position = 1;	if (scr_vert == 0)	{		winsertln(text_win);		draw_line(0,0,point,1,curr_line->line_length);	}	else		scr_vert--;	while (position < curr_line->line_length)	{		position++;		point++;	}}void left(disp)				/* move left one character	*/int disp;{	if (point != curr_line->line)	/* if not at begin of line	*/	{		if ((ee_chinese) && (position >= 2) && (*(point - 2) > 127))		{			point--;			position--;		}		point--;		position--;		scanline(point);		wmove(text_win, scr_vert, (scr_horz - horiz_offset));		scr_pos = scr_horz;	}	else if (curr_line->prev_line != NULL)	{		if (!disp)		{			curr_line = curr_line->prev_line;			point = curr_line->line + curr_line->line_length;			position = curr_line->line_length;			return;		}		position = 1;		prevline();		scanline(point);		scr_pos = scr_horz;		wmove(text_win, scr_vert, (scr_horz - horiz_offset));	}}void right(disp)				/* move right one character	*/int disp;{	if (position < curr_line->line_length)	{		if ((ee_chinese) && (*point > 127) && 		    ((curr_line->line_length - position) >= 2))		{			point++;			position++;		}		point++;		position++;		scanline(point);		wmove(text_win, scr_vert, (scr_horz - horiz_offset));		scr_pos = scr_horz;	}	else if (curr_line->next_line != NULL)	{		if (!disp)		{			curr_line = curr_line->next_line;			point = curr_line->line;			position = 1;			return;		}		nextline();		scr_pos = scr_horz = 0;		if (horiz_offset)		{			horiz_offset = 0;			midscreen(scr_vert, point);		}		wmove(text_win, scr_vert, (scr_horz - horiz_offset));		position = 1;		}}void find_pos()		/* move to the same column as on other line	*/{	scr_horz = 0;	position = 1;	while ((scr_horz < scr_pos) && (position < curr_line->line_length))	{		if (*point == 9)			scr_horz += tabshift(scr_horz);		else if (*point < ' ')			scr_horz += 2;		else if ((ee_chinese) && (*point > 127) && 		    ((curr_line->line_length - position) >= 2))		{			scr_horz += 2;			point++;			position++;		}		else			scr_horz++;		position++;		point++;	}	if ((scr_horz - horiz_offset) > last_col)	{		horiz_offset = (scr_horz - (scr_horz % 8)) - (COLS - 8);		midscreen(scr_vert, point);	}	else if (scr_horz < horiz_offset)	{		horiz_offset = max(0, (scr_horz - (scr_horz % 8)));		midscreen(scr_vert, point);	}	wmove(text_win, scr_vert, (scr_horz - horiz_offset));}void up()					/* move up one line		*/{	if (curr_line->prev_line != NULL)	{		prevline();		point = curr_line->line;		find_pos();	}}void down()					/* move down one line		*/{	if (curr_line->next_line != NULL)	{		nextline();		find_pos();	}}void function_key()				/* process function key		*/{	if (in == KEY_LEFT)		left(TRUE);	else if (in == KEY_RIGHT)		right(TRUE);	else if ( in == KEY_HOME)		top();	else if ( in == KEY_UP)		up();	else if (in == KEY_DOWN)		down();	else if (in == KEY_NPAGE)		move_rel("d", max( 5, (last_line - 5)));	else if (in == KEY_PPAGE)		move_rel("u", max(5, (last_line - 5)));	else if (in == KEY_DL)		del_line();	else if (in == KEY_DC)		del_char();	else if (in == KEY_BACKSPACE)		delete(TRUE);	else if (in == KEY_IL)	{		/* insert a line before current line	*/		insert_line(TRUE);		left(TRUE);	}	else if (in == KEY_F(1))		gold = !gold;	else if (in == KEY_F(2))	{		if (gold)		{			gold = FALSE;			undel_line();		}		else			undel_char();	}	else if (in == KEY_F(3))	{		if (gold)		{			gold = FALSE;			undel_word();		}		else			del_word();	}	else if (in == KEY_F(4))	{		if (gold)		{			gold = FALSE;			paint_info_win();			midscreen(scr_vert, point);		}		else			adv_word();	}	else if (in == KEY_F(5))	{		if (gold)		{			gold = FALSE;			search_prompt();		}		else			search(TRUE);	}	else if (in == KEY_F(6))	{		if (gold)		{			gold = FALSE;			bottom();		}		else			top();	}	else if (in == KEY_F(7))	{		if (gold)		{			gold = FALSE;			eol();		}		else			bol();	}	else if (in == KEY_F(8))	{		if (gold)		{			gold = FALSE;			command_prompt();		} 		else			adv_line();	}}void print_buffer(){	char buffer[256];	sprintf(buffer, ">!%s", print_command);	wmove(com_win, 0, 0);	wclrtoeol(com_win);	wprintw(com_win, printer_msg_str, print_command);	wrefresh(com_win);	command(buffer);}void command_prompt(){	char *cmd_str;	int result;	info_type = COMMANDS;	paint_info_win();	cmd_str = get_string(command_str, TRUE);	if ((result = unique_test(cmd_str, commands)) != 1)	{		werase(com_win);		wmove(com_win, 0, 0);		if (result == 0)			wprintw(com_win, unkn_cmd_str, cmd_str);		else			wprintw(com_win, non_unique_cmd_msg);		wrefresh(com_win);		info_type = CONTROL_KEYS;		paint_info_win();		if (cmd_str != NULL)			free(cmd_str);		return;	}	command(cmd_str);	wrefresh(com_win);	wmove(text_win, scr_vert, (scr_horz - horiz_offset));	info_type = CONTROL_KEYS;	paint_info_win();	if (cmd_str != NULL)		free(cmd_str);}void command(cmd_str1)		/* process commands from keyboard	*/char *cmd_str1;{	char *cmd_str2 = NULL;	char *cmd_str = cmd_str1;	clear_com_win = TRUE;	if (compare(cmd_str, HELP, FALSE))		help();	else if (compare(cmd_str, WRITE, FALSE))	{		if (restrict_mode())		{			return;		}		cmd_str = next_word(cmd_str);		if (*cmd_str == (char) NULL)		{			cmd_str = cmd_str2 = get_string(file_write_prompt_str, TRUE);		}		tmp_file = resolve_name(cmd_str);		write_file(tmp_file);		if (tmp_file != cmd_str)			free(tmp_file);	}	else if (compare(cmd_str, READ, FALSE))	{		if (restrict_mode())		{			return;		}		cmd_str = next_word(cmd_str);		if (*cmd_str == (char) NULL)		{			cmd_str = cmd_str2 = get_string(file_read_prompt_str, TRUE);		}		tmp_file = cmd_str;		recv_file = TRUE;		tmp_file = resolve_name(cmd_str);		check_fp();		if (tmp_file != cmd_str)			free(tmp_file);	}	else if (compare(cmd_str, LINE, FALSE))	{		wmove(com_win, 0, 0);		wclrtoeol(com_win);		wprintw(com_win, line_num_str, curr_line->line_number);		wprintw(com_win, line_len_str, curr_line->line_length);	}	else if (compare(cmd_str, FILE_str, FALSE))	{		wmove(com_win, 0, 0);		wclrtoeol(com_win);		if (in_file_name == NULL)			wprintw(com_win, no_file_string);		else			wprintw(com_win, current_file_str, in_file_name);	}	else if ((*cmd_str >= '0') && (*cmd_str <= '9'))		goto_line(cmd_str);	else if (compare(cmd_str, CHARACTER, FALSE))	{		wmove(com_win, 0, 0);		wclrtoeol(com_win);		wprintw(com_win, char_str, *point);	}	else if (compare(cmd_str, REDRAW, FALSE))		redraw();	else if (compare(cmd_str, RESEQUENCE, FALSE))	{		tmp_line = first_line->next_line;		while (tmp_line != NULL)		{		tmp_line->line_number = tmp_line->prev_line->line_number + 1;			tmp_line = tmp_line->next_line;		}	}	else if (compare(cmd_str, AUTHOR, FALSE))	{

⌨️ 快捷键说明

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