Enable the insert mode. Thanks to stanio@cs.tu-berlin.de!
This commit is contained in:
parent
d911219554
commit
c12b6499fe
3 changed files with 106 additions and 10 deletions
|
@ -43,6 +43,7 @@ static Key keys[] = {
|
||||||
{ MODKEY, GDK_k, scroll_v, { .i = -1 } },
|
{ MODKEY, GDK_k, scroll_v, { .i = -1 } },
|
||||||
{ MODKEY, GDK_b, scroll_v, { .i = -10000 } },
|
{ MODKEY, GDK_b, scroll_v, { .i = -10000 } },
|
||||||
{ MODKEY, GDK_space, scroll_v, { .i = +10000 } },
|
{ MODKEY, GDK_space, scroll_v, { .i = +10000 } },
|
||||||
|
{ 0, GDK_i, insert, { 0 } },
|
||||||
{ MODKEY, GDK_i, scroll_h, { .i = +1 } },
|
{ MODKEY, GDK_i, scroll_h, { .i = +1 } },
|
||||||
{ MODKEY, GDK_u, scroll_h, { .i = -1 } },
|
{ MODKEY, GDK_u, scroll_h, { .i = -1 } },
|
||||||
{ 0, GDK_Escape, stop, { 0 } },
|
{ 0, GDK_Escape, stop, { 0 } },
|
||||||
|
|
41
surf.1
41
surf.1
|
@ -67,6 +67,18 @@ Scrolls page upwards.
|
||||||
.B Ctrl\-j
|
.B Ctrl\-j
|
||||||
Scrolls page downwards.
|
Scrolls page downwards.
|
||||||
.TP
|
.TP
|
||||||
|
.B Ctrl\-b
|
||||||
|
Scroll up one whole page view.
|
||||||
|
.TP
|
||||||
|
.B Ctrl\-Space
|
||||||
|
Scroll down one whole page view.
|
||||||
|
.TP
|
||||||
|
.B Ctrl\-i
|
||||||
|
Scroll horizontally to the right.
|
||||||
|
.TP
|
||||||
|
.B Ctrl\-u
|
||||||
|
Scroll horizontally to the left.
|
||||||
|
.TP
|
||||||
.B Ctrl\-Shift\-k
|
.B Ctrl\-Shift\-k
|
||||||
Zooms page in.
|
Zooms page in.
|
||||||
.TP
|
.TP
|
||||||
|
@ -76,7 +88,20 @@ Zooms page out
|
||||||
.B Ctrl\-Shift\-i
|
.B Ctrl\-Shift\-i
|
||||||
Resets Zoom
|
Resets Zoom
|
||||||
.TP
|
.TP
|
||||||
.B Ctrl\-f
|
.B i
|
||||||
|
Enter insert mode. There all keybindings have effect with and without
|
||||||
|
pressing the modkey.
|
||||||
|
.TP
|
||||||
|
.B ESC
|
||||||
|
Leave the insert mode.
|
||||||
|
.TP
|
||||||
|
.B Ctrl\-h
|
||||||
|
Navigate back one step in history.
|
||||||
|
.TP
|
||||||
|
.B Ctrl\-l
|
||||||
|
Navigate forward one step in history.
|
||||||
|
.TP
|
||||||
|
.B Ctrl\-f and Ctrl\-\\
|
||||||
Opens the search-bar.
|
Opens the search-bar.
|
||||||
.TP
|
.TP
|
||||||
.B Ctrl\-n
|
.B Ctrl\-n
|
||||||
|
@ -104,7 +129,19 @@ Reloads the website without using cache.
|
||||||
Copies current URI to primary selection.
|
Copies current URI to primary selection.
|
||||||
.TP
|
.TP
|
||||||
.B Ctrl\-o
|
.B Ctrl\-o
|
||||||
show the sourcecode of the current page.
|
Show the sourcecode of the current page.
|
||||||
|
.TP
|
||||||
|
.B Ctrl\-v
|
||||||
|
Toggle the enabling of plugins on that surf instance.
|
||||||
|
.TP
|
||||||
|
.B Ctrl\-Shift\-i
|
||||||
|
Toggle auto-loading of images.
|
||||||
|
.TP
|
||||||
|
.B Ctrl\-c
|
||||||
|
Toggle caret browsing.
|
||||||
|
.TP
|
||||||
|
.B Ctrl\-Shift\-s
|
||||||
|
Toggle script execution.
|
||||||
.SH ENVIRONMENT
|
.SH ENVIRONMENT
|
||||||
.TP
|
.TP
|
||||||
.B SURF_USERAGENT
|
.B SURF_USERAGENT
|
||||||
|
|
68
surf.c
68
surf.c
|
@ -79,6 +79,8 @@ static GdkNativeWindow embed = 0;
|
||||||
static gboolean showxid = FALSE;
|
static gboolean showxid = FALSE;
|
||||||
static char winid[64];
|
static char winid[64];
|
||||||
static gboolean loadimage = 1, plugin = 1, script = 1, using_proxy = 0;
|
static gboolean loadimage = 1, plugin = 1, script = 1, using_proxy = 0;
|
||||||
|
static char togglestat[6];
|
||||||
|
static gboolean insertmode = FALSE;
|
||||||
|
|
||||||
static char *buildpath(const char *path);
|
static char *buildpath(const char *path);
|
||||||
static gboolean buttonrelease(WebKitWebView *web, GdkEventButton *e, GList *gl);
|
static gboolean buttonrelease(WebKitWebView *web, GdkEventButton *e, GList *gl);
|
||||||
|
@ -101,6 +103,7 @@ static void find(Client *c, const Arg *arg);
|
||||||
static const char *getatom(Client *c, int a);
|
static const char *getatom(Client *c, int a);
|
||||||
static char *geturi(Client *c);
|
static char *geturi(Client *c);
|
||||||
static gboolean initdownload(WebKitWebView *v, WebKitDownload *o, Client *c);
|
static gboolean initdownload(WebKitWebView *v, WebKitDownload *o, Client *c);
|
||||||
|
static void insert(Client *c, const Arg *arg);
|
||||||
static gboolean keypress(GtkWidget *w, GdkEventKey *ev, Client *c);
|
static gboolean keypress(GtkWidget *w, GdkEventKey *ev, Client *c);
|
||||||
static void linkhover(WebKitWebView *v, const char* t, const char* l, Client *c);
|
static void linkhover(WebKitWebView *v, const char* t, const char* l, Client *c);
|
||||||
static void loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c);
|
static void loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c);
|
||||||
|
@ -127,6 +130,7 @@ static void eval(Client *c, const Arg *arg);
|
||||||
static void stop(Client *c, const Arg *arg);
|
static void stop(Client *c, const Arg *arg);
|
||||||
static void titlechange(WebKitWebView *v, WebKitWebFrame* frame, const char* title, Client *c);
|
static void titlechange(WebKitWebView *v, WebKitWebFrame* frame, const char* title, Client *c);
|
||||||
static void toggle(Client *c, const Arg *arg);
|
static void toggle(Client *c, const Arg *arg);
|
||||||
|
static void gettogglestat(Client *c);
|
||||||
static void update(Client *c);
|
static void update(Client *c);
|
||||||
static void updatewinid(Client *c);
|
static void updatewinid(Client *c);
|
||||||
static void usage(void);
|
static void usage(void);
|
||||||
|
@ -433,20 +437,50 @@ initdownload(WebKitWebView *view, WebKitDownload *o, Client *c) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
insert(Client *c, const Arg *arg) {
|
||||||
|
insertmode = TRUE;
|
||||||
|
update(clients);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
keypress(GtkWidget* w, GdkEventKey *ev, Client *c) {
|
keypress(GtkWidget* w, GdkEventKey *ev, Client *c) {
|
||||||
guint i;
|
guint i, state;
|
||||||
gboolean processed = FALSE;
|
gboolean processed = FALSE;
|
||||||
|
|
||||||
|
/* turn off insert mode */
|
||||||
|
if(insertmode && (ev->keyval == GDK_Escape)) {
|
||||||
|
insertmode = FALSE;
|
||||||
|
update(c);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(insertmode && (((ev->state & MODKEY) != MODKEY) || !MODKEY)) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ev->keyval == GDK_Escape) {
|
||||||
|
webkit_web_view_set_highlight_text_matches(c->view, FALSE);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
updatewinid(c);
|
updatewinid(c);
|
||||||
for(i = 0; i < LENGTH(keys); i++) {
|
for(i = 0; i < LENGTH(keys); i++) {
|
||||||
|
if(!insertmode && (MODKEY & keys[i].mod)) {
|
||||||
|
state = ev->state | MODKEY;
|
||||||
|
} else {
|
||||||
|
state = ev->state;
|
||||||
|
}
|
||||||
|
|
||||||
if(gdk_keyval_to_lower(ev->keyval) == keys[i].keyval
|
if(gdk_keyval_to_lower(ev->keyval) == keys[i].keyval
|
||||||
&& (ev->state & keys[i].mod) == keys[i].mod
|
|
||||||
&& keys[i].func) {
|
&& keys[i].func) {
|
||||||
|
if(state == keys[i].mod) {
|
||||||
keys[i].func(c, &(keys[i].arg));
|
keys[i].func(c, &(keys[i].arg));
|
||||||
processed = TRUE;
|
processed = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return processed;
|
return processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -904,19 +938,43 @@ toggle(Client *c, const Arg *arg) {
|
||||||
reload(c,&a);
|
reload(c,&a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gettogglestat(Client *c){
|
||||||
|
gboolean value;
|
||||||
|
WebKitWebSettings *settings = webkit_web_view_get_settings(c->view);
|
||||||
|
|
||||||
|
togglestat[4] = '\0';
|
||||||
|
g_object_get(G_OBJECT(settings), "auto-load-images", &value, NULL);
|
||||||
|
togglestat[0] = value?'I':'i';
|
||||||
|
g_object_get(G_OBJECT(settings), "enable-scripts", &value, NULL);
|
||||||
|
togglestat[1] = value?'S':'s';
|
||||||
|
g_object_get(G_OBJECT(settings), "enable-plugins", &value, NULL);
|
||||||
|
togglestat[2] = value?'V':'v';
|
||||||
|
g_object_get(G_OBJECT(settings), "enable-caret-browsing",
|
||||||
|
&value, NULL);
|
||||||
|
togglestat[3] = value?'C':'c';
|
||||||
|
|
||||||
|
togglestat[4] = insertmode? '+' : '-';
|
||||||
|
togglestat[5] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
update(Client *c) {
|
update(Client *c) {
|
||||||
char *t;
|
char *t;
|
||||||
|
|
||||||
|
gettogglestat(c);
|
||||||
|
|
||||||
if(c->linkhover) {
|
if(c->linkhover) {
|
||||||
t = g_strdup(c->linkhover);
|
t = g_strdup_printf("%s| %s", togglestat, c->linkhover);
|
||||||
} else if(c->progress != 100) {
|
} else if(c->progress != 100) {
|
||||||
drawindicator(c);
|
drawindicator(c);
|
||||||
gtk_widget_show(c->indicator);
|
gtk_widget_show(c->indicator);
|
||||||
t = g_strdup_printf("[%i%%] %s", c->progress, c->title);
|
t = g_strdup_printf("[%i%%] %s| %s", c->progress, togglestat,
|
||||||
|
c->title);
|
||||||
} else {
|
} else {
|
||||||
gtk_widget_hide_all(c->indicator);
|
gtk_widget_hide_all(c->indicator);
|
||||||
t = g_strdup(c->title);
|
t = g_strdup_printf("%s| %s", togglestat, c->title);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_window_set_title(GTK_WINDOW(c->win), t);
|
gtk_window_set_title(GTK_WINDOW(c->win), t);
|
||||||
|
|
Loading…
Reference in a new issue