.TP
.BI [ N ]k
Scroll page \fIN\fP steps up.
+.TP
+.BI [ N ]]\-]
+Follow the last \fIN\fPth link matching `nextpattern'.
+.TP
+.BI [ N ][\-[
+Follow the last \fIN\fPth link matching `previouspattern'.
.SS Hinting
The hinting is the way to do what you would do with the mouse in common
mouse-driven browsers. Open URI, yank URI, save page and so on. If the hinting
.B input-font-normal (string)
Font used for inputbox.
.TP
+.B nextpattern (string)
+Patterns to use when guessing the next page in a document. Each pattern is
+successively tested against each link in the page beginning from the last
+link. Default "'\\bnext\\b','^(>|>>|»)$','^(>|>>|»)','(>|>>|»)$','\\bmore\\b'"
+.TP
+.B previouspattern (string)
+Patterns to use when guessing the previous page in a document. Each pattern is
+successively tested against each link in the page beginning from the last
+link. Default "\\bprev|previous\\b','^(<|<<|«)$','^(<|<<|«)','(<|<<|«)$'"
+.TP
.B proxy (bool)
Indicates if the environment variable `http_proxy' is evaluated.
.TP
"set insecure-content-run=off",
#endif
"set timeoutlen=1000",
+ "set previouspattern='\\bprev\\|previous\\b','^(<\\|<<\\|«)$','^(<\\|<<\\|«)','(<\\|<<\\|«)$'",
+ "set nextpattern='\\bnext\\b','^(>\\|>>\\|»)$','^(>\\|>>\\|»)','(>\\|>>\\|»)$','\\bmore\\b'",
NULL
};
g_free(js);
}
+void hints_follow_link(const gboolean back, int count)
+{
+ char *pattern = back ? vb.config.prevpattern : vb.config.nextpattern;
+ char *js = g_strdup_printf(
+ "%s.followLink('%s', [%s], %d);", HINT_VAR,
+ back ? "prev" : "next",
+ pattern,
+ count
+ );
+ run_script(js);
+ g_free(js);
+}
+
static void run_script(char *js)
{
+ PRINT_DEBUG("%s", js);
char mode, *value = NULL;
gboolean success = vb_eval_script(
void hints_create(const char *input);
void hints_update(int num);
void hints_fire(void);
+void hints_follow_link(const gboolean back, int count);
void hints_clear(void);
void hints_focus_next(const gboolean back);
}
}
+ /* follow the count last link on pagematching the given pattern */
+ function followLink(rel, pattern, count) {
+ /* returns array of matching elements */
+ function followFrame(frame) {
+ var i, p, reg, res = [],
+ elems = frame.document.getElementsByTagName("a");
+
+ /* first match links by rel attribute */
+ for (i = elems.length - 1; i >= 0; i--) {
+ if (elems[i].rel.toLowerCase() === rel) {
+ res.push(elems[i]);
+ elems.splice(i, 1);
+ }
+ }
+ /* match each pattern successively against each link in the page */
+ for (p = 0; p < pattern.length; p++) {
+ reg = pattern[p];
+ /* begin with the last link on page */
+ for (i = elems.length - 1; i >= 0; i--) {
+ if (elems[i].innerText.match(reg)) {
+ res.push(elems[i]);
+ }
+ }
+ }
+ return res;
+ }
+ var i, j, elems, frames = allFrames(window);
+ for (i = 0; i < frames.length; i++) {
+ elems = followFrame(frames[i]);
+ for (j = 0; j < elems.length; j++) {
+ if (--count == 0) {
+ open(elems[j], false);
+ return "DONE:";
+ }
+ }
+ }
+ return "NONE:";
+ }
+
+ function allFrames(win) {
+ var i, f, frames = [win];
+ for (i = 0; i < win.frames.length; i++) {
+ frames.push(win.frames[i].frameElement);
+ }
+ return frames;
+ }
+
/* the api */
return {
init: function init(prefix, maxHints) {
config.usage = map[prefix][1];
}
},
- create: create,
- update: update,
- clear: clear,
- fire: fire,
- focus: focus
+ create: create,
+ update: update,
+ clear: clear,
+ fire: fire,
+ focus: focus,
+ /* not really hintings but uses similar logic */
+ followLink: followLink
};
})();
Object.freeze(VbHint);
guint timeoutlen; /* timeout for ambiguous mappings */
gboolean strict_focus;
GHashTable *headers; /* holds user defined header appended to requests */
+ char *nextpattern; /* regex patter nfor prev link matching */
+ char *prevpattern; /* regex patter nfor next link matching */
} Config;
typedef struct {
static VbResult normal_open_clipboard(const NormalCmdInfo *info);
static VbResult normal_open(const NormalCmdInfo *info);
static VbResult normal_pass(const NormalCmdInfo *info);
+static VbResult normal_prevnext(const NormalCmdInfo *info);
static VbResult normal_queue(const NormalCmdInfo *info);
static VbResult normal_quit(const NormalCmdInfo *info);
static VbResult normal_scroll(const NormalCmdInfo *info);
/* X 0x58 */ {NULL},
/* Y 0x59 */ {normal_yank},
/* Z 0x5a */ {NULL},
-/* [ 0x5b */ {NULL},
+/* [ 0x5b */ {normal_prevnext},
/* \ 0x5c */ {NULL},
-/* ] 0x5d */ {NULL},
+/* ] 0x5d */ {normal_prevnext},
/* ^ 0x5e */ {NULL},
/* _ 0x5f */ {NULL},
/* ` 0x60 */ {NULL},
info.phase = PHASE_COMPLETE;
} else if (info.phase == PHASE_START && isdigit(key)) {
info.count = info.count * 10 + key - '0';
- } else if (strchr(";zg", (char)key)) {
+ } else if (strchr(";zg[]", (char)key)) {
/* handle commands that needs additional char */
info.phase = PHASE_KEY2;
info.cmd = key;
return RESULT_COMPLETE;
}
+static VbResult normal_prevnext(const NormalCmdInfo *info)
+{
+ int count = info->count ? info->count : 1;
+ if (info->ncmd == ']') {
+ hints_follow_link(false, count);
+ } else if (info->ncmd == '[') {
+ hints_follow_link(true, count);
+ } else {
+ return RESULT_ERROR;
+ }
+ return RESULT_COMPLETE;
+}
+
static VbResult normal_queue(const NormalCmdInfo *info)
{
command_queue(&((Arg){COMMAND_QUEUE_POP}));
static gboolean editor_command(const Setting *s, const SettingType type);
static gboolean timeoutlen(const Setting *s, const SettingType type);
static gboolean headers(const Setting *s, const SettingType type);
+static gboolean nextpattern(const Setting *s, const SettingType type);
static Setting default_settings[] = {
/* webkit settings */
{NULL, "history-max-items", TYPE_INTEGER, history_max_items, {0}},
{NULL, "editor-command", TYPE_CHAR, editor_command, {0}},
{NULL, "header", TYPE_CHAR, headers, {0}},
+ {NULL, "nextpattern", TYPE_CHAR, nextpattern, {0}},
+ {NULL, "previouspattern", TYPE_CHAR, nextpattern, {0}},
};
void setting_init(void)
return true;
}
+
+static gboolean nextpattern(const Setting *s, const SettingType type)
+{
+ if (type == SETTING_GET) {
+ print_value(s, s->name[0] == 'n' ? vb.config.nextpattern : vb.config.prevpattern);
+ } else if (*s->name == 'n') {
+ OVERWRITE_STRING(vb.config.nextpattern, s->arg.s);
+ } else {
+ OVERWRITE_STRING(vb.config.prevpattern, s->arg.s);
+ }
+
+ return true;
+}