mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-24 04:52:28 +01:00
Add [d and ]d.
This commit is contained in:
@@ -50,10 +50,14 @@ var History = Module("history", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
get session() {
|
get session() {
|
||||||
let sh = window.getWebNavigation().sessionHistory;
|
let webNav = window.getWebNavigation()
|
||||||
|
let sh = webNav.sessionHistory;
|
||||||
|
|
||||||
let obj = [];
|
let obj = [];
|
||||||
obj.index = sh.index;
|
obj.__defineGetter__("index", function () sh.index);
|
||||||
|
obj.__defineSetter__("index", function (val) { webNav.gotoIndex(val) });
|
||||||
obj.__iterator__ = function () array.iterItems(this);
|
obj.__iterator__ = function () array.iterItems(this);
|
||||||
|
|
||||||
for (let i in util.range(0, sh.count)) {
|
for (let i in util.range(0, sh.count)) {
|
||||||
obj[i] = update(Object.create(sh.getEntryAtIndex(i, false)),
|
obj[i] = update(Object.create(sh.getEntryAtIndex(i, false)),
|
||||||
{ index: i });
|
{ index: i });
|
||||||
@@ -77,19 +81,46 @@ var History = Module("history", {
|
|||||||
if (steps == 0)
|
if (steps == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let start = 0;
|
let sh = this.session;
|
||||||
let end = window.getWebNavigation().sessionHistory.count - 1;
|
dactyl.assert(steps > 0 && sh.index < sh.length - 1 || steps < 0 && sh.index > 0);
|
||||||
let current = window.getWebNavigation().sessionHistory.index;
|
|
||||||
|
|
||||||
if (current == start && steps < 0 || current == end && steps > 0)
|
|
||||||
dactyl.beep();
|
|
||||||
else {
|
|
||||||
let index = Math.constrain(current + steps, start, end);
|
|
||||||
try {
|
try {
|
||||||
window.getWebNavigation().gotoIndex(index);
|
sh.index = Math.constrain(sh.index + steps, 0, sh.length - 1);
|
||||||
}
|
}
|
||||||
catch (e) {} // We get NS_ERROR_FILE_NOT_FOUND if files in history don't exist
|
catch (e) {} // We get NS_ERROR_FILE_NOT_FOUND if files in history don't exist
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for the *steps*th next *item* in the history list.
|
||||||
|
*
|
||||||
|
* @param {string} item The nebulously defined item to search for.
|
||||||
|
* @param {number} steps The number of steps to step.
|
||||||
|
*/
|
||||||
|
search: function search(item, steps) {
|
||||||
|
var ctxt;
|
||||||
|
var filter = function (item) true;
|
||||||
|
if (item == "domain")
|
||||||
|
var filter = function (item) {
|
||||||
|
let res = item.URI.hostPort != ctxt;
|
||||||
|
ctxt = item.URI.hostPort;
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
|
let sh = this.session;
|
||||||
|
let idx;
|
||||||
|
let sign = steps / Math.abs(steps);
|
||||||
|
|
||||||
|
filter(sh[sh.index]);
|
||||||
|
for (let i = sh.index + sign; steps && i >= 0 && i < sh.length; i += sign)
|
||||||
|
if (filter(sh[i])) {
|
||||||
|
idx = i;
|
||||||
|
steps -= sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
util.dump(idx, sh.index, sh.length, steps);
|
||||||
|
|
||||||
|
dactyl.assert(idx != null);
|
||||||
|
sh.index = idx;
|
||||||
},
|
},
|
||||||
|
|
||||||
goToStart: function goToStart() {
|
goToStart: function goToStart() {
|
||||||
@@ -283,26 +314,30 @@ var History = Module("history", {
|
|||||||
completion.addUrlCompleter("h", "History", completion.history);
|
completion.addUrlCompleter("h", "History", completion.history);
|
||||||
},
|
},
|
||||||
mappings: function () {
|
mappings: function () {
|
||||||
var myModes = config.browserModes;
|
function bind() mappings.add.apply(mappings, [config.browserModes].concat(Array.slice(arguments)));
|
||||||
|
|
||||||
mappings.add(myModes,
|
bind(["<C-o>"], "Go to an older position in the jump list",
|
||||||
["<C-o>"], "Go to an older position in the jump list",
|
function ({ count }) { history.stepTo(-Math.max(count, 1), true); },
|
||||||
function (args) { history.stepTo(-Math.max(args.count, 1), true); },
|
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes,
|
bind(["<C-i>"], "Go to a newer position in the jump list",
|
||||||
["<C-i>"], "Go to a newer position in the jump list",
|
function ({ count }) { history.stepTo(Math.max(count, 1), true); },
|
||||||
function (args) { history.stepTo(Math.max(args.count, 1), true); },
|
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes,
|
bind(["H", "<A-Left>", "<M-Left>"], "Go back in the browser history",
|
||||||
["H", "<A-Left>", "<M-Left>"], "Go back in the browser history",
|
function ({ count }) { history.stepTo(-Math.max(count, 1)); },
|
||||||
function (args) { history.stepTo(-Math.max(args.count, 1)); },
|
|
||||||
{ count: true });
|
{ count: true });
|
||||||
|
|
||||||
mappings.add(myModes,
|
bind(["L", "<A-Right>", "<M-Right>"], "Go forward in the browser history",
|
||||||
["L", "<A-Right>", "<M-Right>"], "Go forward in the browser history",
|
function ({ count }) { history.stepTo(Math.max(count, 1)); },
|
||||||
function (args) { history.stepTo(Math.max(args.count, 1)); },
|
{ count: true });
|
||||||
|
|
||||||
|
bind(["[d"], "Go back to the previous domain in the browser history",
|
||||||
|
function ({ count }) { history.search("domain", -Math.max(count, 1)) },
|
||||||
|
{ count: true });
|
||||||
|
|
||||||
|
bind(["]d"], "Go forward to the next domain in the browser history",
|
||||||
|
function ({ count }) { history.search("domain", Math.max(count, 1)) },
|
||||||
{ count: true });
|
{ count: true });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -291,6 +291,26 @@ want to bypass &dactyl.appName;'s key handling and pass keys directly to
|
|||||||
</description>
|
</description>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<tags><![CDATA[[d]]></tags>
|
||||||
|
<spec><oa>count</oa>[d</spec>
|
||||||
|
<description>
|
||||||
|
<p>
|
||||||
|
Go to the <oa>count</oa>th previous domain in the history stack.
|
||||||
|
</p>
|
||||||
|
</description>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<tags><![CDATA[]d]]></tags>
|
||||||
|
<spec><oa>count</oa>]d</spec>
|
||||||
|
<description>
|
||||||
|
<p>
|
||||||
|
Go to the <oa>count</oa>th next domain in the history stack.
|
||||||
|
</p>
|
||||||
|
</description>
|
||||||
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags><![CDATA[<C-o>]]></tags>
|
<tags><![CDATA[<C-o>]]></tags>
|
||||||
<spec><oa>count</oa><C-o></spec>
|
<spec><oa>count</oa><C-o></spec>
|
||||||
|
|||||||
@@ -83,6 +83,7 @@
|
|||||||
changes. [b6]
|
changes. [b6]
|
||||||
- Added 'timeout' and 'timeoutlen' options. [b6]
|
- Added 'timeout' and 'timeoutlen' options. [b6]
|
||||||
- Added n_{, n_}, n_[, n_], and n_g] mappings. [b7]
|
- Added n_{, n_}, n_[, n_], and n_g] mappings. [b7]
|
||||||
|
- Added n_[d and n_]d. [b8]
|
||||||
- Added <A-b> to execute a builtin mapping. [b6]
|
- Added <A-b> to execute a builtin mapping. [b6]
|
||||||
- Added <A-m>l and <A-m>s to aid in the construction of
|
- Added <A-m>l and <A-m>s to aid in the construction of
|
||||||
macros. [b6]
|
macros. [b6]
|
||||||
|
|||||||
@@ -21,22 +21,13 @@ FEATURES:
|
|||||||
8 add search capability to MOW
|
8 add search capability to MOW
|
||||||
8 registers
|
8 registers
|
||||||
8 Document Caret and Visual modes.
|
8 Document Caret and Visual modes.
|
||||||
8 replace global variables with plugin scoped user options
|
|
||||||
8 adaptive timeout for auto-completions, :set completions can be updated more often than
|
|
||||||
:open foo
|
|
||||||
8 add support for filename special characters such as %
|
8 add support for filename special characters such as %
|
||||||
8 :redir and 'verbosefile'
|
8 :redir and 'verbosefile'
|
||||||
8 middleclick in content == p, and if command line is open, paste there the clipboard buffer
|
8 middleclick in content == p, and if command line is open, paste there the clipboard buffer
|
||||||
8 all search commands should start searching from the top of the visible viewport
|
8 all search commands should start searching from the top of the visible viewport
|
||||||
8 Add information to dactyl/HACKING file about testing and optimization
|
8 Add information to dactyl/HACKING file about testing and optimization
|
||||||
7 describe-key command (prompt for a key and display its binding with documentation)
|
7 describe-key command (prompt for a key and display its binding with documentation)
|
||||||
7 Specify all INSERT mode mappings rather than falling through to the host apps
|
|
||||||
mystery meat mappings.
|
|
||||||
7 use ctrl-n/p in insert mode for word completion
|
7 use ctrl-n/p in insert mode for word completion
|
||||||
7 implement QuickFix window based on ItemList
|
|
||||||
7 [d could go to the last domain in the history stack. So if I browse from
|
|
||||||
google to another page and click 10 links there, [d would take me back to the google page
|
|
||||||
opera's fast forward does something like this
|
|
||||||
7 make an option to disable session saving by default when you close Firefox
|
7 make an option to disable session saving by default when you close Firefox
|
||||||
7 :grep support (needs location list)
|
7 :grep support (needs location list)
|
||||||
6 :mksession
|
6 :mksession
|
||||||
|
|||||||
Reference in New Issue
Block a user