mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-22 21:25:46 +01:00
Show QuickMarked status in statusbar; add URL completion to :qmark.
This commit is contained in:
@@ -14,6 +14,9 @@
|
|||||||
const QuickMarks = Module("quickmarks", {
|
const QuickMarks = Module("quickmarks", {
|
||||||
init: function () {
|
init: function () {
|
||||||
this._qmarks = storage.newMap("quickmarks", { store: true });
|
this._qmarks = storage.newMap("quickmarks", { store: true });
|
||||||
|
storage.addObserver("quickmarks", function () {
|
||||||
|
statusline.updateUrl();
|
||||||
|
}, window);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,6 +32,20 @@ const QuickMarks = Module("quickmarks", {
|
|||||||
dactyl.echomsg({ domains: [util.getHost(location)], message: "Added Quick Mark '" + qmark + "': " + location }, 1);
|
dactyl.echomsg({ domains: [util.getHost(location)], message: "Added Quick Mark '" + qmark + "': " + location }, 1);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of QuickMarks associates with the given URL.
|
||||||
|
*
|
||||||
|
* @param {string} url The url to find QuickMarks for.
|
||||||
|
* @return {[string]}
|
||||||
|
*/
|
||||||
|
find: function find(url) {
|
||||||
|
let res = [];
|
||||||
|
for (let [k, v] in this._qmarks)
|
||||||
|
if (dactyl.stringToURLArray(v).some(function (u) String.replace(u, /#.*/, "") == url))
|
||||||
|
res.push(k);
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the specified quickmarks. The <b>filter</b> is a list of
|
* Deletes the specified quickmarks. The <b>filter</b> is a list of
|
||||||
* quickmarks and ranges are supported. Eg. "ab c d e-k".
|
* quickmarks and ranges are supported. Eg. "ab c d e-k".
|
||||||
@@ -120,15 +137,21 @@ const QuickMarks = Module("quickmarks", {
|
|||||||
commands.add(["qma[rk]"],
|
commands.add(["qma[rk]"],
|
||||||
"Mark a URL with a letter for quick access",
|
"Mark a URL with a letter for quick access",
|
||||||
function (args) {
|
function (args) {
|
||||||
let matches = args.string.match(/^([a-zA-Z0-9])(?:\s+(.+))?$/);
|
if (!/^[a-zA-Z0-9]$/.test(args[0]))
|
||||||
if (!matches)
|
|
||||||
dactyl.echoerr("E488: Trailing characters");
|
dactyl.echoerr("E488: Trailing characters");
|
||||||
else if (!matches[2])
|
else if (!args[1])
|
||||||
quickmarks.add(matches[1], buffer.URL);
|
quickmarks.add(args[0], buffer.URL);
|
||||||
else
|
else
|
||||||
quickmarks.add(matches[1], matches[2]);
|
quickmarks.add(args[0], args[1]);
|
||||||
},
|
},
|
||||||
{ argCount: "+" });
|
{
|
||||||
|
argCount: "+",
|
||||||
|
completer: function (context, args) {
|
||||||
|
if (args.length == 2)
|
||||||
|
return completion.url(context);
|
||||||
|
},
|
||||||
|
literal: 1
|
||||||
|
});
|
||||||
|
|
||||||
commands.add(["qmarks"],
|
commands.add(["qmarks"],
|
||||||
"Show all QuickMarks",
|
"Show all QuickMarks",
|
||||||
|
|||||||
@@ -90,19 +90,9 @@ const StatusLine = Module("statusline", {
|
|||||||
return url;
|
return url;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: this probably needs a more general solution.
|
||||||
if (url == null)
|
if (url == null)
|
||||||
// TODO: this probably needs a more general solution.
|
url = buffer.URL;
|
||||||
url = losslessDecodeURI(buffer.URL);
|
|
||||||
|
|
||||||
// make it even more Vim-like
|
|
||||||
if (url == "about:blank") {
|
|
||||||
if (!buffer.title)
|
|
||||||
url = "[No Name]";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
url = url.replace(RegExp("^dactyl://help/(\\S+)#(.*)"), function (m, n1, n2) n1 + " " + decodeURIComponent(n2) + " [Help]")
|
|
||||||
.replace(RegExp("^dactyl://help/(\\S+)"), "$1 [Help]");
|
|
||||||
}
|
|
||||||
|
|
||||||
// when session information is available, add [+] when we can go
|
// when session information is available, add [+] when we can go
|
||||||
// backwards, [-] when we can go forwards
|
// backwards, [-] when we can go forwards
|
||||||
@@ -119,6 +109,20 @@ const StatusLine = Module("statusline", {
|
|||||||
modified += UTF8("❤");
|
modified += UTF8("❤");
|
||||||
//modified += UTF8("♥");
|
//modified += UTF8("♥");
|
||||||
}
|
}
|
||||||
|
if (modules.quickmarks)
|
||||||
|
modified += quickmarks.find(url.replace(/#.*/, "")).join("");
|
||||||
|
|
||||||
|
url = losslessDecodeURI(url);
|
||||||
|
|
||||||
|
// make it even more Vim-like
|
||||||
|
if (url == "about:blank") {
|
||||||
|
if (!buffer.title)
|
||||||
|
url = "[No Name]";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
url = url.replace(RegExp("^dactyl://help/(\\S+)#(.*)"), function (m, n1, n2) n1 + " " + decodeURIComponent(n2) + " [Help]")
|
||||||
|
.replace(RegExp("^dactyl://help/(\\S+)"), "$1 [Help]");
|
||||||
|
}
|
||||||
|
|
||||||
if (modified)
|
if (modified)
|
||||||
url += " [" + modified + "]";
|
url += " [" + modified + "]";
|
||||||
|
|||||||
@@ -199,10 +199,12 @@
|
|||||||
progress messages are also output to this field.
|
progress messages are also output to this field.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<em>History and bookmark status</em> (<em>[+-❤]</em>): The position of the current page in
|
<em>History and bookmark status</em> (<em>[+-❤⋯]</em>): The position
|
||||||
the tab's session history; + and - indicate that it is possible to move
|
of the current page in the tab's session history; <em>+</em> and
|
||||||
backwards and forwards through the history respectively. ❤ indicates that
|
<em>-</em> indicate that it is possible to move backwards and forwards
|
||||||
the current page is bookmarked.
|
through the history respectively. ❤ indicates that the current page is
|
||||||
|
bookmarked. Any other character indicates a QuickMark matching the
|
||||||
|
current page.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<em>Tab index</em> (<em>[N/M]</em>): N is the index of the currently selected tab and M is
|
<em>Tab index</em> (<em>[N/M]</em>): N is the index of the currently selected tab and M is
|
||||||
|
|||||||
Reference in New Issue
Block a user