mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-14 06:35:46 +01:00
Another attempt at revision 8613b76cff40.
This commit is contained in:
@@ -62,7 +62,7 @@ var Bookmarks = Module("bookmarks", {
|
||||
|
||||
try {
|
||||
let uri = util.createURI(url);
|
||||
if (!force && this.isBookmarked(uri))
|
||||
if (!force && bookmarkcache.isBookmarked(uri))
|
||||
for (var bmark in bookmarkcache)
|
||||
if (bmark.url == uri.spec) {
|
||||
if (title)
|
||||
@@ -146,26 +146,7 @@ var Bookmarks = Module("bookmarks", {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns true if the given URL is bookmarked and that bookmark is
|
||||
* not a Live Bookmark.
|
||||
*
|
||||
* @param {nsIURI|string} url The URL of which to check the bookmarked
|
||||
* state.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isBookmarked: function isBookmarked(uri) {
|
||||
if (isString(uri))
|
||||
uri = util.newURI(uri);
|
||||
try {
|
||||
return services.bookmarks
|
||||
.getBookmarkIdsForURI(uri, {})
|
||||
.some(bookmarkcache.closure.isRegularBookmark);
|
||||
}
|
||||
catch (e) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
isBookmarked: deprecated("bookmarkcache.isBookmarked", { get: function isBookmarked() bookmarkcache.closure.isBookmarked }),
|
||||
|
||||
/**
|
||||
* Remove a bookmark or bookmarks. If *ids* is an array, removes the
|
||||
|
||||
@@ -1008,7 +1008,7 @@ var Buffer = Module("buffer", {
|
||||
function (opt) template.map(buffer.pageInfo[opt][0](), util.identity, ", "),
|
||||
", ");
|
||||
|
||||
if (bookmarks.isBookmarked(this.URL))
|
||||
if (bookmarkcache.isBookmarked(this.URL))
|
||||
info += ", bookmarked";
|
||||
|
||||
let pageInfoText = <>{file.quote()} [{info}] {title}</>;
|
||||
@@ -1640,9 +1640,9 @@ var Buffer = Module("buffer", {
|
||||
};
|
||||
},
|
||||
events: function () {
|
||||
events.addSessionListener(config.browser, "DOMContentLoaded", this.closure.onDOMContentLoaded, true);
|
||||
events.addSessionListener(config.browser, "load", this.closure.onPageLoad, true);
|
||||
events.addSessionListener(config.browser, "scroll", this.closure._updateBufferPosition, false);
|
||||
events.addSessionListener(config.browser, "DOMContentLoaded", buffer.closure.onDOMContentLoaded, true);
|
||||
events.addSessionListener(config.browser, "load", buffer.closure.onPageLoad, true);
|
||||
events.addSessionListener(config.browser, "scroll", buffer.closure._updateBufferPosition, false);
|
||||
},
|
||||
mappings: function () {
|
||||
var myModes = config.browserModes;
|
||||
|
||||
@@ -468,7 +468,7 @@ var Commands = Module("commands", {
|
||||
_addCommand: function (args, replace) {
|
||||
if (!args[3])
|
||||
args[3] = {};
|
||||
args[3].definedAt = commands.getCaller(Components.stack.caller.caller);
|
||||
args[3].definedAt = Commands.getCaller(Components.stack.caller.caller);
|
||||
|
||||
let names = array.flatten(Command.parseSpecs(args[0]));
|
||||
args.parsedSpecs = names;
|
||||
@@ -659,23 +659,6 @@ var Commands = Module("commands", {
|
||||
return this._exCommands.filter(function (cmd) cmd.user);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a frame object describing the currently executing
|
||||
* command, if applicable, otherwise returns the passed frame.
|
||||
*
|
||||
* @param {nsIStackFrame} frame
|
||||
*/
|
||||
getCaller: function (frame) {
|
||||
if (io.sourcing)
|
||||
return {
|
||||
__proto__: frame,
|
||||
filename: io.sourcing.file[0] == "[" ? io.sourcing.file :
|
||||
services.io.newFileURI(File(io.sourcing.file)).spec,
|
||||
lineNumber: io.sourcing.line
|
||||
};
|
||||
return frame;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns true if a command invocation contains a URL referring to the
|
||||
* domain *host*.
|
||||
@@ -1179,6 +1162,23 @@ var Commands = Module("commands", {
|
||||
delete this._exMap[name];
|
||||
}
|
||||
}, {
|
||||
/**
|
||||
* Returns a frame object describing the currently executing
|
||||
* command, if applicable, otherwise returns the passed frame.
|
||||
*
|
||||
* @param {nsIStackFrame} frame
|
||||
*/
|
||||
getCaller: function (frame) {
|
||||
if (io.sourcing)
|
||||
return {
|
||||
__proto__: frame,
|
||||
filename: io.sourcing.file[0] == "[" ? io.sourcing.file :
|
||||
services.io.newFileURI(File(io.sourcing.file)).spec,
|
||||
lineNumber: io.sourcing.line
|
||||
};
|
||||
return frame;
|
||||
},
|
||||
|
||||
// returns [count, parsed_argument]
|
||||
parseArg: function parseArg(str, sep, keepQuotes) {
|
||||
let arg = "";
|
||||
@@ -1552,7 +1552,7 @@ var Commands = Module("commands", {
|
||||
});
|
||||
},
|
||||
javascript: function () {
|
||||
JavaScript.setCompleter([this.get, this.removeUserCommand],
|
||||
JavaScript.setCompleter([commands.get, commands.removeUserCommand],
|
||||
[function () ([c.name, c.description] for (c in commands))]);
|
||||
},
|
||||
mappings: function () {
|
||||
|
||||
@@ -2023,52 +2023,51 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
|
||||
dactyl.log("All modules loaded", 3);
|
||||
|
||||
try {
|
||||
var args = services.fuel && services.fuel.storage.get("dactyl.commandlineArgs", null)
|
||||
|| services.commandLineHandler.optionValue;
|
||||
if (isString(args))
|
||||
args = dactyl.parseCommandLine(args);
|
||||
dactyl.timeout(function () {
|
||||
try {
|
||||
var args = services.fuel && services.fuel.storage.get("dactyl.commandlineArgs", null)
|
||||
|| services.commandLineHandler.optionValue;
|
||||
if (isString(args))
|
||||
args = dactyl.parseCommandLine(args);
|
||||
|
||||
if (args) {
|
||||
dactyl.commandLineOptions.rcFile = args["+u"];
|
||||
dactyl.commandLineOptions.noPlugins = "++noplugin" in args;
|
||||
dactyl.commandLineOptions.postCommands = args["+c"];
|
||||
dactyl.commandLineOptions.preCommands = args["++cmd"];
|
||||
util.dump("Processing command-line option: " + args.string);
|
||||
if (args) {
|
||||
dactyl.commandLineOptions.rcFile = args["+u"];
|
||||
dactyl.commandLineOptions.noPlugins = "++noplugin" in args;
|
||||
dactyl.commandLineOptions.postCommands = args["+c"];
|
||||
dactyl.commandLineOptions.preCommands = args["++cmd"];
|
||||
util.dump("Processing command-line option: " + args.string);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
dactyl.echoerr("Parsing command line options: " + e);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
dactyl.echoerr("Parsing command line options: " + e);
|
||||
}
|
||||
|
||||
dactyl.log("Command-line options: " + util.objectToString(dactyl.commandLineOptions), 3);
|
||||
dactyl.log("Command-line options: " + util.objectToString(dactyl.commandLineOptions), 3);
|
||||
|
||||
// first time intro message
|
||||
const firstTime = "extensions." + config.name + ".firsttime";
|
||||
if (prefs.get(firstTime, true)) {
|
||||
dactyl.timeout(function () {
|
||||
this.withSavedValues(["forceNewTab"], function () {
|
||||
this.forceNewTab = true;
|
||||
this.help();
|
||||
prefs.set(firstTime, false);
|
||||
// first time intro message
|
||||
const firstTime = "extensions." + config.name + ".firsttime";
|
||||
if (prefs.get(firstTime, true)) {
|
||||
dactyl.timeout(function () {
|
||||
this.withSavedValues(["forceNewTab"], function () {
|
||||
this.forceNewTab = true;
|
||||
this.help();
|
||||
prefs.set(firstTime, false);
|
||||
});
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
// TODO: we should have some class where all this guioptions stuff fits well
|
||||
// Dactyl.hideGUI();
|
||||
|
||||
if (dactyl.userEval("typeof document", null, "test.js") === "undefined")
|
||||
jsmodules.__proto__ = XPCSafeJSObjectWrapper(window);
|
||||
|
||||
if (dactyl.commandLineOptions.preCommands)
|
||||
dactyl.commandLineOptions.preCommands.forEach(function (cmd) {
|
||||
dactyl.execute(cmd);
|
||||
});
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
// TODO: we should have some class where all this guioptions stuff fits well
|
||||
// Dactyl.hideGUI();
|
||||
|
||||
if (dactyl.userEval("typeof document", null, "test.js") === "undefined")
|
||||
jsmodules.__proto__ = XPCSafeJSObjectWrapper(window);
|
||||
|
||||
if (dactyl.commandLineOptions.preCommands)
|
||||
dactyl.commandLineOptions.preCommands.forEach(function (cmd) {
|
||||
dactyl.execute(cmd);
|
||||
});
|
||||
|
||||
// finally, read the RC file and source plugins
|
||||
// make sourcing asynchronous, otherwise commands that open new tabs won't work
|
||||
util.timeout(function () {
|
||||
// finally, read the RC file and source plugins
|
||||
let init = services.environment.get(config.idName + "_INIT");
|
||||
let rcFile = io.getRCFile("~");
|
||||
|
||||
@@ -2121,7 +2120,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
dactyl.fullyInitialized = true;
|
||||
dactyl.triggerObserver("enter", null);
|
||||
autocommands.trigger("Enter", {});
|
||||
}, 0);
|
||||
}, 100);
|
||||
|
||||
statusline.update();
|
||||
dactyl.log(config.appName + " fully initialized", 0);
|
||||
|
||||
@@ -172,7 +172,7 @@ var MapHive = Class("MapHive", {
|
||||
extra = extra || {};
|
||||
|
||||
let map = Map(modes, keys, description, action, extra);
|
||||
map.definedAt = commands.getCaller(Components.stack.caller);
|
||||
map.definedAt = Commands.getCaller(Components.stack.caller);
|
||||
map.hive = this;
|
||||
|
||||
if (this.name !== "builtin")
|
||||
@@ -344,7 +344,7 @@ var Mappings = Module("mappings", {
|
||||
*/
|
||||
add: function () {
|
||||
let map = this.builtin.add.apply(this.builtin, arguments);
|
||||
map.definedAt = commands.getCaller(Components.stack.caller);
|
||||
map.definedAt = Commands.getCaller(Components.stack.caller);
|
||||
return map;
|
||||
},
|
||||
|
||||
@@ -361,7 +361,7 @@ var Mappings = Module("mappings", {
|
||||
*/
|
||||
addUserMap: function () {
|
||||
let map = this.user.add.apply(this.user, arguments);
|
||||
map.definedAt = commands.getCaller(Components.stack.caller);
|
||||
map.definedAt = Commands.getCaller(Components.stack.caller);
|
||||
return map;
|
||||
},
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ var Marks = Module("marks", {
|
||||
events: function () {
|
||||
let appContent = document.getElementById("appcontent");
|
||||
if (appContent)
|
||||
events.addSessionListener(appContent, "load", this.closure._onPageLoad, true);
|
||||
events.addSessionListener(appContent, "load", marks.closure._onPageLoad, true);
|
||||
},
|
||||
mappings: function () {
|
||||
var myModes = config.browserModes;
|
||||
|
||||
@@ -660,7 +660,7 @@ var Options = Module("options", {
|
||||
if (!extraInfo)
|
||||
extraInfo = {};
|
||||
|
||||
extraInfo.definedAt = commands.getCaller(Components.stack.caller);
|
||||
extraInfo.definedAt = Commands.getCaller(Components.stack.caller);
|
||||
|
||||
let name = names[0];
|
||||
if (name in this._optionMap) {
|
||||
@@ -973,7 +973,7 @@ var Options = Module("options", {
|
||||
}
|
||||
if (res)
|
||||
dactyl.echoerr(res);
|
||||
option.setFrom = commands.getCaller(null);
|
||||
option.setFrom = Commands.getCaller(null);
|
||||
}
|
||||
}
|
||||
flushList();
|
||||
|
||||
@@ -168,8 +168,8 @@ var StatusLine = Module("statusline", {
|
||||
if (sh && sh.index < sh.count - 1)
|
||||
modified += "-";
|
||||
}
|
||||
if (modules.bookmarks) {
|
||||
if (bookmarks.isBookmarked(buffer.uri))
|
||||
if (modules.bookmarkcache) {
|
||||
if (bookmarkcache.isBookmarked(buffer.uri))
|
||||
modified += UTF8("❤");
|
||||
//modified += UTF8("♥");
|
||||
}
|
||||
|
||||
@@ -875,7 +875,7 @@ var Tabs = Module("tabs", {
|
||||
}
|
||||
for (let event in values(["TabMove", "TabOpen", "TabClose"]))
|
||||
events.addSessionListener(tabContainer, event, callback, false);
|
||||
events.addSessionListener(tabContainer, "TabSelect", this.closure._onTabSelect, false);
|
||||
events.addSessionListener(tabContainer, "TabSelect", tabs.closure._onTabSelect, false);
|
||||
},
|
||||
mappings: function () {
|
||||
mappings.add([modes.NORMAL], ["g0", "g^"],
|
||||
|
||||
Reference in New Issue
Block a user