mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 21:37:58 +01:00
vimperator is default namespace for scripts, :echo, :js and :time now, so if (options["visualbell"]) ... works there
This commit is contained in:
@@ -813,7 +813,8 @@ vimperator.Commands = function () //{{{
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// TODO: move to vimperator.eval()?
|
// TODO: move to vimperator.eval()?
|
||||||
arg = eval(arg);
|
// with (vimperator) means, vimperator is the default namespace "inside" eval
|
||||||
|
arg = eval("with(vimperator){" + arg + "}");
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
@@ -989,7 +990,7 @@ vimperator.Commands = function () //{{{
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
eval(args);
|
eval("with(vimperator){" + args + "}");
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
@@ -2018,7 +2019,7 @@ vimperator.Commands = function () //{{{
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (i--)
|
while (i--)
|
||||||
eval(args);
|
eval("with(vimperator){" + args + "}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (special)
|
if (special)
|
||||||
@@ -2064,7 +2065,7 @@ vimperator.Commands = function () //{{{
|
|||||||
if (args && args[0] == ":")
|
if (args && args[0] == ":")
|
||||||
vimperator.execute(args);
|
vimperator.execute(args);
|
||||||
else
|
else
|
||||||
eval(args);
|
eval("with(vimperator){" + args + "}");
|
||||||
|
|
||||||
if (special)
|
if (special)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -379,7 +379,7 @@ vimperator.Completion = function () // {{{
|
|||||||
{
|
{
|
||||||
g_substrings = [];
|
g_substrings = [];
|
||||||
var matches = str.match(/^(.*?)(\s*\.\s*)?(\w*)$/);
|
var matches = str.match(/^(.*?)(\s*\.\s*)?(\w*)$/);
|
||||||
var object = "window";
|
var objects = [];
|
||||||
var filter = matches[3] || "";
|
var filter = matches[3] || "";
|
||||||
var start = matches[1].length - 1;
|
var start = matches[1].length - 1;
|
||||||
if (matches[2])
|
if (matches[2])
|
||||||
@@ -411,32 +411,37 @@ vimperator.Completion = function () // {{{
|
|||||||
break outer;
|
break outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
object = matches[1].substr(start+1) || "window";
|
|
||||||
|
if (matches[1].substr(start+1))
|
||||||
|
{
|
||||||
|
objects.push(matches[1].substr(start+1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
objects.push("vimperator");
|
||||||
|
objects.push("window");
|
||||||
|
}
|
||||||
|
|
||||||
var completions = [];
|
var completions = [];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
completions = eval(
|
for (var o = 0; o < objects.length; o++)
|
||||||
"var comp = [];" +
|
{
|
||||||
"var type = '';" +
|
completions = completions.concat(eval(
|
||||||
"var value = '';" +
|
"var comp = [];" +
|
||||||
"var obj = eval(" + object + ");" +
|
"var type = '';" +
|
||||||
"for (var i in obj) {" +
|
"var value = '';" +
|
||||||
" try { type = typeof(obj[i]); } catch (e) { type = 'unknown type'; };" +
|
"var obj = eval('with(vimperator){" + objects[o] + "}');" +
|
||||||
" if (type == 'number' || type == 'string' || type == 'boolean') {" +
|
"for (var i in obj) {" +
|
||||||
" value = obj[i];" +
|
" try { type = typeof(obj[i]); } catch (e) { type = 'unknown type'; };" +
|
||||||
" comp.push([[i], type + ': ' + value]); }" +
|
" if (type == 'number' || type == 'string' || type == 'boolean') {" +
|
||||||
// The problem with that is that you complete vimperator.
|
" value = obj[i];" +
|
||||||
// but can't press <Tab> to complete sub items
|
" comp.push([[i], type + ': ' + value]); }" +
|
||||||
// so it's better to complete vimperator and the user can do
|
" else {" +
|
||||||
// .<tab> to get the sub items
|
" comp.push([[i], type]); }" +
|
||||||
//" else if (type == 'function') {" +
|
"} comp;"
|
||||||
//" comp.push([[i+'('], type]); }" +
|
));
|
||||||
//" else if (type == 'object') {" +
|
}
|
||||||
//" comp.push([[i+'.'], type]); }" +
|
|
||||||
" else {" +
|
|
||||||
" comp.push([[i], type]); }" +
|
|
||||||
"} comp;");
|
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -516,7 +516,7 @@ const vimperator = (function () //{{{
|
|||||||
// handle pure javascript files specially
|
// handle pure javascript files specially
|
||||||
if (/\.js$/.test(filename))
|
if (/\.js$/.test(filename))
|
||||||
{
|
{
|
||||||
eval(str);
|
eval("with(vimperator){" + str + "}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -528,7 +528,7 @@ const vimperator = (function () //{{{
|
|||||||
{
|
{
|
||||||
if (heredoc_end.test(line))
|
if (heredoc_end.test(line))
|
||||||
{
|
{
|
||||||
eval(heredoc);
|
eval("with(vimperator){" + heredoc + "}");
|
||||||
heredoc = "";
|
heredoc = "";
|
||||||
heredoc_end = null;
|
heredoc_end = null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user