mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 23:07:59 +01:00
Add :ha >file.ps
This commit is contained in:
@@ -483,21 +483,34 @@ function Buffer() //{{{
|
|||||||
"Print current document",
|
"Print current document",
|
||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
let aps = options.getPref("print.always_print_silent");
|
options.temporaryContext(function () {
|
||||||
let spp = options.getPref("print.show_print_progress");
|
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...");
|
||||||
|
}
|
||||||
|
|
||||||
liberator.echomsg("Sending to printer...");
|
options.setPref("print.always_print_silent", args.bang);
|
||||||
options.setPref("print.always_print_silent", args.bang);
|
options.setPref("print.show_print_progress", !args.bang);
|
||||||
options.setPref("print.show_print_progress", !args.bang);
|
|
||||||
|
|
||||||
getBrowser().contentWindow.print();
|
getBrowser().contentWindow.print();
|
||||||
|
});
|
||||||
|
|
||||||
options.setPref("print.always_print_silent", aps);
|
if (args[0])
|
||||||
options.setPref("print.show_print_progress", spp);
|
liberator.echomsg("Printed: " + args[0].substr(1));
|
||||||
liberator.echomsg("Print job sent.");
|
else
|
||||||
|
liberator.echomsg("Print job sent.");
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
argCount: "0",
|
argCount: "?",
|
||||||
|
literal: 0,
|
||||||
bang: true
|
bang: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -758,9 +758,30 @@ function Commands() //{{{
|
|||||||
if (completeOpt)
|
if (completeOpt)
|
||||||
{
|
{
|
||||||
if (/^custom,/.test(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
|
else
|
||||||
completeFunc = "completion." + completeOptionMap[completeOpt];
|
{
|
||||||
|
completeFunc = function () completion[completeOptionMap[completeOpt]].apply(this, Array.slice(arguments));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!commands.addUserCommand(
|
if (!commands.addUserCommand(
|
||||||
@@ -773,24 +794,7 @@ function Commands() //{{{
|
|||||||
count: countOpt,
|
count: countOpt,
|
||||||
completer: function (context, args) {
|
completer: function (context, args) {
|
||||||
if (completeFunc)
|
if (completeFunc)
|
||||||
{
|
return completeFunc(context, args)
|
||||||
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)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
replacementText: args.literalArg
|
replacementText: args.literalArg
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -99,8 +99,7 @@ function IO() //{{{
|
|||||||
return [];
|
return [];
|
||||||
else
|
else
|
||||||
// empty list item means the current directory
|
// empty list item means the current directory
|
||||||
return list.replace(/,$/, "")
|
return list.replace(/,$/, "").split(",")
|
||||||
.split(",")
|
|
||||||
.map(function (dir) dir == "" ? io.getCurrentDirectory().path : dir);
|
.map(function (dir) dir == "" ? io.getCurrentDirectory().path : dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -302,7 +302,9 @@ function Options() //{{{
|
|||||||
const SAVED = "liberator.saved.";
|
const SAVED = "liberator.saved.";
|
||||||
|
|
||||||
const prefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
const prefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||||
var optionHash = {};
|
const optionHash = {};
|
||||||
|
|
||||||
|
const prefContexts = [];
|
||||||
|
|
||||||
function optionObserver(key, event, option)
|
function optionObserver(key, event, option)
|
||||||
{
|
{
|
||||||
@@ -320,6 +322,13 @@ function Options() //{{{
|
|||||||
|
|
||||||
function storePreference(name, value)
|
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);
|
var type = prefService.getPrefType(name);
|
||||||
switch (typeof value)
|
switch (typeof value)
|
||||||
{
|
{
|
||||||
@@ -988,7 +997,31 @@ function Options() //{{{
|
|||||||
this.setPref(name, !this.getPref(name));
|
this.setPref(name, !this.getPref(name));
|
||||||
else
|
else
|
||||||
liberator.echoerr("E488: Trailing characters: " + name + "!");
|
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.completions = [sh.getEntryAtIndex(i, false) for (i in util.range(sh.index, 0, true))];
|
||||||
context.keys = { text: function (item) item.URI.spec, description: "title" };
|
context.keys = { text: function (item) item.URI.spec, description: "title" };
|
||||||
|
liberator.dump(context.items);
|
||||||
},
|
},
|
||||||
count: true,
|
count: true,
|
||||||
literal: 0
|
literal: 0
|
||||||
|
|||||||
Reference in New Issue
Block a user