1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 10:07:59 +01:00

:! command, fixed statusbar height properly, system() now returns the stdout string

This commit is contained in:
Martin Stubenschrott
2007-09-24 11:48:14 +00:00
parent d2e6d0871c
commit 2550e5d736
4 changed files with 73 additions and 14 deletions

View File

@@ -42,7 +42,7 @@ function Command(specs, action, extra_info) //{{{
for (var i = 0; i < specs.length; i++)
{
var match;
if (match = specs[i].match(/(\w+)\[(\w+)\]/))
if (match = specs[i].match(/(\w+|!)\[(\w+)\]/))
{
short_names.push(match[1]);
long_names.push(match[1] + match[2]);
@@ -114,7 +114,7 @@ Command.prototype.hasName = function(name)
{
if (this.specs[i] == name) // literal command name
return true;
else if (this.specs[i].match(/^\w+\[\w+\]$/)) // abbreviation spec
else if (this.specs[i].match(/^(\w+|!)\[\w+\]$/)) // abbreviation spec
if (matchAbbreviation(name, this.specs[i]))
return true;
}
@@ -194,7 +194,7 @@ function Commands() //{{{
}
// 0 - count, 1 - cmd, 2 - special, 3 - args, 4 - heredoc tag
var matches = string.match(/^:*(\d+)?([a-zA-Z]+)(!)?(?:\s+(.*?)\s*)?$/);
var matches = string.match(/^:*(\d+)?([a-zA-Z]+|!)(!)?(?:\s*(.*?)\s*)?$/);
if (!matches)
return [null, null, null, null, null];
matches.shift();
@@ -1557,6 +1557,23 @@ function Commands() //{{{
"Normally this command operates on the text zoom, if used with <code class=\"argument\">[!]</code> it operates on full zoom."
}
));
addDefaultCommand(new Command(["!", "run"],
function(args, special)
{
// TODO: if special, run the last command
var output = vimperator.system(args)
if (typeof output === "string")
vimperator.echo("<pre>" + output + "</pre>");
else
vimperator.echoerr("Invalid system command: " + args);
},
{
usage: "!{command}",
short_help: "Run a command",
help: "Runs {command} through system() and displays its output." +
"Input redirection (< foo) not done, do not run commands which require stdin or it will hang Firefox!"
}
));
//}}}
} //}}}