Example #1
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;
	}
	return KHR_UNHANDLED;
}
Example #2
0
/* Menu-specific shortcut handler.  Returns code that specifies both taken
 * actions and what should be done next. */
static KHandlerResponse
commands_khandler(FileView *view, menu_data_t *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), "cunabbrev %s", m->items[m->pos]);
		execute_cmdline_command(cmd_buf);

		remove_current_item(m->state);
		return KHR_REFRESH_WINDOW;
	}
	return KHR_UNHANDLED;
}
Example #3
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;
}