diff options
-rw-r--r-- | doc/dwb.1 | 14 | ||||
-rw-r--r-- | scripts/hints.js | 1 | ||||
-rw-r--r-- | src/commands.c | 23 | ||||
-rw-r--r-- | src/config.h | 10 | ||||
-rw-r--r-- | src/dwb.c | 65 | ||||
-rw-r--r-- | src/dwb.h | 5 | ||||
-rw-r--r-- | src/view.c | 3 | ||||
-rw-r--r-- | util/keys.in | 2 |
8 files changed, 96 insertions, 27 deletions
@@ -444,6 +444,20 @@ aliases: .BR phints , .BR phi ). .TP +.BR ;r +Rapid hint mode, each matching hint opens a new tab in background. (command +.BR hint_mode_rapid , +aliases: +.BR rhints , +.BR rhi ). +.TP +.BR ;R +Rapid hint mode, each matching hint opens a new window. (command +.BR hint_mode_rapid , +aliases: +.BR wrhints , +.BR wrhi ). +.TP .BR gf Toggle "view source" (command .BR view_source , diff --git a/scripts/hints.js b/scripts/hints.js index 81b3bc9d..21f25f16 100644 --- a/scripts/hints.js +++ b/scripts/hints.js @@ -466,6 +466,7 @@ var DwbHintObj = (function () { } ret = "_dwb_click_"; } + console.log(ret); __clear(); return ret; }; diff --git a/src/commands.c b/src/commands.c index 21f6b4de..6b2a9f24 100644 --- a/src/commands.c +++ b/src/commands.c @@ -36,7 +36,6 @@ static int inline dwb_floor(double x) { static int inline modulo(int x, int y) { return x - dwb_floor((double)x/y) * y; } - /* commands.h {{{*/ /* commands_simple_command(keyMap *km) {{{*/ void @@ -173,27 +172,7 @@ commands_search(KeyMap *km, Arg *arg) { /* commands_show_hints {{{*/ DwbStatus commands_show_hints(KeyMap *km, Arg *arg) { - DwbStatus ret = STATUS_OK; - if (dwb.state.nv == OPEN_NORMAL) { - dwb_set_open_mode(arg->n | OPEN_VIA_HINTS); - } - if (dwb.state.mode != HINT_MODE) { - gtk_entry_set_text(GTK_ENTRY(dwb.gui.entry), ""); - char *command = g_strdup_printf("DwbHintObj.showHints(%d, %s)", MIN(arg->i, HINT_T_URL), arg->n != OPEN_NORMAL ? "true" : "false"); - char *jsret = dwb_execute_script(MAIN_FRAME(), command, true); - g_free(command); - if (jsret != NULL) { - ret = dwb_evaluate_hints(jsret); - g_free(jsret); - if (ret == STATUS_END) { - return ret; - } - } - dwb.state.mode = HINT_MODE; - dwb.state.hint_type = arg->i; - entry_focus(); - } - return ret; + return dwb_show_hints(arg); }/*}}}*/ /* commands_show_keys(KeyMap *km, Arg *arg){{{*/ diff --git a/src/config.h b/src/config.h index e573f1f9..993d8a0c 100644 --- a/src/config.h +++ b/src/config.h @@ -46,6 +46,8 @@ static KeyValue KEYS[] = { { "hint_mode_nw", { "wf", 0, }, }, { "hint_mode_clipboard", { ";y", 0, }, }, { "hint_mode_primary", { ";Y", 0, }, }, + { "hint_mode_rapid", { ";r", 0, }, }, + { "hint_mode_rapid_nw", { ";R", 0, }, }, { "history_back", { "H", 0, }, }, { "history_forward", { "L", 0, }, }, { "history_back_nv", { "th", 0, }, }, @@ -319,6 +321,14 @@ static FunctionMap FMAP [] = { { { "hint_mode_primary", "Copy to primary", }, CP_COMMANDLINE | CP_HAS_MODE, (Func)commands_show_hints, NO_HINTS, NEVER_SM, { .n = OPEN_NORMAL, .i = HINT_T_PRIMARY }, EP_NONE, { "phints", "phi", NULL }, }, + + { { "hint_mode_rapid", "Rapid hint mode", }, CP_COMMANDLINE | CP_HAS_MODE, + (Func)commands_show_hints, NO_HINTS, NEVER_SM, + { .n = OPEN_NEW_VIEW | OPEN_BACKGROUND, .i = HINT_T_RAPID }, EP_NONE, { "rhints", "rhi", NULL }, }, + + { { "hint_mode_rapid_nw", "Rapid hint mode", }, CP_COMMANDLINE | CP_HAS_MODE, + (Func)commands_show_hints, NO_HINTS, NEVER_SM, + { .n = OPEN_NEW_WINDOW | OPEN_BACKGROUND, .i = HINT_T_RAPID_NW }, EP_NONE, { "wrhints", "wrhi", NULL }, }, { { "hint_mode_download", "Download", }, CP_COMMANDLINE | CP_HAS_MODE, (Func)commands_show_hints, NO_HINTS, NEVER_SM, @@ -92,6 +92,26 @@ typedef struct _EditorInfo { char *tagname; } EditorInfo; +typedef struct HintMap { + int type; + int arg; +} _HintMap; + +struct HintMap hint_map[] = { + { HINT_T_ALL, HINT_T_ALL }, + { HINT_T_LINKS, HINT_T_LINKS }, + { HINT_T_IMAGES, HINT_T_IMAGES }, + { HINT_T_EDITABLE, HINT_T_EDITABLE }, + { HINT_T_URL, HINT_T_URL }, + { HINT_T_CLIPBOARD, HINT_T_CLIPBOARD }, + { HINT_T_PRIMARY, HINT_T_PRIMARY }, + { HINT_T_RAPID, HINT_T_ALL }, + { HINT_T_RAPID_NW, HINT_T_ALL }, +}; + + + + static int signals[] = { SIGFPE, SIGILL, SIGINT, SIGQUIT, SIGTERM, SIGALRM, SIGSEGV}; static int MAX_COMPLETIONS = 11; static char *restore = NULL; @@ -137,7 +157,7 @@ dwb_set_cookies(GList *gl, WebSettings *s) { return STATUS_OK; }/*}}}*/ -/* dwb_set_cookies */ +/* dwb_set_cookies {{{ */ static DwbStatus dwb_set_widget_packing(GList *gl, WebSettings *s) { DwbStatus ret = STATUS_OK; @@ -883,6 +903,7 @@ dwb_focus_view(GList *gl) { gtk_widget_show(VIEW(gl)->scroll); if (! (CURRENT_VIEW()->status->lockprotect & LP_VISIBLE) ) gtk_widget_hide(VIEW(dwb.state.fview)->scroll); + dwb_change_mode(NORMAL_MODE, true); dwb_unfocus(); dwb_focus(gl); } @@ -1257,7 +1278,7 @@ dwb_evaluate_hints(const char *buffer) { dwb_change_mode(INSERT_MODE); ret = STATUS_END; } - else if (!g_strcmp0(buffer, "_dwb_click_")) { + else if (!g_strcmp0(buffer, "_dwb_click_") && HINT_NOT_RAPID ) { dwb.state.scriptlock = 1; if ( !(dwb.state.nv & OPEN_DOWNLOAD) ) { dwb_change_mode(NORMAL_MODE, dwb.state.message_id == 0); @@ -1288,6 +1309,16 @@ dwb_evaluate_hints(const char *buffer) { case HINT_T_PRIMARY : dwb_change_mode(NORMAL_MODE, true); ret = dwb_set_clipboard(buffer, GDK_SELECTION_PRIMARY); break; + case HINT_T_RAPID : a = util_arg_new(); + a->n = OPEN_NEW_VIEW | OPEN_BACKGROUND; + a->i = HINT_T_RAPID; + dwb_show_hints(a); + break; + case HINT_T_RAPID_NW : a = util_arg_new(); + a->n = OPEN_NEW_WINDOW | OPEN_BACKGROUND; + a->i = HINT_T_RAPID; + dwb_show_hints(a); + break; default : return ret; } FREE(a); @@ -1304,7 +1335,7 @@ dwb_update_hints(GdkEventKey *e) { gboolean ret = false; if (e->keyval == GDK_KEY_Return) { - com = g_strdup_printf("DwbHintObj.followActive(%d)", MIN(dwb.state.hint_type, HINT_T_URL)); + com = g_strdup_printf("DwbHintObj.followActive(%d)", hint_map[dwb.state.hint_type].arg); } else if (DWB_TAB_KEY(e)) { if (e->state & GDK_SHIFT_MASK) { @@ -1321,7 +1352,7 @@ dwb_update_hints(GdkEventKey *e) { else { val = util_keyval_to_char(e->keyval, true); snprintf(input, BUFFER_LENGTH, "%s%s", GET_TEXT(), val ? val : ""); - com = g_strdup_printf("DwbHintObj.updateHints(\"%s\", %d)", input, MIN(dwb.state.hint_type, HINT_T_URL)); + com = g_strdup_printf("DwbHintObj.updateHints(\"%s\", %d)", input, hint_map[dwb.state.hint_type].arg); FREE(val); } if (com) { @@ -1336,6 +1367,32 @@ dwb_update_hints(GdkEventKey *e) { return ret; }/*}}}*/ +DwbStatus +dwb_show_hints(Arg *arg) { + DwbStatus ret = STATUS_OK; + if (dwb.state.nv == OPEN_NORMAL) { + dwb_set_open_mode(arg->n | OPEN_VIA_HINTS); + } + if (dwb.state.mode != HINT_MODE) { + gtk_entry_set_text(GTK_ENTRY(dwb.gui.entry), ""); + char *command = g_strdup_printf("DwbHintObj.showHints(%d)", hint_map[arg->i].arg); + char *jsret = dwb_execute_script(MAIN_FRAME(), command, true); + g_free(command); + if (jsret != NULL) { + ret = dwb_evaluate_hints(jsret); + g_free(jsret); + if (ret == STATUS_END) { + return ret; + } + } + dwb.state.mode = HINT_MODE; + dwb.state.hint_type = arg->i; + entry_focus(); + } + return ret; + +} + /* dwb_execute_script {{{*/ char * dwb_execute_script(WebKitWebFrame *frame, const char *com, gboolean ret) { @@ -253,7 +253,10 @@ typedef enum { HINT_T_URL = 4, HINT_T_CLIPBOARD = 5, HINT_T_PRIMARY = 6, + HINT_T_RAPID = 7, + HINT_T_RAPID_NW = 8, } HintType; +#define HINT_NOT_RAPID (dwb.state.hint_type != HINT_T_RAPID && dwb.state.hint_type != HINT_T_RAPID_NW) typedef enum { BAR_VIS_TOP = 1<<0, @@ -324,6 +327,7 @@ typedef enum { SET_URL = 1<<4, OPEN_VIA_HINTS = 1<<5, OPEN_EXPLICIT = 1<<6, + OPEN_BACKGROUND = 1<<7, } Open; enum { @@ -748,6 +752,7 @@ void dwb_glist_prepend_unique(GList **, char *); Navigation * dwb_navigation_from_webkit_history_item(WebKitWebHistoryItem *); gboolean dwb_update_hints(GdkEventKey *); +DwbStatus dwb_show_hints(Arg *); gboolean dwb_search(Arg *); void dwb_submit_searchengine(void); void dwb_save_searchengine(void); @@ -339,8 +339,9 @@ view_navigation_policy_cb(WebKitWebView *web, WebKitWebFrame *frame, WebKitNetwo */ if (dwb.state.nv & OPEN_NEW_VIEW) { if (dwb.state.nv & OPEN_VIA_HINTS || (dwb.state.nv & OPEN_EXPLICIT && reason == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) ) { + gboolean background = dwb.state.nv & OPEN_BACKGROUND ? true : dwb.state.background_tabs; dwb.state.nv = OPEN_NORMAL; - view_add(uri, dwb.state.background_tabs); + view_add(uri, background); webkit_web_policy_decision_ignore(policy); return true; } diff --git a/util/keys.in b/util/keys.in index 087db2e7..0f91cc43 100644 --- a/util/keys.in +++ b/util/keys.in @@ -39,6 +39,8 @@ hint_mode_url_nv Set hint's url in commandline, open in a new tab hint_mode_download Download via hints hint_mode_clipboard Save link location to clipboard hint_mode_primary Save link location to primary selection +hint_mode_rapid Open new tabs in background rapidly +hint_mode_rapid_nw Open new windows rapidly # bookmark_keys Bookmarks & Quickmarks bookmark Bookmark current page |