1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 13:17:58 +01:00

whitespace formatting fixes

This commit is contained in:
Doug Kearns
2007-11-10 15:06:07 +00:00
parent 7e59f88c96
commit 2c5655e182
17 changed files with 692 additions and 692 deletions

View File

@@ -27,7 +27,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
// also includes methods for dealing with keywords and search engines // also includes methods for dealing with keywords and search engines
vimperator.Bookmarks = function() //{{{ vimperator.Bookmarks = function () //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -47,7 +47,7 @@ vimperator.Bookmarks = function() //{{{
var keywords = null; var keywords = null;
if (vimperator.options["preload"]) if (vimperator.options["preload"])
setTimeout(function() { load(); } , 100); setTimeout(function () { load(); } , 100);
function load() function load()
{ {
@@ -102,7 +102,7 @@ vimperator.Bookmarks = function() //{{{
// if "bypass_cache" is true, it will force a reload of the bookmarks database // if "bypass_cache" is true, it will force a reload of the bookmarks database
// on my PC, it takes about 1ms for each bookmark to load, so loading 1000 bookmarks // on my PC, it takes about 1ms for each bookmark to load, so loading 1000 bookmarks
// takes about 1 sec // takes about 1 sec
this.get = function(filter, tags, bypass_cache) this.get = function (filter, tags, bypass_cache)
{ {
if (!bookmarks || bypass_cache) if (!bookmarks || bypass_cache)
load(); load();
@@ -147,7 +147,7 @@ vimperator.Bookmarks = function() //{{{
} }
// returns number of deleted bookmarks // returns number of deleted bookmarks
this.remove = function(url) this.remove = function (url)
{ {
if (!url) if (!url)
return 0; return 0;
@@ -178,7 +178,7 @@ vimperator.Bookmarks = function() //{{{
// TODO: add filtering // TODO: add filtering
// also ensures that each search engine has a Vimperator-friendly alias // also ensures that each search engine has a Vimperator-friendly alias
this.getSearchEngines = function() this.getSearchEngines = function ()
{ {
var search_engines = []; var search_engines = [];
var firefox_engines = search_service.getVisibleEngines({ }); var firefox_engines = search_service.getVisibleEngines({ });
@@ -194,7 +194,7 @@ vimperator.Bookmarks = function() //{{{
var newalias = alias; var newalias = alias;
for (var j = 1; j <= 10; j++) // <=10 is intentional for (var j = 1; j <= 10; j++) // <=10 is intentional
{ {
if (!search_engines.some(function(item) { return (item[0] == newalias); })) if (!search_engines.some(function (item) { return (item[0] == newalias); }))
break; break;
newalias = alias + j; newalias = alias + j;
@@ -212,7 +212,7 @@ vimperator.Bookmarks = function() //{{{
// TODO: add filtering // TODO: add filtering
// format of returned array: // format of returned array:
// [keyword, helptext, url] // [keyword, helptext, url]
this.getKeywords = function() this.getKeywords = function ()
{ {
if (!keywords) if (!keywords)
load(); load();
@@ -223,7 +223,7 @@ vimperator.Bookmarks = function() //{{{
// if @param engine_name is null, it uses the default search engine // if @param engine_name is null, it uses the default search engine
// @returns the url for the search string // @returns the url for the search string
// if the search also requires a postdata, [url, postdata] is returned // if the search also requires a postdata, [url, postdata] is returned
this.getSearchURL = function(text, engine_name) this.getSearchURL = function (text, engine_name)
{ {
var url = null; var url = null;
var postdata = null; var postdata = null;
@@ -271,7 +271,7 @@ vimperator.Bookmarks = function() //{{{
return url; // can be null return url; // can be null
} }
this.list = function(filter, tags, fullmode) this.list = function (filter, tags, fullmode)
{ {
if (fullmode) if (fullmode)
{ {
@@ -328,7 +328,7 @@ vimperator.Bookmarks = function() //{{{
//}}} //}}}
} //}}} } //}}}
vimperator.History = function() //{{{ vimperator.History = function () //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -339,7 +339,7 @@ vimperator.History = function() //{{{
var history = null; var history = null;
if (vimperator.options["preload"]) if (vimperator.options["preload"])
setTimeout(function() { load(); } , 100); setTimeout(function () { load(); } , 100);
function load() function load()
{ {
@@ -374,7 +374,7 @@ vimperator.History = function() //{{{
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
this.get = function(filter) this.get = function (filter)
{ {
if (!history) if (!history)
load(); load();
@@ -389,7 +389,7 @@ vimperator.History = function() //{{{
if (!history) if (!history)
load(); load();
history = history.filter(function(elem) { history = history.filter(function (elem) {
return elem[0] != url; return elem[0] != url;
}); });
@@ -399,7 +399,7 @@ vimperator.History = function() //{{{
// TODO: better names? // TODO: better names?
// and move to vimperator.buffer.? // and move to vimperator.buffer.?
this.stepTo = function(steps) this.stepTo = function (steps)
{ {
var index = getWebNavigation().sessionHistory.index + steps; var index = getWebNavigation().sessionHistory.index + steps;
@@ -413,7 +413,7 @@ vimperator.History = function() //{{{
} }
} }
this.goToStart = function() this.goToStart = function ()
{ {
var index = getWebNavigation().sessionHistory.index; var index = getWebNavigation().sessionHistory.index;
@@ -426,7 +426,7 @@ vimperator.History = function() //{{{
getWebNavigation().gotoIndex(0); getWebNavigation().gotoIndex(0);
} }
this.goToEnd = function() this.goToEnd = function ()
{ {
var index = getWebNavigation().sessionHistory.index; var index = getWebNavigation().sessionHistory.index;
var max = getWebNavigation().sessionHistory.count - 1; var max = getWebNavigation().sessionHistory.count - 1;
@@ -440,7 +440,7 @@ vimperator.History = function() //{{{
getWebNavigation().gotoIndex(max); getWebNavigation().gotoIndex(max);
} }
this.list = function(filter, fullmode) this.list = function (filter, fullmode)
{ {
if (fullmode) if (fullmode)
{ {
@@ -477,7 +477,7 @@ vimperator.History = function() //{{{
//}}} //}}}
} //}}} } //}}}
vimperator.Marks = function() //{{{ vimperator.Marks = function () //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -566,7 +566,7 @@ vimperator.Marks = function() //{{{
umarks.push([mark, url_marks[mark]]); umarks.push([mark, url_marks[mark]]);
// FIXME: why does umarks.sort() cause a "Component is not available = // FIXME: why does umarks.sort() cause a "Component is not available =
// NS_ERROR_NOT_AVAILABLE" exception when used here? // NS_ERROR_NOT_AVAILABLE" exception when used here?
umarks.sort(function(a, b) { umarks.sort(function (a, b) {
if (a[0] < b[0]) if (a[0] < b[0])
return -1; return -1;
else if (a[0] > b[0]) else if (a[0] > b[0])
@@ -583,7 +583,7 @@ vimperator.Marks = function() //{{{
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
// TODO: add support for frameset pages // TODO: add support for frameset pages
this.add = function(mark) this.add = function (mark)
{ {
var win = window.content; var win = window.content;
@@ -613,7 +613,7 @@ vimperator.Marks = function() //{{{
} }
} }
this.remove = function(filter, special) this.remove = function (filter, special)
{ {
if (special) if (special)
{ {
@@ -637,7 +637,7 @@ vimperator.Marks = function() //{{{
} }
} }
this.jumpTo = function(mark) this.jumpTo = function (mark)
{ {
var ok = false; var ok = false;
@@ -691,7 +691,7 @@ vimperator.Marks = function() //{{{
vimperator.echoerr("E20: Mark not set"); // FIXME: move up? vimperator.echoerr("E20: Mark not set"); // FIXME: move up?
} }
this.list = function(filter) this.list = function (filter)
{ {
var marks = getSortedMarks(); var marks = getSortedMarks();
@@ -703,7 +703,7 @@ vimperator.Marks = function() //{{{
if (filter.length > 0) if (filter.length > 0)
{ {
marks = marks.filter(function(mark) { marks = marks.filter(function (mark) {
if (filter.indexOf(mark[0]) > -1) if (filter.indexOf(mark[0]) > -1)
return mark; return mark;
}); });
@@ -732,7 +732,7 @@ vimperator.Marks = function() //{{{
//}}} //}}}
} //}}} } //}}}
vimperator.QuickMarks = function() //{{{ vimperator.QuickMarks = function () //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -751,12 +751,12 @@ vimperator.QuickMarks = function() //{{{
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
this.add = function(qmark, location) this.add = function (qmark, location)
{ {
qmarks[qmark] = location; qmarks[qmark] = location;
} }
this.remove = function(filter) this.remove = function (filter)
{ {
var pattern = new RegExp("[" + filter.replace(/\s+/g, "") + "]"); var pattern = new RegExp("[" + filter.replace(/\s+/g, "") + "]");
@@ -767,12 +767,12 @@ vimperator.QuickMarks = function() //{{{
} }
} }
this.removeAll = function() this.removeAll = function ()
{ {
qmarks = {}; qmarks = {};
} }
this.jumpTo = function(qmark, where) this.jumpTo = function (qmark, where)
{ {
var url = qmarks[qmark]; var url = qmarks[qmark];
@@ -782,7 +782,7 @@ vimperator.QuickMarks = function() //{{{
vimperator.echoerr("E20: QuickMark not set"); vimperator.echoerr("E20: QuickMark not set");
} }
this.list = function(filter) this.list = function (filter)
{ {
var marks = []; var marks = [];
@@ -799,7 +799,7 @@ vimperator.QuickMarks = function() //{{{
if (filter.length > 0) if (filter.length > 0)
{ {
marks = marks.filter(function(mark) { marks = marks.filter(function (mark) {
if (filter.indexOf(mark[0]) > -1) if (filter.indexOf(mark[0]) > -1)
return mark; return mark;
}); });
@@ -822,7 +822,7 @@ vimperator.QuickMarks = function() //{{{
vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE); vimperator.commandline.echo(list, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE);
} }
this.destroy = function() this.destroy = function ()
{ {
// save the quickmarks // save the quickmarks
var saved_qmarks = ""; var saved_qmarks = "";

View File

@@ -26,7 +26,7 @@ the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
vimperator.Buffer = function() //{{{ vimperator.Buffer = function () //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -129,43 +129,43 @@ vimperator.Buffer = function() //{{{
this.lastInputField = null; // used to keep track of the right field for "gi" this.lastInputField = null; // used to keep track of the right field for "gi"
this.__defineGetter__("URL", function() this.__defineGetter__("URL", function ()
{ {
// TODO: .URL is not defined for XUL documents // TODO: .URL is not defined for XUL documents
//return window.content.document.URL; //return window.content.document.URL;
return window.content.document.location.href; return window.content.document.location.href;
}); });
this.__defineGetter__("pageHeight", function() this.__defineGetter__("pageHeight", function ()
{ {
return window.content.innerHeight; return window.content.innerHeight;
}); });
this.__defineGetter__("textZoom", function() this.__defineGetter__("textZoom", function ()
{ {
return getBrowser().mCurrentBrowser.markupDocumentViewer.textZoom * 100; return getBrowser().mCurrentBrowser.markupDocumentViewer.textZoom * 100;
}); });
this.__defineSetter__("textZoom", function(value) this.__defineSetter__("textZoom", function (value)
{ {
setZoom(value, false); setZoom(value, false);
}); });
this.__defineGetter__("fullZoom", function() this.__defineGetter__("fullZoom", function ()
{ {
return getBrowser().mCurrentBrowser.markupDocumentViewer.fullZoom * 100; return getBrowser().mCurrentBrowser.markupDocumentViewer.fullZoom * 100;
}); });
this.__defineSetter__("fullZoom", function(value) this.__defineSetter__("fullZoom", function (value)
{ {
setZoom(value, true); setZoom(value, true);
}); });
this.__defineGetter__("title", function() this.__defineGetter__("title", function ()
{ {
return window.content.document.title; return window.content.document.title;
}); });
// returns an XPathResult object // returns an XPathResult object
this.evaluateXPath = function(expression, doc, elem, asIterator) this.evaluateXPath = function (expression, doc, elem, asIterator)
{ {
if (!doc) if (!doc)
doc = window.content.document; doc = window.content.document;
@@ -191,7 +191,7 @@ vimperator.Buffer = function() //{{{
// in contrast to vim, returns the selection if one is made, // in contrast to vim, returns the selection if one is made,
// otherwise tries to guess the current word unter the text cursor // otherwise tries to guess the current word unter the text cursor
// NOTE: might change the selection // NOTE: might change the selection
this.getCurrentWord = function() this.getCurrentWord = function ()
{ {
var selection = window.content.getSelection().toString(); var selection = window.content.getSelection().toString();
@@ -211,7 +211,7 @@ vimperator.Buffer = function() //{{{
return selection; return selection;
} }
this.list = function(fullmode) this.list = function (fullmode)
{ {
if (fullmode) if (fullmode)
{ {
@@ -258,12 +258,12 @@ vimperator.Buffer = function() //{{{
} }
} }
this.scrollBottom = function() this.scrollBottom = function ()
{ {
scrollToPercentiles(-1, 100); scrollToPercentiles(-1, 100);
} }
this.scrollColumns = function(cols) this.scrollColumns = function (cols)
{ {
var win = window.document.commandDispatcher.focusedWindow; var win = window.document.commandDispatcher.focusedWindow;
const COL_WIDTH = 20; const COL_WIDTH = 20;
@@ -274,42 +274,42 @@ vimperator.Buffer = function() //{{{
win.scrollBy(COL_WIDTH * cols, 0); win.scrollBy(COL_WIDTH * cols, 0);
} }
this.scrollEnd = function() this.scrollEnd = function ()
{ {
scrollToPercentiles(100, -1); scrollToPercentiles(100, -1);
} }
this.scrollLines = function(lines) this.scrollLines = function (lines)
{ {
var win = window.document.commandDispatcher.focusedWindow; var win = window.document.commandDispatcher.focusedWindow;
checkScrollYBounds(win, lines); checkScrollYBounds(win, lines);
win.scrollByLines(lines); win.scrollByLines(lines);
} }
this.scrollPages = function(pages) this.scrollPages = function (pages)
{ {
var win = window.document.commandDispatcher.focusedWindow; var win = window.document.commandDispatcher.focusedWindow;
checkScrollYBounds(win, pages); checkScrollYBounds(win, pages);
win.scrollByPages(pages); win.scrollByPages(pages);
} }
this.scrollToPercentile = function(percentage) this.scrollToPercentile = function (percentage)
{ {
scrollToPercentiles(-1, percentage); scrollToPercentiles(-1, percentage);
} }
this.scrollStart = function() this.scrollStart = function ()
{ {
scrollToPercentiles(0, -1); scrollToPercentiles(0, -1);
} }
this.scrollTop = function() this.scrollTop = function ()
{ {
scrollToPercentiles(-1, 0); scrollToPercentiles(-1, 0);
} }
// TODO: allow callback for filtering out unwanted frames? User defined? // TODO: allow callback for filtering out unwanted frames? User defined?
this.shiftFrameFocus = function(count, forward) this.shiftFrameFocus = function (count, forward)
{ {
if (!window.content.document instanceof HTMLDocument) if (!window.content.document instanceof HTMLDocument)
return; return;
@@ -317,7 +317,7 @@ vimperator.Buffer = function() //{{{
var frames = []; var frames = [];
// find all frames - depth-first search // find all frames - depth-first search
(function(frame) (function (frame)
{ {
if (frame.document.body.localName.toLowerCase() == "body") if (frame.document.body.localName.toLowerCase() == "body")
frames.push(frame); frames.push(frame);
@@ -331,7 +331,7 @@ vimperator.Buffer = function() //{{{
// remove all unfocusable frames // remove all unfocusable frames
// TODO: find a better way to do this - walking the tree is too slow // TODO: find a better way to do this - walking the tree is too slow
var start = document.commandDispatcher.focusedWindow; var start = document.commandDispatcher.focusedWindow;
frames = frames.filter(function(frame) { frames = frames.filter(function (frame) {
frame.focus(); frame.focus();
if (document.commandDispatcher.focusedWindow == frame) if (document.commandDispatcher.focusedWindow == frame)
return frame; return frame;
@@ -404,11 +404,11 @@ vimperator.Buffer = function() //{{{
doc.body.appendChild(indicator); doc.body.appendChild(indicator);
// remove the frame indicator // remove the frame indicator
setTimeout(function() { doc.body.removeChild(indicator); }, 500); setTimeout(function () { doc.body.removeChild(indicator); }, 500);
} }
// updates the buffer preview in place only if list is visible // updates the buffer preview in place only if list is visible
this.updateBufferList = function() this.updateBufferList = function ()
{ {
if (!vimperator.bufferwindow.visible()) if (!vimperator.bufferwindow.visible())
return false; return false;
@@ -421,7 +421,7 @@ vimperator.Buffer = function() //{{{
// XXX: should this be in v.buffers. or v.tabs.? // XXX: should this be in v.buffers. or v.tabs.?
// "buffer" is a string which matches the URL or title of a buffer, if it // "buffer" is a string which matches the URL or title of a buffer, if it
// is null, the last used string is used again // is null, the last used string is used again
this.switchTo = function(buffer, allowNonUnique, count, reverse) this.switchTo = function (buffer, allowNonUnique, count, reverse)
{ {
if (buffer != null) if (buffer != null)
{ {
@@ -472,23 +472,23 @@ vimperator.Buffer = function() //{{{
index += matches.length; index += matches.length;
} }
else else
index = (count-1) % matches.length; index = (count - 1) % matches.length;
vimperator.tabs.select(matches[index], false); vimperator.tabs.select(matches[index], false);
} }
}; };
this.zoomIn = function(steps, full_zoom) this.zoomIn = function (steps, full_zoom)
{ {
bumpZoomLevel(steps, full_zoom); bumpZoomLevel(steps, full_zoom);
}; };
this.zoomOut = function(steps, full_zoom) this.zoomOut = function (steps, full_zoom)
{ {
bumpZoomLevel(-steps, full_zoom); bumpZoomLevel(-steps, full_zoom);
}; };
this.pageInfo = function(verbose) this.pageInfo = function (verbose)
{ {
// TODO: copied from firefox. Needs some review/work... // TODO: copied from firefox. Needs some review/work...
// const feedTypes = { // const feedTypes = {

View File

@@ -26,7 +26,7 @@ the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
vimperator.Command = function(specs, action, extra_info) //{{{ vimperator.Command = function (specs, action, extra_info) //{{{
{ {
if (!specs || !action) if (!specs || !action)
return null; return null;
@@ -34,7 +34,7 @@ vimperator.Command = function(specs, action, extra_info) //{{{
// convert command name abbreviation specs of the form // convert command name abbreviation specs of the form
// 'shortname[optional-tail]' to short and long versions Eg. 'abc[def]' -> // 'shortname[optional-tail]' to short and long versions Eg. 'abc[def]' ->
// 'abc', 'abcdef' // 'abc', 'abcdef'
var parseSpecs = function(specs) var parseSpecs = function (specs)
{ {
var short_names = []; var short_names = [];
var long_names = []; var long_names = [];
@@ -90,14 +90,14 @@ vimperator.Command = function(specs, action, extra_info) //{{{
} }
vimperator.Command.prototype.execute = function(args, special, count, modifiers) vimperator.Command.prototype.execute = function (args, special, count, modifiers)
{ {
return this.action.call(this, args, special, count, modifiers); return this.action.call(this, args, special, count, modifiers);
} }
// return true if the candidate name matches one of the command's aliases // return true if the candidate name matches one of the command's aliases
// (including all acceptable abbreviations) // (including all acceptable abbreviations)
vimperator.Command.prototype.hasName = function(name) vimperator.Command.prototype.hasName = function (name)
{ {
// match a candidate name against a command name abbreviation spec - returning // match a candidate name against a command name abbreviation spec - returning
// true if the candidate matches unambiguously // true if the candidate matches unambiguously
@@ -127,7 +127,7 @@ vimperator.Command.prototype.hasName = function(name)
} }
//}}} //}}}
vimperator.Commands = function() //{{{ vimperator.Commands = function () //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -148,7 +148,7 @@ vimperator.Commands = function() //{{{
function addDefaultCommand(command) function addDefaultCommand(command)
{ {
ex_commands.push(command); ex_commands.push(command);
vimperator.Commands.prototype[command.name] = function(args, special, count, modifiers) vimperator.Commands.prototype[command.name] = function (args, special, count, modifiers)
{ {
command.execute(args, special, count, modifiers); command.execute(args, special, count, modifiers);
} }
@@ -452,12 +452,12 @@ vimperator.Commands = function() //{{{
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
this.__iterator__ = function() this.__iterator__ = function ()
{ {
return commandsIterator(); return commandsIterator();
} }
this.add = function(command) this.add = function (command)
{ {
if (!command) if (!command)
return false; return false;
@@ -467,7 +467,7 @@ vimperator.Commands = function() //{{{
return true; return true;
} }
this.get = function(name) this.get = function (name)
{ {
for (var i = 0; i < ex_commands.length; i++) for (var i = 0; i < ex_commands.length; i++)
{ {
@@ -482,7 +482,7 @@ vimperator.Commands = function() //{{{
// FIXME: doesn't really belong here... // FIXME: doesn't really belong here...
// return [null, null, null, null, heredoc_tag || false]; // return [null, null, null, null, heredoc_tag || false];
// [count, cmd, special, args] = match; // [count, cmd, special, args] = match;
this.parseCommand = function(str, tag) this.parseCommand = function (str, tag)
{ {
// remove comments // remove comments
str.replace(/\s*".*$/, ""); str.replace(/\s*".*$/, "");
@@ -526,14 +526,14 @@ vimperator.Commands = function() //{{{
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
addDefaultCommand(new vimperator.Command(["addo[ns]"], addDefaultCommand(new vimperator.Command(["addo[ns]"],
function() { vimperator.open("chrome://mozapps/content/extensions/extensions.xul", vimperator.NEW_TAB); }, function () { vimperator.open("chrome://mozapps/content/extensions/extensions.xul", vimperator.NEW_TAB); },
{ {
short_help: "Show available Browser Extensions and Themes", short_help: "Show available Browser Extensions and Themes",
help: "You can add/remove/disable browser extensions from this dialog.<br/>Be aware that not all Firefox extensions work, because Vimperator overrides some key bindings and changes Firefox's GUI." help: "You can add/remove/disable browser extensions from this dialog.<br/>Be aware that not all Firefox extensions work, because Vimperator overrides some key bindings and changes Firefox's GUI."
} }
)); ));
addDefaultCommand(new vimperator.Command(["ba[ck]"], addDefaultCommand(new vimperator.Command(["ba[ck]"],
function(args, special, count) function (args, special, count)
{ {
if (special) if (special)
vimperator.history.goToStart(); vimperator.history.goToStart();
@@ -559,7 +559,7 @@ vimperator.Commands = function() //{{{
short_help: "Go back in the browser history", short_help: "Go back in the browser history",
help: "Count is supported, <code class=\"command\">:3back</code> goes back 3 pages in the browser history.<br/>" + help: "Count is supported, <code class=\"command\">:3back</code> goes back 3 pages in the browser history.<br/>" +
"The special version <code class=\"command\">:back!</code> goes to the beginning of the browser history.", "The special version <code class=\"command\">:back!</code> goes to the beginning of the browser history.",
completer: function(filter) completer: function (filter)
{ {
var sh = getWebNavigation().sessionHistory; var sh = getWebNavigation().sessionHistory;
var completions = []; var completions = [];
@@ -576,7 +576,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["bd[elete]", "bw[ipeout]", "bun[load]", "tabc[lose]"], addDefaultCommand(new vimperator.Command(["bd[elete]", "bw[ipeout]", "bun[load]", "tabc[lose]"],
function(args, special, count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count > 0 ? count : 1, special, 0); }, function (args, special, count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count > 0 ? count : 1, special, 0); },
{ {
usage: ["[count]bd[elete][!]"], usage: ["[count]bd[elete][!]"],
short_help: "Delete current buffer (=tab)", short_help: "Delete current buffer (=tab)",
@@ -585,13 +585,13 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["beep"], addDefaultCommand(new vimperator.Command(["beep"],
function() { vimperator.beep(); }, function () { vimperator.beep(); },
{ {
short_help: "Play a system beep" short_help: "Play a system beep"
} }
)); ));
addDefaultCommand(new vimperator.Command(["bma[rk]"], addDefaultCommand(new vimperator.Command(["bma[rk]"],
function(args) function (args)
{ {
var res = parseArgs(args, this.args); var res = parseArgs(args, this.args);
if (!res) if (!res)
@@ -620,11 +620,11 @@ vimperator.Commands = function() //{{{
" -keyword=keyword<br/>", " -keyword=keyword<br/>",
args: [[["-title", "-t"], OPTION_STRING], args: [[["-title", "-t"], OPTION_STRING],
[["-tags", "-T"], OPTION_LIST], [["-tags", "-T"], OPTION_LIST],
[["-keyword", "-k"], OPTION_STRING, function(arg) { return /\w/.test(arg); } ]] [["-keyword", "-k"], OPTION_STRING, function (arg) { return /\w/.test(arg); } ]]
} }
)); ));
addDefaultCommand(new vimperator.Command(["bmarks"], addDefaultCommand(new vimperator.Command(["bmarks"],
function(args, special) function (args, special)
{ {
var res = parseArgs(args, this.args); var res = parseArgs(args, this.args);
if (!res) if (!res)
@@ -640,12 +640,12 @@ vimperator.Commands = function() //{{{
"The special version <code class=\"command\">:bmarks!</code> opens the default Firefox bookmarks window.<br/>" + "The special version <code class=\"command\">:bmarks!</code> opens the default Firefox bookmarks window.<br/>" +
"Filter can also contain the following options:<br/>" + "Filter can also contain the following options:<br/>" +
"-tags=comma,separated,tag,list<br/>", "-tags=comma,separated,tag,list<br/>",
completer: function(filter) { return vimperator.bookmarks.get(filter); }, completer: function (filter) { return vimperator.bookmarks.get(filter); },
args: [[["-tags", "-T"], OPTION_LIST]] args: [[["-tags", "-T"], OPTION_LIST]]
} }
)); ));
addDefaultCommand(new vimperator.Command(["b[uffer]"], addDefaultCommand(new vimperator.Command(["b[uffer]"],
function(args, special) { vimperator.buffer.switchTo(args, special); }, function (args, special) { vimperator.buffer.switchTo(args, special); },
{ {
usage: ["b[uffer][!] {url|index}"], usage: ["b[uffer][!] {url|index}"],
short_help: "Go to buffer from buffer list", short_help: "Go to buffer from buffer list",
@@ -654,11 +654,11 @@ vimperator.Commands = function() //{{{
"it is selected. With <code class=\"argument\">[!]</code> the next buffer matching the argument " + "it is selected. With <code class=\"argument\">[!]</code> the next buffer matching the argument " +
"is selected, even if it cannot be identified uniquely.<br/>" + "is selected, even if it cannot be identified uniquely.<br/>" +
"Use <code class=\"mapping\">b</code> as a shortcut to open this prompt.", "Use <code class=\"mapping\">b</code> as a shortcut to open this prompt.",
completer: function(filter) { return vimperator.completion.get_buffer_completions(filter); } completer: function (filter) { return vimperator.completion.get_buffer_completions(filter); }
} }
)); ));
addDefaultCommand(new vimperator.Command(["buffers", "files", "ls", "tabs"], addDefaultCommand(new vimperator.Command(["buffers", "files", "ls", "tabs"],
function(args, special) function (args, special)
{ {
if (args) if (args)
{ {
@@ -676,7 +676,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["delbm[arks]"], addDefaultCommand(new vimperator.Command(["delbm[arks]"],
function(args, special) function (args, special)
{ {
var url = args; var url = args;
if (!url) if (!url)
@@ -693,11 +693,11 @@ vimperator.Commands = function() //{{{
"Use <code>&lt;Tab&gt;</code> key on a string to complete the URL which you want to delete.<br/>" + "Use <code>&lt;Tab&gt;</code> key on a string to complete the URL which you want to delete.<br/>" +
"The following options WILL be interpreted in the future:<br/>" + "The following options WILL be interpreted in the future:<br/>" +
" [!] a special version to delete ALL bookmarks <br/>", " [!] a special version to delete ALL bookmarks <br/>",
completer: function(filter) { return vimperator.bookmarks.get(filter); } completer: function (filter) { return vimperator.bookmarks.get(filter); }
} }
)); ));
addDefaultCommand(new vimperator.Command(["com[mand]"], addDefaultCommand(new vimperator.Command(["com[mand]"],
function(args) function (args)
{ {
var res = parseArgs(args, this.args); var res = parseArgs(args, this.args);
if (!res) if (!res)
@@ -709,13 +709,13 @@ vimperator.Commands = function() //{{{
usage: ["com[mand][!] [{attr}...] {cmd} {rep}"], usage: ["com[mand][!] [{attr}...] {cmd} {rep}"],
short_help: "Temporarily used for testing args parser", short_help: "Temporarily used for testing args parser",
help: "", help: "",
args: [[["-nargs"], OPTION_STRING, function(arg) { return /^(0|1|\*|\?|\+)$/.test(arg); } ], args: [[["-nargs"], OPTION_STRING, function (arg) { return /^(0|1|\*|\?|\+)$/.test(arg); } ],
[["-bang"], OPTION_NOARG], [["-bang"], OPTION_NOARG],
[["-bar"], OPTION_NOARG]] [["-bar"], OPTION_NOARG]]
} }
)); ));
addDefaultCommand(new vimperator.Command(["delm[arks]"], addDefaultCommand(new vimperator.Command(["delm[arks]"],
function(args, special) function (args, special)
{ {
if (!special && !args) if (!special && !args)
{ {
@@ -768,7 +768,7 @@ vimperator.Commands = function() //{{{
)); ));
addDefaultCommand(new vimperator.Command(["delqm[arks]"], addDefaultCommand(new vimperator.Command(["delqm[arks]"],
function(args, special) function (args, special)
{ {
// TODO: finish arg parsing - we really need a proper way to do this. :) // TODO: finish arg parsing - we really need a proper way to do this. :)
if (!special && !args) if (!special && !args)
@@ -797,7 +797,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["downl[oads]", "dl"], addDefaultCommand(new vimperator.Command(["downl[oads]", "dl"],
function() { vimperator.open("chrome://mozapps/content/downloads/downloads.xul", vimperator.NEW_TAB); }, function () { vimperator.open("chrome://mozapps/content/downloads/downloads.xul", vimperator.NEW_TAB); },
{ {
short_help: "Show progress of current downloads", short_help: "Show progress of current downloads",
help: "Open the original Firefox download dialog in a new tab.<br/>" + help: "Open the original Firefox download dialog in a new tab.<br/>" +
@@ -833,7 +833,7 @@ vimperator.Commands = function() //{{{
return arg; return arg;
} }
addDefaultCommand(new vimperator.Command(["ec[ho]"], addDefaultCommand(new vimperator.Command(["ec[ho]"],
function(args) function (args)
{ {
var res = argToString(args, true); var res = argToString(args, true);
if (res != null) if (res != null)
@@ -845,11 +845,11 @@ vimperator.Commands = function() //{{{
help: "Useful for showing informational messages. Multiple lines can be separated by \\n.<br/>" + help: "Useful for showing informational messages. Multiple lines can be separated by \\n.<br/>" +
"<code class=\"argument\">{expr}</code> can either be a quoted string, or any expression which can be fed to eval() like 4+5. " + "<code class=\"argument\">{expr}</code> can either be a quoted string, or any expression which can be fed to eval() like 4+5. " +
"You can also view the source code of objects and functions if the return value of <code class=\"argument\">{expr}</code> is an object or function.", "You can also view the source code of objects and functions if the return value of <code class=\"argument\">{expr}</code> is an object or function.",
completer: function(filter) { return vimperator.completion.javascript(filter); } completer: function (filter) { return vimperator.completion.javascript(filter); }
} }
)); ));
addDefaultCommand(new vimperator.Command(["echoe[rr]"], addDefaultCommand(new vimperator.Command(["echoe[rr]"],
function(args) function (args)
{ {
var res = argToString(args, false); var res = argToString(args, false);
if (res != null) if (res != null)
@@ -859,11 +859,11 @@ vimperator.Commands = function() //{{{
usage: ["echoe[rr] {expr}"], usage: ["echoe[rr] {expr}"],
short_help: "Display an error string at the bottom of the window", short_help: "Display an error string at the bottom of the window",
help: "Just like <code class=\"command\">:ec[ho]</code>, but echoes the result highlighted in red. Useful for showing important messages.", help: "Just like <code class=\"command\">:ec[ho]</code>, but echoes the result highlighted in red. Useful for showing important messages.",
completer: function(filter) { return vimperator.completion.javascript(filter); } completer: function (filter) { return vimperator.completion.javascript(filter); }
} }
)); ));
addDefaultCommand(new vimperator.Command(["exe[cute]"], addDefaultCommand(new vimperator.Command(["exe[cute]"],
function(args) function (args)
{ {
// TODO: :exec has some difficult semantics -> later // TODO: :exec has some difficult semantics -> later
// var res = parseArgs(args, this.args); // var res = parseArgs(args, this.args);
@@ -881,13 +881,13 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["exu[sage]"], addDefaultCommand(new vimperator.Command(["exu[sage]"],
function(args, special, count, modifiers) { vimperator.help("commands", special, null, modifiers); }, function (args, special, count, modifiers) { vimperator.help("commands", special, null, modifiers); },
{ {
short_help: "Show help for Ex commands" short_help: "Show help for Ex commands"
} }
)); ));
addDefaultCommand(new vimperator.Command(["fo[rward]", "fw"], addDefaultCommand(new vimperator.Command(["fo[rward]", "fw"],
function(args, special, count) function (args, special, count)
{ {
if (special) if (special)
vimperator.history.goToEnd(); vimperator.history.goToEnd();
@@ -913,7 +913,7 @@ vimperator.Commands = function() //{{{
short_help: "Go forward in the browser history", short_help: "Go forward in the browser history",
help: "Count is supported, <code class=\"command\">:3forward</code> goes forward 3 pages in the browser history.<br/>" + help: "Count is supported, <code class=\"command\">:3forward</code> goes forward 3 pages in the browser history.<br/>" +
"The special version <code class=\"command\">:forward!</code> goes to the end of the browser history.", "The special version <code class=\"command\">:forward!</code> goes to the end of the browser history.",
completer: function(filter) completer: function (filter)
{ {
var sh = getWebNavigation().sessionHistory; var sh = getWebNavigation().sessionHistory;
var completions = []; var completions = [];
@@ -930,14 +930,14 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["ha[rdcopy]"], addDefaultCommand(new vimperator.Command(["ha[rdcopy]"],
function() { getBrowser().contentWindow.print(); }, function () { getBrowser().contentWindow.print(); },
{ {
short_help: "Print current document", short_help: "Print current document",
help: "Open a GUI dialog where you can select the printer, number of copies, orientation, etc." help: "Open a GUI dialog where you can select the printer, number of copies, orientation, etc."
} }
)); ));
addDefaultCommand(new vimperator.Command(["h[elp]"], addDefaultCommand(new vimperator.Command(["h[elp]"],
function(args, special, count, modifiers) { vimperator.help(args, special, null, modifiers); }, function (args, special, count, modifiers) { vimperator.help(args, special, null, modifiers); },
{ {
usage: ["h[elp] {subject}"], usage: ["h[elp] {subject}"],
short_help: "Open the help window", short_help: "Open the help window",
@@ -949,21 +949,21 @@ vimperator.Commands = function() //{{{
"<li><code class=\"command\">:help o</code> for mappings (no pre- or postfix)</li>" + "<li><code class=\"command\">:help o</code> for mappings (no pre- or postfix)</li>" +
"</ul>" + "</ul>" +
"You can however use partial stings in the tab completion, so <code class=\"command\">:help he&lt;Tab&gt;</code> completes <code class=\"command\">:help :help</code>.", "You can however use partial stings in the tab completion, so <code class=\"command\">:help he&lt;Tab&gt;</code> completes <code class=\"command\">:help :help</code>.",
completer: function(filter) { return vimperator.completion.get_help_completions(filter); } completer: function (filter) { return vimperator.completion.get_help_completions(filter); }
} }
)); ));
addDefaultCommand(new vimperator.Command(["hist[ory]", "hs"], addDefaultCommand(new vimperator.Command(["hist[ory]", "hs"],
function(args, special) { vimperator.history.list(args, special); }, function (args, special) { vimperator.history.list(args, special); },
{ {
usage: ["hist[ory] [filter]", "history!"], usage: ["hist[ory] [filter]", "history!"],
short_help: "Show recently visited URLs", short_help: "Show recently visited URLs",
help: "Open the message window at the bottom of the screen with all history items which match <code class=\"argument\">[filter]</code> either in the title or URL.<br/>" + help: "Open the message window at the bottom of the screen with all history items which match <code class=\"argument\">[filter]</code> either in the title or URL.<br/>" +
"The special version <code class=\"command\">:history!</code> opens the default Firefox history window.", "The special version <code class=\"command\">:history!</code> opens the default Firefox history window.",
completer: function(filter) { return vimperator.history.get(filter); } completer: function (filter) { return vimperator.history.get(filter); }
} }
)); ));
addDefaultCommand(new vimperator.Command(["javas[cript]", "js"], addDefaultCommand(new vimperator.Command(["javas[cript]", "js"],
function(args, special) function (args, special)
{ {
if (special) // open javascript console if (special) // open javascript console
vimperator.open("chrome://global/content/console.xul", vimperator.NEW_TAB); vimperator.open("chrome://global/content/console.xul", vimperator.NEW_TAB);
@@ -974,7 +974,7 @@ vimperator.Commands = function() //{{{
if (matches && matches[2]) if (matches && matches[2])
{ {
vimperator.commandline.inputMultiline(new RegExp("^" + matches[2] + "$", "m"), vimperator.commandline.inputMultiline(new RegExp("^" + matches[2] + "$", "m"),
function(code) { function (code) {
try try
{ {
eval(matches[1] + "\n" + code); eval(matches[1] + "\n" + code);
@@ -1008,11 +1008,11 @@ vimperator.Commands = function() //{{{
"Rudimentary <code class=\"mapping\">&lt;Tab&gt;</code> completion is available for <code class=\"command\">:javascript {cmd}&lt;Tab&gt;</code> (but not yet for the " + "Rudimentary <code class=\"mapping\">&lt;Tab&gt;</code> completion is available for <code class=\"command\">:javascript {cmd}&lt;Tab&gt;</code> (but not yet for the " +
"<code class=\"command\">:js &lt;&lt;EOF</code> multiline widget). Be aware that Vimperator needs to run {cmd} through eval() " + "<code class=\"command\">:js &lt;&lt;EOF</code> multiline widget). Be aware that Vimperator needs to run {cmd} through eval() " +
"to get the completions, which could have unwanted side effects.", "to get the completions, which could have unwanted side effects.",
completer: function(filter) { return vimperator.completion.javascript(filter); } completer: function (filter) { return vimperator.completion.javascript(filter); }
} }
)); ));
addDefaultCommand(new vimperator.Command(["let"], addDefaultCommand(new vimperator.Command(["let"],
function(args) function (args)
{ {
if (!args) if (!args)
{ {
@@ -1100,7 +1100,7 @@ vimperator.Commands = function() //{{{
)); ));
// code for abbreviations // code for abbreviations
addDefaultCommand(new vimperator.Command(["ab[breviate]"], addDefaultCommand(new vimperator.Command(["ab[breviate]"],
function(args) function (args)
{ {
if (!args) if (!args)
{ {
@@ -1124,7 +1124,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["ca[bbrev]"], addDefaultCommand(new vimperator.Command(["ca[bbrev]"],
function(args) function (args)
{ {
if (!args) if (!args)
{ {
@@ -1146,7 +1146,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["ia[bbrev]"], addDefaultCommand(new vimperator.Command(["ia[bbrev]"],
function(args) function (args)
{ {
if (!args) if (!args)
{ {
@@ -1168,14 +1168,14 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["una[bbreviate]"], addDefaultCommand(new vimperator.Command(["una[bbreviate]"],
function(args) { vimperator.editor.removeAbbreviation("!", args); }, function (args) { vimperator.editor.removeAbbreviation("!", args); },
{ {
usage: ["una[bbreviate] {lhs}"], usage: ["una[bbreviate] {lhs}"],
short_help: "Remove an abbreviation" short_help: "Remove an abbreviation"
} }
)); ));
addDefaultCommand(new vimperator.Command(["cuna[bbrev]"], addDefaultCommand(new vimperator.Command(["cuna[bbrev]"],
function(args) { vimperator.editor.removeAbbreviation("c", args); }, function (args) { vimperator.editor.removeAbbreviation("c", args); },
{ {
usage: ["cuna[bbrev] {lhs}"], usage: ["cuna[bbrev] {lhs}"],
short_help: "Remove an abbreviation for Command-line mode", short_help: "Remove an abbreviation for Command-line mode",
@@ -1183,7 +1183,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["iuna[bbrev]"], addDefaultCommand(new vimperator.Command(["iuna[bbrev]"],
function(args) { vimperator.editor.removeAbbreviation("i", args); }, function (args) { vimperator.editor.removeAbbreviation("i", args); },
{ {
usage: ["iuna[bbrev] {lhs}"], usage: ["iuna[bbrev] {lhs}"],
short_help: "Remove an abbreviation for Insert mode", short_help: "Remove an abbreviation for Insert mode",
@@ -1191,15 +1191,15 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["ab[clear]"], addDefaultCommand(new vimperator.Command(["ab[clear]"],
function(args) { vimperator.editor.removeAllAbbreviations("!"); }, function (args) { vimperator.editor.removeAllAbbreviations("!"); },
{ short_help: "Remove all abbreviations" } { short_help: "Remove all abbreviations" }
)); ));
addDefaultCommand(new vimperator.Command(["cab[clear]"], addDefaultCommand(new vimperator.Command(["cab[clear]"],
function(args) { vimperator.editor.removeAllAbbreviations("c"); }, function (args) { vimperator.editor.removeAllAbbreviations("c"); },
{ short_help: "Remove all abbreviations for Command-line mode" } { short_help: "Remove all abbreviations for Command-line mode" }
)); ));
addDefaultCommand(new vimperator.Command(["iab[clear]"], addDefaultCommand(new vimperator.Command(["iab[clear]"],
function(args) { vimperator.editor.removeAllAbbreviations("i"); }, function (args) { vimperator.editor.removeAllAbbreviations("i"); },
{ short_help: "Remove all abbreviations for Insert mode" } { short_help: "Remove all abbreviations for Insert mode" }
)); ));
// 0 args -> list all maps // 0 args -> list all maps
@@ -1228,7 +1228,7 @@ vimperator.Commands = function() //{{{
if (rhs) if (rhs)
{ {
vimperator.mappings.add(new vimperator.Map([vimperator.modes.NORMAL], [lhs], vimperator.mappings.add(new vimperator.Map([vimperator.modes.NORMAL], [lhs],
function(count) { vimperator.events.feedkeys((count > 1 ? count : "") + rhs, noremap); }, function (count) { vimperator.events.feedkeys((count > 1 ? count : "") + rhs, noremap); },
{ flags: vimperator.Mappings.flags.COUNT, rhs: rhs } { flags: vimperator.Mappings.flags.COUNT, rhs: rhs }
)); ));
} }
@@ -1239,7 +1239,7 @@ vimperator.Commands = function() //{{{
} }
} }
addDefaultCommand(new vimperator.Command(["map"], addDefaultCommand(new vimperator.Command(["map"],
function(args) { map(args, false) }, function (args) { map(args, false) },
{ {
usage: ["map {lhs} {rhs}", "map {lhs}", "map"], usage: ["map {lhs} {rhs}", "map {lhs}", "map"],
short_help: "Map the key sequence {lhs} to {rhs}", short_help: "Map the key sequence {lhs} to {rhs}",
@@ -1248,7 +1248,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["mapc[lear]"], addDefaultCommand(new vimperator.Command(["mapc[lear]"],
function(args) function (args)
{ {
if (args) if (args)
{ {
@@ -1265,7 +1265,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["ma[rk]"], addDefaultCommand(new vimperator.Command(["ma[rk]"],
function(args) function (args)
{ {
if (!args) if (!args)
{ {
@@ -1291,7 +1291,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["marks"], addDefaultCommand(new vimperator.Command(["marks"],
function(args) function (args)
{ {
// ignore invalid mark characters unless there are no valid mark chars // ignore invalid mark characters unless there are no valid mark chars
if (args && !/[a-zA-Z]/.test(args)) if (args && !/[a-zA-Z]/.test(args))
@@ -1310,7 +1310,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["mkv[imperatorrc]"], addDefaultCommand(new vimperator.Command(["mkv[imperatorrc]"],
function(args, special) function (args, special)
{ {
// TODO: "E172: Only one file name allowed" // TODO: "E172: Only one file name allowed"
var filename; var filename;
@@ -1369,7 +1369,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["noh[lsearch]"], addDefaultCommand(new vimperator.Command(["noh[lsearch]"],
function(args) function (args)
{ {
vimperator.search.clear(); vimperator.search.clear();
}, },
@@ -1380,7 +1380,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["norm[al]"], addDefaultCommand(new vimperator.Command(["norm[al]"],
function(args) function (args)
{ {
if (!args) if (!args)
{ {
@@ -1398,7 +1398,7 @@ vimperator.Commands = function() //{{{
)); ));
// TODO: remove duplication in :map // TODO: remove duplication in :map
addDefaultCommand(new vimperator.Command(["no[remap]"], addDefaultCommand(new vimperator.Command(["no[remap]"],
function(args) { map(args, true) }, function (args) { map(args, true) },
{ {
usage: ["no[remap] {lhs} {rhs}", "no[remap] {lhs}", "no[remap]"], usage: ["no[remap] {lhs} {rhs}", "no[remap] {lhs}", "no[remap]"],
short_help: "Map the key sequence {lhs} to {rhs}", short_help: "Map the key sequence {lhs} to {rhs}",
@@ -1406,7 +1406,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["o[pen]", "e[dit]"], addDefaultCommand(new vimperator.Command(["o[pen]", "e[dit]"],
function(args, special) function (args, special)
{ {
if (args) if (args)
{ {
@@ -1445,7 +1445,7 @@ vimperator.Commands = function() //{{{
"The items which are completed on <code class=\"mapping\">&lt;Tab&gt;</code> are specified in the <code class=\"option\">'complete'</code> option.<br/>" + "The items which are completed on <code class=\"mapping\">&lt;Tab&gt;</code> are specified in the <code class=\"option\">'complete'</code> option.<br/>" +
"Without argument, reloads the current page.<br/>" + "Without argument, reloads the current page.<br/>" +
"Without argument but with <code class=\"command\">!</code>, reloads the current page skipping the cache.", "Without argument but with <code class=\"command\">!</code>, reloads the current page skipping the cache.",
completer: function(filter) { return vimperator.completion.get_url_completions(filter); } completer: function (filter) { return vimperator.completion.get_url_completions(filter); }
} }
)); ));
addDefaultCommand(new vimperator.Command(["pa[geinfo]"], addDefaultCommand(new vimperator.Command(["pa[geinfo]"],
@@ -1456,13 +1456,13 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["pc[lose]"], addDefaultCommand(new vimperator.Command(["pc[lose]"],
function() { vimperator.previewwindow.hide(); }, function () { vimperator.previewwindow.hide(); },
{ {
short_help: "Close preview window on bottom of screen" short_help: "Close preview window on bottom of screen"
} }
)); ));
addDefaultCommand(new vimperator.Command(["pref[erences]", "prefs"], addDefaultCommand(new vimperator.Command(["pref[erences]", "prefs"],
function(args, special, count, modifiers) function (args, special, count, modifiers)
{ {
if (!args) if (!args)
{ {
@@ -1494,7 +1494,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["qma[rk]"], addDefaultCommand(new vimperator.Command(["qma[rk]"],
function(args) function (args)
{ {
if (!args) if (!args)
{ {
@@ -1518,7 +1518,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["qmarks"], addDefaultCommand(new vimperator.Command(["qmarks"],
function(args) function (args)
{ {
// ignore invalid mark characters unless there are no valid mark chars // ignore invalid mark characters unless there are no valid mark chars
if (args && !/[a-zA-Z0-9]/.test(args)) if (args && !/[a-zA-Z0-9]/.test(args))
@@ -1537,7 +1537,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["q[uit]"], addDefaultCommand(new vimperator.Command(["q[uit]"],
function() { vimperator.tabs.remove(getBrowser().mCurrentTab, 1, false, 1); }, function () { vimperator.tabs.remove(getBrowser().mCurrentTab, 1, false, 1); },
{ {
short_help: "Quit current tab", short_help: "Quit current tab",
help: "If this is the last tab in the window, close the window. If this was the " + help: "If this is the last tab in the window, close the window. If this was the " +
@@ -1545,14 +1545,14 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["quita[ll]", "qa[ll]"], addDefaultCommand(new vimperator.Command(["quita[ll]", "qa[ll]"],
function() { vimperator.quit(false); }, function () { vimperator.quit(false); },
{ {
short_help: "Quit Vimperator", short_help: "Quit Vimperator",
help: "Quit Vimperator, no matter how many tabs/windows are open. The session is not stored." help: "Quit Vimperator, no matter how many tabs/windows are open. The session is not stored."
} }
)); ));
addDefaultCommand(new vimperator.Command(["redr[aw]"], addDefaultCommand(new vimperator.Command(["redr[aw]"],
function() function ()
{ {
var wu = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). var wu = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
getInterface(Components.interfaces.nsIDOMWindowUtils); getInterface(Components.interfaces.nsIDOMWindowUtils);
@@ -1564,7 +1564,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["re[load]"], addDefaultCommand(new vimperator.Command(["re[load]"],
function(args, special) { vimperator.tabs.reload(getBrowser().mCurrentTab, special); }, function (args, special) { vimperator.tabs.reload(getBrowser().mCurrentTab, special); },
{ {
usage: ["re[load][!]"], usage: ["re[load][!]"],
short_help: "Reload current page", short_help: "Reload current page",
@@ -1572,7 +1572,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["reloada[ll]"], addDefaultCommand(new vimperator.Command(["reloada[ll]"],
function(args, special) { vimperator.tabs.reloadAll(special); }, function (args, special) { vimperator.tabs.reloadAll(special); },
{ {
usage: ["reloada[ll][!]"], usage: ["reloada[ll][!]"],
short_help: "Reload all pages", short_help: "Reload all pages",
@@ -1580,14 +1580,14 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["res[tart]"], addDefaultCommand(new vimperator.Command(["res[tart]"],
function() { vimperator.restart(); }, function () { vimperator.restart(); },
{ {
short_help: "Force the browser to restart", short_help: "Force the browser to restart",
help: "Useful when installing extensions." help: "Useful when installing extensions."
} }
)); ));
addDefaultCommand(new vimperator.Command(["sav[eas]", "w[rite]"], addDefaultCommand(new vimperator.Command(["sav[eas]", "w[rite]"],
function() { saveDocument(window.content.document); }, function () { saveDocument(window.content.document); },
{ {
short_help: "Save current web page to disk", short_help: "Save current web page to disk",
help: "Opens the original Firefox \"Save page as...\" dialog.<br/>" + help: "Opens the original Firefox \"Save page as...\" dialog.<br/>" +
@@ -1596,7 +1596,7 @@ vimperator.Commands = function() //{{{
)); ));
addDefaultCommand(new vimperator.Command(["se[t]"], addDefaultCommand(new vimperator.Command(["se[t]"],
// TODO: support setting multiple options at once // TODO: support setting multiple options at once
function(args, special, count, modifiers) function (args, special, count, modifiers)
{ {
if (special) if (special)
{ {
@@ -1805,12 +1805,12 @@ vimperator.Commands = function() //{{{
"<code class=\"command\">:set option+={value}</code>, <code class=\"command\">:set option^={value}</code> and <code class=\"command\">:set option-={value}</code> " + "<code class=\"command\">:set option+={value}</code>, <code class=\"command\">:set option^={value}</code> and <code class=\"command\">:set option-={value}</code> " +
"adds/multiplies/subtracts <code class=\"argument\">{value}</code> from a number option and appends/prepends/removes <code class=\"argument\">{value}</code> from a string option.<br/>" + "adds/multiplies/subtracts <code class=\"argument\">{value}</code> from a number option and appends/prepends/removes <code class=\"argument\">{value}</code> from a string option.<br/>" +
"<code class=\"command\">:set all</code> shows the current value of all options and <code class=\"command\">:set all&amp;</code> resets all options to their default values.<br/>", "<code class=\"command\">:set all</code> shows the current value of all options and <code class=\"command\">:set all&amp;</code> resets all options to their default values.<br/>",
completer: function(filter) { return vimperator.completion.get_options_completions(filter); } completer: function (filter) { return vimperator.completion.get_options_completions(filter); }
} }
)); ));
// TODO: sclose instead? // TODO: sclose instead?
addDefaultCommand(new vimperator.Command(["sbcl[ose]"], addDefaultCommand(new vimperator.Command(["sbcl[ose]"],
function(args) function (args)
{ {
if (args) if (args)
{ {
@@ -1828,7 +1828,7 @@ vimperator.Commands = function() //{{{
// TODO: sopen instead? Separate :sidebar from :sbopen and make them behave // TODO: sopen instead? Separate :sidebar from :sbopen and make them behave
// more like :cw, :cope etc // more like :cw, :cope etc
addDefaultCommand(new vimperator.Command(["sideb[ar]", "sb[ar]", "sbope[n]"], addDefaultCommand(new vimperator.Command(["sideb[ar]", "sb[ar]", "sbope[n]"],
function(args) function (args)
{ {
if (!args) if (!args)
{ {
@@ -1859,11 +1859,11 @@ vimperator.Commands = function() //{{{
short_help: "Open the sidebar window", short_help: "Open the sidebar window",
help: "<code class=\"argument\">{name}</code> is any of the menu items listed under the standard Firefox View->Sidebar " + help: "<code class=\"argument\">{name}</code> is any of the menu items listed under the standard Firefox View->Sidebar " +
"menu. Add-ons, Preferences and Downloads are also available in the sidebar.", "menu. Add-ons, Preferences and Downloads are also available in the sidebar.",
completer: function(filter) { return vimperator.completion.get_sidebar_completions(filter); } completer: function (filter) { return vimperator.completion.get_sidebar_completions(filter); }
} }
)); ));
addDefaultCommand(new vimperator.Command(["so[urce]"], addDefaultCommand(new vimperator.Command(["so[urce]"],
function(args, special) function (args, special)
{ {
// FIXME: implement proper filename quoting // FIXME: implement proper filename quoting
//if (/[^\\]\s/.test(args)) //if (/[^\\]\s/.test(args))
@@ -1879,14 +1879,14 @@ vimperator.Commands = function() //{{{
short_help: "Read Ex commands from {file}", short_help: "Read Ex commands from {file}",
help: "You can either source files which mostly contain Ex commands like <code class=\"command\">map &lt; gt</code> " + help: "You can either source files which mostly contain Ex commands like <code class=\"command\">map &lt; gt</code> " +
"and put JavaScript code within a:<br/><code class=\"code\">" + "and put JavaScript code within a:<br/><code class=\"code\">" +
"js &lt;&lt;EOF<br/>hello = function() {<br/>&nbsp;&nbsp;alert(\"Hello world\");<br/>}<br/>EOF<br/></code> section.<br/>" + "js &lt;&lt;EOF<br/>hello = function () {<br/>&nbsp;&nbsp;alert(\"Hello world\");<br/>}<br/>EOF<br/></code> section.<br/>" +
"Or you can alternatively source a file which ends in .js, these files are automatically sourced as pure JavaScript files.<br/>" + "Or you can alternatively source a file which ends in .js, these files are automatically sourced as pure JavaScript files.<br/>" +
"NOTE: In both cases you must add functions to the global window object like shown above, functions written as:<br/>" + "NOTE: In both cases you must add functions to the global window object like shown above, functions written as:<br/>" +
"<code class=\"code\">function hello2() {<br/>&nbsp;&nbsp;alert(\"Hello world\");<br/>}<br/></code>are only available within the scope of the script. <br/><br/>" + "<code class=\"code\">function hello2() {<br/>&nbsp;&nbsp;alert(\"Hello world\");<br/>}<br/></code>are only available within the scope of the script. <br/><br/>" +
"The .vimperatorrc file in your home directory and any files in ~/.vimperator/plugin/ are always sourced at startup.<br/>" + "The .vimperatorrc file in your home directory and any files in ~/.vimperator/plugin/ are always sourced at startup.<br/>" +
"~ is supported as a shortcut for the <var>$HOME</var> directory.<br/>" + "~ is supported as a shortcut for the <var>$HOME</var> directory.<br/>" +
"If <code class=\"command\">!</code> is specified, errors are not printed.", "If <code class=\"command\">!</code> is specified, errors are not printed.",
completer: function(filter) { return vimperator.completion.get_file_completions(filter); } completer: function (filter) { return vimperator.completion.get_file_completions(filter); }
} }
)); ));
addDefaultCommand(new vimperator.Command(["st[op]"], addDefaultCommand(new vimperator.Command(["st[op]"],
@@ -1897,24 +1897,24 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["tab"], addDefaultCommand(new vimperator.Command(["tab"],
function(args) { vimperator.execute(args, { 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",
help: "Works only for commands that support it, currently:" + help: "Works only for commands that support it, currently:" +
"<ul><li>:tab help</li>" + "<ul><li>:tab help</li>" +
"<li>:tab prefs[!]</li></ul>", "<li>:tab prefs[!]</li></ul>",
completer: function(filter) { return vimperator.completion.get_command_completions(filter); } completer: function (filter) { return vimperator.completion.get_command_completions(filter); }
} }
)); ));
addDefaultCommand(new vimperator.Command(["tabl[ast]"], addDefaultCommand(new vimperator.Command(["tabl[ast]"],
function() { vimperator.tabs.select("$", false); }, function () { vimperator.tabs.select("$", false); },
{ {
short_help: "Switch to the last tab" short_help: "Switch to the last tab"
} }
)); ));
addDefaultCommand(new vimperator.Command(["tabm[ove]"], addDefaultCommand(new vimperator.Command(["tabm[ove]"],
function(args, special) { vimperator.tabs.move(getBrowser().mCurrentTab, args, special); }, function (args, special) { vimperator.tabs.move(getBrowser().mCurrentTab, args, special); },
{ {
usage: ["tabm[ove] [N]", "tabm[ove][!] +N | -N"], usage: ["tabm[ove] [N]", "tabm[ove][!] +N | -N"],
short_help: "Move the current tab after tab N", short_help: "Move the current tab after tab N",
@@ -1924,7 +1924,7 @@ vimperator.Commands = function() //{{{
)); ));
addDefaultCommand(new vimperator.Command(["tabn[ext]", "tn[ext]"], addDefaultCommand(new vimperator.Command(["tabn[ext]", "tn[ext]"],
// TODO: count support // TODO: count support
function(args) function (args)
{ {
if (!args) if (!args)
{ {
@@ -1950,13 +1950,13 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["tabo[nly]"], addDefaultCommand(new vimperator.Command(["tabo[nly]"],
function() { vimperator.tabs.keepOnly(getBrowser().mCurrentTab); }, function () { vimperator.tabs.keepOnly(getBrowser().mCurrentTab); },
{ {
short_help: "Close all other tabs" short_help: "Close all other tabs"
} }
)); ));
addDefaultCommand(new vimperator.Command(["tabopen", "t[open]", "tabnew", "tabe[dit]"], addDefaultCommand(new vimperator.Command(["tabopen", "t[open]", "tabnew", "tabe[dit]"],
function(args, special) function (args, special)
{ {
var where = special ? vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB; var where = special ? vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB;
if (/\btabopen\b/.test(vimperator.options["activate"])) if (/\btabopen\b/.test(vimperator.options["activate"]))
@@ -1972,12 +1972,12 @@ vimperator.Commands = function() //{{{
short_help: "Open one or more URLs in a new tab", short_help: "Open one or more URLs in a new tab",
help: "Like <code class=\"command\">:open</code> but open URLs in a new tab.<br/>" + help: "Like <code class=\"command\">:open</code> but open URLs in a new tab.<br/>" +
"If used with <code class=\"command\">!</code>, the 'tabopen' value of the <code class=\"option\">'activate'</code> option is negated.", "If used with <code class=\"command\">!</code>, the 'tabopen' value of the <code class=\"option\">'activate'</code> option is negated.",
completer: function(filter) { return vimperator.completion.get_url_completions(filter); } completer: function (filter) { return vimperator.completion.get_url_completions(filter); }
} }
)); ));
addDefaultCommand(new vimperator.Command(["tabp[revious]", "tp[revious]", "tabN[ext]", "tN[ext]"], addDefaultCommand(new vimperator.Command(["tabp[revious]", "tp[revious]", "tabN[ext]", "tN[ext]"],
// TODO: count support // TODO: count support
function(args) function (args)
{ {
if (!args) if (!args)
vimperator.tabs.select("-1", true); vimperator.tabs.select("-1", true);
@@ -1993,14 +1993,14 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["tabr[ewind]", "tabfir[st]"], addDefaultCommand(new vimperator.Command(["tabr[ewind]", "tabfir[st]"],
function() { vimperator.tabs.select(0, false); }, function () { vimperator.tabs.select(0, false); },
{ {
usage: ["tabr[ewind]", "tabfir[st]"], usage: ["tabr[ewind]", "tabfir[st]"],
short_help: "Switch to the first tab" short_help: "Switch to the first tab"
} }
)); ));
addDefaultCommand(new vimperator.Command(["time"], addDefaultCommand(new vimperator.Command(["time"],
function(args, special, count) function (args, special, count)
{ {
try try
{ {
@@ -2091,7 +2091,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["u[ndo]"], addDefaultCommand(new vimperator.Command(["u[ndo]"],
function(args, special, count) function (args, special, count)
{ {
if (count < 1) if (count < 1)
count = 1; count = 1;
@@ -2116,7 +2116,7 @@ vimperator.Commands = function() //{{{
short_help: "Undo closing of a tab", short_help: "Undo closing of a tab",
help: "If a count is given, don't close the last but the <code class=\"argument\">[count]</code>th last tab. " + help: "If a count is given, don't close the last but the <code class=\"argument\">[count]</code>th last tab. " +
"With <code class=\"argument\">[url]</code> restores the tab matching the url.", "With <code class=\"argument\">[url]</code> restores the tab matching the url.",
completer: function(filter) completer: function (filter)
{ {
// get closed-tabs from nsSessionStore // get closed-tabs from nsSessionStore
var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
@@ -2135,7 +2135,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["undoa[ll]"], addDefaultCommand(new vimperator.Command(["undoa[ll]"],
function(args, special, count) function (args, special, count)
{ {
if (count > -1) if (count > -1)
{ {
@@ -2159,7 +2159,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["unl[et]"], addDefaultCommand(new vimperator.Command(["unl[et]"],
function(args, special) function (args, special)
{ {
if (!args) if (!args)
return vimperator.echoerr("E471: Argument required"); return vimperator.echoerr("E471: Argument required");
@@ -2188,7 +2188,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["unm[ap]"], addDefaultCommand(new vimperator.Command(["unm[ap]"],
function(args) function (args)
{ {
if (!args) if (!args)
{ {
@@ -2210,7 +2210,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["ve[rsion]"], addDefaultCommand(new vimperator.Command(["ve[rsion]"],
function(args, special) function (args, special)
{ {
if (special) if (special)
vimperator.open("about:"); vimperator.open("about:");
@@ -2225,13 +2225,13 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["viu[sage]"], addDefaultCommand(new vimperator.Command(["viu[sage]"],
function(args, special, count, modifiers) { vimperator.help("mappings", special, null, modifiers); }, function (args, special, count, modifiers) { vimperator.help("mappings", special, null, modifiers); },
{ {
short_help: "Show help for normal mode commands" short_help: "Show help for normal mode commands"
} }
)); ));
addDefaultCommand(new vimperator.Command(["winc[lose]", "wc[lose]"], addDefaultCommand(new vimperator.Command(["winc[lose]", "wc[lose]"],
function(args) function (args)
{ {
window.close(); window.close();
}, },
@@ -2241,7 +2241,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["wino[pen]", "wo[pen]", "wine[dit]"], addDefaultCommand(new vimperator.Command(["wino[pen]", "wo[pen]", "wine[dit]"],
function(args) function (args)
{ {
if (args) if (args)
vimperator.open(args, vimperator.NEW_WINDOW); vimperator.open(args, vimperator.NEW_WINDOW);
@@ -2255,7 +2255,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["wqa[ll]", "wq", "xa[ll]"], addDefaultCommand(new vimperator.Command(["wqa[ll]", "wq", "xa[ll]"],
function() { vimperator.quit(true); }, function () { vimperator.quit(true); },
{ {
usage: ["wqa[ll]", "xa[ll]"], usage: ["wqa[ll]", "xa[ll]"],
short_help: "Save the session and quit", short_help: "Save the session and quit",
@@ -2264,7 +2264,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["zo[om]"], addDefaultCommand(new vimperator.Command(["zo[om]"],
function(args, special) function (args, special)
{ {
var level; var level;
@@ -2309,7 +2309,7 @@ vimperator.Commands = function() //{{{
} }
)); ));
addDefaultCommand(new vimperator.Command(["!", "run"], addDefaultCommand(new vimperator.Command(["!", "run"],
function(args, special) function (args, special)
{ {
// :!! needs to be treated specially as the command parser sets the special flag but removes the ! from args // :!! needs to be treated specially as the command parser sets the special flag but removes the ! from args
if (special) if (special)

View File

@@ -26,7 +26,7 @@ the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
vimperator.Completion = function() // {{{ vimperator.Completion = function () // {{{
{ {
// The completion substrings, used for showing the longest common match // The completion substrings, used for showing the longest common match
var g_substrings = []; var g_substrings = [];
@@ -63,7 +63,7 @@ vimperator.Completion = function() // {{{
} }
else else
{ {
g_substrings = g_substrings.filter(function($_) { g_substrings = g_substrings.filter(function ($_) {
return list[i][0][j].indexOf($_) >= 0; return list[i][0][j].indexOf($_) >= 0;
}); });
} }
@@ -93,7 +93,7 @@ vimperator.Completion = function() // {{{
} }
else else
{ {
g_substrings = g_substrings.filter(function($_) { g_substrings = g_substrings.filter(function ($_) {
return list[i][0][j].indexOf($_) == 0; return list[i][0][j].indexOf($_) == 0;
}); });
} }
@@ -109,7 +109,7 @@ vimperator.Completion = function() // {{{
* returns the longest common substring * returns the longest common substring
* used for the 'longest' setting for wildmode * used for the 'longest' setting for wildmode
*/ */
get_longest_substring: function() //{{{ get_longest_substring: function () //{{{
{ {
if (g_substrings.length == 0) if (g_substrings.length == 0)
return ""; return "";
@@ -130,7 +130,7 @@ vimperator.Completion = function() // {{{
* depending on the 'complete' option * depending on the 'complete' option
* if the 'complete' argument is passed like "h", it temporarily overrides the complete option * if the 'complete' argument is passed like "h", it temporarily overrides the complete option
*/ */
get_url_completions: function(filter, complete) //{{{ get_url_completions: function (filter, complete) //{{{
{ {
var completions = []; var completions = [];
g_substrings = []; g_substrings = [];
@@ -152,21 +152,21 @@ vimperator.Completion = function() // {{{
return completions; return completions;
}, //}}} }, //}}}
get_search_completions: function(filter) //{{{ get_search_completions: function (filter) //{{{
{ {
var engines = vimperator.bookmarks.getSearchEngines().concat(vimperator.bookmarks.getKeywords()); var engines = vimperator.bookmarks.getSearchEngines().concat(vimperator.bookmarks.getKeywords());
if (!filter) return engines.map(function(engine) { if (!filter) return engines.map(function (engine) {
return [engine[0], engine[1]]; return [engine[0], engine[1]];
}); });
var mapped = engines.map(function(engine) { var mapped = engines.map(function (engine) {
return [[engine[0]], engine[1]]; return [[engine[0]], engine[1]];
}); });
return build_longest_common_substring(mapped, filter); return build_longest_common_substring(mapped, filter);
}, //}}} }, //}}}
// TODO: support file:// and \ or / path separators on both platforms // TODO: support file:// and \ or / path separators on both platforms
get_file_completions: function(filter) get_file_completions: function (filter)
{ {
// this is now also used as part of the url completion, so the // this is now also used as part of the url completion, so the
// substrings shouldn't be cleared for that case // substrings shouldn't be cleared for that case
@@ -185,7 +185,7 @@ vimperator.Completion = function() // {{{
try try
{ {
files = vimperator.io.readDirectory(dir); files = vimperator.io.readDirectory(dir);
mapped = files.map(function(file) { mapped = files.map(function (file) {
return [[file.path], file.isDirectory() ? "Directory" : "File"]; return [[file.path], file.isDirectory() ? "Directory" : "File"];
}); });
} }
@@ -198,7 +198,7 @@ vimperator.Completion = function() // {{{
return build_longest_starting_substring(mapped, filter); return build_longest_starting_substring(mapped, filter);
}, },
get_help_completions: function(filter) //{{{ get_help_completions: function (filter) //{{{
{ {
var help_array = [[["introduction"], "Introductory text"], var help_array = [[["introduction"], "Introductory text"],
[["initialization"], "Initialization and startup"], [["initialization"], "Initialization and startup"],
@@ -207,25 +207,25 @@ vimperator.Completion = function() // {{{
[["options"], "Configuration options"]]; // TODO: hardcoded until we have proper 'pages' [["options"], "Configuration options"]]; // TODO: hardcoded until we have proper 'pages'
g_substrings = []; g_substrings = [];
for (var command in vimperator.commands) for (var command in vimperator.commands)
help_array.push([command.long_names.map(function($_) { return ":" + $_; }), command.short_help]); help_array.push([command.long_names.map(function ($_) { return ":" + $_; }), command.short_help]);
options = this.get_options_completions(filter, true); options = this.get_options_completions(filter, true);
help_array = help_array.concat(options.map(function($_) { help_array = help_array.concat(options.map(function ($_) {
return [ return [
$_[0].map(function($_) { return "'" + $_ + "'"; }), $_[0].map(function ($_) { return "'" + $_ + "'"; }),
$_[1] $_[1]
]; ];
})); }));
for (var map in vimperator.mappings) for (var map in vimperator.mappings)
help_array.push([map.names, map.short_help]); help_array.push([map.names, map.short_help]);
if (!filter) return help_array.map(function($_) { if (!filter) return help_array.map(function ($_) {
return [$_[0][0], $_[1]]; // unfiltered, use the first command return [$_[0][0], $_[1]]; // unfiltered, use the first command
}); });
return build_longest_common_substring(help_array, filter); return build_longest_common_substring(help_array, filter);
}, //}}} }, //}}}
get_command_completions: function(filter) //{{{ get_command_completions: function (filter) //{{{
{ {
g_substrings = []; g_substrings = [];
var completions = []; var completions = [];
@@ -241,7 +241,7 @@ vimperator.Completion = function() // {{{
return build_longest_starting_substring(completions, filter); return build_longest_starting_substring(completions, filter);
}, //}}} }, //}}}
get_options_completions: function(filter, unfiltered) //{{{ get_options_completions: function (filter, unfiltered) //{{{
{ {
g_substrings = []; g_substrings = [];
var options_completions = []; var options_completions = [];
@@ -308,7 +308,7 @@ vimperator.Completion = function() // {{{
} }
else else
{ {
g_substrings = g_substrings.filter(function($_) { g_substrings = g_substrings.filter(function ($_) {
return option.names[j].indexOf($_) == 0; return option.names[j].indexOf($_) == 0;
}); });
} }
@@ -320,7 +320,7 @@ vimperator.Completion = function() // {{{
return options_completions; return options_completions;
}, //}}} }, //}}}
get_buffer_completions: function(filter) //{{{ get_buffer_completions: function (filter) //{{{
{ {
g_substrings = []; g_substrings = [];
var items = []; var items = [];
@@ -350,13 +350,13 @@ vimperator.Completion = function() // {{{
items.push([[(i + 1) + ": " + title, (i + 1) + ": " + url], url]); items.push([[(i + 1) + ": " + title, (i + 1) + ": " + url], url]);
} }
} }
if (!filter) return items.map(function($_) { if (!filter) return items.map(function ($_) {
return [$_[0][0], $_[1]]; return [$_[0][0], $_[1]];
}); });
return build_longest_common_substring(items, filter); return build_longest_common_substring(items, filter);
}, //}}} }, //}}}
get_sidebar_completions: function(filter) //{{{ get_sidebar_completions: function (filter) //{{{
{ {
g_substrings = []; g_substrings = [];
var menu = document.getElementById("viewSidebarMenu") var menu = document.getElementById("viewSidebarMenu")
@@ -368,20 +368,20 @@ vimperator.Completion = function() // {{{
if (!filter) if (!filter)
return nodes; return nodes;
var mapped = nodes.map(function(node) { var mapped = nodes.map(function (node) {
return [[node[0]], node[1]]; return [[node[0]], node[1]];
}); });
return build_longest_common_substring(mapped, filter); return build_longest_common_substring(mapped, filter);
}, //}}} }, //}}}
javascript: function(str) // {{{ javascript: function (str) // {{{
{ {
g_substrings = []; g_substrings = [];
var matches = str.match(/^(.*?)(\s*\.\s*)?(\w*)$/); var matches = str.match(/^(.*?)(\s*\.\s*)?(\w*)$/);
var object = "window"; var object = "window";
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])
{ {
var brackets = 0, parentheses = 0; var brackets = 0, parentheses = 0;
@@ -449,7 +449,7 @@ vimperator.Completion = function() // {{{
// discard all entries in the 'urls' array, which don't match 'filter // discard all entries in the 'urls' array, which don't match 'filter
// urls must be of type [["url", "title"], [...]] or optionally // urls must be of type [["url", "title"], [...]] or optionally
// [["url", "title", keyword, [tags]], [...]] // [["url", "title", keyword, [tags]], [...]]
filterURLArray: function(urls, filter, tags) //{{{ filterURLArray: function (urls, filter, tags) //{{{
{ {
var filtered = []; var filtered = [];
// completions which don't match the url but just the description // completions which don't match the url but just the description
@@ -474,7 +474,7 @@ vimperator.Completion = function() // {{{
if (ignorecase) if (ignorecase)
{ {
filter = filter.toLowerCase(); filter = filter.toLowerCase();
tags = tags.map(function(t) { return t.toLowerCase(); }); tags = tags.map(function (t) { return t.toLowerCase(); });
} }
/* /*
@@ -493,7 +493,7 @@ vimperator.Completion = function() // {{{
{ {
url = url.toLowerCase(); url = url.toLowerCase();
title = title.toLowerCase(); title = title.toLowerCase();
tag = tag.map(function(t) { return t.toLowerCase(); }); tag = tag.map(function (t) { return t.toLowerCase(); });
} }
// filter on tags // filter on tags
@@ -510,7 +510,7 @@ vimperator.Completion = function() // {{{
{ {
// no direct match of filter in the url, but still accept this item // no direct match of filter in the url, but still accept this item
// if _all_ tokens of filter match either the url or the title // if _all_ tokens of filter match either the url or the title
if (filter.split(/\s+/).every(function(token) { if (filter.split(/\s+/).every(function (token) {
return (url.indexOf(token) > -1 || title.indexOf(token) > -1); return (url.indexOf(token) > -1 || title.indexOf(token) > -1);
})) }))
additional_completions.push(urls[i]); additional_completions.push(urls[i]);
@@ -534,7 +534,7 @@ vimperator.Completion = function() // {{{
} }
else else
{ {
g_substrings = g_substrings.filter(function($_) { g_substrings = g_substrings.filter(function ($_) {
return url.indexOf($_) >= 0; return url.indexOf($_) >= 0;
}); });
} }
@@ -547,7 +547,7 @@ vimperator.Completion = function() // {{{
// generic helper function which checks if the given "items" array pass "filter" // generic helper function which checks if the given "items" array pass "filter"
// items must be an array of strings // items must be an array of strings
match: function(items, filter, case_sensitive) match: function (items, filter, case_sensitive)
{ {
if (typeof(filter) != "string" || !items) if (typeof(filter) != "string" || !items)
return false; return false;
@@ -559,13 +559,13 @@ vimperator.Completion = function() // {{{
items_str = items_str.toLowerCase(); items_str = items_str.toLowerCase();
} }
if (filter.split(/\s+/).every(function(str) { return items_str.indexOf(str) > -1; })) if (filter.split(/\s+/).every(function (str) { return items_str.indexOf(str) > -1; }))
return true; return true;
return false; return false;
}, },
exTabCompletion: function(str) //{{{ exTabCompletion: function (str) //{{{
{ {
var [count, cmd, special, args] = vimperator.commands.parseCommand(str); var [count, cmd, special, args] = vimperator.commands.parseCommand(str);
var completions = []; var completions = [];

View File

@@ -29,7 +29,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
// command names taken from: // command names taken from:
// http://developer.mozilla.org/en/docs/Editor_Embedding_Guide // http://developer.mozilla.org/en/docs/Editor_Embedding_Guide
vimperator.Editor = function() //{{{ vimperator.Editor = function () //{{{
{ {
// store our last search with f, F, t or T // store our last search with f, F, t or T
var last_findChar = null; var last_findChar = null;
@@ -50,7 +50,7 @@ vimperator.Editor = function() //{{{
return ed.controllers.getControllerForCommand("cmd_beginLine"); return ed.controllers.getControllerForCommand("cmd_beginLine");
} }
this.line = function() this.line = function ()
{ {
var line = 1; var line = 1;
var text = editor().value; var text = editor().value;
@@ -60,7 +60,7 @@ vimperator.Editor = function() //{{{
return line; return line;
} }
this.col = function() this.col = function ()
{ {
var col = 1; var col = 1;
var text = editor().value; var text = editor().value;
@@ -73,20 +73,20 @@ vimperator.Editor = function() //{{{
return col; return col;
} }
this.unselectText = function() this.unselectText = function ()
{ {
var elt = window.document.commandDispatcher.focusedElement; var elt = window.document.commandDispatcher.focusedElement;
if (elt && elt.selectionEnd) if (elt && elt.selectionEnd)
elt.selectionEnd = elt.selectionStart; elt.selectionEnd = elt.selectionStart;
} }
this.selectedText = function() this.selectedText = function ()
{ {
var text = editor().value; var text = editor().value;
return text.substring(editor().selectionStart, editor().selectionEnd); return text.substring(editor().selectionStart, editor().selectionEnd);
} }
this.pasteClipboard = function() this.pasteClipboard = function ()
{ {
var elt = window.document.commandDispatcher.focusedElement; var elt = window.document.commandDispatcher.focusedElement;
@@ -106,7 +106,7 @@ vimperator.Editor = function() //{{{
} }
// count is optional, defaults to 1 // count is optional, defaults to 1
this.executeCommand = function(cmd, count) this.executeCommand = function (cmd, count)
{ {
var controller = getController(); var controller = getController();
if (!controller || !controller.supportsCommand(cmd) || !controller.isCommandEnabled(cmd)) if (!controller || !controller.supportsCommand(cmd) || !controller.isCommandEnabled(cmd))
@@ -142,7 +142,7 @@ vimperator.Editor = function() //{{{
// cmd = y, d, c // cmd = y, d, c
// motion = b, 0, gg, G, etc. // motion = b, 0, gg, G, etc.
this.executeCommandWithMotion = function(cmd, motion, count) this.executeCommandWithMotion = function (cmd, motion, count)
{ {
if (!typeof count == "number" || count < 1) if (!typeof count == "number" || count < 1)
count = 1; count = 1;
@@ -229,7 +229,7 @@ vimperator.Editor = function() //{{{
// Simple setSelectionRange() would be better, but we want to maintain the correct // Simple setSelectionRange() would be better, but we want to maintain the correct
// order of selectionStart/End (a firefox bug always makes selectionStart <= selectionEnd) // order of selectionStart/End (a firefox bug always makes selectionStart <= selectionEnd)
// Use only for small movements! // Use only for small movements!
this.moveToPosition = function(pos, forward, select) this.moveToPosition = function (pos, forward, select)
{ {
if (!select) if (!select)
{ {
@@ -262,7 +262,7 @@ vimperator.Editor = function() //{{{
} }
// returns the position of char // returns the position of char
this.findCharForward = function(char, count) this.findCharForward = function (char, count)
{ {
if (!editor()) if (!editor())
return -1; return -1;
@@ -288,7 +288,7 @@ vimperator.Editor = function() //{{{
return -1; return -1;
} }
// returns the position of char // returns the position of char
this.findCharBackward = function(char, count) this.findCharBackward = function (char, count)
{ {
if (!editor()) if (!editor())
return -1; return -1;
@@ -314,7 +314,7 @@ vimperator.Editor = function() //{{{
return -1; return -1;
} }
this.editWithExternalEditor = function() this.editWithExternalEditor = function ()
{ {
var textBox = document.commandDispatcher.focusedElement; var textBox = document.commandDispatcher.focusedElement;
var editor = vimperator.options["editor"]; var editor = vimperator.options["editor"];
@@ -380,11 +380,11 @@ vimperator.Editor = function() //{{{
// blink the textbox after returning // blink the textbox after returning
var timeout = 100; var timeout = 100;
textBox.style.backgroundColor = tmpBg; textBox.style.backgroundColor = tmpBg;
setTimeout( function() { setTimeout( function () {
textBox.style.backgroundColor = oldBg; textBox.style.backgroundColor = oldBg;
setTimeout( function() { setTimeout( function () {
textBox.style.backgroundColor = tmpBg; textBox.style.backgroundColor = tmpBg;
setTimeout( function() { setTimeout( function () {
textBox.style.backgroundColor = oldBg; textBox.style.backgroundColor = oldBg;
}, timeout); }, timeout);
}, timeout); }, timeout);
@@ -410,7 +410,7 @@ vimperator.Editor = function() //{{{
} }
// filter is i, c or "!" (insert or command abbreviations or both) // filter is i, c or "!" (insert or command abbreviations or both)
this.listAbbreviations = function(filter, lhs) this.listAbbreviations = function (filter, lhs)
{ {
if (lhs) // list only that one if (lhs) // list only that one
{ {
@@ -459,7 +459,7 @@ vimperator.Editor = function() //{{{
} }
} }
this.addAbbreviation = function(filter, lhs, rhs) this.addAbbreviation = function (filter, lhs, rhs)
{ {
if (!abbrev[lhs]) if (!abbrev[lhs])
{ {
@@ -543,7 +543,7 @@ vimperator.Editor = function() //{{{
// //
} }
this.removeAbbreviation = function(filter, lhs) this.removeAbbreviation = function (filter, lhs)
{ {
if (!lhs) if (!lhs)
{ {
@@ -589,7 +589,7 @@ vimperator.Editor = function() //{{{
return false; return false;
} }
this.removeAllAbbreviations = function(filter) this.removeAllAbbreviations = function (filter)
{ {
if (filter == "!") if (filter == "!")
{ {
@@ -608,7 +608,7 @@ vimperator.Editor = function() //{{{
} }
} }
this.expandAbbreviation = function(filter) // try to find an candidate and replace accordingly this.expandAbbreviation = function (filter) // try to find an candidate and replace accordingly
{ {
var textbox = editor(); var textbox = editor();
var text = textbox.value; var text = textbox.value;

View File

@@ -26,7 +26,7 @@ the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
vimperator.Events = function() //{{{ vimperator.Events = function () //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -35,23 +35,23 @@ vimperator.Events = function() //{{{
// this handler is for middle click only in the content // this handler is for middle click only in the content
//window.addEventListener("mousedown", onVimperatorKeypress, true); //window.addEventListener("mousedown", onVimperatorKeypress, true);
//content.mPanelContainer.addEventListener("mousedown", onVimperatorKeypress, true); //content.mPanelContainer.addEventListener("mousedown", onVimperatorKeypress, true);
//document.getElementById("content").onclick = function(event) { alert("foo"); }; //document.getElementById("content").onclick = function (event) { alert("foo"); };
// any tab related events // any tab related events
var tabcontainer = getBrowser().tabContainer; var tabcontainer = getBrowser().tabContainer;
tabcontainer.addEventListener("TabMove", function(event) { tabcontainer.addEventListener("TabMove", function (event) {
vimperator.statusline.updateTabCount(); vimperator.statusline.updateTabCount();
vimperator.buffer.updateBufferList(); vimperator.buffer.updateBufferList();
}, false); }, false);
tabcontainer.addEventListener("TabOpen", function(event) { tabcontainer.addEventListener("TabOpen", function (event) {
vimperator.statusline.updateTabCount(); vimperator.statusline.updateTabCount();
vimperator.buffer.updateBufferList(); vimperator.buffer.updateBufferList();
}, false); }, false);
tabcontainer.addEventListener("TabClose", function(event) { tabcontainer.addEventListener("TabClose", function (event) {
vimperator.statusline.updateTabCount(); vimperator.statusline.updateTabCount();
vimperator.buffer.updateBufferList(); vimperator.buffer.updateBufferList();
}, false); }, false);
tabcontainer.addEventListener("TabSelect", function(event) { tabcontainer.addEventListener("TabSelect", function (event) {
if (vimperator.mode == vimperator.modes.HINTS) if (vimperator.mode == vimperator.modes.HINTS)
vimperator.modes.reset(); vimperator.modes.reset();
@@ -61,7 +61,7 @@ vimperator.Events = function() //{{{
vimperator.buffer.updateBufferList(); vimperator.buffer.updateBufferList();
vimperator.tabs.updateSelectionHistory(); vimperator.tabs.updateSelectionHistory();
setTimeout(function() { vimperator.focusContent(true); }, 10); // just make sure, that no widget has focus setTimeout(function () { vimperator.focusContent(true); }, 10); // just make sure, that no widget has focus
}, false); }, false);
// this adds an event which is is called on each page load, even if the // this adds an event which is is called on each page load, even if the
@@ -107,7 +107,7 @@ vimperator.Events = function() //{{{
window.addEventListener("DOMMenuBarActive", enterMenuMode, true); window.addEventListener("DOMMenuBarActive", enterMenuMode, true);
window.addEventListener("DOMMenuBarInactive", exitMenuMode, true); window.addEventListener("DOMMenuBarInactive", exitMenuMode, true);
// window.document.addEventListener("DOMTitleChanged", function(event) // window.document.addEventListener("DOMTitleChanged", function (event)
// { // {
// vimperator.log("titlechanged"); // vimperator.log("titlechanged");
// }, null); // }, null);
@@ -231,7 +231,7 @@ vimperator.Events = function() //{{{
// // FIXME: this currently causes window map events which is _very_ annoying // // FIXME: this currently causes window map events which is _very_ annoying
// // we want to stay in command mode after a page has loaded // // we want to stay in command mode after a page has loaded
// //setTimeout(vimperator.focusContent, 10); // //setTimeout(vimperator.focusContent, 10);
// // setTimeout(function() { // // setTimeout(function () {
// // if (doc.commandDispatcher.focusedElement) // // if (doc.commandDispatcher.focusedElement)
// // doc.commandDispatcher.focusedElement.blur(); // // doc.commandDispatcher.focusedElement.blur();
// // alert(doc.commandDispatcher.focusedElement); // // alert(doc.commandDispatcher.focusedElement);
@@ -246,7 +246,7 @@ vimperator.Events = function() //{{{
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
this.wantsModeReset = true; // used in onFocusChange since Firefox is so buggy here this.wantsModeReset = true; // used in onFocusChange since Firefox is so buggy here
this.destroy = function() this.destroy = function ()
{ {
// removeEventListeners() to avoid mem leaks // removeEventListeners() to avoid mem leaks
window.dump("TODO: remove all eventlisteners\n"); window.dump("TODO: remove all eventlisteners\n");
@@ -268,7 +268,7 @@ vimperator.Events = function() //{{{
// //
// @param keys: a string like "2<C-f>" to pass // @param keys: a string like "2<C-f>" to pass
// if you want < to be taken literally, prepend it with a \\ // if you want < to be taken literally, prepend it with a \\
this.feedkeys = function(keys, noremap) this.feedkeys = function (keys, noremap)
{ {
var doc = window.document; var doc = window.document;
var view = window.document.defaultView; var view = window.document.defaultView;
@@ -332,7 +332,7 @@ vimperator.Events = function() //{{{
// a keycode which can be used in mappings // a keycode which can be used in mappings
// e.g. pressing ctrl+n would result in the string "<C-n>" // e.g. pressing ctrl+n would result in the string "<C-n>"
// null if unknown key // null if unknown key
this.toString = function(event) //{{{ this.toString = function (event) //{{{
{ {
if (!event) if (!event)
return; return;
@@ -408,11 +408,11 @@ vimperator.Events = function() //{{{
} //}}} } //}}}
this.isAcceptKey = function(key) this.isAcceptKey = function (key)
{ {
return (key == "<Return>" || key == "<C-j>" || key == "<C-m>"); return (key == "<Return>" || key == "<C-j>" || key == "<C-m>");
} }
this.isCancelKey = function(key) this.isCancelKey = function (key)
{ {
return (key == "<Esc>" || key == "<C-[>" || key == "<C-c>"); return (key == "<Esc>" || key == "<C-[>" || key == "<C-c>");
} }
@@ -422,7 +422,7 @@ vimperator.Events = function() //{{{
// //
// the ugly wantsModeReset is needed, because firefox generates a massive // the ugly wantsModeReset is needed, because firefox generates a massive
// amount of focus changes for things like <C-v><C-k> (focusing the search field) // amount of focus changes for things like <C-v><C-k> (focusing the search field)
this.onFocusChange = function(event) this.onFocusChange = function (event)
{ {
// command line has it's own focus change handler // command line has it's own focus change handler
if (vimperator.mode == vimperator.modes.COMMAND_LINE) if (vimperator.mode == vimperator.modes.COMMAND_LINE)
@@ -455,14 +455,14 @@ vimperator.Events = function() //{{{
vimperator.mode == vimperator.modes.VISUAL) vimperator.mode == vimperator.modes.VISUAL)
{ {
this.wantsModeReset = true; this.wantsModeReset = true;
setTimeout(function() { setTimeout(function () {
if (vimperator.events.wantsModeReset) if (vimperator.events.wantsModeReset)
vimperator.modes.reset(); vimperator.modes.reset();
}, 10); }, 10);
} }
} }
this.onSelectionChange = function(event) this.onSelectionChange = function (event)
{ {
var could_copy = false; var could_copy = false;
var controller = document.commandDispatcher.getControllerForCommand("cmd_copy"); var controller = document.commandDispatcher.getControllerForCommand("cmd_copy");
@@ -488,7 +488,7 @@ vimperator.Events = function() //{{{
} }
// global escape handler, is called in ALL modes // global escape handler, is called in ALL modes
this.onEscape = function() this.onEscape = function ()
{ {
if (!vimperator.modes.passNextKey) if (!vimperator.modes.passNextKey)
{ {
@@ -549,7 +549,7 @@ vimperator.Events = function() //{{{
// this keypress handler gets always called first, even if e.g. // this keypress handler gets always called first, even if e.g.
// the commandline has focus // the commandline has focus
this.onKeyPress = function(event) this.onKeyPress = function (event)
{ {
var key = vimperator.events.toString(event); var key = vimperator.events.toString(event);
if (!key) if (!key)
@@ -732,7 +732,7 @@ vimperator.Events = function() //{{{
window.addEventListener("keypress", this.onKeyPress, true); window.addEventListener("keypress", this.onKeyPress, true);
// this is need for sites like msn.com which focus the input field on keydown // this is need for sites like msn.com which focus the input field on keydown
this.onKeyUpOrDown = function(event) this.onKeyUpOrDown = function (event)
{ {
if (vimperator.modes.passNextKey ^ vimperator.modes.passAllKeys || isFormElemFocused()) if (vimperator.modes.passNextKey ^ vimperator.modes.passAllKeys || isFormElemFocused())
return true; return true;
@@ -745,7 +745,7 @@ vimperator.Events = function() //{{{
this.progressListener = this.progressListener =
{ {
QueryInterface: function(aIID) QueryInterface: function (aIID)
{ {
if (aIID.equals(Components.interfaces.nsIWebProgressListener) || if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
aIID.equals(Components.interfaces.nsIXULBrowserWindow) || // for setOverLink(); aIID.equals(Components.interfaces.nsIXULBrowserWindow) || // for setOverLink();
@@ -756,7 +756,7 @@ vimperator.Events = function() //{{{
}, },
// XXX: function may later be needed to detect a canceled synchronous openURL() // XXX: function may later be needed to detect a canceled synchronous openURL()
onStateChange: function(webProgress, aRequest, flags, aStatus) onStateChange: function (webProgress, aRequest, flags, aStatus)
{ {
// STATE_IS_DOCUMENT | STATE_IS_WINDOW is important, because we also // STATE_IS_DOCUMENT | STATE_IS_WINDOW is important, because we also
// receive statechange events for loading images and other parts of the web page // receive statechange events for loading images and other parts of the web page
@@ -783,29 +783,29 @@ vimperator.Events = function() //{{{
else if (aState & nsIWebProgressListener.STATE_IS_SECURE) else if (aState & nsIWebProgressListener.STATE_IS_SECURE)
vimperator.statusline.setClass("secure"); vimperator.statusline.setClass("secure");
}, },
onStatusChange: function(webProgress, request, status, message) onStatusChange: function (webProgress, request, status, message)
{ {
vimperator.statusline.updateUrl(message); vimperator.statusline.updateUrl(message);
}, },
onProgressChange: function(webProgress, request, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress) onProgressChange: function (webProgress, request, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress)
{ {
vimperator.statusline.updateProgress(curTotalProgress/maxTotalProgress); vimperator.statusline.updateProgress(curTotalProgress/maxTotalProgress);
}, },
// happens when the users switches tabs // happens when the users switches tabs
onLocationChange: function() onLocationChange: function ()
{ {
vimperator.statusline.updateUrl(); vimperator.statusline.updateUrl();
vimperator.statusline.updateProgress(); vimperator.statusline.updateProgress();
// if this is not delayed we get the position of the old buffer // if this is not delayed we get the position of the old buffer
setTimeout(function() { vimperator.statusline.updateBufferPosition(); }, 100); setTimeout(function () { vimperator.statusline.updateBufferPosition(); }, 100);
}, },
// called at the very end of a page load // called at the very end of a page load
asyncUpdateUI: function() asyncUpdateUI: function ()
{ {
setTimeout(vimperator.statusline.updateUrl, 100); setTimeout(vimperator.statusline.updateUrl, 100);
}, },
setOverLink : function(link, b) setOverLink : function (link, b)
{ {
var ssli = vimperator.options["showstatuslinks"]; var ssli = vimperator.options["showstatuslinks"];
if (link && ssli) if (link && ssli)
@@ -826,10 +826,10 @@ vimperator.Events = function() //{{{
}, },
// stub functions for the interfaces // stub functions for the interfaces
setJSStatus: function(status) { ; }, setJSStatus: function (status) { ; },
setJSDefaultStatus: function(status) { ; }, setJSDefaultStatus: function (status) { ; },
setDefaultStatus: function(status) { ; }, setDefaultStatus: function (status) { ; },
onLinkIconAvailable: function() { ; } onLinkIconAvailable: function () { ; }
}; };
window.XULBrowserWindow = this.progressListener; window.XULBrowserWindow = this.progressListener;
@@ -844,7 +844,7 @@ vimperator.Events = function() //{{{
this.prefObserver = this.prefObserver =
{ {
register: function() register: function ()
{ {
var prefService = Components.classes["@mozilla.org/preferences-service;1"] var prefService = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService); .getService(Components.interfaces.nsIPrefService);
@@ -853,13 +853,13 @@ vimperator.Events = function() //{{{
this._branch.addObserver("", this, false); this._branch.addObserver("", this, false);
}, },
unregister: function() unregister: function ()
{ {
if (!this._branch) return; if (!this._branch) return;
this._branch.removeObserver("", this); this._branch.removeObserver("", this);
}, },
observe: function(aSubject, aTopic, aData) observe: function (aSubject, aTopic, aData)
{ {
if (aTopic != "nsPref:changed") return; if (aTopic != "nsPref:changed") return;
// aSubject is the nsIPrefBranch we're observing (after appropriate QI) // aSubject is the nsIPrefBranch we're observing (after appropriate QI)

View File

@@ -37,7 +37,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
// : incremental searches shouldn't permanently update search modifiers // : incremental searches shouldn't permanently update search modifiers
// make sure you only create this object when the "vimperator" object is ready // make sure you only create this object when the "vimperator" object is ready
vimperator.Search = function() //{{{ vimperator.Search = function () //{{{
{ {
var self = this; // needed for callbacks since "this" is the "vimperator" object in a callback var self = this; // needed for callbacks since "this" is the "vimperator" object in a callback
var found = false; // true if the last search was successful var found = false; // true if the last search was successful
@@ -51,13 +51,13 @@ vimperator.Search = function() //{{{
var links_only = false; // search is limited to link text only var links_only = false; // search is limited to link text only
// Event handlers for search - closure is needed // Event handlers for search - closure is needed
vimperator.registerCallback("change", vimperator.modes.SEARCH_FORWARD, function(command) { self.searchKeyPressed(command); }); vimperator.registerCallback("change", vimperator.modes.SEARCH_FORWARD, function (command) { self.searchKeyPressed(command); });
vimperator.registerCallback("submit", vimperator.modes.SEARCH_FORWARD, function(command) { self.searchSubmitted(command); }); vimperator.registerCallback("submit", vimperator.modes.SEARCH_FORWARD, function (command) { self.searchSubmitted(command); });
vimperator.registerCallback("cancel", vimperator.modes.SEARCH_FORWARD, function() { self.searchCanceled(); }); vimperator.registerCallback("cancel", vimperator.modes.SEARCH_FORWARD, function () { self.searchCanceled(); });
// TODO: allow advanced modes in register/triggerCallback // TODO: allow advanced modes in register/triggerCallback
vimperator.registerCallback("change", vimperator.modes.SEARCH_BACKWARD, function(command) { self.searchKeyPressed(command); }); vimperator.registerCallback("change", vimperator.modes.SEARCH_BACKWARD, function (command) { self.searchKeyPressed(command); });
vimperator.registerCallback("submit", vimperator.modes.SEARCH_BACKWARD, function(command) { self.searchSubmitted(command); }); vimperator.registerCallback("submit", vimperator.modes.SEARCH_BACKWARD, function (command) { self.searchSubmitted(command); });
vimperator.registerCallback("cancel", vimperator.modes.SEARCH_BACKWARD, function() { self.searchCanceled(); }); vimperator.registerCallback("cancel", vimperator.modes.SEARCH_BACKWARD, function () { self.searchCanceled(); });
// set search_string, search_pattern, case_sensitive, links_only // set search_string, search_pattern, case_sensitive, links_only
function processUserPattern(pattern) function processUserPattern(pattern)
@@ -81,7 +81,7 @@ vimperator.Search = function() //{{{
links_only = false; links_only = false;
// strip links-only modifiers // strip links-only modifiers
pattern = pattern.replace(/(\\)?\\[uU]/g, function($0, $1) { return $1 ? $0 : ""; }); pattern = pattern.replace(/(\\)?\\[uU]/g, function ($0, $1) { return $1 ? $0 : ""; });
// case sensitivity - \c wins if both modifiers specified // case sensitivity - \c wins if both modifiers specified
if (/\c/.test(pattern)) if (/\c/.test(pattern))
@@ -96,7 +96,7 @@ vimperator.Search = function() //{{{
case_sensitive = true; case_sensitive = true;
// strip case-sensitive modifiers // strip case-sensitive modifiers
pattern = pattern.replace(/(\\)?\\[cC]/g, function($0, $1) { return $1 ? $0 : ""; }); pattern = pattern.replace(/(\\)?\\[cC]/g, function ($0, $1) { return $1 ? $0 : ""; });
// remove any modifer escape \ // remove any modifer escape \
pattern = pattern.replace(/\\(\\[cCuU])/g, "$1"); pattern = pattern.replace(/\\(\\[cCuU])/g, "$1");
@@ -106,7 +106,7 @@ vimperator.Search = function() //{{{
// Called when the search dialog is asked for // Called when the search dialog is asked for
// If you omit "mode", it will default to forward searching // If you omit "mode", it will default to forward searching
this.openSearchDialog = function(mode) this.openSearchDialog = function (mode)
{ {
if (mode == vimperator.modes.SEARCH_BACKWARD) if (mode == vimperator.modes.SEARCH_BACKWARD)
{ {
@@ -124,7 +124,7 @@ vimperator.Search = function() //{{{
// Finds text in a page // Finds text in a page
// TODO: backwards seems impossible i fear :( // TODO: backwards seems impossible i fear :(
this.find = function(str, backwards) this.find = function (str, backwards)
{ {
var fastFind = getBrowser().fastFind; var fastFind = getBrowser().fastFind;
@@ -140,7 +140,7 @@ vimperator.Search = function() //{{{
} }
// Called when the current search needs to be repeated // Called when the current search needs to be repeated
this.findAgain = function(reverse) this.findAgain = function (reverse)
{ {
// this hack is needed to make n/N work with the correct string, if // this hack is needed to make n/N work with the correct string, if
// we typed /foo<esc> after the original search. Since searchString is // we typed /foo<esc> after the original search. Since searchString is
@@ -159,7 +159,7 @@ vimperator.Search = function() //{{{
{ {
// hack needed, because wrapping causes a "scroll" event which clears // hack needed, because wrapping causes a "scroll" event which clears
// our command line // our command line
setTimeout(function() { setTimeout(function () {
if (up) if (up)
vimperator.commandline.echo("search hit TOP, continuing at BOTTOM", vimperator.commandline.HL_WARNING); vimperator.commandline.echo("search hit TOP, continuing at BOTTOM", vimperator.commandline.HL_WARNING);
else else
@@ -176,7 +176,7 @@ vimperator.Search = function() //{{{
} }
// Called when the user types a key in the search dialog. Triggers a find attempt if 'incsearch' is set // Called when the user types a key in the search dialog. Triggers a find attempt if 'incsearch' is set
this.searchKeyPressed = function(command) this.searchKeyPressed = function (command)
{ {
if (vimperator.options["incsearch"]) if (vimperator.options["incsearch"])
this.find(command, backwards); this.find(command, backwards);
@@ -184,7 +184,7 @@ vimperator.Search = function() //{{{
// Called when the enter key is pressed to trigger a search // Called when the enter key is pressed to trigger a search
// use forced_direction if you call this function directly // use forced_direction if you call this function directly
this.searchSubmitted = function(command, forced_backward) this.searchSubmitted = function (command, forced_backward)
{ {
if (typeof forced_backward === "boolean") if (typeof forced_backward === "boolean")
backwards = forced_backward; backwards = forced_backward;
@@ -203,7 +203,7 @@ vimperator.Search = function() //{{{
// TODO: move to find() when reverse incremental searching is kludged in // TODO: move to find() when reverse incremental searching is kludged in
// need to find again for reverse searching // need to find again for reverse searching
if (backwards) if (backwards)
setTimeout(function() { self.findAgain(false); }, 0); setTimeout(function () { self.findAgain(false); }, 0);
if (vimperator.options["hlsearch"]) if (vimperator.options["hlsearch"])
this.highlight(search_string); this.highlight(search_string);
@@ -213,14 +213,14 @@ vimperator.Search = function() //{{{
// Called when the search is canceled - for example if someone presses // Called when the search is canceled - for example if someone presses
// escape while typing a search // escape while typing a search
this.searchCanceled = function() this.searchCanceled = function ()
{ {
this.clear(); this.clear();
// TODO: code to reposition the document to the place before search started // TODO: code to reposition the document to the place before search started
} }
// this is not dependent on the value of 'hlsearch' // this is not dependent on the value of 'hlsearch'
this.highlight = function(text) this.highlight = function (text)
{ {
// already highlighted? // already highlighted?
if (window.content.document.getElementsByClassName("__mozilla-findbar-search").length > 0) if (window.content.document.getElementsByClassName("__mozilla-findbar-search").length > 0)
@@ -233,7 +233,7 @@ vimperator.Search = function() //{{{
gFindBar._highlightDoc("white", "black", text); gFindBar._highlightDoc("white", "black", text);
// TODO: seems fast enough for now...just // TODO: seems fast enough for now...just
(function(win) (function (win)
{ {
for (var i = 0; i < win.frames.length; i++) for (var i = 0; i < win.frames.length; i++)
arguments.callee(win.frames[i]); arguments.callee(win.frames[i]);
@@ -248,7 +248,7 @@ vimperator.Search = function() //{{{
// TODO: remove highlighting from non-link matches (HTML - A/AREA with href attribute; XML - Xlink [type="simple"]) // TODO: remove highlighting from non-link matches (HTML - A/AREA with href attribute; XML - Xlink [type="simple"])
} }
this.clear = function() this.clear = function ()
{ {
gFindBar._highlightDoc(); gFindBar._highlightDoc();
// need to manually collapse the selection if the document is not // need to manually collapse the selection if the document is not

View File

@@ -26,7 +26,7 @@ the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
vimperator.help = function(section, easter) //{{{ vimperator.help = function (section, easter) //{{{
{ {
if (easter) if (easter)
{ {
@@ -255,7 +255,7 @@ vimperator.help = function(section, easter) //{{{
} }
// FIXME // FIXME
setTimeout(function() { setTimeout(function () {
if (section) if (section)
{ {
function findSectionElement(section) function findSectionElement(section)

View File

@@ -26,7 +26,7 @@ the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
vimperator.Hints = function() //{{{ vimperator.Hints = function () //{{{
{ {
var submode = ""; // used for extended mode, can be "o", "t", "y", etc. var submode = ""; // used for extended mode, can be "o", "t", "y", etc.
var hintString = ""; // the typed string part of the hint is in this string var hintString = ""; // the typed string part of the hint is in this string
@@ -383,13 +383,13 @@ vimperator.Hints = function() //{{{
// USE THIS FOR MAKING THE SELECTED ELEM RED // USE THIS FOR MAKING THE SELECTED ELEM RED
// firstElem.style.backgroundColor = "red"; // firstElem.style.backgroundColor = "red";
// firstElem.style.color = "white"; // firstElem.style.color = "white";
// setTimeout(function() { // setTimeout(function () {
// firstElem.style.backgroundColor = firstElemBgColor; // firstElem.style.backgroundColor = firstElemBgColor;
// firstElem.style.color = firstElemColor; // firstElem.style.color = firstElemColor;
// }, 200); // }, 200);
// OR USE THIS FOR BLINKING: // OR USE THIS FOR BLINKING:
// var counter = 0; // var counter = 0;
// var id = setInterval(function() { // var id = setInterval(function () {
// firstElem.style.backgroundColor = "red"; // firstElem.style.backgroundColor = "red";
// if (counter % 2 == 0) // if (counter % 2 == 0)
// firstElem.style.backgroundColor = "yellow"; // firstElem.style.backgroundColor = "yellow";
@@ -403,7 +403,7 @@ vimperator.Hints = function() //{{{
// clearTimeout(id); // clearTimeout(id);
// } // }
// }, 100); // }, 100);
setTimeout(function() { setTimeout(function () {
firstElem.style.backgroundColor = firstElemBgColor; firstElem.style.backgroundColor = firstElemBgColor;
firstElem.style.color = firstElemColor; firstElem.style.color = firstElemColor;
}, timeout); }, timeout);
@@ -427,7 +427,7 @@ vimperator.Hints = function() //{{{
var first_href = valid_hints[0].getAttribute("href") || null; var first_href = valid_hints[0].getAttribute("href") || null;
if (first_href) if (first_href)
{ {
if (valid_hints.some( function(e) { return e.getAttribute("href") != first_href; } )) if (valid_hints.some( function (e) { return e.getAttribute("href") != first_href; } ))
return false; return false;
} }
else if (valid_hints.length > 1) else if (valid_hints.length > 1)
@@ -458,7 +458,7 @@ vimperator.Hints = function() //{{{
if (vimperator.modes.extended & vimperator.modes.ALWAYS_HINT) if (vimperator.modes.extended & vimperator.modes.ALWAYS_HINT)
{ {
setTimeout(function() { setTimeout(function () {
canUpdate = true; canUpdate = true;
hintString = ""; hintString = "";
hintNumber = 0; hintNumber = 0;
@@ -467,7 +467,7 @@ vimperator.Hints = function() //{{{
} }
else else
{ {
setTimeout( function() { setTimeout( function () {
if (vimperator.mode == vimperator.modes.HINTS) if (vimperator.mode == vimperator.modes.HINTS)
vimperator.modes.reset(false); vimperator.modes.reset(false);
}, timeout); }, timeout);
@@ -481,7 +481,7 @@ vimperator.Hints = function() //{{{
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// TODO: implement framesets // TODO: implement framesets
this.show = function(mode, minor, filter) this.show = function (mode, minor, filter)
{ {
if (mode == vimperator.modes.EXTENDED_HINT && !/^[;asoOtTwWyY]$/.test(minor)) if (mode == vimperator.modes.EXTENDED_HINT && !/^[;asoOtTwWyY]$/.test(minor))
{ {
@@ -520,12 +520,12 @@ vimperator.Hints = function() //{{{
return true; return true;
}; };
this.hide = function() this.hide = function ()
{ {
removeHints(0); removeHints(0);
}; };
this.onEvent = function(event) this.onEvent = function (event)
{ {
var key = vimperator.events.toString(event); var key = vimperator.events.toString(event);
var followFirst = false; var followFirst = false;
@@ -653,7 +653,7 @@ vimperator.Hints = function() //{{{
{ {
var timeout = vimperator.options["hinttimeout"]; var timeout = vimperator.options["hinttimeout"];
if (timeout > 0) if (timeout > 0)
activeTimeout = setTimeout(function() { processHints(true); }, timeout); activeTimeout = setTimeout(function () { processHints(true); }, timeout);
return false; return false;
} }

View File

@@ -27,7 +27,7 @@ the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
vimperator.IO = function() vimperator.IO = function ()
{ {
var environment_service = Components.classes["@mozilla.org/process/environment;1"] var environment_service = Components.classes["@mozilla.org/process/environment;1"]
.getService(Components.interfaces.nsIEnvironment); .getService(Components.interfaces.nsIEnvironment);
@@ -43,7 +43,7 @@ vimperator.IO = function()
MODE_SYNC: 0x40, MODE_SYNC: 0x40,
MODE_EXCL: 0x80, MODE_EXCL: 0x80,
expandPath: function(path) expandPath: function (path)
{ {
const WINDOWS = navigator.platform == "Win32"; const WINDOWS = navigator.platform == "Win32";
@@ -84,7 +84,7 @@ vimperator.IO = function()
return path; return path;
}, },
getPluginDir: function() getPluginDir: function ()
{ {
var plugin_dir; var plugin_dir;
@@ -98,7 +98,7 @@ vimperator.IO = function()
return plugin_dir.exists() && plugin_dir.isDirectory() ? plugin_dir : null; return plugin_dir.exists() && plugin_dir.isDirectory() ? plugin_dir : null;
}, },
getRCFile: function() getRCFile: function ()
{ {
var rc_file1 = this.getFile(this.expandPath("~/.vimperatorrc")); var rc_file1 = this.getFile(this.expandPath("~/.vimperatorrc"));
var rc_file2 = this.getFile(this.expandPath("~/_vimperatorrc")); var rc_file2 = this.getFile(this.expandPath("~/_vimperatorrc"));
@@ -116,7 +116,7 @@ vimperator.IO = function()
// return a nsILocalFile for path where you can call isDirectory(), etc. on // return a nsILocalFile for path where you can call isDirectory(), etc. on
// caller must check with .exists() if the returned file really exists // caller must check with .exists() if the returned file really exists
getFile: function(path) getFile: function (path)
{ {
var file = Components.classes["@mozilla.org/file/local;1"]. var file = Components.classes["@mozilla.org/file/local;1"].
createInstance(Components.interfaces.nsILocalFile); createInstance(Components.interfaces.nsILocalFile);
@@ -127,7 +127,7 @@ vimperator.IO = function()
// TODO: make secure // TODO: make secure
// returns a nsILocalFile or null if it could not be created // returns a nsILocalFile or null if it could not be created
createTempFile: function() createTempFile: function ()
{ {
var file = Components.classes["@mozilla.org/file/local;1"]. var file = Components.classes["@mozilla.org/file/local;1"].
createInstance(Components.interfaces.nsILocalFile); createInstance(Components.interfaces.nsILocalFile);
@@ -150,7 +150,7 @@ vimperator.IO = function()
}, },
// file is either a full pathname or an instance of file instanceof nsILocalFile // file is either a full pathname or an instance of file instanceof nsILocalFile
readDirectory: function(file) readDirectory: function (file)
{ {
if (typeof file == "string") if (typeof file == "string")
file = this.getFile(file); file = this.getFile(file);
@@ -175,7 +175,7 @@ vimperator.IO = function()
// file is either a full pathname or an instance of file instanceof nsILocalFile // file is either a full pathname or an instance of file instanceof nsILocalFile
// reads a file in "text" mode and returns the string // reads a file in "text" mode and returns the string
readFile: function(file) readFile: function (file)
{ {
var ifstream = Components.classes["@mozilla.org/network/file-input-stream;1"] var ifstream = Components.classes["@mozilla.org/network/file-input-stream;1"]
.createInstance(Components.interfaces.nsIFileInputStream); .createInstance(Components.interfaces.nsIFileInputStream);
@@ -206,7 +206,7 @@ vimperator.IO = function()
// file is either a full pathname or an instance of file instanceof nsILocalFile // file is either a full pathname or an instance of file instanceof nsILocalFile
// default permission = 0644, only used when creating a new file, does not change permissions if the file exists // default permission = 0644, only used when creating a new file, does not change permissions if the file exists
// mode can be ">" or ">>" in addition to the normal MODE_* flags // mode can be ">" or ">>" in addition to the normal MODE_* flags
writeFile: function(file, buf, mode, perms) writeFile: function (file, buf, mode, perms)
{ {
var ofstream = Components.classes["@mozilla.org/network/file-output-stream;1"] var ofstream = Components.classes["@mozilla.org/network/file-output-stream;1"]
.createInstance(Components.interfaces.nsIFileOutputStream); .createInstance(Components.interfaces.nsIFileOutputStream);

File diff suppressed because it is too large Load Diff

View File

@@ -26,7 +26,7 @@ the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
vimperator.modes = (function() vimperator.modes = (function ()
{ {
var main = 1; // NORMAL var main = 1; // NORMAL
var extended = 0; // NONE var extended = 0; // NONE
@@ -143,12 +143,12 @@ vimperator.modes = (function()
MENU: 1 << 18, // a popupmenu is active MENU: 1 << 18, // a popupmenu is active
LINE: 1 << 19, // linewise visual mode LINE: 1 << 19, // linewise visual mode
reset: function(silent) reset: function (silent)
{ {
this.set(vimperator.modes.NORMAL, vimperator.modes.NONE, silent); this.set(vimperator.modes.NORMAL, vimperator.modes.NONE, silent);
}, },
show: function() show: function ()
{ {
if (!vimperator.options["showmode"]) if (!vimperator.options["showmode"])
return; return;
@@ -166,7 +166,7 @@ vimperator.modes = (function()
// helper function to set both modes in one go // helper function to set both modes in one go
// if silent == true, you also need to take care of the mode handling changes yourself // if silent == true, you also need to take care of the mode handling changes yourself
set: function(main_mode, extended_mode, silent) set: function (main_mode, extended_mode, silent)
{ {
// if a main mode is set, the extended is always cleared // if a main mode is set, the extended is always cleared
if (typeof main_mode === "number") if (typeof main_mode === "number")
@@ -187,12 +187,12 @@ vimperator.modes = (function()
}, },
// add/remove always work on the extended mode only // add/remove always work on the extended mode only
add: function(mode) add: function (mode)
{ {
extended |= mode; extended |= mode;
this.show(); this.show();
}, },
remove: function(mode) remove: function (mode)
{ {
extended = (extended | mode) ^ mode; extended = (extended | mode) ^ mode;
this.show(); this.show();

View File

@@ -26,7 +26,7 @@ the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
vimperator.Option = function(names, type, extra_info) //{{{ vimperator.Option = function (names, type, extra_info) //{{{
{ {
if (!names || !type) if (!names || !type)
return null; return null;
@@ -77,7 +77,7 @@ vimperator.Option = function(names, type, extra_info) //{{{
// NOTE: forced defaults need to use vimperator.options.getPref // NOTE: forced defaults need to use vimperator.options.getPref
this.__defineGetter__("value", this.__defineGetter__("value",
function() function ()
{ {
if (this.getter) if (this.getter)
this.getter.call(this); this.getter.call(this);
@@ -85,7 +85,7 @@ vimperator.Option = function(names, type, extra_info) //{{{
} }
); );
this.__defineSetter__("value", this.__defineSetter__("value",
function(new_value) function (new_value)
{ {
value = new_value; value = new_value;
if (this.setter) if (this.setter)
@@ -96,7 +96,7 @@ vimperator.Option = function(names, type, extra_info) //{{{
// TODO: add is[Type]() queries for use in set()? // TODO: add is[Type]() queries for use in set()?
// : add isValid() or just throw an exception? // : add isValid() or just throw an exception?
this.hasName = function(name) this.hasName = function (name)
{ {
for (var i = 0; i < this.names.length; i++) for (var i = 0; i < this.names.length; i++)
{ {
@@ -106,7 +106,7 @@ vimperator.Option = function(names, type, extra_info) //{{{
return false; return false;
} }
this.isValidValue = function(value) this.isValidValue = function (value)
{ {
if (this.validator) if (this.validator)
return this.validator(value); return this.validator(value);
@@ -114,13 +114,13 @@ vimperator.Option = function(names, type, extra_info) //{{{
return true; return true;
} }
this.reset = function() this.reset = function ()
{ {
this.value = this.default_value; this.value = this.default_value;
} }
} //}}} } //}}}
vimperator.Options = function() //{{{ vimperator.Options = function () //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -312,12 +312,12 @@ vimperator.Options = function() //{{{
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
this.__iterator__ = function() this.__iterator__ = function ()
{ {
return optionsIterator(); return optionsIterator();
} }
this.get = function(name) this.get = function (name)
{ {
for (var i = 0; i < options.length; i++) for (var i = 0; i < options.length; i++)
{ {
@@ -327,14 +327,14 @@ vimperator.Options = function() //{{{
return null; return null;
} }
this.add = function(option) this.add = function (option)
{ {
this.__defineGetter__(option.name, function() { return option.value; }); this.__defineGetter__(option.name, function () { return option.value; });
this.__defineSetter__(option.name, function(value) { option.value = value; }); this.__defineSetter__(option.name, function (value) { option.value = value; });
options.push(option); options.push(option);
} }
this.destroy = function() this.destroy = function ()
{ {
// reset some modified firefox prefs // reset some modified firefox prefs
if (loadPreference("dom.popup_allowed_events", "change click dblclick mouseup reset submit") if (loadPreference("dom.popup_allowed_events", "change click dblclick mouseup reset submit")
@@ -342,7 +342,7 @@ vimperator.Options = function() //{{{
storePreference("dom.popup_allowed_events", popup_allowed_events); storePreference("dom.popup_allowed_events", popup_allowed_events);
} }
this.list = function(only_non_default) this.list = function (only_non_default)
{ {
// TODO: columns like Vim? // TODO: columns like Vim?
var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "<br/>" + var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "<br/>" +
@@ -385,7 +385,7 @@ vimperator.Options = function() //{{{
} }
// this hack is only needed, because we need to do asynchronous loading of the .vimperatorrc // this hack is only needed, because we need to do asynchronous loading of the .vimperatorrc
this.setInitialGUI = function() this.setInitialGUI = function ()
{ {
if (!guioptions_done) if (!guioptions_done)
this.get("guioptions").reset(); this.get("guioptions").reset();
@@ -397,22 +397,22 @@ vimperator.Options = function() //{{{
// TODO: separate Preferences from Options? Would these utility functions // TODO: separate Preferences from Options? Would these utility functions
// be better placed in the 'core' vimperator namespace somewhere? // be better placed in the 'core' vimperator namespace somewhere?
this.setPref = function(name, value) this.setPref = function (name, value)
{ {
return storePreference(name, value, true); return storePreference(name, value, true);
} }
this.getPref = function(name, forced_default) this.getPref = function (name, forced_default)
{ {
return loadPreference(name, forced_default, true); return loadPreference(name, forced_default, true);
} }
this.setFirefoxPref = function(name, value) this.setFirefoxPref = function (name, value)
{ {
return storePreference(name, value); return storePreference(name, value);
} }
this.getFirefoxPref = function(name, forced_default) this.getFirefoxPref = function (name, forced_default)
{ {
return loadPreference(name, forced_default); return loadPreference(name, forced_default);
} }
@@ -437,9 +437,9 @@ vimperator.Options = function() //{{{
"<li><b>paste</b>: <code class=\"mapping\">P</code> and <code class=\"mapping\">gP</code> mappings</li>" + "<li><b>paste</b>: <code class=\"mapping\">P</code> and <code class=\"mapping\">gP</code> mappings</li>" +
"</ul>", "</ul>",
default_value: "homepage,quickmark,tabopen,paste", default_value: "homepage,quickmark,tabopen,paste",
validator: function(value) validator: function (value)
{ {
return value.split(",").every(function(item) { return /^(homepage|quickmark|tabopen|paste|)$/.test(item); }); return value.split(",").every(function (item) { return /^(homepage|quickmark|tabopen|paste|)$/.test(item); });
} }
} }
)); ));
@@ -456,7 +456,7 @@ vimperator.Options = function() //{{{
"The order is important, so <code class=\"command\">:set complete=bs</code> would list bookmarks first, and then any available quick searches.<br/>" + "The order is important, so <code class=\"command\">:set complete=bs</code> would list bookmarks first, and then any available quick searches.<br/>" +
"Add <code class=\"option\">'sort'</code> to the <code class=\"option\">'wildoptions'</code> option if you want all entries sorted.", "Add <code class=\"option\">'sort'</code> to the <code class=\"option\">'wildoptions'</code> option if you want all entries sorted.",
default_value: "sfbh", default_value: "sfbh",
validator: function(value) { return !/[^sfbh]/.test(value); } validator: function (value) { return !/[^sfbh]/.test(value); }
} }
)); ));
this.add(new vimperator.Option(["defsearch", "ds"], "string", this.add(new vimperator.Option(["defsearch", "ds"], "string",
@@ -464,7 +464,7 @@ vimperator.Options = function() //{{{
short_help: "Set the default search engine", short_help: "Set the default search engine",
help: "The default search engine is used in the <code class=\"command\">:[tab]open [arg]</code> command " + help: "The default search engine is used in the <code class=\"command\">:[tab]open [arg]</code> command " +
"if [arg] neither looks like a URL or like a specified search engine/keyword.", "if [arg] neither looks like a URL or like a specified search engine/keyword.",
completer: function() { return [["foo", "bar"], ["shit", "blub"]]; }, completer: function () { return [["foo", "bar"], ["shit", "blub"]]; },
default_value: "google" default_value: "google"
} }
)); ));
@@ -494,8 +494,8 @@ vimperator.Options = function() //{{{
this.add(new vimperator.Option(["fullscreen", "fs"], "boolean", this.add(new vimperator.Option(["fullscreen", "fs"], "boolean",
{ {
short_help: "Show the current window fullscreen", short_help: "Show the current window fullscreen",
setter: function(value) { window.fullScreen = value; }, setter: function (value) { window.fullScreen = value; },
getter: function() { return window.fullScreen; }, getter: function () { return window.fullScreen; },
default_value: false default_value: false
} }
)); ));
@@ -508,9 +508,9 @@ vimperator.Options = function() //{{{
"<li><b>T</b>: toolbar</li>" + "<li><b>T</b>: toolbar</li>" +
"<li><b>b</b>: bookmark bar</li>" + "<li><b>b</b>: bookmark bar</li>" +
"</ul>", "</ul>",
setter: function(value) { setGuiOptions(value); }, setter: function (value) { setGuiOptions(value); },
default_value: "", default_value: "",
validator: function(value) { return !/[^mTb]/.test(value); } validator: function (value) { return !/[^mTb]/.test(value); }
} }
)); ));
this.add(new vimperator.Option(["hinttimeout", "hto"], "number", this.add(new vimperator.Option(["hinttimeout", "hto"], "number",
@@ -518,7 +518,7 @@ vimperator.Options = function() //{{{
short_help: "Automatically follow non unique numerical hint after {arg} ms", short_help: "Automatically follow non unique numerical hint after {arg} ms",
help: "Set to 0 (the default) to only follow numeric hints after pressing &lt;Return&gt; or when the hint is unique.", help: "Set to 0 (the default) to only follow numeric hints after pressing &lt;Return&gt; or when the hint is unique.",
default_value: 0, default_value: 0,
validator: function(value) { return value >= 0; } validator: function (value) { return value >= 0; }
} }
)); ));
this.add(new vimperator.Option(["hintstyle", "hs"], "string", this.add(new vimperator.Option(["hintstyle", "hs"], "string",
@@ -537,7 +537,7 @@ vimperator.Options = function() //{{{
this.add(new vimperator.Option(["hlsearch", "hls"], "boolean", this.add(new vimperator.Option(["hlsearch", "hls"], "boolean",
{ {
short_help: "Highlight previous search pattern matches", short_help: "Highlight previous search pattern matches",
setter: function(value) { if (value) vimperator.search.highlight(); else vimperator.search.clear(); }, setter: function (value) { if (value) vimperator.search.highlight(); else vimperator.search.clear(); },
default_value: false default_value: false
} }
)); ));
@@ -580,8 +580,8 @@ vimperator.Options = function() //{{{
"</ul>" + "</ul>" +
"NOTE: laststatus=1 not implemented yet.", "NOTE: laststatus=1 not implemented yet.",
default_value: 2, default_value: 2,
setter: function(value) { setLastStatus(value); }, setter: function (value) { setLastStatus(value); },
validator: function(value) { return (value >= 0 && value <= 2); } validator: function (value) { return (value >= 0 && value <= 2); }
} }
)); ));
this.add(new vimperator.Option(["linksearch", "lks"], "boolean", this.add(new vimperator.Option(["linksearch", "lks"], "boolean",
@@ -624,8 +624,8 @@ vimperator.Options = function() //{{{
"</ul>" + "</ul>" +
"NOTE: This option does not change the popup blocker of Firefox in any way.", "NOTE: This option does not change the popup blocker of Firefox in any way.",
default_value: 1, default_value: 1,
setter: function(value) { setPopups(value); }, setter: function (value) { setPopups(value); },
validator: function(value) { return (value >= 0 && value <= 3); } validator: function (value) { return (value >= 0 && value <= 3); }
} }
)); ));
this.add(new vimperator.Option(["preload"], "boolean", this.add(new vimperator.Option(["preload"], "boolean",
@@ -643,7 +643,7 @@ vimperator.Options = function() //{{{
"Close the preview window with <code class=\"command\">:pclose</code>.<br/>" + "Close the preview window with <code class=\"command\">:pclose</code>.<br/>" +
"NOTE: Option currently disabled", "NOTE: Option currently disabled",
default_value: 10, default_value: 10,
validator: function(value) { return (value >= 1 && value <= 50); } validator: function (value) { return (value >= 1 && value <= 50); }
} }
)); ));
this.add(new vimperator.Option(["scroll", "scr"], "number", this.add(new vimperator.Option(["scroll", "scr"], "number",
@@ -653,7 +653,7 @@ vimperator.Options = function() //{{{
"When a <code class=\"argument\">{count}</code> is specified to the <code class=\"mapping\">&lt;C-u&gt;</code> or <code class=\"mapping\">&lt;C-d&gt;</code> commands this is used to set the value of <code class=\"option\">'scroll'</code> and also used for the current command. " + "When a <code class=\"argument\">{count}</code> is specified to the <code class=\"mapping\">&lt;C-u&gt;</code> or <code class=\"mapping\">&lt;C-d&gt;</code> commands this is used to set the value of <code class=\"option\">'scroll'</code> and also used for the current command. " +
"The value can be reset to half the window height with <code class=\"command\">:set scroll=0</code>.", "The value can be reset to half the window height with <code class=\"command\">:set scroll=0</code>.",
default_value: 0, default_value: 0,
validator: function(value) { return value >= 0; } validator: function (value) { return value >= 0; }
} }
)); ));
this.add(new vimperator.Option(["showmode", "smd"], "boolean", this.add(new vimperator.Option(["showmode", "smd"], "boolean",
@@ -673,7 +673,7 @@ vimperator.Options = function() //{{{
"<li><b>2</b>: Show the link in the command line</li>" + "<li><b>2</b>: Show the link in the command line</li>" +
"</ul>", "</ul>",
default_value: 1, default_value: 1,
validator: function(value) { return (value >= 0 && value <= 2); } validator: function (value) { return (value >= 0 && value <= 2); }
} }
)); ));
this.add(new vimperator.Option(["showtabline", "stal"], "number", this.add(new vimperator.Option(["showtabline", "stal"], "number",
@@ -685,9 +685,9 @@ vimperator.Options = function() //{{{
"<li><b>1</b>: Show tab bar only if more than one tab is open</li>" + "<li><b>1</b>: Show tab bar only if more than one tab is open</li>" +
"<li><b>2</b>: Always show tab bar</li>" + "<li><b>2</b>: Always show tab bar</li>" +
"</ul>", "</ul>",
setter: function(value) { setShowTabline(value); }, setter: function (value) { setShowTabline(value); },
default_value: 2, default_value: 2,
validator: function(value) { return (value >= 0 && value <= 2); } validator: function (value) { return (value >= 0 && value <= 2); }
} }
)); ));
this.add(new vimperator.Option(["smartcase", "scs"], "boolean", this.add(new vimperator.Option(["smartcase", "scs"], "boolean",
@@ -703,7 +703,7 @@ vimperator.Options = function() //{{{
help: "Vimperator changes the browser title from \"Title of web page - Mozilla Firefox\" to " + help: "Vimperator changes the browser title from \"Title of web page - Mozilla Firefox\" to " +
"\"Title of web page - Vimperator\".<br/>If you don't like that, you can restore it with: " + "\"Title of web page - Vimperator\".<br/>If you don't like that, you can restore it with: " +
"<code class=\"command\">:set titlestring=Mozilla Firefox</code>.", "<code class=\"command\">:set titlestring=Mozilla Firefox</code>.",
setter: function(value) { setTitleString(value); }, setter: function (value) { setTitleString(value); },
default_value: "Vimperator" default_value: "Vimperator"
} }
)); ));
@@ -711,8 +711,8 @@ vimperator.Options = function() //{{{
{ {
short_help: "Show current website with a minimal style sheet to make it easily accessible", short_help: "Show current website with a minimal style sheet to make it easily accessible",
help: "Note that this is a local option for now, later it may be split into a global and <code class=\"command\">:setlocal</code> part", help: "Note that this is a local option for now, later it may be split into a global and <code class=\"command\">:setlocal</code> part",
setter: function(value) { getMarkupDocumentViewer().authorStyleDisabled = value; }, setter: function (value) { getMarkupDocumentViewer().authorStyleDisabled = value; },
getter: function() { return getMarkupDocumentViewer().authorStyleDisabled; }, getter: function () { return getMarkupDocumentViewer().authorStyleDisabled; },
default_value: false default_value: false
} }
)); ));
@@ -722,13 +722,13 @@ vimperator.Options = function() //{{{
help: "When bigger than zero, Vimperator will give messages about what it is doing. They are printed to the error console which can be shown with <code class=\"command\">:javascript!</code>.<br/>" + help: "When bigger than zero, Vimperator will give messages about what it is doing. They are printed to the error console which can be shown with <code class=\"command\">:javascript!</code>.<br/>" +
"The highest value is 9, being the most verbose mode.", "The highest value is 9, being the most verbose mode.",
default_value: 0, default_value: 0,
validator: function(value) { return (value >= 0 && value <= 9); } validator: function (value) { return (value >= 0 && value <= 9); }
} }
)); ));
this.add(new vimperator.Option(["visualbell", "vb"], "boolean", this.add(new vimperator.Option(["visualbell", "vb"], "boolean",
{ {
short_help: "Use visual bell instead of beeping on errors", short_help: "Use visual bell instead of beeping on errors",
setter: function(value) { vimperator.options.setFirefoxPref("accessibility.typeaheadfind.enablesound", !value); }, setter: function (value) { vimperator.options.setFirefoxPref("accessibility.typeaheadfind.enablesound", !value); },
default_value: false default_value: false
} }
)); ));
@@ -750,9 +750,9 @@ vimperator.Options = function() //{{{
"</table>" + "</table>" +
"When there is only a single match, it is fully completed regardless of the case.", "When there is only a single match, it is fully completed regardless of the case.",
default_value: "list:full", default_value: "list:full",
validator: function(value) validator: function (value)
{ {
return value.split(",").every(function(item) { return /^(full|longest|list|list:full|list:longest|)$/.test(item); }); return value.split(",").every(function (item) { return /^(full|longest|list|list:full|list:longest|)$/.test(item); });
} }
} }
)); ));
@@ -765,7 +765,7 @@ vimperator.Options = function() //{{{
"<tr><td><b>sort</b></td><td>Always sorts completion list, overriding the <code class=\"option\">'complete'</code> option.</td></tr>" + "<tr><td><b>sort</b></td><td>Always sorts completion list, overriding the <code class=\"option\">'complete'</code> option.</td></tr>" +
"</table>", "</table>",
default_value: "", default_value: "",
validator: function(value) { return /^sort$/.test(value); } validator: function (value) { return /^sort$/.test(value); }
} }
)); ));
//}}} //}}}

View File

@@ -32,7 +32,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
* Firefox 3.0, then this class should go away and their tab methods should be used * Firefox 3.0, then this class should go away and their tab methods should be used
* @deprecated * @deprecated
*/ */
vimperator.Tabs = function() //{{{ vimperator.Tabs = function () //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -87,7 +87,7 @@ vimperator.Tabs = function() //{{{
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
// @returns the index of the currently selected tab starting with 0 // @returns the index of the currently selected tab starting with 0
this.index = function(tab) this.index = function (tab)
{ {
if (tab) if (tab)
{ {
@@ -103,14 +103,14 @@ vimperator.Tabs = function() //{{{
return getBrowser().tabContainer.selectedIndex; return getBrowser().tabContainer.selectedIndex;
} }
this.count = function() this.count = function ()
{ {
return getBrowser().mTabs.length; return getBrowser().mTabs.length;
} }
// TODO: implement filter // TODO: implement filter
// @returns an array of tabs which match filter // @returns an array of tabs which match filter
this.get = function(filter) this.get = function (filter)
{ {
var buffers = []; var buffers = [];
var browsers = getBrowser().browsers; var browsers = getBrowser().browsers;
@@ -124,7 +124,7 @@ vimperator.Tabs = function() //{{{
return buffers; return buffers;
} }
this.getTab = function(index) this.getTab = function (index)
{ {
if (index) if (index)
return getBrowser().mTabs[index]; return getBrowser().mTabs[index];
@@ -137,7 +137,7 @@ vimperator.Tabs = function() //{{{
* NOTE: position is a 0 based index * NOTE: position is a 0 based index
* FIXME: tabmove! N should probably produce an error * FIXME: tabmove! N should probably produce an error
*/ */
this.move = function(tab, spec, wrap) this.move = function (tab, spec, wrap)
{ {
if (spec === "") if (spec === "")
spec = "$"; // if not specified, move to the last tab -> XXX: move to ex handling? spec = "$"; // if not specified, move to the last tab -> XXX: move to ex handling?
@@ -149,7 +149,7 @@ vimperator.Tabs = function() //{{{
/* quit_on_last_tab = 1: quit without saving session /* quit_on_last_tab = 1: quit without saving session
* quit_on_last_tab = 2: quit and save session * quit_on_last_tab = 2: quit and save session
*/ */
this.remove = function(tab, count, focus_left_tab, quit_on_last_tab) this.remove = function (tab, count, focus_left_tab, quit_on_last_tab)
{ {
function removeOrBlankTab (tab) function removeOrBlankTab (tab)
{ {
@@ -203,12 +203,12 @@ vimperator.Tabs = function() //{{{
} }
} }
this.keepOnly = function(tab) this.keepOnly = function (tab)
{ {
getBrowser().removeAllTabsBut(tab); getBrowser().removeAllTabsBut(tab);
} }
this.select = function(spec, wrap) this.select = function (spec, wrap)
{ {
var index = indexFromSpec(spec, wrap); var index = indexFromSpec(spec, wrap);
if (index === false) if (index === false)
@@ -223,7 +223,7 @@ vimperator.Tabs = function() //{{{
// tab that was selected when the session was created. As a result the // tab that was selected when the session was created. As a result the
// alternate after a restart is often incorrectly tab 1 when there // alternate after a restart is often incorrectly tab 1 when there
// shouldn't be one yet. // shouldn't be one yet.
this.updateSelectionHistory = function() this.updateSelectionHistory = function ()
{ {
alternates = [this.getTab(), alternates[0]]; alternates = [this.getTab(), alternates[0]];
this.alternate = alternates[1]; this.alternate = alternates[1];
@@ -232,7 +232,7 @@ vimperator.Tabs = function() //{{{
// TODO: move to v.buffers // TODO: move to v.buffers
this.alternate = this.getTab(); this.alternate = this.getTab();
this.reload = function(tab, bypass_cache) this.reload = function (tab, bypass_cache)
{ {
if (bypass_cache) if (bypass_cache)
{ {
@@ -246,7 +246,7 @@ vimperator.Tabs = function() //{{{
} }
} }
this.reloadAll = function(bypass_cache) this.reloadAll = function (bypass_cache)
{ {
if (bypass_cache) if (bypass_cache)
{ {

View File

@@ -32,7 +32,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
* it consists of a prompt and command field * it consists of a prompt and command field
* be sure to only create objects of this class when the chrome is ready * be sure to only create objects of this class when the chrome is ready
*/ */
vimperator.CommandLine = function() //{{{ vimperator.CommandLine = function () //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -51,22 +51,22 @@ vimperator.CommandLine = function() //{{{
cmd: null, // ex command history cmd: null, // ex command history
search: null, // text search history search: null, // text search history
get: function() { return this[this._mode]; }, get: function () { return this[this._mode]; },
set: function(lines) { this[this._mode] = lines; }, set: function (lines) { this[this._mode] = lines; },
load: function() load: function ()
{ {
this.cmd = vimperator.options.getPref("commandline_cmd_history", "").split("\n"); this.cmd = vimperator.options.getPref("commandline_cmd_history", "").split("\n");
this.search = vimperator.options.getPref("commandline_search_history", "").split("\n"); this.search = vimperator.options.getPref("commandline_search_history", "").split("\n");
}, },
save: function() save: function ()
{ {
vimperator.options.setPref("commandline_cmd_history", this.cmd.join("\n")); vimperator.options.setPref("commandline_cmd_history", this.cmd.join("\n"));
vimperator.options.setPref("commandline_search_history", this.search.join("\n")); vimperator.options.setPref("commandline_search_history", this.search.join("\n"));
}, },
add: function(str) add: function (str)
{ {
if (!str) if (!str)
return; return;
@@ -74,7 +74,7 @@ vimperator.CommandLine = function() //{{{
var lines = this.get(); var lines = this.get();
// remove all old history lines which have this string // remove all old history lines which have this string
lines = lines.filter(function(line) { lines = lines.filter(function (line) {
return line != str; return line != str;
}); });
@@ -251,12 +251,12 @@ vimperator.CommandLine = function() //{{{
// FORCE_MULTILINE is given, FORCE_MULTILINE takes precedence // FORCE_MULTILINE is given, FORCE_MULTILINE takes precedence
this.APPEND_TO_MESSAGES = 1 << 3; // will show the string in :messages this.APPEND_TO_MESSAGES = 1 << 3; // will show the string in :messages
this.getCommand = function() this.getCommand = function ()
{ {
return command_widget.value; return command_widget.value;
}; };
this.open = function(prompt, cmd, ext_mode) this.open = function (prompt, cmd, ext_mode)
{ {
// save the current prompts, we need it later if the command widget // save the current prompts, we need it later if the command widget
// receives focus without calling the this.open() method // receives focus without calling the this.open() method
@@ -279,7 +279,7 @@ vimperator.CommandLine = function() //{{{
}; };
// normally used when pressing esc, does not execute a command // normally used when pressing esc, does not execute a command
this.close = function() this.close = function ()
{ {
var res = vimperator.triggerCallback("cancel", cur_extended_mode); var res = vimperator.triggerCallback("cancel", cur_extended_mode);
history.add(this.getCommand()); history.add(this.getCommand());
@@ -287,7 +287,7 @@ vimperator.CommandLine = function() //{{{
this.clear(); this.clear();
} }
this.clear = function() this.clear = function ()
{ {
multiline_input_widget.collapsed = true; multiline_input_widget.collapsed = true;
multiline_output_widget.collapsed = true; multiline_output_widget.collapsed = true;
@@ -298,7 +298,7 @@ vimperator.CommandLine = function() //{{{
// TODO: add :messages entry // TODO: add :messages entry
// vimperator.echo uses different order of flags as it omits the hightlight group, change v.commandline.echo argument order? --mst // vimperator.echo uses different order of flags as it omits the hightlight group, change v.commandline.echo argument order? --mst
this.echo = function(str, highlight_group, flags) this.echo = function (str, highlight_group, flags)
{ {
var focused = document.commandDispatcher.focusedElement; var focused = document.commandDispatcher.focusedElement;
if (focused && focused == command_widget.inputField || focused == multiline_input_widget.inputField) if (focused && focused == command_widget.inputField || focused == multiline_input_widget.inputField)
@@ -331,7 +331,7 @@ vimperator.CommandLine = function() //{{{
// this will prompt the user for a string // this will prompt the user for a string
// vimperator.commandline.input("(s)ave or (o)pen the file?") // vimperator.commandline.input("(s)ave or (o)pen the file?")
this.input = function(str) this.input = function (str)
{ {
// TODO: unfinished, need to find out how/if we can block the execution of code // TODO: unfinished, need to find out how/if we can block the execution of code
// to make this code synchronous or at least use a callback // to make this code synchronous or at least use a callback
@@ -342,7 +342,7 @@ vimperator.CommandLine = function() //{{{
// reads a multi line input and returns the string once the last line matches // reads a multi line input and returns the string once the last line matches
// @param until_regexp // @param until_regexp
this.inputMultiline = function(until_regexp, callback_func) this.inputMultiline = function (until_regexp, callback_func)
{ {
// save the mode, because we need to restore it // save the mode, because we need to restore it
old_mode = vimperator.mode; old_mode = vimperator.mode;
@@ -357,19 +357,19 @@ vimperator.CommandLine = function() //{{{
multiline_input_widget.value = ""; multiline_input_widget.value = "";
autosizeMultilineInputWidget(); autosizeMultilineInputWidget();
setTimeout(function() { setTimeout(function () {
multiline_input_widget.focus(); multiline_input_widget.focus();
}, 10); }, 10);
}; };
this.onEvent = function(event) this.onEvent = function (event)
{ {
var command = this.getCommand(); var command = this.getCommand();
if (event.type == "blur") if (event.type == "blur")
{ {
// prevent losing focus, there should be a better way, but it just didn't work otherwise // prevent losing focus, there should be a better way, but it just didn't work otherwise
setTimeout(function() { setTimeout(function () {
if (vimperator.mode == vimperator.modes.COMMAND_LINE && if (vimperator.mode == vimperator.modes.COMMAND_LINE &&
!(vimperator.modes.extended & vimperator.modes.INPUT_MULTILINE) && !(vimperator.modes.extended & vimperator.modes.INPUT_MULTILINE) &&
!(vimperator.modes.extended & vimperator.modes.OUTPUT_MULTILINE)) !(vimperator.modes.extended & vimperator.modes.OUTPUT_MULTILINE))
@@ -484,7 +484,7 @@ vimperator.CommandLine = function() //{{{
// sort the completion list // sort the completion list
if (vimperator.options["wildoptions"].search(/\bsort\b/) > -1) if (vimperator.options["wildoptions"].search(/\bsort\b/) > -1)
{ {
completions.sort(function(a, b) { completions.sort(function (a, b) {
if (a[0] < b[0]) if (a[0] < b[0])
return -1; return -1;
else if (a[0] > b[0]) else if (a[0] > b[0])
@@ -598,7 +598,7 @@ vimperator.CommandLine = function() //{{{
} }
} }
this.onMultilineInputEvent = function(event) this.onMultilineInputEvent = function (event)
{ {
if (event.type == "keypress") if (event.type == "keypress")
{ {
@@ -623,7 +623,7 @@ vimperator.CommandLine = function() //{{{
else if (event.type == "blur") else if (event.type == "blur")
{ {
if (vimperator.modes.extended & vimperator.modes.INPUT_MULTILINE) if (vimperator.modes.extended & vimperator.modes.INPUT_MULTILINE)
setTimeout(function() { multiline_input_widget.inputField.focus(); }, 0); setTimeout(function () { multiline_input_widget.inputField.focus(); }, 0);
} }
else if (event.type == "input") else if (event.type == "input")
{ {
@@ -633,7 +633,7 @@ vimperator.CommandLine = function() //{{{
// FIXME: if 'more' is set and the MOW is not scrollable we should still // FIXME: if 'more' is set and the MOW is not scrollable we should still
// allow a down motion after an up rather than closing // allow a down motion after an up rather than closing
this.onMultilineOutputEvent = function(event) this.onMultilineOutputEvent = function (event)
{ {
var win = multiline_output_widget.contentWindow; var win = multiline_output_widget.contentWindow;
@@ -829,7 +829,7 @@ vimperator.CommandLine = function() //{{{
} }
// it would be better if we had a destructor in javascript ... // it would be better if we had a destructor in javascript ...
this.destroy = function() this.destroy = function ()
{ {
history.save(); history.save();
} }
@@ -842,7 +842,7 @@ vimperator.CommandLine = function() //{{{
* @param id: the id of the the XUL widget which we want to fill * @param id: the id of the the XUL widget which we want to fill
* @param options: an optional hash which modifies the behavior of the list * @param options: an optional hash which modifies the behavior of the list
*/ */
vimperator.InformationList = function(id, options) //{{{ vimperator.InformationList = function (id, options) //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -942,7 +942,7 @@ vimperator.InformationList = function(id, options) //{{{
* use entries of 'compl' to fill the list. * use entries of 'compl' to fill the list.
* Required format: [["left", "right"], ["another"], ["completion"]] * Required format: [["left", "right"], ["another"], ["completion"]]
*/ */
this.show = function(compl) this.show = function (compl)
{ {
//max_items = vimperator.options["previewheight"]; //max_items = vimperator.options["previewheight"];
@@ -968,12 +968,12 @@ vimperator.InformationList = function(id, options) //{{{
} }
} }
this.hide = function() this.hide = function ()
{ {
widget.hidden = true; widget.hidden = true;
} }
this.visible = function() this.visible = function ()
{ {
return !widget.hidden; return !widget.hidden;
} }
@@ -981,7 +981,7 @@ vimperator.InformationList = function(id, options) //{{{
/** /**
* select index, refill list if necessary * select index, refill list if necessary
*/ */
this.selectItem = function(index) this.selectItem = function (index)
{ {
if (widget.hidden) if (widget.hidden)
return; return;
@@ -1029,7 +1029,7 @@ vimperator.InformationList = function(id, options) //{{{
widget.selectedIndex = index - list_offset; widget.selectedIndex = index - list_offset;
} }
this.onEvent = function(event) this.onEvent = function (event)
{ {
var listcells = document.getElementsByTagName("listcell"); var listcells = document.getElementsByTagName("listcell");
// 2 columns for now, use the first column // 2 columns for now, use the first column
@@ -1045,7 +1045,7 @@ vimperator.InformationList = function(id, options) //{{{
//}}} //}}}
} //}}} } //}}}
vimperator.StatusLine = function() //{{{ vimperator.StatusLine = function () //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -1065,7 +1065,7 @@ vimperator.StatusLine = function() //{{{
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
this.setClass = function(type) this.setClass = function (type)
{ {
var highlight_group; var highlight_group;
@@ -1086,7 +1086,7 @@ vimperator.StatusLine = function() //{{{
}; };
// update all fields of the statusline // update all fields of the statusline
this.update = function() this.update = function ()
{ {
this.updateUrl(); this.updateUrl();
this.updateInputBuffer(); this.updateInputBuffer();
@@ -1096,7 +1096,7 @@ vimperator.StatusLine = function() //{{{
} }
// if "url" is ommited, build a usable string for the URL // if "url" is ommited, build a usable string for the URL
this.updateUrl = function(url) this.updateUrl = function (url)
{ {
if (typeof url == "string") if (typeof url == "string")
{ {
@@ -1130,7 +1130,7 @@ vimperator.StatusLine = function() //{{{
url_widget.value = url; url_widget.value = url;
}; };
this.updateInputBuffer = function(buffer) this.updateInputBuffer = function (buffer)
{ {
if (!buffer || typeof buffer != "string") if (!buffer || typeof buffer != "string")
buffer = ""; buffer = "";
@@ -1138,7 +1138,7 @@ vimperator.StatusLine = function() //{{{
inputbuffer_widget.value = buffer; inputbuffer_widget.value = buffer;
}; };
this.updateProgress = function(progress) this.updateProgress = function (progress)
{ {
if (!progress) if (!progress)
progress = ""; progress = "";
@@ -1169,7 +1169,7 @@ vimperator.StatusLine = function() //{{{
}; };
// you can omit either of the 2 arguments // you can omit either of the 2 arguments
this.updateTabCount = function(cur_index, total_tabs) this.updateTabCount = function (cur_index, total_tabs)
{ {
if (!cur_index || typeof cur_index != "number") if (!cur_index || typeof cur_index != "number")
cur_index = vimperator.tabs.index() + 1; cur_index = vimperator.tabs.index() + 1;
@@ -1180,7 +1180,7 @@ vimperator.StatusLine = function() //{{{
}; };
// percent is given between 0 and 1 // percent is given between 0 and 1
this.updateBufferPosition = function(percent) this.updateBufferPosition = function (percent)
{ {
if (!percent || typeof percent != "number") if (!percent || typeof percent != "number")
{ {
@@ -1189,7 +1189,7 @@ vimperator.StatusLine = function() //{{{
} }
var bufferposition_str = ""; var bufferposition_str = "";
percent = Math.round(percent*100); percent = Math.round(percent * 100);
if (percent < 0) bufferposition_str = "All"; if (percent < 0) bufferposition_str = "All";
else if (percent == 0) bufferposition_str = "Top"; else if (percent == 0) bufferposition_str = "Top";
else if (percent < 10) bufferposition_str = " " + percent + "%"; else if (percent < 10) bufferposition_str = " " + percent + "%";

View File

@@ -27,7 +27,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
vimperator.util = { vimperator.util = {
escapeHTML: function(str) escapeHTML: function (str)
{ {
// XXX: the following code is _much_ slower than a simple .replace() // XXX: the following code is _much_ slower than a simple .replace()
// :history display went down from 2 to 1 second after changing // :history display went down from 2 to 1 second after changing
@@ -41,7 +41,7 @@ vimperator.util = {
// TODO: use :highlight color groups // TODO: use :highlight color groups
// if "process_strings" is true, any passed strings will be surrounded by " and // if "process_strings" is true, any passed strings will be surrounded by " and
// any line breaks are displayed as \n // any line breaks are displayed as \n
colorize: function(arg, process_strings) colorize: function (arg, process_strings)
{ {
var type = typeof(arg); var type = typeof(arg);
@@ -91,7 +91,7 @@ vimperator.util = {
// 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']
stringToURLArray: function(str) stringToURLArray: function (str)
{ {
var urls = str.split(/\s*\,\s+/); var urls = str.split(/\s*\,\s+/);
@@ -166,7 +166,7 @@ vimperator.util = {
return urls; return urls;
}, },
highlightURL: function(str, force) highlightURL: function (str, force)
{ {
if (force || /^[a-zA-Z]+:\/\/.*\//.test(str)) if (force || /^[a-zA-Z]+:\/\/.*\//.test(str))
return "<a class='hl-URL' href='" + str + "'>" + vimperator.util.escapeHTML(str) + "</a>"; return "<a class='hl-URL' href='" + str + "'>" + vimperator.util.escapeHTML(str) + "</a>";
@@ -174,7 +174,7 @@ vimperator.util = {
return str; return str;
}, },
formatNumber: function(num) formatNumber: function (num)
{ {
var strNum = (num + "").split(".", 2); var strNum = (num + "").split(".", 2);

View File

@@ -26,7 +26,7 @@ the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
const vimperator = (function() //{{{ const vimperator = (function () //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -72,13 +72,13 @@ const vimperator = (function() //{{{
// "cancel" // "cancel"
// "complete" // "complete"
// TODO: "zoom": if the zoom value of the current buffer changed // TODO: "zoom": if the zoom value of the current buffer changed
registerCallback: function(type, mode, func) registerCallback: function (type, mode, func)
{ {
// TODO: check if callback is already registered // TODO: check if callback is already registered
callbacks.push([type, mode, func]); callbacks.push([type, mode, func]);
}, },
triggerCallback: function(type, mode, data) triggerCallback: function (type, mode, data)
{ {
// dump("type: " + type + " mode: " + mode + "data: " + data + "\n"); // dump("type: " + type + " mode: " + mode + "data: " + data + "\n");
for (var i in callbacks) for (var i in callbacks)
@@ -90,7 +90,7 @@ const vimperator = (function() //{{{
return false; return false;
}, },
beep: function() beep: function ()
{ {
if (vimperator.options["visualbell"]) if (vimperator.options["visualbell"])
{ {
@@ -102,7 +102,7 @@ const vimperator = (function() //{{{
popup.height = box.height; popup.height = box.height;
popup.width = box.width; popup.width = box.width;
popup.openPopup(win, "overlap", 0, 0, false, false); popup.openPopup(win, "overlap", 0, 0, false, false);
setTimeout(function() { popup.hidePopup(); }, 50); setTimeout(function () { popup.hidePopup(); }, 50);
} }
else else
{ {
@@ -110,14 +110,14 @@ const vimperator = (function() //{{{
} }
}, },
copyToClipboard: function(str) copyToClipboard: function (str)
{ {
var clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"] var clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.getService(Components.interfaces.nsIClipboardHelper); .getService(Components.interfaces.nsIClipboardHelper);
clipboardHelper.copyString(str); clipboardHelper.copyString(str);
}, },
execute: function(str, modifiers) execute: function (str, modifiers)
{ {
// skip comments and blank lines // skip comments and blank lines
if (/^\s*("|$)/.test(str)) if (/^\s*("|$)/.test(str))
@@ -149,7 +149,7 @@ const vimperator = (function() //{{{
// after pressing Escape, put focus on a non-input field of the browser document // after pressing Escape, put focus on a non-input field of the browser document
// if clearFocusedElement, also blur a focused link // if clearFocusedElement, also blur a focused link
focusContent: function(clearFocusedElement) focusContent: function (clearFocusedElement)
{ {
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]. var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"].
getService(Components.interfaces.nsIWindowWatcher); getService(Components.interfaces.nsIWindowWatcher);
@@ -161,7 +161,7 @@ const vimperator = (function() //{{{
}, },
// partial sixth level expression evaluation // partial sixth level expression evaluation
eval: function(string) eval: function (string)
{ {
string = string.toString().replace(/^\s*/, "").replace(/\s*$/, ""); string = string.toString().replace(/^\s*/, "").replace(/\s*$/, "");
var match = string.match(/^&(\w+)/); var match = string.match(/^&(\w+)/);
@@ -207,7 +207,7 @@ const vimperator = (function() //{{{
return; return;
}, },
variableReference: function(string) variableReference: function (string)
{ {
if (!string) if (!string)
return [null, null, null]; return [null, null, null];
@@ -235,7 +235,7 @@ const vimperator = (function() //{{{
// TODO: move to vimp.util.? --mst // TODO: move to vimp.util.? --mst
// if color = true it uses HTML markup to color certain items // if color = true it uses HTML markup to color certain items
objectToString: function(object, color) objectToString: function (object, color)
{ {
if (object === null) if (object === null)
return "null"; return "null";
@@ -286,7 +286,7 @@ const vimperator = (function() //{{{
// logs a message to the javascript error console // logs a message to the javascript error console
// if msg is an object, it is beautified // if msg is an object, it is beautified
log: function(msg, level) log: function (msg, level)
{ {
//if (vimperator.options.getPref("verbose") >= level) // FIXME: hangs vimperator, probably timing issue --mst //if (vimperator.options.getPref("verbose") >= level) // FIXME: hangs vimperator, probably timing issue --mst
if (typeof msg == "object") if (typeof msg == "object")
@@ -305,7 +305,7 @@ const vimperator = (function() //{{{
// @param callback: not implemented, will be allowed to specify a callback function // @param callback: not implemented, will be allowed to specify a callback function
// which is called, when the page finished loading // which is called, when the page finished loading
// @returns true when load was initiated, or false on error // @returns true when load was initiated, or false on error
open: function(urls, where, callback) open: function (urls, where, callback)
{ {
// convert the string to an array of converted URLs // convert the string to an array of converted URLs
// -> see vimperator.util.stringToURLArray for more details // -> see vimperator.util.stringToURLArray for more details
@@ -365,7 +365,7 @@ const vimperator = (function() //{{{
}, },
// quit vimperator, no matter how many tabs/windows are open // quit vimperator, no matter how many tabs/windows are open
quit: function(save_session) quit: function (save_session)
{ {
if (save_session) if (save_session)
vimperator.options.setFirefoxPref("browser.startup.page", 3); // start with saved session vimperator.options.setFirefoxPref("browser.startup.page", 3); // start with saved session
@@ -375,7 +375,7 @@ const vimperator = (function() //{{{
goQuitApplication(); goQuitApplication();
}, },
restart: function() restart: function ()
{ {
const nsIAppStartup = Components.interfaces.nsIAppStartup; const nsIAppStartup = Components.interfaces.nsIAppStartup;
@@ -407,7 +407,7 @@ const vimperator = (function() //{{{
.quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit); .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit);
}, },
run: function(program, args, blocking) run: function (program, args, blocking)
{ {
var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
const WINDOWS = navigator.platform == "Win32"; const WINDOWS = navigator.platform == "Win32";
@@ -487,15 +487,15 @@ const vimperator = (function() //{{{
filein.remove(false); filein.remove(false);
// if there is only one \n at the end, chop it off // if there is only one \n at the end, chop it off
if (output && output.indexOf("\n") == output.length-1) if (output && output.indexOf("\n") == output.length - 1)
output = output.substr(0, output.length-1); output = output.substr(0, output.length - 1);
return output; return output;
}, },
// 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)
{ {
filename = vimperator.io.expandPath(filename); filename = vimperator.io.expandPath(filename);
@@ -519,7 +519,7 @@ const vimperator = (function() //{{{
{ {
var heredoc = ""; var heredoc = "";
var heredoc_end = null; // the string which ends the heredoc var heredoc_end = null; // the string which ends the heredoc
str.split("\n").forEach(function(line) str.split("\n").forEach(function (line)
{ {
if (heredoc_end) // we already are in a heredoc if (heredoc_end) // we already are in a heredoc
{ {
@@ -571,7 +571,7 @@ const vimperator = (function() //{{{
} }
}, },
startup: function() startup: function ()
{ {
window.dump("Vimperator startup\n"); window.dump("Vimperator startup\n");
vimperator.log("Initializing vimperator object...", 1); vimperator.log("Initializing vimperator object...", 1);
@@ -617,19 +617,19 @@ const vimperator = (function() //{{{
vimperator.completion = new vimperator.Completion(); vimperator.completion = new vimperator.Completion();
vimperator.log("All modules loaded", 3); vimperator.log("All modules loaded", 3);
vimperator.echo = function(str, flags) { vimperator.commandline.echo(str, vimperator.commandline.HL_NORMAL, flags); }; vimperator.echo = function (str, flags) { vimperator.commandline.echo(str, vimperator.commandline.HL_NORMAL, flags); };
vimperator.echoerr = function(str, flags) { vimperator.commandline.echo(str, vimperator.commandline.HL_ERRORMSG, flags); }; vimperator.echoerr = function (str, flags) { vimperator.commandline.echo(str, vimperator.commandline.HL_ERRORMSG, flags); };
vimperator.globalVariables = {}; vimperator.globalVariables = {};
// 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 vimperator.completion.exTabCompletion(str); } ); vimperator.registerCallback("complete", vimperator.modes.EX, function (str) { return vimperator.completion.exTabCompletion(str); } );
// first time intro message // first time intro message
if (vimperator.options.getPref("firsttime", true)) if (vimperator.options.getPref("firsttime", true))
{ {
setTimeout(function() { setTimeout(function () {
vimperator.help(null, null, null, { inTab: true }); vimperator.help(null, null, null, { inTab: true });
vimperator.options.setPref("firsttime", false); vimperator.options.setPref("firsttime", false);
}, 1000); }, 1000);
@@ -644,7 +644,7 @@ const vimperator = (function() //{{{
// finally, read a ~/.vimperatorrc // finally, read a ~/.vimperatorrc
// make sourcing asynchronous, otherwise commands that open new tabs won't work // make sourcing asynchronous, otherwise commands that open new tabs won't work
setTimeout(function() { setTimeout(function () {
var rc_file = vimperator.io.getRCFile(); var rc_file = vimperator.io.getRCFile();
@@ -661,7 +661,7 @@ const vimperator = (function() //{{{
{ {
var files = vimperator.io.readDirectory(plugin_dir.path); var files = vimperator.io.readDirectory(plugin_dir.path);
vimperator.log("Sourcing plugin directory...", 3); vimperator.log("Sourcing plugin directory...", 3);
files.forEach(function(file) { files.forEach(function (file) {
if (!file.isDirectory() && /\.(js|vimp)$/i.test(file.path)) if (!file.isDirectory() && /\.(js|vimp)$/i.test(file.path))
vimperator.source(file.path, false); vimperator.source(file.path, false);
}); });
@@ -687,7 +687,7 @@ const vimperator = (function() //{{{
vimperator.log("Vimperator fully initialized", 1); vimperator.log("Vimperator fully initialized", 1);
}, },
shutdown: function() shutdown: function ()
{ {
window.dump("Vimperator shutdown\n"); window.dump("Vimperator shutdown\n");
@@ -700,7 +700,7 @@ const vimperator = (function() //{{{
window.dump("All vimperator modules destroyed\n"); window.dump("All vimperator modules destroyed\n");
}, },
sleep: function(ms) sleep: function (ms)
{ {
var threadManager = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager); var threadManager = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager);
var mainThread = threadManager.mainThread; var mainThread = threadManager.mainThread;
@@ -723,15 +723,15 @@ const vimperator = (function() //{{{
}, },
// be sure to call GUI related methods like alert() or dump() ONLY in the main thread // be sure to call GUI related methods like alert() or dump() ONLY in the main thread
callFunctionInThread: function(thread, func, args) callFunctionInThread: function (thread, func, args)
{ {
function CallbackEvent (func, args) function CallbackEvent(func, args)
{ {
if (!(args instanceof Array)) if (!(args instanceof Array))
args = []; args = [];
return { return {
QueryInterface: function(iid) QueryInterface: function (iid)
{ {
if (iid.equals(Components.interfaces.nsIRunnable) || if (iid.equals(Components.interfaces.nsIRunnable) ||
iid.equals(Components.interfaces.nsISupports)) iid.equals(Components.interfaces.nsISupports))
@@ -739,7 +739,7 @@ const vimperator = (function() //{{{
throw Components.results.NS_ERROR_NO_INTERFACE; throw Components.results.NS_ERROR_NO_INTERFACE;
}, },
run: function() run: function ()
{ {
func.apply(window, args); func.apply(window, args);
} }