mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 20:37:58 +01:00
Add :ha >file.ps
This commit is contained in:
@@ -483,21 +483,34 @@ function Buffer() //{{{
|
||||
"Print current document",
|
||||
function (args)
|
||||
{
|
||||
let aps = options.getPref("print.always_print_silent");
|
||||
let spp = options.getPref("print.show_print_progress");
|
||||
|
||||
options.temporaryContext(function () {
|
||||
if (args[0])
|
||||
{
|
||||
if (args[0][0] != ">")
|
||||
return liberator.echoerr("E488: Trailing characters");
|
||||
options.setPref("print.print_to_file", "true");
|
||||
options.setPref("print.print_to_filename", io.getFile(args[0].substr(1)).path);
|
||||
liberator.echomsg("Printing to file: " + args[0].substr(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
liberator.echomsg("Sending to printer...");
|
||||
}
|
||||
|
||||
options.setPref("print.always_print_silent", args.bang);
|
||||
options.setPref("print.show_print_progress", !args.bang);
|
||||
|
||||
getBrowser().contentWindow.print();
|
||||
});
|
||||
|
||||
options.setPref("print.always_print_silent", aps);
|
||||
options.setPref("print.show_print_progress", spp);
|
||||
if (args[0])
|
||||
liberator.echomsg("Printed: " + args[0].substr(1));
|
||||
else
|
||||
liberator.echomsg("Print job sent.");
|
||||
},
|
||||
{
|
||||
argCount: "0",
|
||||
argCount: "?",
|
||||
literal: 0,
|
||||
bang: true
|
||||
});
|
||||
|
||||
|
||||
@@ -758,9 +758,30 @@ function Commands() //{{{
|
||||
if (completeOpt)
|
||||
{
|
||||
if (/^custom,/.test(completeOpt))
|
||||
completeFunc = completeOpt.substr(7);
|
||||
{
|
||||
completeFunc = function ()
|
||||
{
|
||||
try
|
||||
{
|
||||
var completer = liberator.eval(completeOpt.substr(7));
|
||||
|
||||
if (!(completer instanceof Function))
|
||||
throw new TypeError("User-defined custom completer '" + completeOpt.substr(7) + "' is not a function");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
// FIXME: should be pushed to the MOW
|
||||
liberator.echoerr("E117: Unknown function: " + completeOpt.substr(7));
|
||||
liberator.log(e);
|
||||
return undefined;
|
||||
}
|
||||
return completer.apply(this, Array.slice(arguments));
|
||||
}
|
||||
}
|
||||
else
|
||||
completeFunc = "completion." + completeOptionMap[completeOpt];
|
||||
{
|
||||
completeFunc = function () completion[completeOptionMap[completeOpt]].apply(this, Array.slice(arguments));
|
||||
}
|
||||
}
|
||||
|
||||
if (!commands.addUserCommand(
|
||||
@@ -773,24 +794,7 @@ function Commands() //{{{
|
||||
count: countOpt,
|
||||
completer: function (context, args) {
|
||||
if (completeFunc)
|
||||
{
|
||||
try
|
||||
{
|
||||
var completer = liberator.eval(completeFunc);
|
||||
|
||||
if (!(completer instanceof Function))
|
||||
throw new TypeError("User-defined custom completer '" + completeFunc + "' is not a function");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
// FIXME: should be pushed to the MOW
|
||||
liberator.echoerr("E117: Unknown function: " + completeFunc);
|
||||
liberator.log(e);
|
||||
return;
|
||||
}
|
||||
|
||||
completer.call(completion, context, args)
|
||||
}
|
||||
return completeFunc(context, args)
|
||||
},
|
||||
replacementText: args.literalArg
|
||||
},
|
||||
|
||||
@@ -99,8 +99,7 @@ function IO() //{{{
|
||||
return [];
|
||||
else
|
||||
// empty list item means the current directory
|
||||
return list.replace(/,$/, "")
|
||||
.split(",")
|
||||
return list.replace(/,$/, "").split(",")
|
||||
.map(function (dir) dir == "" ? io.getCurrentDirectory().path : dir);
|
||||
}
|
||||
|
||||
|
||||
@@ -302,7 +302,9 @@ function Options() //{{{
|
||||
const SAVED = "liberator.saved.";
|
||||
|
||||
const prefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||
var optionHash = {};
|
||||
const optionHash = {};
|
||||
|
||||
const prefContexts = [];
|
||||
|
||||
function optionObserver(key, event, option)
|
||||
{
|
||||
@@ -320,6 +322,13 @@ function Options() //{{{
|
||||
|
||||
function storePreference(name, value)
|
||||
{
|
||||
if (prefContexts.length)
|
||||
{
|
||||
let val = loadPreference(name, null);
|
||||
if (val != null)
|
||||
prefContexts[prefContexts.length - 1][name] = val;
|
||||
}
|
||||
|
||||
var type = prefService.getPrefType(name);
|
||||
switch (typeof value)
|
||||
{
|
||||
@@ -988,7 +997,31 @@ function Options() //{{{
|
||||
this.setPref(name, !this.getPref(name));
|
||||
else
|
||||
liberator.echoerr("E488: Trailing characters: " + name + "!");
|
||||
},
|
||||
|
||||
pushContext: function ()
|
||||
{
|
||||
prefContexts.push({});
|
||||
},
|
||||
|
||||
popContext: function ()
|
||||
{
|
||||
for (let [k, v] in Iterator(prefContexts.pop()))
|
||||
storePreference(k, v);
|
||||
},
|
||||
|
||||
temporaryContext: function (fn, self)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.pushContext();
|
||||
return fn.call(self);
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.popContext();
|
||||
}
|
||||
},
|
||||
};
|
||||
//}}}
|
||||
}; //}}}
|
||||
|
||||
@@ -701,6 +701,7 @@ function History() //{{{
|
||||
|
||||
context.completions = [sh.getEntryAtIndex(i, false) for (i in util.range(sh.index, 0, true))];
|
||||
context.keys = { text: function (item) item.URI.spec, description: "title" };
|
||||
liberator.dump(context.items);
|
||||
},
|
||||
count: true,
|
||||
literal: 0
|
||||
|
||||
Reference in New Issue
Block a user