mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 21:38:11 +01:00
@@ -648,7 +648,7 @@ const CommandLine = Module("commandline", {
|
|||||||
* commandline.FORCE_MULTILINE - Forces the message to appear in
|
* commandline.FORCE_MULTILINE - Forces the message to appear in
|
||||||
* the MOW.
|
* the MOW.
|
||||||
*/
|
*/
|
||||||
echo: requiresMainThread(function echo(str, highlightGroup, flags) {
|
echo: function echo(str, highlightGroup, flags) {
|
||||||
// dactyl.echo uses different order of flags as it omits the highlight group, change commandline.echo argument order? --mst
|
// dactyl.echo uses different order of flags as it omits the highlight group, change commandline.echo argument order? --mst
|
||||||
if (this._silent)
|
if (this._silent)
|
||||||
return;
|
return;
|
||||||
@@ -694,7 +694,7 @@ const CommandLine = Module("commandline", {
|
|||||||
|
|
||||||
if (action)
|
if (action)
|
||||||
action.call(this, str, highlightGroup, single);
|
action.call(this, str, highlightGroup, single);
|
||||||
}),
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prompt the user. Sets modes.main to COMMAND_LINE, which the user may
|
* Prompt the user. Sets modes.main to COMMAND_LINE, which the user may
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ const CompletionContext = Class("CompletionContext", {
|
|||||||
if (this._completions)
|
if (this._completions)
|
||||||
this.hasItems = this._completions.length > 0;
|
this.hasItems = this._completions.length > 0;
|
||||||
if (this.updateAsync && !this.noUpdate)
|
if (this.updateAsync && !this.noUpdate)
|
||||||
util.callInMainThread(function () { this.onUpdate(); }, this);
|
this.onUpdate();
|
||||||
},
|
},
|
||||||
|
|
||||||
get createRow() this._createRow || template.completionRow, // XXX
|
get createRow() this._createRow || template.completionRow, // XXX
|
||||||
@@ -364,22 +364,6 @@ const CompletionContext = Class("CompletionContext", {
|
|||||||
set generate(arg) {
|
set generate(arg) {
|
||||||
this.hasItems = true;
|
this.hasItems = true;
|
||||||
this._generate = arg;
|
this._generate = arg;
|
||||||
if (this.background && this.regenerate) {
|
|
||||||
let lock = {};
|
|
||||||
this.cache.backgroundLock = lock;
|
|
||||||
this.incomplete = true;
|
|
||||||
let thread = this.getCache("backgroundThread", util.newThread);
|
|
||||||
util.callAsync(thread, this, function () {
|
|
||||||
if (this.cache.backgroundLock != lock)
|
|
||||||
return;
|
|
||||||
let items = this.generate();
|
|
||||||
if (this.cache.backgroundLock != lock)
|
|
||||||
return;
|
|
||||||
this.incomplete = false;
|
|
||||||
if (items != null)
|
|
||||||
this.completions = items;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
get ignoreCase() {
|
get ignoreCase() {
|
||||||
@@ -395,11 +379,11 @@ const CompletionContext = Class("CompletionContext", {
|
|||||||
set ignoreCase(val) this._ignoreCase = val,
|
set ignoreCase(val) this._ignoreCase = val,
|
||||||
|
|
||||||
get items() {
|
get items() {
|
||||||
if (!this.hasItems || this.backgroundLock)
|
if (!this.hasItems)
|
||||||
return [];
|
return [];
|
||||||
|
|
||||||
// Regenerate completions if we must
|
// Regenerate completions if we must
|
||||||
if (this.generate && !this.background) {
|
if (this.generate) {
|
||||||
// XXX
|
// XXX
|
||||||
this.noUpdate = true;
|
this.noUpdate = true;
|
||||||
this.completions = this.generate();
|
this.completions = this.generate();
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ const Dactyl = Module("dactyl", {
|
|||||||
* bell may be either audible or visual depending on the value of the
|
* bell may be either audible or visual depending on the value of the
|
||||||
* 'visualbell' option.
|
* 'visualbell' option.
|
||||||
*/
|
*/
|
||||||
beep: requiresMainThread(function () {
|
beep: function () {
|
||||||
if (options["visualbell"]) {
|
if (options["visualbell"]) {
|
||||||
// flash the visual bell
|
// flash the visual bell
|
||||||
let panel = document.getElementById("dactyl-deck-bell");
|
let panel = document.getElementById("dactyl-deck-bell");
|
||||||
@@ -156,7 +156,7 @@ const Dactyl = Module("dactyl", {
|
|||||||
let soundService = Cc["@mozilla.org/sound;1"].getService(Ci.nsISound);
|
let soundService = Cc["@mozilla.org/sound;1"].getService(Ci.nsISound);
|
||||||
soundService.beep();
|
soundService.beep();
|
||||||
}
|
}
|
||||||
}),
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a string from the system clipboard.
|
* Reads a string from the system clipboard.
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ const Editor = Module("editor", {
|
|||||||
dactyl.assert(args.length >= 1, "No editor specified");
|
dactyl.assert(args.length >= 1, "No editor specified");
|
||||||
|
|
||||||
args.push(path);
|
args.push(path);
|
||||||
util.callInThread(null, io.run, io.expandPath(args.shift()), args, true);
|
io.run(io.expandPath(args.shift()), args, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: clean up with 2 functions for textboxes and currentEditor?
|
// TODO: clean up with 2 functions for textboxes and currentEditor?
|
||||||
|
|||||||
@@ -263,12 +263,11 @@ lookup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
let process = services.create("process");
|
let process = services.create("process");
|
||||||
let isMain = services.get("threading").isMainThread;
|
|
||||||
|
|
||||||
process.init(file);
|
process.init(file);
|
||||||
process.run(blocking && !isMain, args.map(String), args.length);
|
process.run(false, args.map(String), args.length);
|
||||||
try {
|
try {
|
||||||
if (blocking && isMain)
|
if (blocking)
|
||||||
while (process.isRunning)
|
while (process.isRunning)
|
||||||
util.threadYield(false, true);
|
util.threadYield(false, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ defineModule("base", {
|
|||||||
"call", "callable", "ctypes", "curry", "debuggerProperties", "defineModule",
|
"call", "callable", "ctypes", "curry", "debuggerProperties", "defineModule",
|
||||||
"endModule", "forEach", "isArray", "isGenerator", "isinstance",
|
"endModule", "forEach", "isArray", "isGenerator", "isinstance",
|
||||||
"isObject", "isString", "isSubclass", "iter", "iterAll", "keys",
|
"isObject", "isString", "isSubclass", "iter", "iterAll", "keys",
|
||||||
"memoize", "properties", "requiresMainThread", "set", "update", "values",
|
"memoize", "properties", "set", "update", "values",
|
||||||
"withCallerGlobal"
|
"withCallerGlobal"
|
||||||
],
|
],
|
||||||
use: ["services", "util"]
|
use: ["services", "util"]
|
||||||
@@ -587,22 +587,6 @@ function curry(fn, length, self, acc) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Wraps a function so that when called it will always run synchronously
|
|
||||||
* in the main thread. Return values are not preserved.
|
|
||||||
*
|
|
||||||
* @param {function}
|
|
||||||
* @returns {function}
|
|
||||||
*/
|
|
||||||
function requiresMainThread(callback)
|
|
||||||
function wrapper() {
|
|
||||||
let mainThread = services.get("threading").mainThread;
|
|
||||||
if (services.get("threading").isMainThread)
|
|
||||||
callback.apply(this, arguments);
|
|
||||||
else
|
|
||||||
mainThread.dispatch(Runnable(this, callback, arguments), mainThread.DISPATCH_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
let sandbox = Cu.Sandbox(this);
|
let sandbox = Cu.Sandbox(this);
|
||||||
sandbox.__proto__ = this;
|
sandbox.__proto__ = this;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -97,54 +97,6 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
throw new FailedAssertion(message);
|
throw new FailedAssertion(message);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls a function synchronously in the main thread. Return values are not
|
|
||||||
* preserved.
|
|
||||||
*
|
|
||||||
* @param {function} callback
|
|
||||||
* @param {object} self The this object for the call.
|
|
||||||
* @returns {function}
|
|
||||||
*/
|
|
||||||
callInMainThread: function (callback, self) {
|
|
||||||
let mainThread = services.get("threading").mainThread;
|
|
||||||
if (services.get("threading").isMainThread)
|
|
||||||
callback.call(self);
|
|
||||||
else
|
|
||||||
mainThread.dispatch(Runnable(self, callback, Array.slice(arguments, 2)), mainThread.DISPATCH_NORMAL);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls a function asynchronously on a new thread.
|
|
||||||
*
|
|
||||||
* @param {nsIThread} thread The thread to call the function on. If no
|
|
||||||
* thread is specified a new one is created.
|
|
||||||
* @optional
|
|
||||||
* @param {Object} self The 'this' object used when executing the
|
|
||||||
* function.
|
|
||||||
* @param {function} func The function to execute.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
callAsync: function (thread, self, func) {
|
|
||||||
thread = thread || services.get("threading").newThread(0);
|
|
||||||
thread.dispatch(Runnable(self, func, Array.slice(arguments, 3)), thread.DISPATCH_NORMAL);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls a function synchronously on a new thread.
|
|
||||||
*
|
|
||||||
* NOTE: Be sure to call GUI related methods like alert() or dump()
|
|
||||||
* ONLY in the main thread.
|
|
||||||
*
|
|
||||||
* @param {nsIThread} thread The thread to call the function on. If no
|
|
||||||
* thread is specified a new one is created.
|
|
||||||
* @optional
|
|
||||||
* @param {function} func The function to execute.
|
|
||||||
*/
|
|
||||||
callInThread: function (thread, func) {
|
|
||||||
thread = thread || services.get("threading").newThread(0);
|
|
||||||
thread.dispatch(Runnable(null, func, Array.slice(arguments, 2)), thread.DISPATCH_SYNC);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a shallow copy of *obj*.
|
* Returns a shallow copy of *obj*.
|
||||||
*
|
*
|
||||||
@@ -605,8 +557,6 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
return ary;
|
return ary;
|
||||||
},
|
},
|
||||||
|
|
||||||
newThread: function () services.get("threading").newThread(0),
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a URI string into a URI object.
|
* Converts a URI string into a URI object.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user