mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 20:07:59 +01:00
move the execute() global function to a slot of vimperator
This commit is contained in:
@@ -421,7 +421,7 @@ function Commands() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultCommand(new Command(["exe[cute]"],
|
addDefaultCommand(new Command(["exe[cute]"],
|
||||||
execute,
|
function(args) { vimperator.execute(args) },
|
||||||
{
|
{
|
||||||
usage: ["exe[cute] {expr1} [ ... ]"],
|
usage: ["exe[cute] {expr1} [ ... ]"],
|
||||||
short_help: "Execute the string that results from the evaluation of {expr1} as an Ex command.",
|
short_help: "Execute the string that results from the evaluation of {expr1} as an Ex command.",
|
||||||
@@ -541,7 +541,7 @@ function Commands() //{{{
|
|||||||
if (/^:/.test(rhs))
|
if (/^:/.test(rhs))
|
||||||
{
|
{
|
||||||
vimperator.mappings.add(
|
vimperator.mappings.add(
|
||||||
new Map(vimperator.modes.NORMAL, [lhs], function() { execute(rhs); }, { rhs: rhs })
|
new Map(vimperator.modes.NORMAL, [lhs], function() { vimperator.execute(rhs); }, { rhs: rhs })
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -651,7 +651,7 @@ function Commands() //{{{
|
|||||||
if (/^:/.test(rhs))
|
if (/^:/.test(rhs))
|
||||||
{
|
{
|
||||||
vimperator.mappings.add(
|
vimperator.mappings.add(
|
||||||
new Map(vimperator.modes.NORMAL, [lhs], function() { execute(rhs); }, { rhs: rhs })
|
new Map(vimperator.modes.NORMAL, [lhs], function() { vimperator.execute(rhs); }, { rhs: rhs })
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -933,7 +933,7 @@ function Commands() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultCommand(new Command(["tab"],
|
addDefaultCommand(new Command(["tab"],
|
||||||
function() { execute(arguments[0], null, null, {inTab: true}); },
|
function(args) { vimperator.execute(args, { inTab: true }); },
|
||||||
{
|
{
|
||||||
usage: ["tab {cmd}"],
|
usage: ["tab {cmd}"],
|
||||||
short_help: "Execute {cmd} and tell it to output in a new tab",
|
short_help: "Execute {cmd} and tell it to output in a new tab",
|
||||||
@@ -1195,19 +1195,6 @@ function tokenize_ex(string, tag)
|
|||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function execute(string)
|
|
||||||
{
|
|
||||||
if (!string)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var tokens = tokenize_ex(string.replace(/^'(.*)'$/, '$1'));
|
|
||||||
tokens[4] = arguments[3];
|
|
||||||
|
|
||||||
return execute_command.apply(this, tokens);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* takes a string like 'google bla, www.osnews.com'
|
/* takes a string like 'google bla, www.osnews.com'
|
||||||
* and returns an array ['www.google.com/search?q=bla', 'www.osnews.com']
|
* and returns an array ['www.google.com/search?q=bla', 'www.osnews.com']
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -207,7 +207,18 @@ const vimperator = (function() //{{{
|
|||||||
sound_service.beep();
|
sound_service.beep();
|
||||||
},
|
},
|
||||||
|
|
||||||
// After pressing Escape, put focus on a non-input field of the browser document
|
execute: function(string, modifiers)
|
||||||
|
{
|
||||||
|
if (!string)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var tokens = tokenize_ex(string.replace(/^'(.*)'$/, '$1'));
|
||||||
|
tokens[4] = modifiers;
|
||||||
|
|
||||||
|
return execute_command.apply(this, tokens);
|
||||||
|
},
|
||||||
|
|
||||||
|
// after pressing Escape, put focus on a non-input field of the browser document
|
||||||
focusContent: function()
|
focusContent: function()
|
||||||
{
|
{
|
||||||
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"].
|
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"].
|
||||||
@@ -454,7 +465,7 @@ const vimperator = (function() //{{{
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// files which end in .js are sourced as pure javascript files,
|
// files which end in .js are sourced as pure javascript files,
|
||||||
// no need (actually forbidden) to add: js <<EOF ... EOF around those files
|
// no need (actually forbidden) to add: js <<EOF ... EOF around those files
|
||||||
source: function(filename, silent)
|
source: function(filename, silent)
|
||||||
{
|
{
|
||||||
@@ -491,7 +502,7 @@ const vimperator = (function() //{{{
|
|||||||
var s = fd.read();
|
var s = fd.read();
|
||||||
fd.close();
|
fd.close();
|
||||||
|
|
||||||
// handle pure javascript files special
|
// handle pure javascript files specially
|
||||||
if (filename.search("\.js$") != -1)
|
if (filename.search("\.js$") != -1)
|
||||||
eval(s);
|
eval(s);
|
||||||
else
|
else
|
||||||
@@ -580,12 +591,12 @@ const vimperator = (function() //{{{
|
|||||||
vimperator.echoerr = vimperator.commandline.echoErr;
|
vimperator.echoerr = vimperator.commandline.echoErr;
|
||||||
|
|
||||||
// TODO: move elsewhere
|
// TODO: move elsewhere
|
||||||
vimperator.registerCallback("submit", vimperator.modes.EX, function(command) { /*vimperator.*/execute(command); } );
|
vimperator.registerCallback("submit", vimperator.modes.EX, function(command) { vimperator.execute(command); } );
|
||||||
vimperator.registerCallback("complete", vimperator.modes.EX, function(str) { return exTabCompletion(str); } );
|
vimperator.registerCallback("complete", vimperator.modes.EX, function(str) { return exTabCompletion(str); } );
|
||||||
|
|
||||||
//TODO: move most of the following code to Options constructor
|
//TODO: move most of the following code to Options constructor
|
||||||
|
|
||||||
// work around firefox popup blocker
|
// work around firefox popup blocker
|
||||||
popup_allowed_events = Options.getFirefoxPref('dom.popup_allowed_events', 'change click dblclick mouseup reset submit');
|
popup_allowed_events = Options.getFirefoxPref('dom.popup_allowed_events', 'change click dblclick mouseup reset submit');
|
||||||
if (!popup_allowed_events.match("keypress"))
|
if (!popup_allowed_events.match("keypress"))
|
||||||
Options.setFirefoxPref('dom.popup_allowed_events', popup_allowed_events + " keypress");
|
Options.setFirefoxPref('dom.popup_allowed_events', popup_allowed_events + " keypress");
|
||||||
@@ -637,7 +648,7 @@ const vimperator = (function() //{{{
|
|||||||
{
|
{
|
||||||
window.dump("Vimperator shutdown\n");
|
window.dump("Vimperator shutdown\n");
|
||||||
|
|
||||||
/*** save our preferences ***/
|
// save our preferences
|
||||||
vimperator.commandline.destroy();
|
vimperator.commandline.destroy();
|
||||||
vimperator.events.destroy();
|
vimperator.events.destroy();
|
||||||
vimperator.quickmarks.destroy();
|
vimperator.quickmarks.destroy();
|
||||||
|
|||||||
Reference in New Issue
Block a user