示例#1
0
文件: cmdline.c 项目: sklnd/vifm
static void
restore_user_input(void)
{
	input_stat.cmd_pos = -1;
	free(input_stat.line);
	input_stat.line = my_wcsdup(input_stat.line_buf);
	input_stat.len = wcslen(input_stat.line);
	update_cmdline();
}
示例#2
0
文件: cmdline.c 项目: ackeack/workenv
static void
complete_next(const hist_t *hist, size_t len)
{
	if(hist_is_empty(hist))
	{
		return;
	}

	if(input_stat.history_search != HIST_SEARCH)
	{
		if(input_stat.cmd_pos <= 0)
		{
			restore_user_input();
			return;
		}
		input_stat.cmd_pos--;
	}
	else
	{
		int pos = input_stat.cmd_pos;
		int len = input_stat.hist_search_len;
		while(--pos >= 0)
		{
			wchar_t *const buf = to_wide(hist->items[pos]);
			if(wcsncmp(input_stat.line, buf, len) == 0)
			{
				free(buf);
				break;
			}
			free(buf);
		}
		if(pos < 0)
		{
			restore_user_input();
			return;
		}
		input_stat.cmd_pos = pos;
	}

	(void)replace_input_line(hist->items[input_stat.cmd_pos]);

	update_cmdline();

	if(input_stat.cmd_pos > len - 1)
	{
		input_stat.cmd_pos = len - 1;
	}
}
示例#3
0
文件: cmdline.c 项目: ackeack/workenv
static void
complete_prev(const hist_t *hist, size_t len)
{
	if(hist_is_empty(hist))
	{
		return;
	}

	if(input_stat.history_search != HIST_SEARCH)
	{
		if(input_stat.cmd_pos == hist->pos)
			return;
		input_stat.cmd_pos++;
	}
	else
	{
		int pos = input_stat.cmd_pos;
		int len = input_stat.hist_search_len;
		while(++pos <= hist->pos)
		{
			wchar_t *buf;

			buf = to_wide(hist->items[pos]);
			if(wcsncmp(input_stat.line, buf, len) == 0)
			{
				free(buf);
				break;
			}
			free(buf);
		}
		if(pos > hist->pos)
			return;
		input_stat.cmd_pos = pos;
	}

	(void)replace_input_line(hist->items[input_stat.cmd_pos]);

	update_cmdline();

	if(input_stat.cmd_pos > len - 1)
	{
		input_stat.cmd_pos = len - 1;
	}
}