Ejemplo n.º 1
0
KHandlerResponse
filelist_khandler(FileView *view, menu_data_t *m, const wchar_t keys[])
{
	if(wcscmp(keys, L"gf") == 0)
	{
		(void)goto_selected_file(m, curr_view, m->items[m->pos], 0);
		return KHR_CLOSE_MENU;
	}
	else if(wcscmp(keys, L"e") == 0)
	{
		(void)goto_selected_file(m, curr_view, m->items[m->pos], 1);
		return KHR_REFRESH_WINDOW;
	}
	else if(wcscmp(keys, L"c") == 0)
	{
		/* Insert just file name. */
		int line_num;
		const char *const rel_base = get_relative_path_base(m, view);
		char *const path = parse_file_spec(m->items[m->pos], &line_num, rel_base);
		if(path == NULL)
		{
			show_error_msg("Command insertion", "No valid filename found");
			return KHR_REFRESH_WINDOW;
		}
		menu_morph_into_cmdline(CLS_COMMAND, path, 1);
		free(path);
		return KHR_MORPHED_MENU;
	}

	return KHR_UNHANDLED;
}
Ejemplo n.º 2
0
Archivo: menus.c Proyecto: lyuts/vifm
KHandlerResponse
filelist_khandler(menu_info *m, const wchar_t keys[])
{
	if(wcscmp(keys, L"gf") == 0)
	{
		goto_selected_file(curr_view, m->items[m->pos], 0);
		return KHR_CLOSE_MENU;
	}
	else if(wcscmp(keys, L"e") == 0)
	{
		goto_selected_file(curr_view, m->items[m->pos], 1);
		return KHR_REFRESH_WINDOW;
	}
	return KHR_UNHANDLED;
}
Ejemplo n.º 3
0
int
show_bmarks_menu(FileView *view, const char tags[], int go_on_single_match)
{
	static menu_info m;
	init_menu_info(&m, strdup("Bookmarks"), strdup("No bookmarks found"));
	m.execute_handler = &execute_bmarks_cb;
	m.key_handler = &bmarks_khandler;

	if(is_null_or_empty(tags))
	{
		bmarks_list(&bmarks_cb, &m);
	}
	else
	{
		bmarks_find(tags, &bmarks_cb, &m);
	}

	if(go_on_single_match && m.len == 1)
	{
		goto_selected_file(view, m.items[m.pos], 0);
		reset_popup_menu(&m);
		return curr_stats.save_msg;
	}

	return display_menu(&m, view);
}
Ejemplo n.º 4
0
/* Callback that is called when menu item is selected.  Should return non-zero
 * to stay in menu mode. */
static int
execute_users_cb(FileView *view, menu_info *m)
{
	const int navigate = m->extra_data;
	if(navigate)
	{
		goto_selected_file(view, m->items[m->pos], 0);
	}
	return 0;
}
Ejemplo n.º 5
0
/* Menu-specific shortcut handler.  Returns code that specifies both taken
 * actions and what should be done next. */
static KHandlerResponse
bmarks_khandler(menu_info *m, const wchar_t keys[])
{
	if(wcscmp(keys, L"dd") == 0)
	{
		bmarks_remove(m->data[m->pos]);
		remove_current_item(m);
		return KHR_REFRESH_WINDOW;
	}
	else if(wcscmp(keys, L"gf") == 0)
	{
		goto_selected_file(curr_view, m->data[m->pos], 0);
		return KHR_CLOSE_MENU;
	}
	else if(wcscmp(keys, L"e") == 0)
	{
		goto_selected_file(curr_view, m->data[m->pos], 1);
		return KHR_REFRESH_WINDOW;
	}
	/* Can't reuse filelist_khandler() here as it works with m->items, not with
	 * m->data. */
	return KHR_UNHANDLED;
}
Ejemplo n.º 6
0
TEST(can_navigate_to_broken_symlink, IF(not_windows))
{
	char *saved_cwd;

	strcpy(lwin.curr_dir, ".");

	saved_cwd = save_cwd();
	assert_success(chdir(SANDBOX_PATH));

	/* symlink() is not available on Windows, but other code is fine. */
#ifndef _WIN32
	assert_success(symlink("/wrong/path", "broken-link"));
#endif

	/* Were trying to open broken link, which will fail, but the parsing part
	 * should succeed. */
	restore_cwd(saved_cwd);
	assert_success(goto_selected_file(&lwin, SANDBOX_PATH "/broken-link:", 1));

	assert_success(remove(SANDBOX_PATH "/broken-link"));
}
Ejemplo n.º 7
0
/* Callback that is called when menu item is selected.  Should return non-zero
 * to stay in menu mode. */
static int
execute_bmarks_cb(FileView *view, menu_info *m)
{
	goto_selected_file(view, m->data[m->pos], 0);
	return 0;
}