1999-11-18 20:05:24 -08:00
|
|
|
/*
|
2009-10-25 11:35:54 -07:00
|
|
|
* Copyright (C) 1997-2009, Michael Jennings
|
1999-08-17 18:12:47 -07:00
|
|
|
*
|
1999-11-18 20:05:24 -08:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
1999-08-17 18:12:47 -07:00
|
|
|
*
|
1999-11-18 20:05:24 -08:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies of the Software, its documentation and marketing & publicity
|
|
|
|
* materials, and acknowledgment shall be given in the documentation, materials
|
|
|
|
* and software packages that this Software was used.
|
1999-08-17 18:12:47 -07:00
|
|
|
*
|
1999-11-18 20:05:24 -08:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1999-08-17 18:12:47 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
static const char cvs_ident[] = "$Id$";
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "feature.h"
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <limits.h>
|
|
|
|
|
1999-10-07 15:18:14 -07:00
|
|
|
#include "startup.h"
|
1999-08-17 18:12:47 -07:00
|
|
|
#include "actions.h"
|
|
|
|
#include "command.h"
|
|
|
|
#include "e.h"
|
|
|
|
#include "events.h"
|
|
|
|
#include "menus.h"
|
|
|
|
#include "options.h"
|
|
|
|
#include "pixmap.h"
|
|
|
|
#include "screen.h"
|
2001-05-07 22:17:36 -07:00
|
|
|
#include "script.h"
|
1999-08-17 18:12:47 -07:00
|
|
|
#include "scrollbar.h"
|
|
|
|
#include "term.h"
|
|
|
|
#include "windows.h"
|
2002-06-02 17:24:22 -07:00
|
|
|
#ifdef ESCREEN
|
|
|
|
# include "screamcfg.h"
|
|
|
|
#endif
|
1999-08-17 18:12:47 -07:00
|
|
|
|
2009-10-07 20:47:32 -07:00
|
|
|
static spif_bool_t action_handle_string(event_t *ev, spif_eterm_action_t action);
|
|
|
|
static spif_bool_t action_handle_echo(event_t *ev, spif_eterm_action_t action);
|
|
|
|
static spif_bool_t action_handle_script(event_t *ev, spif_eterm_action_t action);
|
|
|
|
static spif_bool_t action_handle_menu(event_t *ev, spif_eterm_action_t action);
|
|
|
|
static spif_bool_t action_check_button(spif_uchar_t button, int x_button);
|
|
|
|
static spif_bool_t action_check_keysym(KeySym keysym, KeySym x_keysym);
|
|
|
|
static spif_bool_t action_check_modifiers(spif_ushort_t mod, int x_mod);
|
|
|
|
static spif_bool_t action_matches_event(spif_eterm_action_t action, event_t *ev);
|
1999-08-17 18:12:47 -07:00
|
|
|
|
2009-10-07 20:47:32 -07:00
|
|
|
/* Global action list. FIXME: Should be member of terminal object. */
|
|
|
|
spif_vector_t actions = NULL;
|
|
|
|
|
|
|
|
/* *INDENT-OFF* */
|
|
|
|
static SPIF_CONST_TYPE(class) ea_class = {
|
|
|
|
SPIF_DECL_CLASSNAME(eterm_action),
|
|
|
|
(spif_func_t) spif_eterm_action_new,
|
|
|
|
(spif_func_t) spif_eterm_action_init,
|
|
|
|
(spif_func_t) spif_eterm_action_done,
|
|
|
|
(spif_func_t) spif_eterm_action_del,
|
|
|
|
(spif_func_t) spif_eterm_action_show,
|
|
|
|
(spif_func_t) spif_eterm_action_comp,
|
|
|
|
(spif_func_t) spif_eterm_action_dup,
|
|
|
|
(spif_func_t) spif_eterm_action_type
|
|
|
|
};
|
|
|
|
SPIF_TYPE(class) SPIF_CLASS_VAR(eterm_action) = &ea_class;
|
|
|
|
/* *INDENT-ON* */
|
|
|
|
|
|
|
|
spif_eterm_action_t
|
|
|
|
spif_eterm_action_new(void)
|
|
|
|
{
|
|
|
|
spif_eterm_action_t self;
|
|
|
|
|
|
|
|
self = SPIF_ALLOC(eterm_action);
|
|
|
|
if (!spif_eterm_action_init(self)) {
|
|
|
|
SPIF_DEALLOC(self);
|
2010-09-12 23:36:22 -07:00
|
|
|
self = (spif_eterm_action_t) NULL;
|
2009-10-07 20:47:32 -07:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
spif_eterm_action_t
|
|
|
|
spif_eterm_action_new_from_data(spif_eterm_action_type_t type, spif_ushort_t modifiers,
|
|
|
|
spif_uchar_t button, KeySym keysym, spif_ptr_t param)
|
|
|
|
{
|
|
|
|
spif_eterm_action_t self;
|
|
|
|
|
|
|
|
self = SPIF_ALLOC(eterm_action);
|
|
|
|
if (!spif_eterm_action_init_from_data(self, type, modifiers, button, keysym, param)) {
|
|
|
|
SPIF_DEALLOC(self);
|
2010-09-12 23:36:22 -07:00
|
|
|
self = (spif_eterm_action_t) NULL;
|
2009-10-07 20:47:32 -07:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
spif_bool_t
|
|
|
|
spif_eterm_action_del(spif_eterm_action_t self)
|
|
|
|
{
|
|
|
|
spif_eterm_action_done(self);
|
|
|
|
SPIF_DEALLOC(self);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
spif_bool_t
|
|
|
|
spif_eterm_action_init(spif_eterm_action_t self)
|
|
|
|
{
|
|
|
|
spif_obj_init(SPIF_OBJ(self));
|
|
|
|
spif_obj_set_class(SPIF_OBJ(self), SPIF_CLASS_VAR(eterm_action));
|
|
|
|
self->type = ETERM_ACTION_NONE;
|
|
|
|
self->modifiers = ETERM_MOD_NONE;
|
|
|
|
self->button = ETERM_BUTTON_NONE;
|
|
|
|
self->keysym = ETERM_KEYSYM_NONE;
|
2010-09-12 23:36:22 -07:00
|
|
|
self->handler = (spif_eterm_action_handler_t) NULL;
|
|
|
|
self->parameter = (spif_eterm_action_parameter_t) NULL;
|
2009-10-07 20:47:32 -07:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
spif_bool_t
|
|
|
|
spif_eterm_action_init_from_data(spif_eterm_action_t self, spif_eterm_action_type_t type,
|
|
|
|
spif_ushort_t modifiers, spif_uchar_t button, KeySym keysym, spif_ptr_t param)
|
|
|
|
{
|
|
|
|
spif_obj_init(SPIF_OBJ(self));
|
|
|
|
spif_obj_set_class(SPIF_OBJ(self), SPIF_CLASS_VAR(eterm_action));
|
|
|
|
self->type = type;
|
|
|
|
self->modifiers = modifiers;
|
|
|
|
self->button = button;
|
|
|
|
self->keysym = keysym;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case ETERM_ACTION_STRING:
|
2010-09-12 23:36:22 -07:00
|
|
|
self->handler = (spif_eterm_action_handler_t) action_handle_string;
|
|
|
|
self->parameter = (spif_obj_t) spif_str_new_from_ptr(param);
|
2009-10-07 20:47:32 -07:00
|
|
|
/*parse_escaped_string(self->parameter.string); */
|
|
|
|
break;
|
|
|
|
case ETERM_ACTION_ECHO:
|
2010-09-12 23:36:22 -07:00
|
|
|
self->handler = (spif_eterm_action_handler_t) action_handle_echo;
|
|
|
|
self->parameter = (spif_obj_t) spif_str_new_from_ptr(param);
|
2009-10-07 20:47:32 -07:00
|
|
|
/*parse_escaped_string(self->parameter.string); */
|
|
|
|
break;
|
|
|
|
case ETERM_ACTION_SCRIPT:
|
2010-09-12 23:36:22 -07:00
|
|
|
self->handler = (spif_eterm_action_handler_t) action_handle_script;
|
|
|
|
self->parameter = (spif_obj_t) spif_str_new_from_ptr(param);
|
2009-10-07 20:47:32 -07:00
|
|
|
break;
|
|
|
|
case ETERM_ACTION_MENU:
|
2010-09-12 23:36:22 -07:00
|
|
|
self->handler = (spif_eterm_action_handler_t) action_handle_menu;
|
2009-10-07 20:47:32 -07:00
|
|
|
/*self->parameter.menu = (menu_t *) param; */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
D_ACTIONS(("Added action. modifiers == 0x%08x, button == %d, keysym == 0x%08x\n",
|
2010-09-12 23:36:22 -07:00
|
|
|
self->modifiers, self->button, (unsigned) self->keysym));
|
2009-10-07 20:47:32 -07:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
spif_bool_t
|
|
|
|
spif_eterm_action_done(spif_eterm_action_t self)
|
|
|
|
{
|
|
|
|
if (!SPIF_OBJ_ISNULL(self->parameter)) {
|
|
|
|
if ((self->type == ETERM_ACTION_STRING)
|
|
|
|
|| (self->type == ETERM_ACTION_ECHO)
|
|
|
|
|| (self->type == ETERM_ACTION_SCRIPT)) {
|
|
|
|
spif_str_del(SPIF_STR(self->parameter));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
self->type = ETERM_ACTION_NONE;
|
|
|
|
self->modifiers = ETERM_MOD_NONE;
|
|
|
|
self->button = ETERM_BUTTON_NONE;
|
|
|
|
self->keysym = ETERM_KEYSYM_NONE;
|
2010-09-12 23:36:22 -07:00
|
|
|
self->handler = (spif_eterm_action_handler_t) NULL;
|
|
|
|
self->parameter = (spif_eterm_action_parameter_t) NULL;
|
2009-10-07 20:47:32 -07:00
|
|
|
spif_obj_done(SPIF_OBJ(self));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
spif_str_t
|
|
|
|
spif_eterm_action_show(spif_eterm_action_t self, spif_charptr_t name, spif_str_t buff, size_t indent)
|
|
|
|
{
|
|
|
|
char tmp[4096];
|
|
|
|
|
|
|
|
if (SPIF_ETERM_ACTION_ISNULL(self)) {
|
|
|
|
SPIF_OBJ_SHOW_NULL(eterm_action, name, buff, indent, tmp);
|
|
|
|
return buff;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(tmp, ' ', indent);
|
|
|
|
snprintf(tmp + indent, sizeof(tmp) - indent, "(spif_eterm_action_t) %s: {\n", name);
|
|
|
|
if (SPIF_STR_ISNULL(buff)) {
|
|
|
|
buff = spif_str_new_from_ptr(tmp);
|
|
|
|
} else {
|
|
|
|
spif_str_append_from_ptr(buff, tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(tmp + indent, sizeof(tmp) - indent, " (spif_eterm_action_type_t) type: %d\n", self->type);
|
|
|
|
spif_str_append_from_ptr(buff, tmp);
|
|
|
|
snprintf(tmp + indent, sizeof(tmp) - indent, " (spif_ushort_t) modifiers: %c%c%c%c\n", SHOW_MODS(self->modifiers));
|
|
|
|
spif_str_append_from_ptr(buff, tmp);
|
|
|
|
snprintf(tmp + indent, sizeof(tmp) - indent, " (spif_uchar_t) button: %d\n", self->button);
|
|
|
|
spif_str_append_from_ptr(buff, tmp);
|
2010-09-12 23:36:22 -07:00
|
|
|
snprintf(tmp + indent, sizeof(tmp) - indent, " (KeySym) keysym: %04x\n", (unsigned) self->keysym);
|
2009-10-07 20:47:32 -07:00
|
|
|
|
|
|
|
spif_str_append_from_ptr(buff, tmp);
|
|
|
|
snprintf(tmp + indent, sizeof(tmp) - indent, " (spif_eterm_action_handler_t) handler: %10p\n", self->handler);
|
|
|
|
spif_str_append_from_ptr(buff, tmp);
|
|
|
|
snprintf(tmp + indent, sizeof(tmp) - indent, " (spif_eterm_action_parameter_t) parameter: %10p\n", self->parameter);
|
|
|
|
spif_str_append_from_ptr(buff, tmp);
|
|
|
|
|
|
|
|
snprintf(tmp + indent, sizeof(tmp) - indent, "}\n");
|
|
|
|
spif_str_append_from_ptr(buff, tmp);
|
|
|
|
return buff;
|
|
|
|
}
|
|
|
|
|
|
|
|
spif_cmp_t
|
|
|
|
spif_eterm_action_comp(spif_eterm_action_t self, spif_eterm_action_t other)
|
2001-05-18 23:56:45 -07:00
|
|
|
{
|
2009-10-07 20:47:32 -07:00
|
|
|
spif_cmp_t c;
|
|
|
|
|
|
|
|
SPIF_OBJ_COMP_CHECK_NULL(self, other);
|
2010-09-12 23:36:22 -07:00
|
|
|
c = SPIF_CMP_FROM_INT((int) (self->type) - (int) (other->type));
|
2009-10-07 20:47:32 -07:00
|
|
|
|
|
|
|
if (!SPIF_CMP_IS_EQUAL(c)) {
|
|
|
|
return c;
|
|
|
|
}
|
2010-09-12 23:36:22 -07:00
|
|
|
c = SPIF_CMP_FROM_INT((int) (self->button) - (int) (other->button));
|
2009-10-07 20:47:32 -07:00
|
|
|
|
|
|
|
if (!SPIF_CMP_IS_EQUAL(c)) {
|
|
|
|
return c;
|
|
|
|
}
|
2010-09-12 23:36:22 -07:00
|
|
|
c = SPIF_CMP_FROM_INT((int) (self->keysym) - (int) (other->keysym));
|
2009-10-07 20:47:32 -07:00
|
|
|
|
|
|
|
if (!SPIF_CMP_IS_EQUAL(c)) {
|
|
|
|
return c;
|
|
|
|
}
|
2010-09-12 23:36:22 -07:00
|
|
|
return SPIF_CMP_FROM_INT((int) (self->modifiers) - (int) (other->modifiers));
|
2009-10-07 20:47:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
spif_eterm_action_t
|
|
|
|
spif_eterm_action_dup(spif_eterm_action_t self)
|
|
|
|
{
|
|
|
|
spif_eterm_action_t tmp;
|
|
|
|
|
2010-09-12 23:36:22 -07:00
|
|
|
REQUIRE_RVAL(!SPIF_ETERM_ACTION_ISNULL(self), (spif_eterm_action_t) NULL);
|
2009-10-07 20:47:32 -07:00
|
|
|
tmp = spif_eterm_action_new();
|
|
|
|
tmp->type = self->type;
|
|
|
|
tmp->modifiers = self->modifiers;
|
|
|
|
tmp->button = self->button;
|
|
|
|
tmp->keysym = self->keysym;
|
|
|
|
tmp->handler = self->handler;
|
|
|
|
tmp->parameter = self->parameter;
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
spif_classname_t
|
|
|
|
spif_eterm_action_type(spif_eterm_action_t self)
|
|
|
|
{
|
|
|
|
return SPIF_OBJ_CLASSNAME(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
SPIF_DEFINE_PROPERTY_FUNC_NONOBJ(eterm_action, eterm_action_type, type);
|
|
|
|
SPIF_DEFINE_PROPERTY_FUNC_NONOBJ(eterm_action, ushort, modifiers);
|
|
|
|
SPIF_DEFINE_PROPERTY_FUNC_NONOBJ(eterm_action, uchar, button);
|
|
|
|
SPIF_DEFINE_PROPERTY_FUNC_C(eterm_action, KeySym, keysym);
|
|
|
|
SPIF_DEFINE_PROPERTY_FUNC_NONOBJ(eterm_action, eterm_action_handler, handler);
|
|
|
|
SPIF_DEFINE_PROPERTY_FUNC_NONOBJ(eterm_action, eterm_action_parameter, parameter);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static spif_bool_t
|
|
|
|
action_handle_string(event_t *ev, spif_eterm_action_t action)
|
|
|
|
{
|
|
|
|
REQUIRE_RVAL(!SPIF_PTR_ISNULL(ev), FALSE);
|
|
|
|
REQUIRE_RVAL(!SPIF_STR_ISNULL(action->parameter), FALSE);
|
|
|
|
cmd_write(SPIF_STR_STR(action->parameter), spif_str_get_len(SPIF_STR(action->parameter)));
|
2002-05-04 07:25:30 -07:00
|
|
|
return 1;
|
1999-08-17 18:12:47 -07:00
|
|
|
}
|
|
|
|
|
2009-10-07 20:47:32 -07:00
|
|
|
static spif_bool_t
|
|
|
|
action_handle_echo(event_t *ev, spif_eterm_action_t action)
|
2001-05-18 23:56:45 -07:00
|
|
|
{
|
2009-10-07 20:47:32 -07:00
|
|
|
REQUIRE_RVAL(!SPIF_PTR_ISNULL(ev), FALSE);
|
|
|
|
REQUIRE_RVAL(!SPIF_STR_ISNULL(action->parameter), FALSE);
|
2002-05-13 15:47:08 -07:00
|
|
|
#ifdef ESCREEN
|
2002-06-02 17:24:22 -07:00
|
|
|
if (TermWin.screen && TermWin.screen->backend) {
|
|
|
|
# ifdef NS_HAVE_SCREEN
|
|
|
|
/* translate escapes */
|
2009-10-07 20:47:32 -07:00
|
|
|
ns_parse_screen_interactive(TermWin.screen, SPIF_STR_STR(action->parameter));
|
2002-06-02 17:24:22 -07:00
|
|
|
# endif
|
|
|
|
} else
|
2002-05-13 15:47:08 -07:00
|
|
|
#endif
|
2009-10-07 20:47:32 -07:00
|
|
|
tt_write(SPIF_STR_STR(action->parameter), spif_str_get_len(SPIF_STR(action->parameter)));
|
2002-05-04 07:25:30 -07:00
|
|
|
return 1;
|
1999-08-17 18:12:47 -07:00
|
|
|
}
|
|
|
|
|
2009-10-07 20:47:32 -07:00
|
|
|
static spif_bool_t
|
|
|
|
action_handle_script(event_t *ev, spif_eterm_action_t action)
|
2001-05-18 23:56:45 -07:00
|
|
|
{
|
2009-10-07 20:47:32 -07:00
|
|
|
REQUIRE_RVAL(!SPIF_PTR_ISNULL(ev), FALSE);
|
|
|
|
REQUIRE_RVAL(!SPIF_STR_ISNULL(action->parameter), FALSE);
|
|
|
|
script_parse(SPIF_STR_STR(action->parameter));
|
2002-05-04 07:25:30 -07:00
|
|
|
return 1;
|
2000-07-03 12:08:41 -07:00
|
|
|
}
|
|
|
|
|
2009-10-07 20:47:32 -07:00
|
|
|
static spif_bool_t
|
|
|
|
action_handle_menu(event_t *ev, spif_eterm_action_t action)
|
2001-05-18 23:56:45 -07:00
|
|
|
{
|
2009-10-07 20:47:32 -07:00
|
|
|
REQUIRE_RVAL(!SPIF_PTR_ISNULL(ev), FALSE);
|
|
|
|
REQUIRE_RVAL(!SPIF_PTR_ISNULL(action->parameter), FALSE);
|
|
|
|
/*menu_invoke(ev->xbutton.x, ev->xbutton.y, TermWin.parent, action->parameter.menu, ev->xbutton.time); */
|
2002-05-04 07:25:30 -07:00
|
|
|
return 1;
|
1999-08-17 18:12:47 -07:00
|
|
|
}
|
|
|
|
|
2009-10-07 20:47:32 -07:00
|
|
|
static spif_bool_t
|
|
|
|
action_check_button(spif_uchar_t button, int x_button)
|
Mon Jun 11 17:49:55 PDT 2001 Michael Jennings <mej@eterm.org>
Okay, first off, I removed 3 scaled backgrounds. See www.kainx.org or
my post to enlightenment-devel for details.
Second, I redid the default bindings for the mouse wheel. Basically,
the wheel alone will scroll by pages. Ctrl+wheel will scroll by pages
in groups of 5. Shift+wheel will scroll by a single line. If you
hold down the Alt key, the same combinations will work the same way,
but instead of scrolling within Eterm, they'll scroll the application
in the terminal (by sending PgUp/PgDn and up/down arrows). This works
in less, bash, and any other application which groks those keys.
I also added a --without-mousewheel option to configure that will turn
off the default scrollwheel bindings. Of course, you can always use
action bindings in the config file to bind/rebind these any way you
like.
While I was at it, I found and fixed a bug in the handling of the
Alt and Meta keys.
I added a scroll() function to the script stuff which allows you to
bind keys/buttons to scroll up and down. While I was at it, I added
comments to script.c for each function you can use.
And finally, the config file parser was moved to libast.
SVN revision: 4806
2001-06-11 18:04:45 -07:00
|
|
|
{
|
2002-05-04 07:25:30 -07:00
|
|
|
/* The event we're looking at is a button press. Make sure the
|
|
|
|
current action is also, and that it matches. Continue if not. */
|
|
|
|
D_ACTIONS(("Checking button %d vs x_button %d\n", button, x_button));
|
2009-10-07 20:47:32 -07:00
|
|
|
if (button == ETERM_BUTTON_NONE) {
|
2002-05-04 07:25:30 -07:00
|
|
|
/* It was a button press, and this action is not a button action. */
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-10-07 20:47:32 -07:00
|
|
|
if ((button != ETERM_BUTTON_ANY) && (button != x_button)) {
|
2002-05-04 07:25:30 -07:00
|
|
|
/* It's a specific button, and the two don't match. */
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
D_ACTIONS(("Button match confirmed.\n"));
|
|
|
|
return TRUE;
|
Mon Jun 11 17:49:55 PDT 2001 Michael Jennings <mej@eterm.org>
Okay, first off, I removed 3 scaled backgrounds. See www.kainx.org or
my post to enlightenment-devel for details.
Second, I redid the default bindings for the mouse wheel. Basically,
the wheel alone will scroll by pages. Ctrl+wheel will scroll by pages
in groups of 5. Shift+wheel will scroll by a single line. If you
hold down the Alt key, the same combinations will work the same way,
but instead of scrolling within Eterm, they'll scroll the application
in the terminal (by sending PgUp/PgDn and up/down arrows). This works
in less, bash, and any other application which groks those keys.
I also added a --without-mousewheel option to configure that will turn
off the default scrollwheel bindings. Of course, you can always use
action bindings in the config file to bind/rebind these any way you
like.
While I was at it, I found and fixed a bug in the handling of the
Alt and Meta keys.
I added a scroll() function to the script stuff which allows you to
bind keys/buttons to scroll up and down. While I was at it, I added
comments to script.c for each function you can use.
And finally, the config file parser was moved to libast.
SVN revision: 4806
2001-06-11 18:04:45 -07:00
|
|
|
}
|
|
|
|
|
2009-10-07 20:47:32 -07:00
|
|
|
static spif_bool_t
|
Mon Jun 11 17:49:55 PDT 2001 Michael Jennings <mej@eterm.org>
Okay, first off, I removed 3 scaled backgrounds. See www.kainx.org or
my post to enlightenment-devel for details.
Second, I redid the default bindings for the mouse wheel. Basically,
the wheel alone will scroll by pages. Ctrl+wheel will scroll by pages
in groups of 5. Shift+wheel will scroll by a single line. If you
hold down the Alt key, the same combinations will work the same way,
but instead of scrolling within Eterm, they'll scroll the application
in the terminal (by sending PgUp/PgDn and up/down arrows). This works
in less, bash, and any other application which groks those keys.
I also added a --without-mousewheel option to configure that will turn
off the default scrollwheel bindings. Of course, you can always use
action bindings in the config file to bind/rebind these any way you
like.
While I was at it, I found and fixed a bug in the handling of the
Alt and Meta keys.
I added a scroll() function to the script stuff which allows you to
bind keys/buttons to scroll up and down. While I was at it, I added
comments to script.c for each function you can use.
And finally, the config file parser was moved to libast.
SVN revision: 4806
2001-06-11 18:04:45 -07:00
|
|
|
action_check_keysym(KeySym keysym, KeySym x_keysym)
|
|
|
|
{
|
2002-05-04 07:25:30 -07:00
|
|
|
/* The event we're looking at is a key press. Make sure the
|
|
|
|
current action is also, and that it matches. Continue if not. */
|
|
|
|
D_ACTIONS(("Checking keysym 0x%08x vs x_keysym 0x%08x\n", keysym, x_keysym));
|
|
|
|
if (keysym == None) {
|
|
|
|
return FALSE;
|
|
|
|
} else if (keysym != x_keysym) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
D_ACTIONS(("Keysym match confirmed.\n"));
|
|
|
|
return TRUE;
|
Mon Jun 11 17:49:55 PDT 2001 Michael Jennings <mej@eterm.org>
Okay, first off, I removed 3 scaled backgrounds. See www.kainx.org or
my post to enlightenment-devel for details.
Second, I redid the default bindings for the mouse wheel. Basically,
the wheel alone will scroll by pages. Ctrl+wheel will scroll by pages
in groups of 5. Shift+wheel will scroll by a single line. If you
hold down the Alt key, the same combinations will work the same way,
but instead of scrolling within Eterm, they'll scroll the application
in the terminal (by sending PgUp/PgDn and up/down arrows). This works
in less, bash, and any other application which groks those keys.
I also added a --without-mousewheel option to configure that will turn
off the default scrollwheel bindings. Of course, you can always use
action bindings in the config file to bind/rebind these any way you
like.
While I was at it, I found and fixed a bug in the handling of the
Alt and Meta keys.
I added a scroll() function to the script stuff which allows you to
bind keys/buttons to scroll up and down. While I was at it, I added
comments to script.c for each function you can use.
And finally, the config file parser was moved to libast.
SVN revision: 4806
2001-06-11 18:04:45 -07:00
|
|
|
}
|
|
|
|
|
2009-10-07 20:47:32 -07:00
|
|
|
static spif_bool_t
|
|
|
|
action_check_modifiers(spif_ushort_t mod, int x_mod)
|
Mon Jun 11 17:49:55 PDT 2001 Michael Jennings <mej@eterm.org>
Okay, first off, I removed 3 scaled backgrounds. See www.kainx.org or
my post to enlightenment-devel for details.
Second, I redid the default bindings for the mouse wheel. Basically,
the wheel alone will scroll by pages. Ctrl+wheel will scroll by pages
in groups of 5. Shift+wheel will scroll by a single line. If you
hold down the Alt key, the same combinations will work the same way,
but instead of scrolling within Eterm, they'll scroll the application
in the terminal (by sending PgUp/PgDn and up/down arrows). This works
in less, bash, and any other application which groks those keys.
I also added a --without-mousewheel option to configure that will turn
off the default scrollwheel bindings. Of course, you can always use
action bindings in the config file to bind/rebind these any way you
like.
While I was at it, I found and fixed a bug in the handling of the
Alt and Meta keys.
I added a scroll() function to the script stuff which allows you to
bind keys/buttons to scroll up and down. While I was at it, I added
comments to script.c for each function you can use.
And finally, the config file parser was moved to libast.
SVN revision: 4806
2001-06-11 18:04:45 -07:00
|
|
|
{
|
2009-10-07 20:47:32 -07:00
|
|
|
spif_uint32_t m = (AltMask | MetaMask | NumLockMask);
|
Mon Jun 11 17:49:55 PDT 2001 Michael Jennings <mej@eterm.org>
Okay, first off, I removed 3 scaled backgrounds. See www.kainx.org or
my post to enlightenment-devel for details.
Second, I redid the default bindings for the mouse wheel. Basically,
the wheel alone will scroll by pages. Ctrl+wheel will scroll by pages
in groups of 5. Shift+wheel will scroll by a single line. If you
hold down the Alt key, the same combinations will work the same way,
but instead of scrolling within Eterm, they'll scroll the application
in the terminal (by sending PgUp/PgDn and up/down arrows). This works
in less, bash, and any other application which groks those keys.
I also added a --without-mousewheel option to configure that will turn
off the default scrollwheel bindings. Of course, you can always use
action bindings in the config file to bind/rebind these any way you
like.
While I was at it, I found and fixed a bug in the handling of the
Alt and Meta keys.
I added a scroll() function to the script stuff which allows you to
bind keys/buttons to scroll up and down. While I was at it, I added
comments to script.c for each function you can use.
And finally, the config file parser was moved to libast.
SVN revision: 4806
2001-06-11 18:04:45 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
/* When we do have to check the modifiers, we do so in this order to eliminate the
|
|
|
|
most popular choices first. If any test fails, we return FALSE. */
|
2009-10-07 20:47:32 -07:00
|
|
|
D_ACTIONS(("Checking modifier set 0x%08x (%c%c%c%c) vs. X modifier set 0x%08x (%c%c%c%c)\n",
|
|
|
|
mod, SHOW_MODS(mod), x_mod, SHOW_X_MODS(x_mod)));
|
|
|
|
if (mod != ETERM_MOD_ANY) {
|
2002-05-04 07:25:30 -07:00
|
|
|
/* LOGICAL_XOR() returns true if either the first parameter or the second parameter
|
|
|
|
is true, but not both...just like XOR. If the mask we're looking for is set in
|
|
|
|
mod but not in x_mod, or set in x_mod but not in mod, we don't have a match. */
|
2009-10-07 20:47:32 -07:00
|
|
|
if (LOGICAL_XOR((mod & ETERM_MOD_CTRL), (x_mod & ControlMask))) {
|
2002-05-04 07:25:30 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
2009-10-07 20:47:32 -07:00
|
|
|
if (LOGICAL_XOR((mod & ETERM_MOD_SHIFT), (x_mod & ShiftMask))) {
|
2002-05-04 07:25:30 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (MetaMask != AltMask) {
|
2009-10-07 20:47:32 -07:00
|
|
|
if (LOGICAL_XOR((mod & ETERM_MOD_ALT), (x_mod & AltMask))) {
|
2002-05-04 07:25:30 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
2009-10-07 20:47:32 -07:00
|
|
|
if (LOGICAL_XOR((mod & ETERM_MOD_META), (x_mod & MetaMask))) {
|
2002-05-04 07:25:30 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
} else {
|
2009-10-07 20:47:32 -07:00
|
|
|
if (LOGICAL_XOR((mod & (ETERM_MOD_META | ETERM_MOD_ALT)), (x_mod & (MetaMask | AltMask)))) {
|
2002-05-04 07:25:30 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2009-10-07 20:47:32 -07:00
|
|
|
if (LOGICAL_XOR((mod & ETERM_MOD_LOCK), (x_mod & LockMask))) {
|
2002-05-04 07:25:30 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* These tests can't use LOGICAL_XOR because the second test has an additional
|
|
|
|
restriction that the Mod?Mask cannot be set in m; i.e., we want to ignore
|
|
|
|
any Mod?Mask assigned to Alt, Meta, or the NumLock On state. */
|
2009-10-07 20:47:32 -07:00
|
|
|
if (((mod & ETERM_MOD_MOD1) && !(x_mod & Mod1Mask)) || (!(mod & ETERM_MOD_MOD1) && (x_mod & Mod1Mask) && !(Mod1Mask & m))) {
|
2002-05-04 07:25:30 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
2009-10-07 20:47:32 -07:00
|
|
|
if (((mod & ETERM_MOD_MOD2) && !(x_mod & Mod2Mask)) || (!(mod & ETERM_MOD_MOD2) && (x_mod & Mod2Mask) && !(Mod2Mask & m))) {
|
2002-05-04 07:25:30 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
2009-10-07 20:47:32 -07:00
|
|
|
if (((mod & ETERM_MOD_MOD3) && !(x_mod & Mod3Mask)) || (!(mod & ETERM_MOD_MOD3) && (x_mod & Mod3Mask) && !(Mod3Mask & m))) {
|
2002-05-04 07:25:30 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
2009-10-07 20:47:32 -07:00
|
|
|
if (((mod & ETERM_MOD_MOD4) && !(x_mod & Mod4Mask)) || (!(mod & ETERM_MOD_MOD4) && (x_mod & Mod4Mask) && !(Mod4Mask & m))) {
|
2002-05-04 07:25:30 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
2009-10-07 20:47:32 -07:00
|
|
|
if (((mod & ETERM_MOD_MOD5) && !(x_mod & Mod5Mask)) || (!(mod & ETERM_MOD_MOD5) && (x_mod & Mod5Mask) && !(Mod5Mask & m))) {
|
2002-05-04 07:25:30 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
Mon Jun 11 17:49:55 PDT 2001 Michael Jennings <mej@eterm.org>
Okay, first off, I removed 3 scaled backgrounds. See www.kainx.org or
my post to enlightenment-devel for details.
Second, I redid the default bindings for the mouse wheel. Basically,
the wheel alone will scroll by pages. Ctrl+wheel will scroll by pages
in groups of 5. Shift+wheel will scroll by a single line. If you
hold down the Alt key, the same combinations will work the same way,
but instead of scrolling within Eterm, they'll scroll the application
in the terminal (by sending PgUp/PgDn and up/down arrows). This works
in less, bash, and any other application which groks those keys.
I also added a --without-mousewheel option to configure that will turn
off the default scrollwheel bindings. Of course, you can always use
action bindings in the config file to bind/rebind these any way you
like.
While I was at it, I found and fixed a bug in the handling of the
Alt and Meta keys.
I added a scroll() function to the script stuff which allows you to
bind keys/buttons to scroll up and down. While I was at it, I added
comments to script.c for each function you can use.
And finally, the config file parser was moved to libast.
SVN revision: 4806
2001-06-11 18:04:45 -07:00
|
|
|
}
|
2002-05-04 07:25:30 -07:00
|
|
|
D_ACTIONS(("Modifier match confirmed.\n"));
|
|
|
|
return TRUE;
|
Mon Jun 11 17:49:55 PDT 2001 Michael Jennings <mej@eterm.org>
Okay, first off, I removed 3 scaled backgrounds. See www.kainx.org or
my post to enlightenment-devel for details.
Second, I redid the default bindings for the mouse wheel. Basically,
the wheel alone will scroll by pages. Ctrl+wheel will scroll by pages
in groups of 5. Shift+wheel will scroll by a single line. If you
hold down the Alt key, the same combinations will work the same way,
but instead of scrolling within Eterm, they'll scroll the application
in the terminal (by sending PgUp/PgDn and up/down arrows). This works
in less, bash, and any other application which groks those keys.
I also added a --without-mousewheel option to configure that will turn
off the default scrollwheel bindings. Of course, you can always use
action bindings in the config file to bind/rebind these any way you
like.
While I was at it, I found and fixed a bug in the handling of the
Alt and Meta keys.
I added a scroll() function to the script stuff which allows you to
bind keys/buttons to scroll up and down. While I was at it, I added
comments to script.c for each function you can use.
And finally, the config file parser was moved to libast.
SVN revision: 4806
2001-06-11 18:04:45 -07:00
|
|
|
}
|
|
|
|
|
2009-10-07 20:47:32 -07:00
|
|
|
spif_bool_t
|
|
|
|
eterm_action_dispatch(event_t *ev)
|
2001-05-18 23:56:45 -07:00
|
|
|
{
|
2009-10-07 20:47:32 -07:00
|
|
|
spif_eterm_action_t action;
|
|
|
|
spif_iterator_t iter;
|
|
|
|
|
|
|
|
ASSERT_RVAL(ev != NULL, FALSE);
|
|
|
|
ASSERT_RVAL(ev->xany.type == ButtonPress || ev->xany.type == KeyPress, FALSE);
|
|
|
|
D_ACTIONS(("Event %8p: Button %d, Keycode %d, Key State 0x%08x (modifiers %c%c%c%c)\n",
|
2010-09-12 23:36:22 -07:00
|
|
|
ev, ev->xbutton.button, (int) ev->xkey.keycode, ev->xkey.state, SHOW_X_MODS(ev->xkey.state)));
|
2009-10-07 20:47:32 -07:00
|
|
|
D_ACTIONS(("Searching %d actions to find match.\n", SPIF_VECTOR_COUNT(actions)));
|
|
|
|
|
|
|
|
for (iter = SPIF_VECTOR_ITERATOR(actions); SPIF_ITERATOR_HAS_NEXT(iter);) {
|
2010-09-12 23:36:22 -07:00
|
|
|
action = (spif_eterm_action_t) SPIF_ITERATOR_NEXT(iter);
|
2009-10-07 20:47:32 -07:00
|
|
|
if (action_matches_event(action, ev)) {
|
|
|
|
D_ACTIONS(("Spawning handler for action object %10p.\n", action));
|
2010-09-12 23:36:22 -07:00
|
|
|
return (spif_bool_t) (((spif_eterm_action_handler_t) (action->handler)) (ev, action));
|
2002-05-04 07:25:30 -07:00
|
|
|
}
|
1999-08-17 18:12:47 -07:00
|
|
|
}
|
2009-10-07 20:47:32 -07:00
|
|
|
return FALSE;
|
1999-08-17 18:12:47 -07:00
|
|
|
}
|
|
|
|
|
2009-10-07 20:47:32 -07:00
|
|
|
static spif_bool_t
|
|
|
|
action_matches_event(spif_eterm_action_t action, event_t *ev)
|
2002-05-04 07:25:30 -07:00
|
|
|
{
|
2010-09-12 23:36:22 -07:00
|
|
|
/* The very first thing we do is match the event type to the type
|
|
|
|
of the current action. This means that we'll only run through
|
|
|
|
the modifier checks below if we absolutely have to. */
|
|
|
|
D_ACTIONS(("Checking action %10p for match to event %10p.\n", action, ev));
|
|
|
|
if (ev->xany.type == ButtonPress) {
|
|
|
|
if (!action_check_button(action->button, ev->xbutton.button)) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
} else if (ev->xany.type == KeyPress) {
|
|
|
|
if (!action_check_keysym(action->keysym, XKeycodeToKeysym(Xdisplay, ev->xkey.keycode, 0))) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
2009-10-07 20:47:32 -07:00
|
|
|
} else {
|
|
|
|
ASSERT_NOTREACHED_RVAL(FALSE);
|
2000-07-03 12:08:41 -07:00
|
|
|
}
|
2009-10-07 20:47:32 -07:00
|
|
|
if (action_check_modifiers(action->modifiers, ev->xkey.state)) {
|
|
|
|
D_ACTIONS(("Match found.\n"));
|
|
|
|
return TRUE;
|
2002-05-04 07:25:30 -07:00
|
|
|
}
|
2009-10-07 20:47:32 -07:00
|
|
|
return FALSE;
|
1999-08-17 18:12:47 -07:00
|
|
|
}
|