From ac29e49b3dcea6d6d00fc612e51bacc02b0f657d Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Sun, 7 Aug 2011 15:35:35 -0400 Subject: [PATCH] Add g]. --- common/content/buffer.js | 11 ++++++++++- common/content/marks.js | 4 ++-- common/locale/en-US/buffer.xml | 9 +++++++++ pentadactyl/NEWS | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/common/content/buffer.js b/common/content/buffer.js index 25c8cfed..279b3c94 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -820,8 +820,9 @@ var Buffer = Module("buffer", { * @param {number} count The number of elements to jump. * @optional * @param {boolean} reverse If true, search backwards. @optional + * @param {boolean} offScreen If true, include only off-screen elements. @optional */ - findJump: function findJump(arg, count, reverse) { + findJump: function findJump(arg, count, reverse, offScreen) { const FUDGE = 10; let path = options["jumptags"][arg]; @@ -832,6 +833,9 @@ var Buffer = Module("buffer", { .filter(function (e) e[1] > FUDGE) .sort(function (a, b) a[1] - b[1]) + if (offScreen && !reverse) + elems = elems.filter(function (e) e[1] > this, window.innerHeight); + let idx = Math.min((count || 1) - 1, elems.length); dactyl.assert(idx in elems); @@ -1840,6 +1844,11 @@ var Buffer = Module("buffer", { function (args) { buffer.findJump(args.arg, args.count, true); }, { arg: true, count: true }); + mappings.add([modes.NORMAL], ["g]"], + "Jump to the next off-screen element as defined by 'jumptags'", + function (args) { buffer.findJump(args.arg, args.count, false, true); }, + { arg: true, count: true }); + mappings.add([modes.NORMAL], ["]"], "Jump to the next element as defined by 'jumptags'", function (args) { buffer.findJump(args.arg, args.count, false); }, diff --git a/common/content/marks.js b/common/content/marks.js index 14683421..d0c7c252 100644 --- a/common/content/marks.js +++ b/common/content/marks.js @@ -171,10 +171,10 @@ var Marks = Module("marks", { var node = buffer.findScrollable(0, (mark.offset || mark.position).x) else for (node in util.evaluateXPath(mark.xpath, buffer.focusedFrame.document)) - ; + break; util.assert(node); - util.scrollIntoView(node, true); + util.scrollIntoView(node); if (mark.position) Buffer.scrollToPercent(node, mark.position.x * 100, mark.position.y * 100); diff --git a/common/locale/en-US/buffer.xml b/common/locale/en-US/buffer.xml index 7f514a91..40de0fe9 100644 --- a/common/locale/en-US/buffer.xml +++ b/common/locale/en-US/buffer.xml @@ -344,6 +344,15 @@ + + g] + count]arg + +

Jump to the next off-screen element as defined by jumptags.

+
+
+ + { count{ diff --git a/pentadactyl/NEWS b/pentadactyl/NEWS index 20dfde11..1be83db6 100644 --- a/pentadactyl/NEWS +++ b/pentadactyl/NEWS @@ -81,7 +81,7 @@ - Added site-specific mapping groups and related command changes. [b6] - Added 'timeout' and 'timeoutlen' options. [b6] - - Added n_{, n_}, n_[, and n_] mappings. [b7] + - Added n_{, n_}, n_[, n_], and n_g] mappings. [b7] - Added to execute a builtin mapping. [b6] - Added l and s to aid in the construction of macros. [b6]