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

📄 control.c

📁 aee是一种易使用的文本编辑器。你可以不用说明书来使用它。它提供终端接口和本地的X-windows接口。它的特性包括即弹的菜单
💻 C
📖 第 1 页 / 共 4 页
字号:
					if (counter < right_margin)						left_margin = counter;					else					{						wmove(com_win, 0, 0);						werase(com_win);						wprintw(com_win, left_mrgn_err_msg);						wrefresh(com_win);					}					free(string);				}				break;			case 13:				string = get_string(right_mrgn_prompt, TRUE);				if (string != NULL)				{					counter = atoi(string);					if (counter > left_margin)						right_margin = counter;					else					{						wmove(com_win, 0, 0);						werase(com_win);						wprintw(com_win, right_mrgn_err_msg);						wrefresh(com_win);					}					free(string);				}				break;			case 14:				temp_int = info_win_height;				string = get_string(info_win_height_prompt, TRUE);				if (string != NULL)				{					counter = atoi(string);					if ((counter > 0) && (counter <= MAX_HELP_LINES))						info_win_height = counter + 1;					else					{						wmove(com_win, 0, 0);						werase(com_win);						wprintw(com_win, info_win_height_err);						wrefresh(com_win);					}					free(string);					if ((info_win_height != temp_int) && (info_window))					{						redo_win();						curr_buff->last_line = curr_buff->lines - 1;						new_screen();						paint_info_win();						redraw();					}				}				break;			case 15:				text_only = !text_only;				break;			case 16:				if (text_only)					curr_buff->dos_file = !curr_buff->dos_file;				break;			case 17:				dump_aee_conf();				break;			default:				break;		}	}	while (ret_value != 0);}void search_op(){	search(TRUE, curr_buff->curr_line, curr_buff->position, curr_buff->pointer, 0, FALSE, TRUE);}int file_op(arg)int arg;{	char *string;	int flag;	if (restrict_mode())	{		return(1);	}	if (arg == READ_FILE)	{		string = get_string(file_read_prompt_str, TRUE);		recv_file = TRUE;		tmp_file = resolve_name(string);		check_fp();		if (tmp_file != string)			free(tmp_file);		free(string);	}	else if (arg == WRITE_FILE)	{		string = get_string(file_write_prompt_str, TRUE);		tmp_file = resolve_name(string);		write_file(tmp_file);		if (tmp_file != string)			free(tmp_file);		free(string);	}	else if (arg == SAVE_FILE)	{	/*	 |	changes made here should be reflected in finish()	 */		if (!curr_buff->edit_buffer)			chng_buf(main_buffer_name);		if (!curr_buff->changed)		{			wmove(com_win, 0, 0);			wprintw(com_win, no_chng_no_save );			wclrtoeol(com_win);			wrefresh(com_win);			return(0);		}		string = curr_buff->full_name;		if ((string != NULL) && (*string != (char)NULL))			flag = TRUE;		else			flag = FALSE;		if ((string == NULL) || (*string == (char) NULL))			string = get_string(save_file_name_prompt, TRUE);		if ((string == NULL) || (*string == (char) NULL))		{			wmove(com_win, 0, 0);			wprintw(com_win, file_not_saved_msg );			wclrtoeol(com_win);			wrefresh(com_win);			clr_cmd_line = TRUE;			return(0);		}		if (!flag)		{			tmp_file = resolve_name(string);			if (tmp_file != string)			{				free(string);				string = tmp_file;			}		}		if (write_file(string))		{			if (curr_buff->file_name == NULL)			{				curr_buff->full_name = get_full_path(string, 							curr_buff->orig_dir);				curr_buff->file_name = 					ae_basename(curr_buff->full_name);			}			curr_buff->changed = FALSE;			change = FALSE;		}		else 		{			if (!flag)				free(string);			return(1);		}	}	return(0);}void info_op(){	info_window = !info_window;	redo_win();	curr_buff->last_line = curr_buff->lines - 1;	new_screen();	if (info_window)		paint_info_win();	redraw();}int macro_assign(keys, macro_string)char *keys[];char *macro_string;{	int counter;	char *temp;	for (counter = 0; counter < 32; counter++)	{		temp = keys[counter];		if (compare(temp, macro_string, FALSE))		{			temp = next_word(temp);			if (*temp == (char) NULL)				return(counter);		}	}	return(-1);}void get_key_assgn(){	int counter;	int local_index;	assignment[gold_key_index].ckey = 0;	if ((local_index = macro_assign(ctr, assignment[gold_key_index].macro)) != -1)	{		assignment[gold_key_index].ckey = local_index;	}	for (counter = 1; counter < gold_key_index; counter++)	{		assignment[counter].ckey = -1;		assignment[counter].gckey = -1;		if ((local_index = macro_assign(ctr, assignment[counter].macro)) != -1)		{			assignment[counter].ckey = local_index;		}		if (((local_index = macro_assign(g_ctr, assignment[counter].macro)) != -1) && (assignment[gold_key_index].ckey))		{			assignment[counter].gckey = local_index;		}	}	paint_information();}void paint_information(){	int counter;	int local_index;	int line_index;	int column, width;	char buffer[64];	for (counter = 0; counter < (info_win_height - 1); counter++)	{		info_data[counter][0] = (char) NULL;	}	width = 0;	column = 0;	for (counter = 0, local_index = 1; 		((width + column) <= min(COLS, MAX_HELP_COLS)) && 			(local_index < (gold_key_index + 1)) &&			(assignment[local_index].macro != NULL); 						counter++, local_index++)	{		line_index = counter % (info_win_height - 1);		if (line_index == 0)			column += width;		while ((assignment[local_index].ckey < 0) && 				(assignment[local_index].gckey < 0) &&				(assignment[local_index].macro != NULL))			local_index++;		if (local_index > gold_key_index)			break;		if (assignment[local_index].ckey >= 0)		{			if (assignment[local_index].ckey  == 26) 						/* corresponds with Escape */				sprintf(buffer, "Esc  %s ", 					assignment[local_index].description);			else				sprintf(buffer, "^%c   %s ", 					(assignment[local_index].ckey + 'A'), 					assignment[local_index].description);		}		else if (assignment[local_index].gckey > 0)			sprintf(buffer, "^%c^%c %s ", 				(assignment[gold_key_index].ckey + 'A'), 				(assignment[local_index].gckey + 'A'), 				assignment[local_index].description);		width = max(width, strlen(buffer));		if ((width + column) <= min(COLS, MAX_HELP_COLS))			strcat(info_data[line_index], buffer);	}}void paint_info_win(){	int counter;	int width, column;	int index;	if ((!info_window) || (info_win == 0))		return;        werase(info_win);	if (info_type == COMMANDS)	{		index = 0;		for (column = 0; column < COLS && (commands[index] != NULL); 							  column += width + 1)		{			width = 0;			for (counter = 0; 				counter < (info_win_height - 1) && 					(commands[index] != NULL); 								counter++)			{				width = max(width, strlen(commands[index]));				if ((width + column) < COLS)				{					wmove(info_win, counter, column);					waddstr(info_win, commands[index]);				}				index++;			}		}	}	else if (info_type == CONTROL_KEYS)	{		for (counter = 0; counter < (info_win_height - 1); counter++)		{			wmove(info_win, counter, 0);			wclrtoeol(info_win);			waddstr(info_win, info_data[counter]);		}	}	wmove(info_win, (info_win_height - 1), 0);	if (!nohighlight)		wstandout(info_win);	wprintw(info_win, info_help_msg);	for (counter = strlen(info_help_msg); counter < COLS; counter++)		waddch(info_win, '=');	wstandend(info_win);	wrefresh(info_win);}/* |	The following routine tests the input string against the list of  |	strings, to determine if the string is a unique match with one of the  |	valid values. */int unique_test(string, list)char *string;char *list[];{	int counter;	int num_match;	int result;	num_match = 0;	counter = 0;	while (list[counter] != NULL)	{		result = compare(string, list[counter], FALSE);		if (result)			num_match++;		counter++;	}	return(num_match);}void command_prompt(){	char *cmd_str;	int result;	info_type = COMMANDS;	paint_info_win();	cmd_str = get_string(cmd_prompt, 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_msg, 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);	info_type = CONTROL_KEYS;	paint_info_win();	if (cmd_str != NULL)		free(cmd_str);}void command(cmd_str)	/* process commands from command line	*/char *cmd_str;{	char *cmd_str2;	char *c_temp;	char *name;	char *tmp;	char dir;	int alloc_space;	/* have we allocated more space ?	*/	int c_int;	int retval;	int gold_flag;	int temp_int;	struct tab_stops *temp_stack;	clr_cmd_line = TRUE;	alloc_space = FALSE;	cmd_str2 = cmd_str;	if (compare(cmd_str, EXPAND_str, FALSE))		expand = TRUE;	else if (compare(cmd_str, NOEXPAND_str, FALSE))		expand = FALSE;	else if (compare(cmd_str, NOJUSTIFY_str, FALSE))		right_justify = FALSE;	else if (compare(cmd_str, JUSTIFY_str, FALSE))		right_justify = TRUE;	else if (compare(cmd_str, EXIT_str, FALSE))		finish(cmd_str);	else if (compare(cmd_str, QUIT_str, FALSE))		quit(cmd_str);	else if (compare(cmd_str, AUTOFORMAT_str, FALSE))	{		auto_format = TRUE;		observ_margins = TRUE;		indent = FALSE;	}	else if (compare(cmd_str, NOAUTOFORMAT_str, FALSE))		auto_format = FALSE;	else if (compare(cmd_str, INFO_str, FALSE))	{		if (info_window == FALSE)			info_op();	}	else if (compare(cmd_str, NOINFO_str, FALSE))	{		if (info_window == TRUE)			info_op();	}	else if (compare(cmd_str, TABS_str, FALSE))	{		cmd_str = next_word(cmd_str);		if (*cmd_str != (char) NULL)		{			tab_set(cmd_str);			new_screen();		}		else		{			temp_stack = tabs->next_stop;			werase(com_win);			wmove(com_win, 0, 0);			wprintw(com_win, tab_msg);			while (temp_stack != NULL)			{				wprintw(com_win, "%d ", temp_stack->column);				temp_stack = temp_stack->next_stop;			}		}	}	else if (compare(cmd_str, UNTABS_str, FALSE))	{		unset_tab(cmd_str);		new_screen();	}	else if (compare(cmd_str, SPACING_str, FALSE))	{		cmd_str2 = next_word(cmd_str);		if (*cmd_str2 != (char) NULL)		{			tab_spacing = atoi(cmd_str2);			midscreen(curr_buff->scr_vert, curr_buff->position);		}		else		{			werase(com_win);			wmove(com_win, 0, 0);			wprintw(com_win, SPACING_msg, tab_spacing);		}	}	else if (compare(cmd_str, WRITE_str, FALSE))	{		if (restrict_mode())		{			return;		}		cmd_str2 = next_word(cmd_str);		if (*cmd_str2 == (char) NULL)		{			alloc_space = TRUE;			cmd_str2 = get_string(file_write_prompt_str, TRUE);		}		tmp = cmd_str2;		while ((*tmp != ' ') && (*tmp != '\t') && (*tmp != (char) NULL))			tmp++;		*tmp = (char) NULL;		tmp_file = resolve_name(cmd_str2);		write_file(tmp_file);		if (tmp_file != cmd_str2)			free(tmp_file);		if (alloc_space)			free(cmd_str2);	}	else if (compare(cmd_str, READ_str, FALSE))	{		if (restrict_mode())		{			return;		}		cmd_str2 = next_word(cmd_str);

⌨️ 快捷键说明

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