From 933f4908179be474f8f86ff8e3b20fc2d91cf428 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 20 Oct 2011 06:04:10 -0400 Subject: [PATCH] More comprehensive :jumps. --- common/content/bookmarks.js | 8 -------- common/content/history.js | 27 +++++++++++++++++++++++++ common/content/marks.js | 8 ++++++++ common/locale/en-US/messages.properties | 3 +++ common/modules/template.jsm | 4 ++++ 5 files changed, 42 insertions(+), 8 deletions(-) diff --git a/common/content/bookmarks.js b/common/content/bookmarks.js index 79e19360..bac3335b 100644 --- a/common/content/bookmarks.js +++ b/common/content/bookmarks.js @@ -382,14 +382,6 @@ var Bookmarks = Module("bookmarks", { }, { }, { commands: function () { - commands.add(["ju[mps]"], - "Show jumplist", - function () { - let sh = history.session; - commandline.commandOutput(template.jumps(sh.index, sh)); - }, - { argCount: "0" }); - // TODO: Clean this up. const tags = { names: ["-tags", "-T"], diff --git a/common/content/history.js b/common/content/history.js index 6670b3ac..fdaedff1 100644 --- a/common/content/history.js +++ b/common/content/history.js @@ -293,6 +293,33 @@ var History = Module("history", { ], privateData: true }); + + commands.add(["ju[mps]"], + "Show jumplist", + function () { + let sh = history.session; + let index = sh.index; + + let jumps = marks.jumps; + if (jumps.index < 0) + jumps = [sh[sh.index]]; + else { + index += jumps.index; + jumps = jumps.locations.map(function (l) ({ + __proto__: l, + title: buffer.title, + get URI() util.newURI(this.location) + })); + } + + let list = sh.slice(0, sh.index) + .concat(jumps) + .concat(sh.slice(sh.index + 1)); + + commandline.commandOutput(template.jumps(index, list)); + }, + { argCount: "0" }); + }, completion: function () { completion.domain = function (context) { diff --git a/common/content/marks.js b/common/content/marks.js index 53b14788..4454ce17 100644 --- a/common/content/marks.js +++ b/common/content/marks.js @@ -133,6 +133,14 @@ var Marks = Module("marks", { }); }, + get jumps() { + let store = buffer.localStore; + return { + index: store.jumpsIndex, + locations: store.jumps.map(function (j) j.mark) + }; + }, + /** * Remove all marks matching *filter*. If *special* is given, removes all * local marks. diff --git a/common/locale/en-US/messages.properties b/common/locale/en-US/messages.properties index 062fa056..b82fe6e5 100644 --- a/common/locale/en-US/messages.properties +++ b/common/locale/en-US/messages.properties @@ -344,6 +344,9 @@ title.Totals = Totals title.URI = URI title.Version = Version +title.HPos = HPos +title.VPos = VPos + variable.none = No variables found window.cantAttachSame = Can't reattach to the same window diff --git a/common/modules/template.jsm b/common/modules/template.jsm index b8aff65f..1ce8b9a7 100644 --- a/common/modules/template.jsm +++ b/common/modules/template.jsm @@ -392,6 +392,8 @@ var Template = Module("Template", { return + + @@ -400,6 +402,8 @@ var Template = Module("Template", { + + )
{_("title.Jump")}{_("title.HPos")}{_("title.VPos")} {_("title.Title")} {_("title.URI")}
{idx == index ? ">" : ""} {Math.abs(idx - index)}{val.offset ? val.offset.x : ""}{val.offset ? val.offset.y : ""} {val.title} {util.losslessDecodeURI(val.URI.spec)}