Exemplo n.º 1
0
/* Tries to navigate to menu search match specified via pos argument.  If pos is
 * negative, match wasn't found and the message is printed.  Returns new value
 * for save_msg flag. */
static int
navigate_to_match(menu_state_t *m, int pos)
{
	if(pos > -1)
	{
		if(!m->search_highlight)
		{
			/* Might need to highlight other items, so redraw whole menu. */
			m->search_highlight = 1;
			m->d->pos = pos;
			draw_menu(m);
		}
		else
		{
			menu_current_line_erase(m);
			move_to_menu_pos(pos, m);
		}
		menu_print_search_msg(m);
	}
	else
	{
		move_to_menu_pos(m->d->pos, m);
		if(cfg.wrap_scan)
		{
			menu_print_search_msg(m);
		}
	}
	return 1;
}
Exemplo n.º 2
0
static int
search_menu_backwards(menu_info *m, int start_pos)
{
	int match_up = -1;
	int match_down = -1;
	int x;

	for(x = m->len - 1; x > -1; x--)
	{
		if(!m->matches[x])
			continue;

		if(match_up < 0)
		{
			if(x <= start_pos)
				match_up = x;
		}
		if(match_down < 0)
		{
			if(x > start_pos)
				match_down = x;
		}
	}

	if(match_up > -1 || match_down > -1)
	{
		int pos;

		if(!cfg.wrap_scan && match_up <= -1)
		{
			status_bar_errorf("Search hit TOP without match for: %s", m->regexp);
			return 1;
		}

		pos = (match_up > -1) ? match_up : match_down;

		clean_menu_position(m);
		move_to_menu_pos(pos, m);
		status_bar_messagef("%d %s", m->matching_entries,
				(m->matching_entries == 1) ? "match" : "matches");
	}
	else
	{
		move_to_menu_pos(m->pos, m);
		if(!cfg.wrap_scan)
			status_bar_errorf("Search hit TOP without match for: %s", m->regexp);
		else
			status_bar_errorf("No matches for: %s", m->regexp);
		return 1;
	}
	return 0;
}
Exemplo n.º 3
0
Arquivo: menu.c Projeto: cfillion/vifm
static void
cmd_L(key_info_t key_info, keys_info_t *keys_info)
{
	int top;
	int off;
	if(menu->key_handler != NULL)
	{
		if(pass_combination_to_khandler(L"L"))
		{
			return;
		}
	}

	off = MAX(cfg.scroll_off, 0);
	if(off > menu->win_rows/2)
		return;

	if(menu->top + menu->win_rows < menu->len - 1)
		top = menu->top + menu->win_rows - off;
	else
		top = menu->top + menu->win_rows;

	clean_menu_position(menu);
	move_to_menu_pos(top - 3, menu);
	wrefresh(menu_win);
}
Exemplo n.º 4
0
void
remove_current_item(menu_state_t *ms)
{
	menu_data_t *const m = ms->d;
	menu_current_line_erase(ms);

	remove_from_string_array(m->items, m->len, m->pos);

	if(m->data != NULL)
	{
		remove_from_string_array(m->data, m->len, m->pos);
	}

	if(m->void_data != NULL)
	{
		memmove(m->void_data + m->pos, m->void_data + m->pos + 1,
				sizeof(*m->void_data)*((m->len - 1) - m->pos));
	}

	if(ms->matches != NULL)
	{
		if(ms->matches[m->pos][0] >= 0)
		{
			--ms->matching_entries;
		}
		memmove(ms->matches + m->pos, ms->matches + m->pos + 1,
				sizeof(*ms->matches)*((m->len - 1) - m->pos));
	}

	--m->len;
	draw_menu(ms);

	move_to_menu_pos(m->pos, ms);
}
Exemplo n.º 5
0
Arquivo: menu.c Projeto: cfillion/vifm
void
update_menu(void)
{
	draw_menu(menu);
	move_to_menu_pos(menu->pos, menu);
	wrefresh(menu_win);
}
Exemplo n.º 6
0
int
search_menu_list(const char *pattern, menu_info *m)
{
	int save = 0;
	int i;

	if(pattern != NULL)
	{
		m->regexp = strdup(pattern);
		if(search_menu(m, m->pos) != 0)
		{
			draw_menu(m);
			move_to_menu_pos(m->pos, m);
			return 1;
		}
		draw_menu(m);
	}

	for(i = 0; i < search_repeat; i++)
		switch(m->match_dir)
		{
			case NONE:
				save = search_menu_forwards(m, m->pos + 1);
				break;
			case UP:
				save = search_menu_backwards(m, m->pos - 1);
				break;
			case DOWN:
				save = search_menu_forwards(m, m->pos + 1);
				break;
			default:
				break;
		}
	return save;
}
Exemplo n.º 7
0
Arquivo: menu.c Projeto: cfillion/vifm
static void
cmd_gg(key_info_t key_info, keys_info_t *keys_info)
{
	if(key_info.count == NO_COUNT_GIVEN)
		key_info.count = 1;

	clean_menu_position(menu);
	move_to_menu_pos(key_info.count - 1, menu);
	wrefresh(menu_win);
}
Exemplo n.º 8
0
Arquivo: menus.c Projeto: lyuts/vifm
void
redraw_menu(menu_info *m)
{
	resize_for_menu_like();
	m->win_rows = getmaxy(menu_win);

	draw_menu(m);
	move_to_menu_pos(m->pos, m);
	wrefresh(menu_win);
}
Exemplo n.º 9
0
Arquivo: menu.c Projeto: cfillion/vifm
static int
goto_cmd(const cmd_info_t *cmd_info)
{
	if(cmd_info->end == NOT_DEF)
		return 0;
	clean_menu_position(menu);
	move_to_menu_pos(cmd_info->end, menu);
	wrefresh(menu_win);
	return 0;
}
Exemplo n.º 10
0
static void
cmd_M(key_info_t key_info, keys_info_t *keys_info)
{
	int new_pos;
	if(menu->len < menu->win_rows)
		new_pos = menu->len/2;
	else
		new_pos = menu->top + (menu->win_rows - 3)/2;

	clean_menu_position(menu);
	move_to_menu_pos(new_pos, menu);
	wrefresh(menu_win);
}
Exemplo n.º 11
0
Arquivo: menu.c Projeto: cfillion/vifm
static void
cmd_k(key_info_t key_info, keys_info_t *keys_info)
{
	if(menu->pos == 0)
		return;
	if(key_info.count == NO_COUNT_GIVEN)
		key_info.count = 1;

	clean_menu_position(menu);
	menu->pos -= key_info.count;
	move_to_menu_pos(menu->pos, menu);
	wrefresh(menu_win);
}
Exemplo n.º 12
0
Arquivo: menu.c Projeto: cfillion/vifm
/* Moves cursor to the middle of the window. */
static void
cmd_M(key_info_t key_info, keys_info_t *keys_info)
{
	int new_pos;
	if(menu->len < menu->win_rows)
		new_pos = DIV_ROUND_UP(menu->len, 2);
	else
		new_pos = menu->top + DIV_ROUND_UP(menu->win_rows - 3, 2);

	clean_menu_position(menu);
	move_to_menu_pos(MAX(0, new_pos - 1), menu);
	wrefresh(menu_win);
}
Exemplo n.º 13
0
void
redraw_menu(menu_state_t *m)
{
	if(resize_for_menu_like() != 0)
	{
		return;
	}

	m->win_rows = getmaxy(menu_win);

	draw_menu(m);
	move_to_menu_pos(m->d->pos, m);
	wrefresh(menu_win);
}
Exemplo n.º 14
0
Arquivo: menu.c Projeto: cfillion/vifm
static void
cmd_H(key_info_t key_info, keys_info_t *keys_info)
{
	int top;
	int off = MAX(cfg.scroll_off, 0);
	if(off > menu->win_rows/2)
		return;

	if(menu->top == 0)
		top = 0;
	else
		top = menu->top + off;

	clean_menu_position(menu);
	move_to_menu_pos(top, menu);
	wrefresh(menu_win);
}
Exemplo n.º 15
0
int
display_menu(menu_state_t *m, FileView *view)
{
	if(m->d->len < 1)
	{
		status_bar_message(m->d->empty_msg);
		reset_menu_data(m->d);
		return 1;
	}

	init_menu_state(m, view);

	setup_menu();
	draw_menu(m);
	move_to_menu_pos(m->d->pos, m);
	enter_menu_mode(m->d, view);
	return 0;
}
Exemplo n.º 16
0
Arquivo: menus.c Projeto: lyuts/vifm
int
display_menu(menu_info *m, FileView *view)
{
	if(m->len < 1)
	{
		status_bar_message(m->empty_msg);
		reset_popup_menu(m);
		return 1;
	}
	else
	{
		setup_menu();
		draw_menu(m);
		move_to_menu_pos(m->pos, m);
		enter_menu_mode(m, view);
		return 0;
	}
}
Exemplo n.º 17
0
Arquivo: menus.c Projeto: lyuts/vifm
void
remove_current_item(menu_info *m)
{
	clean_menu_position(m);

	remove_from_string_array(m->items, m->len, m->pos);
	if(m->matches != NULL)
	{
		if(m->matches[m->pos])
			m->matching_entries--;
		memmove(m->matches + m->pos, m->matches + m->pos + 1,
				sizeof(int)*((m->len - 1) - m->pos));
	}
	m->len--;
	draw_menu(m);

	move_to_menu_pos(m->pos, m);
}
Exemplo n.º 18
0
int
search_menu_list(const char pattern[], menu_data_t *m, int print_errors)
{
	menu_state_t *const ms = m->state;
	const int do_search = (pattern != NULL || ms->matches == NULL);
	int save = 0;
	int i;

	if(pattern != NULL)
	{
		replace_string(&ms->regexp, pattern);
	}

	if(do_search)
	{
		/* Reactivate match highlighting on search. */
		ms->search_highlight = 1;
		if(search_menu(ms, m->pos, print_errors) != 0)
		{
			draw_menu(ms);
			move_to_menu_pos(m->pos, ms);
			return -1;
		}
		draw_menu(ms);
	}

	for(i = 0; i < ms->search_repeat; ++i)
	{
		if(ms->backward_search)
		{
			save = search_menu_backwards(ms, m->pos - 1);
		}
		else
		{
			save = search_menu_forwards(ms, m->pos + 1);
		}
	}
	return save;
}