From 17b882fe0fe58e839739f99e4bf44332867a59de Mon Sep 17 00:00:00 2001 From: Marco Peereboom Date: Sat, 20 Feb 2010 21:05:22 +0000 Subject: Add forward and back keys --- xxxterm.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/xxxterm.c b/xxxterm.c index 80072d3..e7c7ffc 100644 --- a/xxxterm.c +++ b/xxxterm.c @@ -50,12 +50,14 @@ static char *version = "$xxxterm$"; #define XT_D_TAB 0x0004 #define XT_D_URL 0x0008 #define XT_D_CMD 0x0010 +#define XT_D_NAV 0x0020 u_int32_t swm_debug = 0 | XT_D_MOVE | XT_D_KEY | XT_D_TAB | XT_D_URL | XT_D_CMD + | XT_D_NAV ; #else #define DPRINTF(x...) @@ -124,6 +126,10 @@ struct karg { #define XT_TAB_DELETE (2) #define XT_TAB_DELQUIT (3) +#define XT_NAV_INVALID (0) +#define XT_NAV_BACK (1) +#define XT_NAV_FORWARD (2) + /* globals */ extern char *__progname; GtkWidget *main_window; @@ -192,6 +198,23 @@ quit(struct tab *t, struct karg *args) return (1); } +int +navaction(struct tab *t, struct karg *args) +{ + DNPRINTF(XT_D_NAV, "navaction: tab %d opcode %d\n", + t->tab_id, args->i); + + switch (args->i) { + case XT_NAV_BACK: + webkit_web_view_go_back(t->wv); + break; + case XT_NAV_FORWARD: + webkit_web_view_go_forward(t->wv); + break; + } + return (XT_CB_PASSTHROUGH); +} + int move(struct tab *t, struct karg *args) { @@ -389,6 +412,10 @@ struct key { { GDK_SHIFT_MASK, 0, GDK_colon, command, {0} }, { GDK_CONTROL_MASK, 0, GDK_q, quit, {0} }, + /* navigation */ + { 0, 0, GDK_BackSpace, navaction, {.i = XT_NAV_BACK} }, + { GDK_SHIFT_MASK, 0, GDK_BackSpace, navaction, {.i = XT_NAV_FORWARD} }, + /* vertical movement */ { 0, 0, GDK_j, move, {.i = XT_MOVE_DOWN} }, { 0, 0, GDK_Down, move, {.i = XT_MOVE_DOWN} }, -- cgit 1.4.1-2-gfad0