1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 07:17:59 +01:00
This commit is contained in:
Kris Maglione
2011-08-07 15:35:35 -04:00
parent 6739ab0ef0
commit ac29e49b3d
4 changed files with 22 additions and 4 deletions

View File

@@ -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); },