示例#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;
}
示例#2
0
/* Menu-specific shortcut handler.  Returns code that specifies both taken
 * actions and what should be done next. */
static KHandlerResponse
commands_khandler(menu_info *m, const wchar_t keys[])
{
	if(wcscmp(keys, L"dd") == 0)
	{
		/* Remove element. */
		char cmd_buf[512];

		break_at(m->items[m->pos], ' ');
		snprintf(cmd_buf, sizeof(cmd_buf), "delcommand %s", m->items[m->pos]);
		execute_cmdline_command(cmd_buf);

		remove_current_item(m);
		return KHR_REFRESH_WINDOW;
	}
	else if(wcscmp(keys, L"c") == 0)
	{
		const char *const rhs = skip_whitespace(after_first(m->items[m->pos], ' '));
		/* Insert command RHS. */
		if(rhs[0] == ':')
		{
			menu_morph_into_cmdline(CLS_COMMAND, skip_whitespace(rhs + 1), 0);
		}
		else if(rhs[0] == '/')
		{
			menu_morph_into_cmdline(CLS_FSEARCH, rhs + 1, 0);
		}
		else if(rhs[0] == '=')
		{
			menu_morph_into_cmdline(CLS_FILTER, rhs + 1, 0);
		}
		else
		{
			/* filter commands go here. */
			menu_morph_into_cmdline(CLS_COMMAND, rhs, (rhs[0] != '!'));
		}
		return KHR_MORPHED_MENU;
	}
	return KHR_UNHANDLED;
}
示例#3
0
/* Menu-specific shortcut handler.  Returns code that specifies both taken
 * actions and what should be done next. */
static KHandlerResponse
filetypes_khandler(menu_info *m, const wchar_t keys[])
{
	if(wcscmp(keys, L"c") == 0)
	{
		const char *prog_str = after_first(m->data[m->pos], '|');
		if(prog_str[0] != '\0')
		{
			menu_morph_into_cmdline(CLS_COMMAND, prog_str, 1);
			return KHR_MORPHED_MENU;
		}
	}
	return KHR_UNHANDLED;
}
示例#4
0
/* Menu-specific shortcut handler.  Returns code that specifies both taken
 * actions and what should be done next. */
static KHandlerResponse
history_khandler(menu_info *m, const wchar_t keys[])
{
	if(wcscmp(keys, L"c") == 0)
	{
		/* Initialize to prevent possible compiler warnings. */
		CmdLineSubmode submode = CLS_COMMAND;
		switch((HistoryType)m->extra_data)
		{
			case CMDHISTORY:     submode = CLS_COMMAND; break;
			case FSEARCHHISTORY: submode = CLS_FSEARCH; break;
			case BSEARCHHISTORY: submode = CLS_BSEARCH; break;
			case FILTERHISTORY:  submode = CLS_FILTER; break;

			case PROMPTHISTORY:
				/* Can't edit prompt input. */
				return KHR_UNHANDLED;
		}

		menu_morph_into_cmdline(submode, m->items[m->pos], 0);
		return KHR_MORPHED_MENU;
	}
	return KHR_UNHANDLED;
}