aboutsummaryrefslogtreecommitdiffstats
path: root/reporter.js
diff options
context:
space:
mode:
authoranekos2010-03-20 11:07:35 +0000
committeranekos2010-03-20 11:07:35 +0000
commit69472d98e29035af8427d15ef9d7dc45798ac165 (patch)
tree354124d7e00808a8f05bcdcb71cfb9ec2724cbe4 /reporter.js
parent62e534e643aaff947daf23c8d48f2c50aa39bd4e (diff)
downloadvimperator-plugins-69472d98e29035af8427d15ef9d7dc45798ac165.tar.bz2
クリップボード対応
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@37071 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'reporter.js')
-rwxr-xr-xreporter.js51
1 files changed, 42 insertions, 9 deletions
diff --git a/reporter.js b/reporter.js
index abf5746..a905d6a 100755
--- a/reporter.js
+++ b/reporter.js
@@ -65,15 +65,27 @@ let PLUGIN_INFO =
const File = io.File || io.getFile;
- function openFileWith (path, block) {
+ function openClipBoardWith (path, overwrite, block) {
+ let buffer = '';
+ block({
+ write: function (s) buffer += s,
+ writeln: function (s) this.write(s + '\n')
+ });
+ util.copyToClipboard(buffer);
+ }
+
+ function openFileWith (path, overwrite, block) {
let localFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
let out = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
let conv = Cc['@mozilla.org/intl/converter-output-stream;1'].
createInstance(Ci.nsIConverterOutputStream);
let file = File(io.expandPath(path));
- if (file.exists())
+ if (file.exists()) {
+ if (!overwrite)
+ return liberator.echoerr(path + ' already exists (add ! to override)');
file.remove(false);
+ }
localFile.initWithPath(file.path);
out.init(localFile, 0x02 | 0x08, 0664, 0);
@@ -103,20 +115,27 @@ let PLUGIN_INFO =
desc,
function (args) {
let filename = args[0];
- return openFileWith(
+ let clip = args['-clipboard'];
+ if (!!clip === !!filename)
+ return liberator.echoerr(
+ clip ? 'E488: Trailing characters'
+ : 'E471: Argument required');
+ return (clip ? openClipBoardWith : openFileWith)(
filename,
+ args.bang,
function (file) {
- if (file.exists() && !args.bang)
- return liberator.echoerr(filename + ' already exists (add ! to override)');
return action(file, args);
}
);
},
{
- argCount: '1',
+ literalArg: 0,
bang: true,
- options: options,
- completer: function (context) completion.file(context, true)
+ options: [[['-clipboard', '-c'], commands.OPTION_NOARG]].concat(options),
+ completer: function (context, args) {
+ if (!args['-clipboard'])
+ completion.file(context, true)
+ }
},
true
);
@@ -167,7 +186,7 @@ let PLUGIN_INFO =
let value = options.getPref(name);
if (typeof value === 'string' && limit && value.length > limit)
continue;
- file.writeln("set! " + name + "=" + quote(value));
+ file.writeln("set! " + name + "=" + esc(quote(value)));
}
},
@@ -197,6 +216,20 @@ let PLUGIN_INFO =
});
defineCommand({
+ names: ['mkplugins'],
+ desc: 'Write current plugin list to the specified file',
+ options: [LIMIT_OPTION],
+ action: Writer.plugins
+ });
+
+ defineCommand({
+ names: ['mkaddons'],
+ desc: 'Write current ' + config.hostApplication + ' Addon list to the specified file',
+ options: [LIMIT_OPTION],
+ action: Writer.addons
+ });
+
+ defineCommand({
names: ['mkreport'],
desc: 'Write the report for your question.',
options: [LIMIT_OPTION],