From fa1229294cd190a51a346c0e167aa5546047c084 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Mon, 19 Nov 2007 03:52:36 +0000 Subject: [PATCH] use camel case for all indentifiers --- content/bookmarks.js | 184 +++++++-------- content/buffers.js | 60 ++--- content/commands.js | 408 ++++++++++++++++----------------- content/completion.js | 166 +++++++------- content/editor.js | 26 +-- content/events.js | 34 +-- content/find.js | 88 ++++---- content/help.js | 16 +- content/hints.js | 64 +++--- content/io.js | 48 ++-- content/mappings.js | 318 +++++++++++++------------- content/modes.js | 26 +-- content/options.js | 258 ++++++++++----------- content/tabs.js | 28 +-- content/ui.js | 513 +++++++++++++++++++++--------------------- content/util.js | 26 ++- content/vimperator.js | 42 ++-- 17 files changed, 1154 insertions(+), 1151 deletions(-) diff --git a/content/bookmarks.js b/content/bookmarks.js index df71f51f..e7b01dea 100644 --- a/content/bookmarks.js +++ b/content/bookmarks.js @@ -33,15 +33,15 @@ vimperator.Bookmarks = function () //{{{ ////////////////////// PRIVATE SECTION ///////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - const history_service = Components.classes["@mozilla.org/browser/nav-history-service;1"] + const historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"] .getService(Components.interfaces.nsINavHistoryService); - const bookmarks_service = Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"] + const bookmarksService = Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"] .getService(Components.interfaces.nsINavBookmarksService); - const tagging_service = Components.classes["@mozilla.org/browser/tagging-service;1"] + const taggingService = Components.classes["@mozilla.org/browser/tagging-service;1"] .getService(Components.interfaces.nsITaggingService); - const search_service = Components.classes["@mozilla.org/browser/search-service;1"] + const searchService = Components.classes["@mozilla.org/browser/search-service;1"] .getService(Components.interfaces.nsIBrowserSearchService); - const io_service = Components.classes["@mozilla.org/network/io-service;1"] + const ioService = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService); var bookmarks = null; @@ -55,18 +55,18 @@ vimperator.Bookmarks = function () //{{{ // update our bookmark cache bookmarks = []; // also clear our bookmark cache keywords = []; - var root = bookmarks_service.bookmarksRoot; + var root = bookmarksService.bookmarksRoot; var folders = [root]; - var query = history_service.getNewQuery(); - var options = history_service.getNewQueryOptions(); + var query = historyService.getNewQuery(); + var options = historyService.getNewQueryOptions(); // query.searchTerms = "test"; while (folders.length > 0) { //comment out the next line for now; the bug hasn't been fixed; final version should include the next line //options.setGroupingMode(options.GROUP_BY_FOLDER); query.setFolders(folders, 1); - var result = history_service.executeQuery(query, options); + var result = historyService.executeQuery(query, options); //result.sortingMode = options.SORT_BY_DATE_DESCENDING; result.sortingMode = options.SORT_BY_VISITCOUNT_DESCENDING; var rootNode = result.root; @@ -81,11 +81,11 @@ vimperator.Bookmarks = function () //{{{ folders.push(node.itemId); else if (node.type == node.RESULT_TYPE_URI) // bookmark { - var kw = bookmarks_service.getKeywordForBookmark(node.itemId); + var kw = bookmarksService.getKeywordForBookmark(node.itemId); if (kw) keywords.push([kw, node.title, node.uri]); - var tags = tagging_service.getTagsForURI(io_service.newURI(node.uri, null, null)); + var tags = taggingService.getTagsForURI(ioService.newURI(node.uri, null, null)); bookmarks.push([node.uri, node.title, kw, tags]); } } @@ -101,12 +101,12 @@ vimperator.Bookmarks = function () //{{{ return { - // if "bypass_cache" is true, it will force a reload of the bookmarks database + // if "bypassCache" 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 // takes about 1 sec - get: function (filter, tags, bypass_cache) + get: function (filter, tags, bypassCache) { - if (!bookmarks || bypass_cache) + if (!bookmarks || bypassCache) load(); return vimperator.completion.filterURLArray(bookmarks, filter, tags); @@ -123,19 +123,19 @@ vimperator.Bookmarks = function () //{{{ try { - var uri = io_service.newURI(url, null, null); - var id = bookmarks_service.insertBookmark(bookmarks_service.bookmarksRoot, uri, -1, title); + var uri = ioService.newURI(url, null, null); + var id = bookmarksService.insertBookmark(bookmarksService.bookmarksRoot, uri, -1, title); if (!id) return false; if (keyword) { - bookmarks_service.setKeywordForBookmark(id, keyword); + bookmarksService.setKeywordForBookmark(id, keyword); keywords.unshift([keyword, title, url]); } if (tags) - tagging_service.tagURI(uri, tags); + taggingService.tagURI(uri, tags); } catch (e) { @@ -178,12 +178,12 @@ vimperator.Bookmarks = function () //{{{ var i = 0; try { - var uri = io_service.newURI(url, null, null); + var uri = ioService.newURI(url, null, null); var count = {}; - var bmarks = bookmarks_service.getBookmarkIdsForURI(uri, count); + var bmarks = bookmarksService.getBookmarkIdsForURI(uri, count); for (; i < bmarks.length; i++) - bookmarks_service.removeItem(bmarks[i]); + bookmarksService.removeItem(bmarks[i]); } catch (e) { @@ -203,33 +203,33 @@ vimperator.Bookmarks = function () //{{{ // also ensures that each search engine has a Vimperator-friendly alias getSearchEngines: function () { - var search_engines = []; - var firefox_engines = search_service.getVisibleEngines({ }); - for (var i in firefox_engines) + var searchEngines = []; + var firefoxEngines = searchService.getVisibleEngines({ }); + for (var i in firefoxEngines) { - var alias = firefox_engines[i].alias; + var alias = firefoxEngines[i].alias; if (!alias || !/^[a-z0-9_-]+$/.test(alias)) - alias = firefox_engines[i].name.replace(/^\W*([a-zA-Z_-]+).*/, "$1").toLowerCase(); + alias = firefoxEngines[i].name.replace(/^\W*([a-zA-Z_-]+).*/, "$1").toLowerCase(); if (!alias) alias = "search"; // for search engines which we can't find a suitable alias // make sure we can use search engines which would have the same alias (add numbers at the end) - var newalias = alias; + var newAlias = alias; for (var j = 1; j <= 10; j++) // <=10 is intentional { - if (!search_engines.some(function (item) { return (item[0] == newalias); })) + if (!searchEngines.some(function (item) { return (item[0] == newAlias); })) break; - newalias = alias + j; + newAlias = alias + j; } // only write when it changed, writes are really slow - if (firefox_engines[i].alias != newalias) - firefox_engines[i].alias = newalias; + if (firefoxEngines[i].alias != newAlias) + firefoxEngines[i].alias = newAlias; - search_engines.push([firefox_engines[i].alias, firefox_engines[i].description]); + searchEngines.push([firefoxEngines[i].alias, firefoxEngines[i].description]); } - return search_engines; + return searchEngines; }, // TODO: add filtering @@ -243,29 +243,29 @@ vimperator.Bookmarks = function () //{{{ return keywords; }, - // if @param engine_name is null, it uses the default search engine + // if @param engineName is null, it uses the default search engine // @returns the url for the search string - // if the search also requires a postdata, [url, postdata] is returned - getSearchURL: function (text, engine_name) + // if the search also requires a postData, [url, postData] is returned + getSearchURL: function (text, engineName) { var url = null; - var postdata = null; - if (!engine_name) - engine_name = vimperator.options["defsearch"]; + var postData = null; + if (!engineName) + engineName = vimperator.options["defsearch"]; // we need to make sure our custom alias have been set, even if the user // did not :open once before this.getSearchEngines(); // first checks the search engines for a match - var engine = search_service.getEngineByAlias(engine_name); + var engine = searchService.getEngineByAlias(engineName); if (engine) { if (text) { var submission = engine.getSubmission(text, null); url = submission.uri.spec; - postdata = submission.postData; + postData = submission.postData; } else url = engine.searchForm; @@ -277,7 +277,7 @@ vimperator.Bookmarks = function () //{{{ for (var i in keywords) { - if (keywords[i][0] == engine_name) + if (keywords[i][0] == engineName) { if (text == null) text = ""; @@ -287,9 +287,9 @@ vimperator.Bookmarks = function () //{{{ } } - // if we came here, the engine_name is neither a search engine or URL - if (postdata) - return [url, postdata]; + // if we came here, the engineName is neither a search engine or URL + if (postData) + return [url, postData]; else return url; // can be null }, @@ -359,7 +359,7 @@ vimperator.History = function () //{{{ ////////////////////// PRIVATE SECTION ///////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - const history_service = Components.classes["@mozilla.org/browser/nav-history-service;1"] + const historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"] .getService(Components.interfaces.nsINavHistoryService); var history = null; @@ -373,11 +373,11 @@ vimperator.History = function () //{{{ // no query parameters will get all history // XXX default sorting is... ? - var options = history_service.getNewQueryOptions(); - var query = history_service.getNewQuery(); + var options = historyService.getNewQueryOptions(); + var query = historyService.getNewQuery(); // execute the query - var result = history_service.executeQuery(query, options); + var result = historyService.executeQuery(query, options); var rootNode = result.root; rootNode.containerOpen = true; // iterate over the immediate children of this folder @@ -513,24 +513,24 @@ vimperator.Marks = function () //{{{ ////////////////////// PRIVATE SECTION ///////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - var local_marks = {}; - var url_marks = {}; - var pending_jumps = []; - var appcontent = document.getElementById("appcontent"); + var localMarks = {}; + var urlMarks = {}; + var pendingJumps = []; + var appContent = document.getElementById("appcontent"); - if (appcontent) - appcontent.addEventListener("load", onPageLoad, true); + if (appContent) + appContent.addEventListener("load", onPageLoad, true); function onPageLoad(event) { var win = event.originalTarget.defaultView; - for (var i = 0, length = pending_jumps.length; i < length; i++) + for (var i = 0, length = pendingJumps.length; i < length; i++) { - var mark = pending_jumps[i]; + var mark = pendingJumps[i]; if (win.location.href == mark.location) { win.scrollTo(mark.position.x * win.scrollMaxX, mark.position.y * win.scrollMaxY); - pending_jumps.splice(i, 1); + pendingJumps.splice(i, 1); return; } } @@ -538,17 +538,17 @@ vimperator.Marks = function () //{{{ function removeLocalMark(mark) { - if (mark in local_marks) + if (mark in localMarks) { var win = window.content; - for (var i = 0; i < local_marks[mark].length; i++) + for (var i = 0; i < localMarks[mark].length; i++) { - if (local_marks[mark][i].location == win.location.href) + if (localMarks[mark][i].location == win.location.href) { - vimperator.log("Deleting local mark: " + mark + " | " + local_marks[mark][i].location + " | (" + local_marks[mark][i].position.x + ", " + local_marks[mark][i].position.y + ") | tab: " + vimperator.tabs.index(local_marks[mark][i].tab), 5); - local_marks[mark].splice(i, 1); - if (local_marks[mark].length == 0) - delete local_marks[mark]; + vimperator.log("Deleting local mark: " + mark + " | " + localMarks[mark][i].location + " | (" + localMarks[mark][i].position.x + ", " + localMarks[mark][i].position.y + ") | tab: " + vimperator.tabs.index(localMarks[mark][i].tab), 5); + localMarks[mark].splice(i, 1); + if (localMarks[mark].length == 0) + delete localMarks[mark]; break; } } @@ -557,10 +557,10 @@ vimperator.Marks = function () //{{{ function removeURLMark(mark) { - if (mark in url_marks) + if (mark in urlMarks) { - vimperator.log("Deleting URL mark: " + mark + " | " + url_marks[mark].location + " | (" + url_marks[mark].position.x + ", " + url_marks[mark].position.y + ") | tab: " + vimperator.tabs.index(url_marks[mark].tab), 5); - delete url_marks[mark]; + vimperator.log("Deleting URL mark: " + mark + " | " + urlMarks[mark].location + " | (" + urlMarks[mark].position.x + ", " + urlMarks[mark].position.y + ") | tab: " + vimperator.tabs.index(urlMarks[mark].tab), 5); + delete urlMarks[mark]; } } @@ -579,12 +579,12 @@ vimperator.Marks = function () //{{{ // local marks var lmarks = []; - for (var mark in local_marks) + for (var mark in localMarks) { - for (var i = 0; i < local_marks[mark].length; i++) + for (var i = 0; i < localMarks[mark].length; i++) { - if (local_marks[mark][i].location == window.content.location.href) - lmarks.push([mark, local_marks[mark][i]]); + if (localMarks[mark][i].location == window.content.location.href) + lmarks.push([mark, localMarks[mark][i]]); } } lmarks.sort(); @@ -592,8 +592,8 @@ vimperator.Marks = function () //{{{ // URL marks var umarks = []; - for (var mark in url_marks) - umarks.push([mark, url_marks[mark]]); + for (var mark in urlMarks) + umarks.push([mark, urlMarks[mark]]); // FIXME: why does umarks.sort() cause a "Component is not available = // NS_ERROR_NOT_AVAILABLE" exception when used here? umarks.sort(function (a, b) { @@ -632,16 +632,16 @@ vimperator.Marks = function () //{{{ if (isURLMark(mark)) { vimperator.log("Adding URL mark: " + mark + " | " + win.location.href + " | (" + position.x + ", " + position.y + ") | tab: " + vimperator.tabs.index(vimperator.tabs.getTab()), 5); - url_marks[mark] = { location: win.location.href, position: position, tab: vimperator.tabs.getTab() }; + urlMarks[mark] = { location: win.location.href, position: position, tab: vimperator.tabs.getTab() }; } else if (isLocalMark(mark)) { // remove any previous mark of the same name for this location removeLocalMark(mark); - if (!local_marks[mark]) - local_marks[mark] = []; + if (!localMarks[mark]) + localMarks[mark] = []; vimperator.log("Adding local mark: " + mark + " | " + win.location.href + " | (" + position.x + ", " + position.y + ")", 5); - local_marks[mark].push({ location: win.location.href, position: position }); + localMarks[mark].push({ location: win.location.href, position: position }); } }, @@ -650,18 +650,18 @@ vimperator.Marks = function () //{{{ if (special) { // :delmarks! only deletes a-z marks - for (var mark in local_marks) + for (var mark in localMarks) removeLocalMark(mark); } else { var pattern = new RegExp("[" + filter.replace(/\s+/g, "") + "]"); - for (var mark in url_marks) + for (var mark in urlMarks) { if (pattern.test(mark)) removeURLMark(mark); } - for (var mark in local_marks) + for (var mark in localMarks) { if (pattern.test(mark)) removeLocalMark(mark); @@ -675,12 +675,12 @@ vimperator.Marks = function () //{{{ if (isURLMark(mark)) { - var slice = url_marks[mark]; + var slice = urlMarks[mark]; if (slice && slice.tab && slice.tab.linkedBrowser) { if (!slice.tab.parentNode) { - pending_jumps.push(slice); + pendingJumps.push(slice); // NOTE: this obviously won't work on generated pages using // non-unique URLs, like Vimperator's help :( vimperator.open(slice.location, vimperator.NEW_TAB); @@ -693,7 +693,7 @@ vimperator.Marks = function () //{{{ var win = slice.tab.linkedBrowser.contentWindow; if (win.location.href != slice.location) { - pending_jumps.push(slice); + pendingJumps.push(slice); win.location.href = slice.location; return; } @@ -706,7 +706,7 @@ vimperator.Marks = function () //{{{ else if (isLocalMark(mark)) { var win = window.content; - var slice = local_marks[mark] || []; + var slice = localMarks[mark] || []; for (var i = 0; i < slice.length; i++) { @@ -773,12 +773,12 @@ vimperator.QuickMarks = function () //{{{ /////////////////////////////////////////////////////////////////////////////{{{ var qmarks = {}; - var saved_marks = vimperator.options.getPref("quickmarks", "").split("\n"); + var savedMarks = vimperator.options.getPref("quickmarks", "").split("\n"); // load the saved quickmarks -- TODO: change to sqlite - for (var i = 0; i < saved_marks.length - 1; i += 2) + for (var i = 0; i < savedMarks.length - 1; i += 2) { - qmarks[saved_marks[i]] = saved_marks[i + 1]; + qmarks[savedMarks[i]] = savedMarks[i + 1]; } /////////////////////////////////////////////////////////////////////////////}}} @@ -861,15 +861,15 @@ vimperator.QuickMarks = function () //{{{ destroy: function () { // save the quickmarks - var saved_qmarks = ""; + var savedQuickMarks = ""; for (var i in qmarks) { - saved_qmarks += i + "\n"; - saved_qmarks += qmarks[i] + "\n"; + savedQuickMarks += i + "\n"; + savedQuickMarks += qmarks[i] + "\n"; } - vimperator.options.setPref("quickmarks", saved_qmarks); + vimperator.options.setPref("quickmarks", savedQuickMarks); } }; //}}} diff --git a/content/buffers.js b/content/buffers.js index 0b7eba0e..329115dc 100644 --- a/content/buffers.js +++ b/content/buffers.js @@ -35,10 +35,10 @@ vimperator.Buffer = function () //{{{ // used for the "B" mapping to remember the last :buffer[!] command var lastBufferSwitchArgs = ""; var lastBufferSwitchSpecial = true; - var zoom_levels = [ 1, 10, 25, 50, 75, 90, 100, + var zoomLevels = [ 1, 10, 25, 50, 75, 90, 100, 120, 150, 200, 300, 500, 1000, 2000 ]; - function setZoom(value, full_zoom) + function setZoom(value, fullZoom) { if (value < 1 || value > 2000) { @@ -46,12 +46,12 @@ vimperator.Buffer = function () //{{{ return false; } - if (full_zoom) + if (fullZoom) getBrowser().mCurrentBrowser.markupDocumentViewer.fullZoom = value / 100.0; else getBrowser().mCurrentBrowser.markupDocumentViewer.textZoom = value / 100.0; - vimperator.echo((full_zoom ? "Full zoom: " : "Text zoom: ") + value + "%"); + vimperator.echo((fullZoom ? "Full zoom: " : "Text zoom: ") + value + "%"); // TODO: shouldn't this just recalculate hint coords, rather than // unsuccessfully attempt to reshow hints? i.e. isn't it just relying @@ -60,9 +60,9 @@ vimperator.Buffer = function () //{{{ // vimperator.hints.reshowHints(); } - function bumpZoomLevel(steps, full_zoom) + function bumpZoomLevel(steps, fullZoom) { - if (full_zoom) + if (fullZoom) var value = getBrowser().mCurrentBrowser.markupDocumentViewer.fullZoom * 100.0; else var value = getBrowser().mCurrentBrowser.markupDocumentViewer.textZoom * 100.0; @@ -70,9 +70,9 @@ vimperator.Buffer = function () //{{{ var index = -1; if (steps <= 0) { - for (var i = zoom_levels.length - 1; i >= 0; i--) + for (var i = zoomLevels.length - 1; i >= 0; i--) { - if ((zoom_levels[i] + 0.01) < value) // 0.01 for float comparison + if ((zoomLevels[i] + 0.01) < value) // 0.01 for float comparison { index = i + 1 + steps; break; @@ -81,21 +81,21 @@ vimperator.Buffer = function () //{{{ } else { - for (var i = 0; i < zoom_levels.length; i++) + for (var i = 0; i < zoomLevels.length; i++) { - if ((zoom_levels[i] - 0.01) > value) // 0.01 for float comparison + if ((zoomLevels[i] - 0.01) > value) // 0.01 for float comparison { index = i - 1 + steps; break; } } } - if (index < 0 || index >= zoom_levels.length) + if (index < 0 || index >= zoomLevels.length) { vimperator.beep(); return; } - setZoom(zoom_levels[index], full_zoom); + setZoom(zoomLevels[index], fullZoom); } function checkScrollYBounds(win, direction) @@ -203,26 +203,26 @@ vimperator.Buffer = function () //{{{ offsetX = offsetX || 1; offsetY = offsetY || 1; - var new_tab = false, new_window = false; + var newTab = false, newWindow = false; switch (where) { case vimperator.NEW_TAB: case vimperator.NEW_BACKGROUND_TAB: - new_tab = true; + newTab = true; break; case vimperator.NEW_WINDOW: - new_window = true; + newWindow = true; break; default: vimperator.log("Invalid where argument for followLink()"); } var evt = doc.createEvent("MouseEvents"); - evt.initMouseEvent("mousedown", true, true, view, 1, offsetX, offsetY, 0, 0, /*ctrl*/ new_tab, /*event.altKey*/0, /*event.shiftKey*/ new_window, /*event.metaKey*/ new_tab, 0, null); + evt.initMouseEvent("mousedown", true, true, view, 1, offsetX, offsetY, 0, 0, /*ctrl*/ newTab, /*event.altKey*/0, /*event.shiftKey*/ newWindow, /*event.metaKey*/ newTab, 0, null); elem.dispatchEvent(evt); //var evt = doc.createEvent("MouseEvents"); - evt.initMouseEvent("click", true, true, view, 1, offsetX, offsetY, 0, 0, /*ctrl*/ new_tab, /*event.altKey*/0, /*event.shiftKey*/ new_window, /*event.metaKey*/ new_tab, 0, null); + evt.initMouseEvent("click", true, true, view, 1, offsetX, offsetY, 0, 0, /*ctrl*/ newTab, /*event.altKey*/0, /*event.shiftKey*/ newWindow, /*event.metaKey*/ newTab, 0, null); elem.dispatchEvent(evt); }, @@ -235,14 +235,14 @@ vimperator.Buffer = function () //{{{ if (!selection) { - var selection_controller = getBrowser().docShell + var selectionController = getBrowser().docShell .QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsISelectionDisplay) .QueryInterface(Components.interfaces.nsISelectionController); - selection_controller.setCaretEnabled(true); - selection_controller.wordMove(false, false); - selection_controller.wordMove(true, true); + selectionController.setCaretEnabled(true); + selectionController.wordMove(false, false); + selectionController.wordMove(true, true); selection = window.content.getSelection().toString(); } @@ -260,7 +260,7 @@ vimperator.Buffer = function () //{{{ } else { - var items = vimperator.completion.get_buffer_completions(""); + var items = vimperator.completion.getBufferCompletions(""); vimperator.bufferwindow.show(items); vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex); } @@ -268,7 +268,7 @@ vimperator.Buffer = function () //{{{ else { // TODO: move this to vimperator.buffers.get() - var items = vimperator.completion.get_buffer_completions(""); + var items = vimperator.completion.getBufferCompletions(""); var number, indicator, title, url; var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "
" + ""; @@ -451,7 +451,7 @@ vimperator.Buffer = function () //{{{ if (!vimperator.bufferwindow.visible()) return false; - var items = vimperator.completion.get_buffer_completions(""); + var items = vimperator.completion.getBufferCompletions(""); vimperator.bufferwindow.show(items); vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex); }, @@ -484,7 +484,7 @@ vimperator.Buffer = function () //{{{ return vimperator.tabs.select(parseInt(match[1], 10) - 1, false); // make it zero-based var matches = []; - var lower_buffer = buffer.toLowerCase(); + var lowerBuffer = buffer.toLowerCase(); var first = vimperator.tabs.index() + (reverse ? 0 : 1); for (var i = 0; i < getBrowser().browsers.length; i++) { @@ -494,7 +494,7 @@ vimperator.Buffer = function () //{{{ if (url == buffer) return vimperator.tabs.select(index, false); - if (url.indexOf(buffer) >= 0 || title.indexOf(lower_buffer) >= 0) + if (url.indexOf(buffer) >= 0 || title.indexOf(lowerBuffer) >= 0) matches.push(index); } if (matches.length == 0) @@ -516,14 +516,14 @@ vimperator.Buffer = function () //{{{ } }, - zoomIn: function (steps, full_zoom) + zoomIn: function (steps, fullZoom) { - bumpZoomLevel(steps, full_zoom); + bumpZoomLevel(steps, fullZoom); }, - zoomOut: function (steps, full_zoom) + zoomOut: function (steps, fullZoom) { - bumpZoomLevel(-steps, full_zoom); + bumpZoomLevel(-steps, fullZoom); }, pageInfo: function (verbose) diff --git a/content/commands.js b/content/commands.js index 3937aec3..9bdbfa7f 100644 --- a/content/commands.js +++ b/content/commands.js @@ -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. }}} ***** END LICENSE BLOCK *****/ -vimperator.Command = function (specs, action, extra_info) //{{{ +vimperator.Command = function (specs, action, extraInfo) //{{{ { if (!specs || !action) return null; @@ -36,56 +36,56 @@ vimperator.Command = function (specs, action, extra_info) //{{{ // 'abc', 'abcdef' var parseSpecs = function (specs) { - var short_names = []; - var long_names = []; + var shortNames = []; + var longNames = []; var names = []; for (var i = 0; i < specs.length; i++) { var match; if (match = specs[i].match(/(\w+|!)\[(\w+)\]/)) { - short_names.push(match[1]); - long_names.push(match[1] + match[2]); + shortNames.push(match[1]); + longNames.push(match[1] + match[2]); // order as long1, short1, long2, short2 names.push(match[1] + match[2]); names.push(match[1]); } else { - long_names.push(specs[i]); + longNames.push(specs[i]); names.push(specs[i]); } } - return { names: names, long_names: long_names, short_names: short_names }; + return { names: names, longNames: longNames, shortNames: shortNames }; }; this.specs = specs; - var expanded_specs = parseSpecs(specs); - this.short_names = expanded_specs.short_names; - this.long_names = expanded_specs.long_names; + var expandedSpecs = parseSpecs(specs); + this.shortNames = expandedSpecs.shortNames; + this.longNames = expandedSpecs.longNames; // return the primary command name (the long name of the first spec listed) - this.name = this.long_names[0]; + this.name = this.longNames[0]; // return all command name aliases - this.names = expanded_specs.names; + this.names = expandedSpecs.names; this.action = action; // TODO: build a better default usage string this.usage = [this.specs[0]]; - if (extra_info) + if (extraInfo) { - //var flags = extra_info.flags || 0; + //var flags = extraInfo.flags || 0; - if (extra_info.usage) - this.usage = extra_info.usage; + if (extraInfo.usage) + this.usage = extraInfo.usage; - this.help = extra_info.help || null; - this.short_help = extra_info.short_help || null; - this.completer = extra_info.completer || null; - this.args = extra_info.args || []; + this.help = extraInfo.help || null; + this.shortHelp = extraInfo.shortHelp || null; + this.completer = extraInfo.completer || null; + this.args = extraInfo.args || []; } }; @@ -142,8 +142,8 @@ vimperator.Commands = function () //{{{ const OPTION_FLOAT = 5; const OPTION_LIST = 6; - var ex_commands = []; - var last_run_command = ""; // updated whenever the users runs a command with :! + var exCommands = []; + var lastRunCommand = ""; // updated whenever the users runs a command with :! // in '-quoted strings, only ' and \ itself are escaped // in "-quoted strings, also ", \n and \t are translated @@ -164,9 +164,9 @@ vimperator.Commands = function () //{{{ // returns [count, parsed_argument] function getNextArg(str) { - var in_single_string = false; - var in_double_string = false; - var in_escape_key = false; + var inSingleString = false; + var inDoubleString = false; + var inEscapeKey = false; var arg = ""; @@ -176,27 +176,27 @@ vimperator.Commands = function () //{{{ switch (str[i]) { case "\"": - if (in_escape_key) + if (inEscapeKey) { - in_escape_key = false; + inEscapeKey = false; break; } - if (!in_single_string) + if (!inSingleString) { - in_double_string = !in_double_string; + inDoubleString = !inDoubleString; continue outer; } break; case "'": - if (in_escape_key) + if (inEscapeKey) { - in_escape_key = false; + inEscapeKey = false; break; } - if (!in_double_string) + if (!inDoubleString) { - in_single_string = !in_single_string; + inSingleString = !inSingleString; continue outer; } break; @@ -204,36 +204,36 @@ vimperator.Commands = function () //{{{ // \ is an escape key for non quoted or "-quoted strings // for '-quoted strings it is taken literally, apart from \' and \\ case "\\": - if (in_escape_key) + if (inEscapeKey) { - in_escape_key = false; + inEscapeKey = false; break; } else { // only escape "\\" and "\ " in non quoted strings - if (!in_single_string && !in_double_string && str[i + 1] != "\\" && str[i + 1] != " ") + if (!inSingleString && !inDoubleString && str[i + 1] != "\\" && str[i + 1] != " ") continue outer; // only escape "\\" and "\'" in single quoted strings - else if (in_single_string && str[i + 1] != "\\" && str[i + 1] != "'") + else if (inSingleString && str[i + 1] != "\\" && str[i + 1] != "'") break; else { - in_escape_key = true; + inEscapeKey = true; continue outer; } } break; default: - if (in_single_string) + if (inSingleString) { - in_escape_key = false; + inEscapeKey = false; break; } - else if (in_escape_key) + else if (inEscapeKey) { - in_escape_key = false; + inEscapeKey = false; switch (str[i]) { case "n": arg += "\n"; continue outer; @@ -242,7 +242,7 @@ vimperator.Commands = function () //{{{ break; // this makes "a\fb" -> afb; wanted or should we return ab? --mst } } - else if (!in_double_string && /\s/.test(str[i])) + else if (!inDoubleString && /\s/.test(str[i])) { return [i, arg]; } @@ -253,9 +253,9 @@ vimperator.Commands = function () //{{{ } // TODO: add parsing of a " comment here: - if (in_double_string || in_single_string) + if (inDoubleString || inSingleString) return [-1, "E114: Missing quote"]; - if (in_escape_key) + if (inEscapeKey) return [-1, "trailing \\"]; else return [str.length, arg]; @@ -433,8 +433,8 @@ vimperator.Commands = function () //{{{ function commandsIterator() { - for (var i = 0; i < ex_commands.length; i++) - yield ex_commands[i]; + for (var i = 0; i < exCommands.length; i++) + yield exCommands[i]; throw StopIteration; } @@ -456,15 +456,15 @@ vimperator.Commands = function () //{{{ { command.execute(args, special, count, modifiers); }; - ex_commands.push(command); + exCommands.push(command); }, get: function (name) { - for (var i = 0; i < ex_commands.length; i++) + for (var i = 0; i < exCommands.length; i++) { - if (ex_commands[i].hasName(name)) - return ex_commands[i]; + if (exCommands[i].hasName(name)) + return exCommands[i]; } return null; @@ -522,7 +522,7 @@ vimperator.Commands = function () //{{{ commandManager.add(new vimperator.Command(["addo[ns]"], function () { vimperator.open("chrome://mozapps/content/extensions/extensions.xul", vimperator.NEW_TAB); }, { - short_help: "Show available Browser Extensions and Themes", + shortHelp: "Show available Browser Extensions and Themes", help: "You can add/remove/disable browser extensions from this dialog.
Be aware that not all Firefox extensions work, because Vimperator overrides some key bindings and changes Firefox's GUI." } )); @@ -550,7 +550,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["[count]ba[ck][!] [url]"], - short_help: "Go back in the browser history", + shortHelp: "Go back in the browser history", help: "Count is supported, :3back goes back 3 pages in the browser history.
" + "The special version :back! goes to the beginning of the browser history.", completer: function (filter) @@ -573,7 +573,7 @@ vimperator.Commands = function () //{{{ function (args, special, count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count > 0 ? count : 1, special, 0); }, { usage: ["[count]bd[elete][!]"], - short_help: "Delete current buffer (=tab)", + shortHelp: "Delete current buffer (=tab)", help: "Count is supported, :2bd removes two tabs and the one to the right is selected. " + "Do :bdelete! to select the tab to the left after removing the current tab." } @@ -581,7 +581,7 @@ vimperator.Commands = function () //{{{ commandManager.add(new vimperator.Command(["beep"], function () { vimperator.beep(); }, { - short_help: "Play a system beep" + shortHelp: "Play a system beep" } )); commandManager.add(new vimperator.Command(["bma[rk]"], @@ -610,7 +610,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["bma[rk] [-title=title] [-keyword=kw] [-tags=tag1,tag2] [url]"], - short_help: "Add a bookmark", + shortHelp: "Add a bookmark", help: "If you don't add a custom title, either the title of the web page or the URL is taken as the title.
" + "You can omit the optional [url] argument, so just do :bmark to bookmark the currently loaded web page with a default title and without any tags.
" + "The following options are interpreted:
" + @@ -634,7 +634,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["bmarks [filter]", "bmarks!"], - short_help: "Show bookmarks", + shortHelp: "Show bookmarks", help: "Open the message window at the bottom of the screen with all bookmarks which match [filter] either in the title or URL.
" + "The special version :bmarks! opens the default Firefox bookmarks window.
" + "Filter can also contain the following options:
" + @@ -647,13 +647,13 @@ vimperator.Commands = function () //{{{ function (args, special) { vimperator.buffer.switchTo(args, special); }, { usage: ["b[uffer][!] {url|index}"], - short_help: "Go to buffer from buffer list", + shortHelp: "Go to buffer from buffer list", help: "Argument can be either the buffer index or the full URL.
" + "If argument is neither a full URL nor an index but uniquely identifies a buffer, " + "it is selected. With [!] the next buffer matching the argument " + "is selected, even if it cannot be identified uniquely.
" + "Use b as a shortcut to open this prompt.", - completer: function (filter) { return vimperator.completion.get_buffer_completions(filter); } + completer: function (filter) { return vimperator.completion.getBufferCompletions(filter); } } )); commandManager.add(new vimperator.Command(["dia[log]"], @@ -690,7 +690,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["dia[log] [firefox-dialog]"], - short_help: "Open a firefox-dialog", + shortHelp: "Open a firefox-dialog", help: "Available dialogs: use completion on :dialog <tab>", completer: function (filter) { return vimperator.completion.dialog(filter); } } @@ -708,7 +708,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["buffers[!]"], - short_help: "Show a list of all buffers (=tabs)", + shortHelp: "Show a list of all buffers (=tabs)", help: "The special version :buffers! opens the buffer list in a persistent preview window. " + "Call the special version of this command again to close the window." } @@ -720,12 +720,12 @@ vimperator.Commands = function () //{{{ if (!url) url = vimperator.buffer.URL; - var deleted_count = vimperator.bookmarks.remove(url); - vimperator.echo(deleted_count + " bookmark(s) with url `" + url + "' deleted", vimperator.commandline.FORCE_SINGLELINE); + var deletedCount = vimperator.bookmarks.remove(url); + vimperator.echo(deletedCount + " bookmark(s) with url `" + url + "' deleted", vimperator.commandline.FORCE_SINGLELINE); }, { usage: ["delbm[arks] [url]"], - short_help: "Delete a bookmark", + shortHelp: "Delete a bookmark", help: "Deletes all bookmarks which match the [url]. " + "If omitted, [url] defaults to the URL of the current buffer. " + "Use <Tab> key on a string to complete the URL which you want to delete.
" + @@ -745,7 +745,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["com[mand][!] [{attr}...] {cmd} {rep}"], - short_help: "Temporarily used for testing args parser", + shortHelp: "Temporarily used for testing args parser", help: "", args: [[["-nargs"], OPTION_STRING, function (arg) { return /^(0|1|\*|\?|\+)$/.test(arg); }], [["-bang"], OPTION_NOARG], @@ -797,7 +797,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["delm[arks] {marks}", "delm[arks]!"], - short_help: "Delete the specified marks", + shortHelp: "Delete the specified marks", help: "Marks are presented as a list. Example:
" + ":delmarks Aa b p deletes marks A, a, b and p
" + ":delmarks b-p deletes all marks in the range b to p
" + @@ -827,7 +827,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["delqm[arks] {marks}", "delqm[arks]!"], - short_help: "Delete the specified QuickMarks", + shortHelp: "Delete the specified QuickMarks", help: "QuickMarks are presented as a list. Example:
" + ":delqmarks Aa b p deletes QuickMarks A, a, b and p
" + ":delqmarks b-p deletes all QuickMarks in the range b to p
" + @@ -837,7 +837,7 @@ vimperator.Commands = function () //{{{ commandManager.add(new vimperator.Command(["downl[oads]", "dl"], function () { vimperator.open("chrome://mozapps/content/downloads/downloads.xul", vimperator.NEW_TAB); }, { - short_help: "Show progress of current downloads", + shortHelp: "Show progress of current downloads", help: "Open the original Firefox download dialog in a new tab.
" + "Here, downloads can be paused, canceled and resumed." } @@ -880,7 +880,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["ec[ho] {expr}"], - short_help: "Display a string at the bottom of the window", + shortHelp: "Display a string at the bottom of the window", help: "Useful for showing informational messages. Multiple lines can be separated by \\n.
" + "{expr} 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 {expr} is an object or function.", @@ -896,7 +896,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["echoe[rr] {expr}"], - short_help: "Display an error string at the bottom of the window", + shortHelp: "Display an error string at the bottom of the window", help: "Just like :ec[ho], but echoes the result highlighted in red. Useful for showing important messages.", completer: function (filter) { return vimperator.completion.javascript(filter); } } @@ -915,14 +915,14 @@ vimperator.Commands = function () //{{{ }, { usage: ["exe[cute] {expr1} [ ... ]"], - short_help: "Execute the string that results from the evaluation of {expr1} as an Ex command.", + shortHelp: "Execute the string that results from the evaluation of {expr1} as an Ex command.", help: "Example: :execute echo test shows a message with the text "test".
" } )); commandManager.add(new vimperator.Command(["exu[sage]"], function (args, special, count, modifiers) { vimperator.help("commands", special, null, modifiers); }, { - short_help: "Show help for Ex commands" + shortHelp: "Show help for Ex commands" } )); commandManager.add(new vimperator.Command(["fo[rward]", "fw"], @@ -949,7 +949,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["[count]fo[rward][!] [url]"], - short_help: "Go forward in the browser history", + shortHelp: "Go forward in the browser history", help: "Count is supported, :3forward goes forward 3 pages in the browser history.
" + "The special version :forward! goes to the end of the browser history.", completer: function (filter) @@ -971,7 +971,7 @@ vimperator.Commands = function () //{{{ commandManager.add(new vimperator.Command(["ha[rdcopy]"], function () { getBrowser().contentWindow.print(); }, { - short_help: "Print current document", + shortHelp: "Print current document", help: "Open a GUI dialog where you can select the printer, number of copies, orientation, etc." } )); @@ -979,7 +979,7 @@ vimperator.Commands = function () //{{{ function (args, special, count, modifiers) { vimperator.help(args, special, null, modifiers); }, { usage: ["h[elp] {subject}"], - short_help: "Open the help window", + shortHelp: "Open the help window", help: "You can jump to the specified {subject} with :help {subject}.
" + "Make sure you use the full Vim notation when jumping to {subject}. This means:
" + "" + "You can however use partial stings in the tab completion, so :help he<Tab> completes :help :help.", - completer: function (filter) { return vimperator.completion.get_help_completions(filter); } + completer: function (filter) { return vimperator.completion.getHelpCompletions(filter); } } )); commandManager.add(new vimperator.Command(["hist[ory]", "hs"], function (args, special) { vimperator.history.list(args, special); }, { usage: ["hist[ory] [filter]", "history!"], - short_help: "Show recently visited URLs", + shortHelp: "Show recently visited URLs", help: "Open the message window at the bottom of the screen with all history items which match [filter] either in the title or URL.
" + "The special version :history! opens the default Firefox history window.", completer: function (filter) { return vimperator.history.get(filter); } @@ -1040,7 +1040,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["javas[cript] {cmd}", "javascript <<{endpattern}\\n{script}\\n{endpattern}", "javascript[!]"], // \\n is changed to
in the help.js code - short_help: "Run any JavaScript command through eval()", + shortHelp: "Run any JavaScript command through eval()", help: "Acts as a JavaScript interpreter by passing the argument to eval().
" + ":javascript alert('Hello world') shows a dialog box with the text \"Hello world\".
" + ":javascript <<EOF reads all the lines until a line starting with 'EOF' is found, and interpret them with the JavaScript eval() function.
" + @@ -1141,7 +1141,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["let {var-name} [+-.]= {expr1}", "let {var-name}", "let"], - short_help: "Sets or lists a variable", + shortHelp: "Sets or lists a variable", help: "Sets the variable {var-name} " + "to the value of the expression {expr1}." + "If no expression is given, the value of the variable is displayed." + @@ -1167,7 +1167,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["ab[breviate] {lhs} {rhs}", "ab[breviate] {lhs}", "ab[breviate]"], - short_help: "Abbreviate a key sequence", + shortHelp: "Abbreviate a key sequence", help: "Abbreviate {lhs} to {rhs}.
" + "If only {lhs} given, list that particual abbreviation.
" + "List all abbreviations, if no arguments to are given.
" @@ -1191,7 +1191,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["ca[bbrev] {lhs} {rhs}", "ca[bbrev] {lhs}", "ca[bbrev]"], - short_help: "Abbreviate a key sequence for Command-line mode", + shortHelp: "Abbreviate a key sequence for Command-line mode", help: "Same as :ab[reviate], but for Command-line mode only." } )); @@ -1213,7 +1213,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["ia[bbrev] {lhs} {rhs}", "ia[bbrev] {lhs}", "ia[bbrev]"], - short_help: "Abbreviate a key sequence for Insert mode", + shortHelp: "Abbreviate a key sequence for Insert mode", help: "Same as :ab[breviate], but for Insert mode only." } )); @@ -1221,14 +1221,14 @@ vimperator.Commands = function () //{{{ function (args) { vimperator.editor.removeAbbreviation("!", args); }, { usage: ["una[bbreviate] {lhs}"], - short_help: "Remove an abbreviation" + shortHelp: "Remove an abbreviation" } )); commandManager.add(new vimperator.Command(["cuna[bbrev]"], function (args) { vimperator.editor.removeAbbreviation("c", args); }, { usage: ["cuna[bbrev] {lhs}"], - short_help: "Remove an abbreviation for Command-line mode", + shortHelp: "Remove an abbreviation for Command-line mode", help: "Same as :una[bbreviate], but for Command-line mode only." } )); @@ -1236,21 +1236,21 @@ vimperator.Commands = function () //{{{ function (args) { vimperator.editor.removeAbbreviation("i", args); }, { usage: ["iuna[bbrev] {lhs}"], - short_help: "Remove an abbreviation for Insert mode", + shortHelp: "Remove an abbreviation for Insert mode", help: "Same as :una[bbreviate], but for Insert mode only." } )); commandManager.add(new vimperator.Command(["abc[lear]"], function (args) { vimperator.editor.removeAllAbbreviations("!"); }, - { short_help: "Remove all abbreviations" } + { shortHelp: "Remove all abbreviations" } )); commandManager.add(new vimperator.Command(["cabc[lear]"], function (args) { vimperator.editor.removeAllAbbreviations("c"); }, - { short_help: "Remove all abbreviations for Command-line mode" } + { shortHelp: "Remove all abbreviations for Command-line mode" } )); commandManager.add(new vimperator.Command(["iabc[lear]"], function (args) { vimperator.editor.removeAllAbbreviations("i"); }, - { short_help: "Remove all abbreviations for Insert mode" } + { shortHelp: "Remove all abbreviations for Insert mode" } )); // 0 args -> list all maps // 1 arg -> list the maps starting with args @@ -1265,14 +1265,14 @@ vimperator.Commands = function () //{{{ var matches = args.match(/^([^\s]+)(?:\s+(.+))?$/); var [lhs, rhs] = [matches[1], matches[2]]; - var leader_reg = //i; + var leaderRegexp = //i; - if (leader_reg.test(lhs)) + if (leaderRegexp.test(lhs)) { - var leader_ref = vimperator.variableReference("mapleader"); - var leader = leader_ref[0] ? leader_ref[0][leader_ref[1]] : "\\"; + var leaderRef = vimperator.variableReference("mapleader"); + var leader = leaderRef[0] ? leaderRef[0][leaderRef[1]] : "\\"; - lhs = lhs.replace(leader_reg, leader); + lhs = lhs.replace(leaderRegexp, leader); } if (rhs) @@ -1292,7 +1292,7 @@ vimperator.Commands = function () //{{{ function (args) { map(args, false); }, { usage: ["map {lhs} {rhs}", "map {lhs}", "map"], - short_help: "Map the key sequence {lhs} to {rhs}", + shortHelp: "Map the key sequence {lhs} to {rhs}", help: "The {rhs} is remapped, allowing for nested and recursive mappings.
" + "Mappings are NOT saved during sessions, make sure you put them in your vimperatorrc file!" } @@ -1309,7 +1309,7 @@ vimperator.Commands = function () //{{{ vimperator.mappings.removeAll(vimperator.modes.NORMAL); }, { - short_help: "Remove all mappings", + shortHelp: "Remove all mappings", help: "All user-defined mappings which were set by " + ":map or :noremap are cleared." } @@ -1337,7 +1337,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["ma[rk] {a-zA-Z}"], - short_help: "Mark current location within the web page" + shortHelp: "Mark current location within the web page" } )); commandManager.add(new vimperator.Command(["marks"], @@ -1355,7 +1355,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["marks [arg]"], - short_help: "Show all location marks of current web page", + shortHelp: "Show all location marks of current web page", help: "If [arg] is specified then limit the list to those marks mentioned." } )); @@ -1391,7 +1391,7 @@ vimperator.Commands = function () //{{{ { // TODO: options should be queried for this info // TODO: string/list options might need escaping in future - if (!/fullscreen|usermode/.test(option.name) && option.value != option.default_value) + if (!/fullscreen|usermode/.test(option.name) && option.value != option.defaultValue) { if (option.type == "boolean") line += "set " + (option.value ? option.name : "no" + option.name) + "\n"; @@ -1412,7 +1412,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["mkv[imperatorrc] [file]"], - short_help: "Write current key mappings and changed options to [file]", + shortHelp: "Write current key mappings and changed options to [file]", help: "If no [file] is specified then ~/.vimperatorrc is written unless this file already exists. " + "The special version will overwrite [file] if it exists.
" + "WARNING: this differs from Vim's behavior which defaults to writing the file in the current directory." @@ -1424,7 +1424,7 @@ vimperator.Commands = function () //{{{ vimperator.search.clear(); }, { - short_help: "Remove the search highlighting", + shortHelp: "Remove the search highlighting", help: "The document highlighting is turned back on when another search command is used or the " + "'hlsearch' option is set." } @@ -1442,7 +1442,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["norm[al][!] {commands}"], - short_help: "Execute Normal mode commands", + shortHelp: "Execute Normal mode commands", help: "Example: :normal 20j scrolls 20 lines down. " + "If the [!] is specified mappings will not be used." } @@ -1452,7 +1452,7 @@ vimperator.Commands = function () //{{{ function (args) { map(args, true); }, { usage: ["no[remap] {lhs} {rhs}", "no[remap] {lhs}", "no[remap]"], - short_help: "Map the key sequence {lhs} to {rhs}", + shortHelp: "Map the key sequence {lhs} to {rhs}", help: "No remapping of the {rhs} is performed." } )); @@ -1473,7 +1473,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["o[pen] [url] [, url]"], - short_help: "Open one or more URLs in the current tab", + shortHelp: "Open one or more URLs in the current tab", help: "Multiple URLs can be separated with \", \". Note that the space after the comma is required.
" + "Each token is analyzed and in this order:
" + "
    " + @@ -1496,20 +1496,20 @@ vimperator.Commands = function () //{{{ "The items which are completed on <Tab> are specified in the 'complete' option.
    " + "Without argument, reloads the current page.
    " + "Without argument but with !, reloads the current page skipping the cache.", - completer: function (filter) { return vimperator.completion.get_url_completions(filter); } + completer: function (filter) { return vimperator.completion.getUrlCompletions(filter); } } )); commandManager.add(new vimperator.Command(["pa[geinfo]"], function () { vimperator.buffer.pageInfo(true); }, { - short_help: "Show various page information", + shortHelp: "Show various page information", help: "See :help 'pageinfo' for available options", } )); commandManager.add(new vimperator.Command(["pc[lose]"], function () { vimperator.previewwindow.hide(); }, { - short_help: "Close preview window on bottom of screen" + shortHelp: "Close preview window on bottom of screen" } )); commandManager.add(new vimperator.Command(["pref[erences]", "prefs"], @@ -1538,7 +1538,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["pref[erences][!]"], - short_help: "Show Browser Preferences", + shortHelp: "Show Browser Preferences", help: "You can change the browser preferences from this dialog. " + "Be aware that not all Firefox preferences work, because Vimperator overrides some key bindings and changes Firefox's GUI.
    " + ":prefs! opens about:config in the current tab where you can change advanced Firefox preferences." @@ -1563,7 +1563,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["qma[rk] {a-zA-Z0-9} [url]"], - short_help: "Mark a URL with a letter for quick access", + shortHelp: "Mark a URL with a letter for quick access", help: "You can also mark whole groups like this:
    "+ ":qmark f http://forum1.com, http://forum2.com, imdb some artist" } @@ -1583,14 +1583,14 @@ vimperator.Commands = function () //{{{ }, { usage: ["qmarks [arg]"], - short_help: "Show all QuickMarks", + shortHelp: "Show all QuickMarks", help: "If [arg] is specified then limit the list to those QuickMarks mentioned." } )); commandManager.add(new vimperator.Command(["q[uit]"], function () { vimperator.tabs.remove(getBrowser().mCurrentTab, 1, false, 1); }, { - short_help: "Quit current tab", + shortHelp: "Quit current tab", help: "If this is the last tab in the window, close the window. If this was the " + "last window, close Vimperator. When quitting Vimperator, the session is not stored." } @@ -1598,7 +1598,7 @@ vimperator.Commands = function () //{{{ commandManager.add(new vimperator.Command(["quita[ll]", "qa[ll]"], function () { vimperator.quit(false); }, { - short_help: "Quit Vimperator", + shortHelp: "Quit Vimperator", help: "Quit Vimperator, no matter how many tabs/windows are open. The session is not stored." } )); @@ -1610,7 +1610,7 @@ vimperator.Commands = function () //{{{ wu.redraw(); }, { - short_help: "Redraw the screen", + shortHelp: "Redraw the screen", help: "Useful to update the screen halfway executing a script or function." } )); @@ -1618,7 +1618,7 @@ vimperator.Commands = function () //{{{ function (args, special) { vimperator.tabs.reload(getBrowser().mCurrentTab, special); }, { usage: ["re[load][!]"], - short_help: "Reload current page", + shortHelp: "Reload current page", help: "Forces reloading of the current page. If ! is given, skip the cache." } )); @@ -1626,21 +1626,21 @@ vimperator.Commands = function () //{{{ function (args, special) { vimperator.tabs.reloadAll(special); }, { usage: ["reloada[ll][!]"], - short_help: "Reload all pages", + shortHelp: "Reload all pages", help: "Forces reloading of all pages. If ! is given, skip the cache." } )); commandManager.add(new vimperator.Command(["res[tart]"], function () { vimperator.restart(); }, { - short_help: "Force the browser to restart", + shortHelp: "Force the browser to restart", help: "Useful when installing extensions." } )); commandManager.add(new vimperator.Command(["sav[eas]", "w[rite]"], function () { saveDocument(window.content.document); }, { - short_help: "Save current web page to disk", + shortHelp: "Save current web page to disk", help: "Opens the original Firefox \"Save page as...\" dialog.
    " + "There, you can save the current web page to disk with various options." } @@ -1655,11 +1655,11 @@ vimperator.Commands = function () //{{{ return; } - var only_non_default = false; // used for :set to print non-default options + var onlyNondefault = false; // used for :set to print non-default options if (!args) { args = "all"; - only_non_default = true; + onlyNondefault = true; } // 1 2 3 4 5 6 @@ -1670,9 +1670,9 @@ vimperator.Commands = function () //{{{ return; } - var unset_boolean = false; + var unsetBoolean = false; if (matches[1] == "no") - unset_boolean = true; + unsetBoolean = true; var name = matches[2]; var all = false; @@ -1686,19 +1686,19 @@ vimperator.Commands = function () //{{{ return; } - var value_given = !!matches[4]; + var valueGiven = !!matches[4]; var get = false; - if (all || matches[3] == "?" || (option.type != "boolean" && !value_given)) + if (all || matches[3] == "?" || (option.type != "boolean" && !valueGiven)) get = true; var reset = false; if (matches[3] == "&") reset = true; - var invert_boolean = false; + var invertBoolean = false; if (matches[1] == "inv" || matches[3] == "!") - invert_boolean = true; + invertBoolean = true; var operator = matches[5]; @@ -1724,7 +1724,7 @@ vimperator.Commands = function () //{{{ { if (all) { - vimperator.options.list(only_non_default); + vimperator.options.list(onlyNondefault); } else { @@ -1740,22 +1740,22 @@ vimperator.Commands = function () //{{{ // benefit else { - var current_value = option.value; - var new_value; + var currentValue = option.value; + var newValue; switch (option.type) { case "boolean": - if (value_given) + if (valueGiven) { vimperator.echoerr("E474: Invalid argument: " + args); return; } - if (invert_boolean) - new_value = !option.value; + if (invertBoolean) + newValue = !option.value; else - new_value = !unset_boolean; + newValue = !unsetBoolean; break; @@ -1769,64 +1769,64 @@ vimperator.Commands = function () //{{{ } if (operator == "+") - new_value = current_value + value; + newValue = currentValue + value; else if (operator == "-") - new_value = current_value - value; + newValue = currentValue - value; else if (operator == "^") - new_value = current_value * value; + newValue = currentValue * value; else - new_value = value; + newValue = value; break; case "charlist": if (operator == "+") - new_value = current_value.replace(new RegExp("[" + value + "]", "g"), "") + value; + newValue = currentValue.replace(new RegExp("[" + value + "]", "g"), "") + value; else if (operator == "-") - new_value = current_value.replace(value, ""); + newValue = currentValue.replace(value, ""); else if (operator == "^") // NOTE: Vim doesn't prepend if there's a match in the current value - new_value = value + current_value.replace(new RegExp("[" + value + "]", "g"), ""); + newValue = value + currentValue.replace(new RegExp("[" + value + "]", "g"), ""); else - new_value = value; + newValue = value; break; case "stringlist": if (operator == "+") { - if (!current_value.match(value)) - new_value = (current_value ? current_value + "," : "") + value; + if (!currentValue.match(value)) + newValue = (currentValue ? currentValue + "," : "") + value; else - new_value = current_value; + newValue = currentValue; } else if (operator == "-") { - new_value = current_value.replace(new RegExp("^" + value + ",?|," + value), ""); + newValue = currentValue.replace(new RegExp("^" + value + ",?|," + value), ""); } else if (operator == "^") { - if (!current_value.match(value)) - new_value = value + (current_value ? "," : "") + current_value; + if (!currentValue.match(value)) + newValue = value + (currentValue ? "," : "") + currentValue; else - new_value = current_value; + newValue = currentValue; } else { - new_value = value; + newValue = value; } break; case "string": if (operator == "+") - new_value = current_value + value; + newValue = currentValue + value; else if (operator == "-") - new_value = current_value.replace(value, ""); + newValue = currentValue.replace(value, ""); else if (operator == "^") - new_value = value + current_value; + newValue = value + currentValue; else - new_value = value; + newValue = value; break; @@ -1834,8 +1834,8 @@ vimperator.Commands = function () //{{{ vimperator.echoerr("E685: Internal error: option type `" + option.type + "' not supported"); } - if (option.isValidValue(new_value)) - option.value = new_value; + if (option.isValidValue(newValue)) + option.value = newValue; else // FIXME: need to be able to specify more specific errors vimperator.echoerr("E474: Invalid argument: " + args); @@ -1843,7 +1843,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["se[t][!]", "se[t] {option}?", "se[t] [no]{option}", "se[t] {option}[+-]={value}", "se[t] {option}! | inv{option}", "se[t] {option}&"], - short_help: "Set an option", + shortHelp: "Set an option", help: "Permanently change an option.
    " + ":set without an argument shows all Vimperator options which differ from their default values.
    " + ":set! without an argument shows all about:config preferences which differ from their default values.
    " + @@ -1856,7 +1856,7 @@ vimperator.Commands = function () //{{{ ":set option+={value}, :set option^={value} and :set option-={value} " + "adds/multiplies/subtracts {value} from a number option and appends/prepends/removes {value} from a string option.
    " + ":set all shows the current value of all options and :set all& resets all options to their default values.
    ", - completer: function (filter) { return vimperator.completion.get_options_completions(filter); } + completer: function (filter) { return vimperator.completion.getOptionCompletions(filter); } } )); // TODO: sclose instead? @@ -1873,7 +1873,7 @@ vimperator.Commands = function () //{{{ toggleSidebar(); }, { - short_help: "Close the sidebar window" + shortHelp: "Close the sidebar window" } )); // TODO: sopen instead? Separate :sidebar from :sbopen and make them behave @@ -1907,10 +1907,10 @@ vimperator.Commands = function () //{{{ }, { usage: ["sidebar {name}"], - short_help: "Open the sidebar window", + shortHelp: "Open the sidebar window", help: "{name} 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.", - completer: function (filter) { return vimperator.completion.get_sidebar_completions(filter); } + completer: function (filter) { return vimperator.completion.getSidebarCompletions(filter); } } )); commandManager.add(new vimperator.Command(["so[urce]"], @@ -1927,7 +1927,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["so[urce][!] {file}"], - short_help: "Read Ex commands from {file}", + shortHelp: "Read Ex commands from {file}", help: "You can either source files which mostly contain Ex commands like map < gt " + "and put JavaScript code within a:
    " + "js <<EOF
    hello = function () {
      alert(\"Hello world\");
    }
    EOF
    section.
    " + @@ -1937,13 +1937,13 @@ vimperator.Commands = function () //{{{ "The .vimperatorrc file in your home directory and any files in ~/.vimperator/plugin/ are always sourced at startup.
    " + "~ is supported as a shortcut for the $HOME directory.
    " + "If ! is specified, errors are not printed.", - completer: function (filter) { return vimperator.completion.get_file_completions(filter); } + completer: function (filter) { return vimperator.completion.getFileCompletions(filter); } } )); commandManager.add(new vimperator.Command(["st[op]"], BrowserStop, { - short_help: "Stop loading", + shortHelp: "Stop loading", help: "Stop loading current web page." } )); @@ -1951,24 +1951,24 @@ vimperator.Commands = function () //{{{ function (args) { vimperator.execute(args, { inTab: true }); }, { usage: ["tab {cmd}"], - short_help: "Execute {cmd} and tell it to output in a new tab", + shortHelp: "Execute {cmd} and tell it to output in a new tab", help: "Works only for commands that support it, currently:" + "
    • :tab help
    • " + "
    • :tab prefs[!]
    ", - completer: function (filter) { return vimperator.completion.get_command_completions(filter); } + completer: function (filter) { return vimperator.completion.getCommandCompletions(filter); } } )); commandManager.add(new vimperator.Command(["tabl[ast]"], function () { vimperator.tabs.select("$", false); }, { - short_help: "Switch to the last tab" + shortHelp: "Switch to the last tab" } )); commandManager.add(new vimperator.Command(["tabm[ove]"], function (args, special) { vimperator.tabs.move(getBrowser().mCurrentTab, args, special); }, { usage: ["tabm[ove] [N]", "tabm[ove][!] +N | -N"], - short_help: "Move the current tab after tab N", + shortHelp: "Move the current tab after tab N", help: "When N is 0 the current tab is made the first one. Without N the current tab is made the last one. " + "N can also be prefixed with '+' or '-' to indicate a relative movement. If ! is specified the movement wraps around the start or end of the tab list." } @@ -1996,14 +1996,14 @@ vimperator.Commands = function () //{{{ }, { usage: ["tabn[ext] [count]"], - short_help: "Switch to the next or [count]th tab", + shortHelp: "Switch to the next or [count]th tab", help: "Cycles to the first tab when the last is selected and {count} is not specified." } )); commandManager.add(new vimperator.Command(["tabo[nly]"], function () { vimperator.tabs.keepOnly(getBrowser().mCurrentTab); }, { - short_help: "Close all other tabs" + shortHelp: "Close all other tabs" } )); commandManager.add(new vimperator.Command(["tabopen", "t[open]", "tabnew", "tabe[dit]"], @@ -2020,10 +2020,10 @@ vimperator.Commands = function () //{{{ }, { usage: ["tabopen [url] [, url]"], - short_help: "Open one or more URLs in a new tab", + shortHelp: "Open one or more URLs in a new tab", help: "Like :open but open URLs in a new tab.
    " + "If used with !, the 'tabopen' value of the 'activate' option is negated.", - completer: function (filter) { return vimperator.completion.get_url_completions(filter); } + completer: function (filter) { return vimperator.completion.getUrlCompletions(filter); } } )); commandManager.add(new vimperator.Command(["tabp[revious]", "tp[revious]", "tabN[ext]", "tN[ext]"], @@ -2039,7 +2039,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["tabp[revious] [count]"], - short_help: "Switch to the previous tab or go [count] tabs back", + shortHelp: "Switch to the previous tab or go [count] tabs back", help: "Wraps around from the first tab to the last tab." } )); @@ -2047,7 +2047,7 @@ vimperator.Commands = function () //{{{ function () { vimperator.tabs.select(0, false); }, { usage: ["tabr[ewind]", "tabfir[st]"], - short_help: "Switch to the first tab" + shortHelp: "Switch to the first tab" } )); commandManager.add(new vimperator.Command(["time"], @@ -2058,7 +2058,7 @@ vimperator.Commands = function () //{{{ if (count > 1) { var i = count; - var before_time = Date.now(); + var beforeTime = Date.now(); if (args && args[0] == ":") { @@ -2074,43 +2074,43 @@ vimperator.Commands = function () //{{{ if (special) return; - var after_time = Date.now(); + var afterTime = Date.now(); - if ((after_time - before_time) / count >= 100) + if ((afterTime - beforeTime) / count >= 100) { - var each = ((after_time - before_time) / 1000.0 / count); - var each_units = "sec"; + var each = ((afterTime - beforeTime) / 1000.0 / count); + var eachUnits = "sec"; } else { - var each = ((after_time - before_time) / count); - var each_units = "msec"; + var each = ((afterTime - beforeTime) / count); + var eachUnits = "msec"; } - if (after_time - before_time >= 100) + if (afterTime - beforeTime >= 100) { - var total = ((after_time - before_time) / 1000.0); - var total_units = "sec"; + var total = ((afterTime - beforeTime) / 1000.0); + var totalUnits = "sec"; } else { - var total = (after_time - before_time); - var total_units = "msec"; + var total = (afterTime - beforeTime); + var totalUnits = "msec"; } var str = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "
    " + "
" + "" + "" + - "" + - "" + + "" + + "" + "
Code execution summary
Executed:" + count + "times
Each time:" + each.toFixed(2) + "" + each_units + "
Total time:" + total.toFixed(2) + "" + total_units + "
Each time:" + each.toFixed(2) + "" + eachUnits + "
Total time:" + total.toFixed(2) + "" + totalUnits + "
"; vimperator.commandline.echo(str, vimperator.commandline.HL_NORMAL, vimperator.commandline.FORCE_MULTILINE); } else { - var before_time = Date.now(); + var beforeTime = Date.now(); if (args && args[0] == ":") vimperator.execute(args); else @@ -2119,12 +2119,12 @@ vimperator.Commands = function () //{{{ if (special) return; - var after_time = Date.now(); + var afterTime = Date.now(); - if (after_time - before_time >= 100) - vimperator.echo("Total time: " + ((after_time - before_time) / 1000.0).toFixed(2) + " sec"); + if (afterTime - beforeTime >= 100) + vimperator.echo("Total time: " + ((afterTime - beforeTime) / 1000.0).toFixed(2) + " sec"); else - vimperator.echo("Total time: " + (after_time - before_time) + " msec"); + vimperator.echo("Total time: " + (afterTime - beforeTime) + " msec"); } } catch (e) @@ -2134,7 +2134,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["{count}time[!] {code|:command}"], - short_help: "Profile a piece of code or a command", + shortHelp: "Profile a piece of code or a command", help: "Runs {code} {count} times (default 1) and returns the elapsed time. " + "{code} is always passed to JavaScript's eval(), which might be slow, so take the results with a grain of salt.
" + "If {code} starts with a :, it is executed as a Vimperator command.
" + @@ -2164,7 +2164,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["[count]u[ndo][!] [url]"], - short_help: "Undo closing of a tab", + shortHelp: "Undo closing of a tab", help: "If a count is given, don't close the last but the [count]th last tab. " + "With [url] restores the tab matching the url.", completer: function (filter) @@ -2205,7 +2205,7 @@ vimperator.Commands = function () //{{{ undoCloseTab(); // doesn't work with i as the index to undoCloseTab }, { - short_help: "Undo closing of all closed tabs", + shortHelp: "Undo closing of all closed tabs", help: "Firefox stores up to 10 closed tabs, even after a browser restart." } )); @@ -2236,7 +2236,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["unl[et][!] {name} ..."], - short_help: "Deletes a variable.", + shortHelp: "Deletes a variable.", help: "Deletes the variable {name}." + "Several variable names can be given." } @@ -2259,7 +2259,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["unm[ap] {lhs}"], - short_help: "Remove the mapping of {lhs}", + shortHelp: "Remove the mapping of {lhs}", help: "" } )); @@ -2274,14 +2274,14 @@ vimperator.Commands = function () //{{{ }, { usage: ["ve[rsion][!]"], - short_help: "Show version information", + shortHelp: "Show version information", help: "You can show the Firefox version page with :version!." } )); commandManager.add(new vimperator.Command(["viu[sage]"], function (args, special, count, modifiers) { vimperator.help("mappings", special, null, modifiers); }, { - short_help: "Show help for normal mode commands" + shortHelp: "Show help for normal mode commands" } )); commandManager.add(new vimperator.Command(["winc[lose]", "wc[lose]"], @@ -2291,7 +2291,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["winc[ose] [url] [, url]"], - short_help: "Close window" + shortHelp: "Close window" } )); commandManager.add(new vimperator.Command(["wino[pen]", "wo[pen]", "wine[dit]"], @@ -2304,7 +2304,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["wino[pen] [url] [, url]"], - short_help: "Open one or more URLs in a new window", + shortHelp: "Open one or more URLs in a new window", help: "Like :open but open URLs in a new window.
" } )); @@ -2312,7 +2312,7 @@ vimperator.Commands = function () //{{{ function () { vimperator.quit(true); }, { usage: ["wqa[ll]", "xa[ll]"], - short_help: "Save the session and quit", + shortHelp: "Save the session and quit", help: "Quit Vimperator, no matter how many tabs/windows are open. The session is stored.
" + ":wq is different as in Vim, as it closes the window instead of just one tab by popular demand. Complain on the mailing list, if you want to change that." } @@ -2356,7 +2356,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["zo[om][!] [value]", "zo[om][!] +{value} | -{value}"], - short_help: "Set zoom value of current web page", + shortHelp: "Set zoom value of current web page", help: "If {value} can be an absolute value between 1 and 2000% or a relative value if prefixed with - or +. " + "If {value} is omitted, zoom is reset to 100%.
" + "Normally this command operates on the text zoom, if used with [!] it operates on full zoom." @@ -2370,8 +2370,8 @@ vimperator.Commands = function () //{{{ args = "!" + (args || ""); // TODO: better escaping of ! to also substitute \\! correctly - args = args.replace(/(^|[^\\])!/g, "$1" + last_run_command); - last_run_command = args; + args = args.replace(/(^|[^\\])!/g, "$1" + lastRunCommand); + lastRunCommand = args; var output = vimperator.system(args); if (output) @@ -2379,7 +2379,7 @@ vimperator.Commands = function () //{{{ }, { usage: ["!{cmd}"], - short_help: "Run a command", + shortHelp: "Run a command", help: "Runs {cmd} through system() and displays its output. " + "Any '!' in {cmd} is replaced with the previous external command. " + "But not when there is a backslash before the '!', then that backslash is removed.
" + diff --git a/content/completion.js b/content/completion.js index 07bff18b..f894e15f 100644 --- a/content/completion.js +++ b/content/completion.js @@ -29,11 +29,11 @@ the terms of any one of the MPL, the GPL or the LGPL. vimperator.Completion = function () // {{{ { // The completion substrings, used for showing the longest common match - var g_substrings = []; + var substrings = []; // function uses smartcase // list = [ [['com1', 'com2'], 'text'], [['com3', 'com4'], 'text'] ] - function build_longest_common_substring(list, filter) //{{{ + function buildLongestCommonSubstring(list, filter) //{{{ { var filtered = []; var ignorecase = false; @@ -51,19 +51,19 @@ vimperator.Completion = function () // {{{ if (item.indexOf(filter) == -1) continue; - if (g_substrings.length == 0) + if (substrings.length == 0) { - var last_index = item.lastIndexOf(filter); + var lastIndex = item.lastIndexOf(filter); var length = item.length; - for (var k = item.indexOf(filter); k != -1 && k <= last_index; k = item.indexOf(filter, k + 1)) + for (var k = item.indexOf(filter); k != -1 && k <= lastIndex; k = item.indexOf(filter, k + 1)) { for (var l = k + filter.length; l <= length; l++) - g_substrings.push(list[i][0][j].substring(k, l)); + substrings.push(list[i][0][j].substring(k, l)); } } else { - g_substrings = g_substrings.filter(function ($_) { + substrings = substrings.filter(function ($_) { return list[i][0][j].indexOf($_) >= 0; }); } @@ -75,7 +75,7 @@ vimperator.Completion = function () // {{{ } //}}} /* this function is case sensitive and should be documented about input and output ;) */ - function build_longest_starting_substring(list, filter) //{{{ + function buildLongestStartingSubstring(list, filter) //{{{ { var filtered = []; for (var i = 0; i < list.length; i++) @@ -85,15 +85,15 @@ vimperator.Completion = function () // {{{ if (list[i][0][j].indexOf(filter) != 0) continue; - if (g_substrings.length == 0) + if (substrings.length == 0) { var length = list[i][0][j].length; for (var k = filter.length; k <= length; k++) - g_substrings.push(list[i][0][j].substring(0, k)); + substrings.push(list[i][0][j].substring(0, k)); } else { - g_substrings = g_substrings.filter(function ($_) { + substrings = substrings.filter(function ($_) { return list[i][0][j].indexOf($_) == 0; }); } @@ -109,23 +109,23 @@ vimperator.Completion = function () // {{{ * returns the longest common substring * used for the 'longest' setting for wildmode */ - get_longest_substring: function () //{{{ + getLongestSubstring: function () //{{{ { - if (g_substrings.length == 0) + if (substrings.length == 0) return ""; - var longest = g_substrings[0]; - for (var i = 1; i < g_substrings.length; i++) + var longest = substrings[0]; + for (var i = 1; i < substrings.length; i++) { - if (g_substrings[i].length > longest.length) - longest = g_substrings[i]; + if (substrings[i].length > longest.length) + longest = substrings[i]; } return longest; }, //}}} dialog: function (filter) //{{{ { - g_substrings = []; + substrings = []; var nodes = [ ["about", "About Firefox"], ["addbookmark", "Add bookmarks for the current page"], @@ -155,7 +155,7 @@ vimperator.Completion = function () // {{{ return [[node[0]], node[1]]; }); - return build_longest_common_substring(mapped, filter); + return buildLongestCommonSubstring(mapped, filter); }, //}}} /* @@ -165,29 +165,29 @@ vimperator.Completion = function () // {{{ * depending on the 'complete' option * if the 'complete' argument is passed like "h", it temporarily overrides the complete option */ - get_url_completions: function (filter, complete) //{{{ + getUrlCompletions: function (filter, complete) //{{{ { var completions = []; - g_substrings = []; + substrings = []; var cpt = complete || vimperator.options["complete"]; // join all completion arrays together for (var i = 0; i < cpt.length; i++) { if (cpt[i] == "s") - completions = completions.concat(this.get_search_completions(filter)); + completions = completions.concat(this.getSearchCompletions(filter)); else if (cpt[i] == "b") completions = completions.concat(vimperator.bookmarks.get(filter)); else if (cpt[i] == "h") completions = completions.concat(vimperator.history.get(filter)); else if (cpt[i] == "f") - completions = completions.concat(this.get_file_completions(filter, true)); + completions = completions.concat(this.getFileCompletions(filter, true)); } return completions; }, //}}} - get_search_completions: function (filter) //{{{ + getSearchCompletions: function (filter) //{{{ { var engines = vimperator.bookmarks.getSearchEngines().concat(vimperator.bookmarks.getKeywords()); @@ -197,16 +197,16 @@ vimperator.Completion = function () // {{{ var mapped = engines.map(function (engine) { return [[engine[0]], engine[1]]; }); - return build_longest_common_substring(mapped, filter); + return buildLongestCommonSubstring(mapped, filter); }, //}}} // TODO: support file:// and \ or / path separators on both platforms - get_file_completions: function (filter) + getFileCompletions: function (filter) { // this is now also used as part of the url completion, so the // substrings shouldn't be cleared for that case if (!arguments[1]) - g_substrings = []; + substrings = []; var matches = filter.match(/^(.*[\/\\])(.*?)$/); var dir; @@ -230,56 +230,56 @@ vimperator.Completion = function () // {{{ } - return build_longest_starting_substring(mapped, filter); + return buildLongestStartingSubstring(mapped, filter); }, - get_help_completions: function (filter) //{{{ + getHelpCompletions: function (filter) //{{{ { - var help_array = [[["introduction"], "Introductory text"], + var helpArray = [[["introduction"], "Introductory text"], [["initialization"], "Initialization and startup"], [["mappings"], "Normal mode commands"], [["commands"], "Ex commands"], [["options"], "Configuration options"]]; // TODO: hardcoded until we have proper 'pages' - g_substrings = []; + substrings = []; for (var command in vimperator.commands) - help_array.push([command.long_names.map(function ($_) { return ":" + $_; }), command.short_help]); - options = this.get_options_completions(filter, true); - help_array = help_array.concat(options.map(function ($_) { + helpArray.push([command.longNames.map(function ($_) { return ":" + $_; }), command.shortHelp]); + options = this.getOptionCompletions(filter, true); + helpArray = helpArray.concat(options.map(function ($_) { return [ $_[0].map(function ($_) { return "'" + $_ + "'"; }), $_[1] ]; })); for (var map in vimperator.mappings) - help_array.push([map.names, map.short_help]); + helpArray.push([map.names, map.shortHelp]); - if (!filter) return help_array.map(function ($_) { + if (!filter) return helpArray.map(function ($_) { return [$_[0][0], $_[1]]; // unfiltered, use the first command }); - return build_longest_common_substring(help_array, filter); + return buildLongestCommonSubstring(helpArray, filter); }, //}}} - get_command_completions: function (filter) //{{{ + getCommandCompletions: function (filter) //{{{ { - g_substrings = []; + substrings = []; var completions = []; if (!filter) { for (var command in vimperator.commands) - completions.push([command.name, command.short_help]); + completions.push([command.name, command.shortHelp]); return completions; } for (var command in vimperator.commands) - completions.push([command.long_names, command.short_help]); - return build_longest_starting_substring(completions, filter); + completions.push([command.longNames, command.shortHelp]); + return buildLongestStartingSubstring(completions, filter); }, //}}} - get_options_completions: function (filter, unfiltered) //{{{ + getOptionCompletions: function (filter, unfiltered) //{{{ { - g_substrings = []; - var options_completions = []; + substrings = []; + var optionCompletions = []; var prefix = filter.match(/^no|inv/) || ""; if (prefix) @@ -292,7 +292,7 @@ vimperator.Completion = function () // {{{ { if (prefix && option.type != "boolean") continue; - options.push([option.names, option.short_help]); + options.push([option.names, option.shortHelp]); } return options; } @@ -304,7 +304,7 @@ vimperator.Completion = function () // {{{ { if (prefix && option.type != "boolean") continue; - options.push([prefix + option.name, option.short_help]); + options.push([prefix + option.name, option.shortHelp]); } return options; } @@ -316,15 +316,15 @@ vimperator.Completion = function () // {{{ { if (option.hasName(filter)) { - options_completions.push([filter + "=" + option.value, ""]); - return options_completions; + optionCompletions.push([filter + "=" + option.value, ""]); + return optionCompletions; } } - return options_completions; + return optionCompletions; } // can't use b_l_s_s, since this has special requirements (the prefix) - var filter_length = filter.length; + var filterLength = filter.length; for (var option in vimperator.options) { if (prefix && option.type != "boolean") @@ -335,29 +335,29 @@ vimperator.Completion = function () // {{{ if (option.names[j].indexOf(filter) != 0) continue; - if (g_substrings.length == 0) + if (substrings.length == 0) { var length = option.names[j].length; - for (var k = filter_length; k <= length; k++) - g_substrings.push(prefix + option.names[j].substring(0, k)); + for (var k = filterLength; k <= length; k++) + substrings.push(prefix + option.names[j].substring(0, k)); } else { - g_substrings = g_substrings.filter(function ($_) { + substrings = substrings.filter(function ($_) { return option.names[j].indexOf($_) == 0; }); } - options_completions.push([prefix + option.names[j], option.short_help]); + optionCompletions.push([prefix + option.names[j], option.shortHelp]); break; } } - return options_completions; + return optionCompletions; }, //}}} - get_buffer_completions: function (filter) //{{{ + getBufferCompletions: function (filter) //{{{ { - g_substrings = []; + substrings = []; var items = []; var num = getBrowser().browsers.length; var title, url; @@ -388,12 +388,12 @@ vimperator.Completion = function () // {{{ if (!filter) return items.map(function ($_) { return [$_[0][0], $_[1]]; }); - return build_longest_common_substring(items, filter); + return buildLongestCommonSubstring(items, filter); }, //}}} - get_sidebar_completions: function (filter) //{{{ + getSidebarCompletions: function (filter) //{{{ { - g_substrings = []; + substrings = []; var menu = document.getElementById("viewSidebarMenu"); var nodes = []; @@ -407,12 +407,12 @@ vimperator.Completion = function () // {{{ return [[node[0]], node[1]]; }); - return build_longest_common_substring(mapped, filter); + return buildLongestCommonSubstring(mapped, filter); }, //}}} javascript: function (str) // {{{ { - g_substrings = []; + substrings = []; var matches = str.match(/^(.*?)(\s*\.\s*)?(\w*)$/); var objects = []; var filter = matches[3] || ""; @@ -483,7 +483,7 @@ vimperator.Completion = function () // {{{ completions = []; } - return build_longest_starting_substring(completions, filter); + return buildLongestStartingSubstring(completions, filter); }, // }}} // discard all entries in the 'urls' array, which don't match 'filter @@ -494,7 +494,7 @@ vimperator.Completion = function () // {{{ var filtered = []; // completions which don't match the url but just the description // list them add the end of the array - var additional_completions = []; + var additionalCompletions = []; if (urls.length == 0) return []; @@ -519,7 +519,7 @@ vimperator.Completion = function () // {{{ /* * Longest Common Subsequence - * This shouldn't use build_longest_common_substring + * This shouldn't use buildLongestCommonSubstring * for performance reasons, so as not to cycle through the urls twice */ outer: @@ -553,28 +553,28 @@ vimperator.Completion = function () // {{{ if (filter.split(/\s+/).every(function (token) { return (url.indexOf(token) > -1 || title.indexOf(token) > -1); })) - additional_completions.push(urls[i]); + additionalCompletions.push(urls[i]); continue; } // TODO: refactor out? And just build if wildmode contains longest? - if (g_substrings.length == 0) // Build the substrings + if (substrings.length == 0) // Build the substrings { - var last_index = url.lastIndexOf(filter); - var url_length = url.length; - if (last_index >= 0 && last_index < url_length) // do not build substrings, if we don't match filter + var lastIndex = url.lastIndexOf(filter); + var urlLength = url.length; + if (lastIndex >= 0 && lastIndex < urlLength) // do not build substrings, if we don't match filter { - for (var k = url.indexOf(filter); k != -1 && k <= last_index; k = url.indexOf(filter, k + 1)) + for (var k = url.indexOf(filter); k != -1 && k <= lastIndex; k = url.indexOf(filter, k + 1)) { - for (var l = k + filter.length; l <= url_length; l++) - g_substrings.push(url.substring(k, l)); + for (var l = k + filter.length; l <= urlLength; l++) + substrings.push(url.substring(k, l)); } } } else { - g_substrings = g_substrings.filter(function ($_) { + substrings = substrings.filter(function ($_) { return url.indexOf($_) >= 0; }); } @@ -582,24 +582,24 @@ vimperator.Completion = function () // {{{ filtered.push(urls[i]); } - return filtered.concat(additional_completions); + return filtered.concat(additionalCompletions); }, //}}} // generic helper function which checks if the given "items" array pass "filter" // items must be an array of strings - match: function (items, filter, case_sensitive) + match: function (items, filter, caseSensitive) { if (typeof filter != "string" || !items) return false; - var items_str = items.join(" "); - if (!case_sensitive) + var itemsStr = items.join(" "); + if (!caseSensitive) { filter = filter.toLowerCase(); - items_str = items_str.toLowerCase(); + itemsStr = itemsStr.toLowerCase(); } - if (filter.split(/\s+/).every(function (str) { return items_str.indexOf(str) > -1; })) + if (filter.split(/\s+/).every(function (str) { return itemsStr.indexOf(str) > -1; })) return true; return false; @@ -616,7 +616,7 @@ vimperator.Completion = function () // {{{ var matches = str.match(/^(:*\d*)\w*$/); if (matches) { - completions = this.get_command_completions(cmd); + completions = this.getCommandCompletions(cmd); start = matches[1].length; } else // dynamically get completions as specified with the command's completer function diff --git a/content/editor.js b/content/editor.js index c6b4dd0d..27872b0d 100644 --- a/content/editor.js +++ b/content/editor.js @@ -32,8 +32,8 @@ the terms of any one of the MPL, the GPL or the LGPL. vimperator.Editor = function () //{{{ { // store our last search with f, F, t or T - var last_findChar = null; - var last_findChar_func = null; + var lastFindChar = null; + var lastFindCharFunc = null; var abbrev = {}; // abbrev["lhr"][0]["{i,c,!}","rhs"] function editor() @@ -120,7 +120,7 @@ vimperator.Editor = function () //{{{ if (typeof count != "number" || count < 1) count = 1; - var did_command = false; + var didCommand = false; while (count--) { // some commands need this try/catch workaround, because a cmd_charPrevious triggered @@ -129,11 +129,11 @@ vimperator.Editor = function () //{{{ try { controller.doCommand(cmd); - did_command = true; + didCommand = true; } catch (e) { - if (!did_command) + if (!didCommand) vimperator.beep(); return false; } @@ -269,8 +269,8 @@ vimperator.Editor = function () //{{{ if (!editor()) return -1; - last_findChar = ch; - last_findChar_func = this.findCharForward; + lastFindChar = ch; + lastFindCharFunc = this.findCharForward; var text = editor().value; if (!typeof count == "number" || count < 1) @@ -296,8 +296,8 @@ vimperator.Editor = function () //{{{ if (!editor()) return -1; - last_findChar = ch; - last_findChar_func = this.findCharBackward; + lastFindChar = ch; + lastFindCharFunc = this.findCharBackward; var text = editor().value; if (!typeof count == "number" || count < 1) @@ -630,11 +630,11 @@ vimperator.Editor = function () //{{{ { // if found, replace accordingly var len = foundWord.length; - var abbr_text = abbrev[lhs][i][1]; - text = text.substring(0, currStart - len) + abbr_text + text.substring(currStart); + var abbrText = abbrev[lhs][i][1]; + text = text.substring(0, currStart - len) + abbrText + text.substring(currStart); textbox.value = text; - textbox.selectionStart = currStart - len + abbr_text.length; - textbox.selectionEnd = currEnd - len + abbr_text.length; + textbox.selectionStart = currStart - len + abbrText.length; + textbox.selectionEnd = currEnd - len + abbrText.length; break; } } diff --git a/content/events.js b/content/events.js index 2cd3cf22..91944ff1 100644 --- a/content/events.js +++ b/content/events.js @@ -78,7 +78,7 @@ vimperator.Events = function () //{{{ ///////////////////////////////////////////////////////// // track if a popup is open or the menubar is active - var active_menubar = false; + var activeMenubar = false; function enterPopupMode(event) { if (event.originalTarget.localName == "tooltip" || event.originalTarget.id == "vimperator-visualbell") @@ -89,17 +89,17 @@ vimperator.Events = function () //{{{ function exitPopupMode() { // gContextMenu is set to NULL by firefox, when a context menu is closed - if (!gContextMenu && !active_menubar) + if (!gContextMenu && !activeMenubar) vimperator.modes.remove(vimperator.modes.MENU); } function enterMenuMode() { - active_menubar = true; + activeMenubar = true; vimperator.modes.add(vimperator.modes.MENU); } function exitMenuMode() { - active_menubar = false; + activeMenubar = false; vimperator.modes.remove(vimperator.modes.MENU); } window.addEventListener("popupshown", enterPopupMode, true); @@ -468,14 +468,14 @@ vimperator.Events = function () //{{{ onSelectionChange: function (event) { - var could_copy = false; + var couldCopy = false; var controller = document.commandDispatcher.getControllerForCommand("cmd_copy"); if (controller && controller.isCommandEnabled("cmd_copy")) - could_copy = true; + couldCopy = true; if (vimperator.mode != vimperator.modes.VISUAL) { - if (could_copy) + if (couldCopy) { if ((vimperator.mode == vimperator.modes.TEXTAREA || (vimperator.modes.extended & vimperator.modes.TEXTAREA)) && !vimperator.options["insertmode"]) @@ -486,7 +486,7 @@ vimperator.Events = function () //{{{ } //else //{ - // if (!could_copy && vimperator.modes.extended & vimperator.modes.CARET) + // if (!couldCopy && vimperator.modes.extended & vimperator.modes.CARET) // vimperator.mode = vimperator.modes.CARET; //} }, @@ -642,13 +642,13 @@ vimperator.Events = function () //{{{ } } - var count_str = vimperator.input.buffer.match(/^[0-9]*/)[0]; - var candidate_command = (vimperator.input.buffer + key).replace(count_str, ""); + var countStr = vimperator.input.buffer.match(/^[0-9]*/)[0]; + var candidateCommand = (vimperator.input.buffer + key).replace(countStr, ""); var map; if (event.noremap) - map = vimperator.mappings.getDefaultMap(vimperator.mode, candidate_command); + map = vimperator.mappings.getDefaultMap(vimperator.mode, candidateCommand); else - map = vimperator.mappings.get(vimperator.mode, candidate_command); + map = vimperator.mappings.get(vimperator.mode, candidateCommand); // counts must be at the start of a complete mapping (10j -> go 10 lines down) if (/^[1-9][0-9]*$/.test(vimperator.input.buffer + key)) @@ -670,7 +670,7 @@ vimperator.Events = function () //{{{ } else if (map) { - vimperator.input.count = parseInt(count_str, 10); + vimperator.input.count = parseInt(countStr, 10); if (isNaN(vimperator.input.count)) vimperator.input.count = -1; if (map.flags & vimperator.Mappings.flags.ARGUMENT) @@ -682,7 +682,7 @@ vimperator.Events = function () //{{{ { if (key != "" && key != "") { - vimperator.input.pendingMotionMap.execute(candidate_command, vimperator.input.count, null); + vimperator.input.pendingMotionMap.execute(candidateCommand, vimperator.input.count, null); } vimperator.input.pendingMotionMap = null; vimperator.input.buffer = ""; @@ -701,7 +701,7 @@ vimperator.Events = function () //{{{ stop = false; } } - else if (vimperator.mappings.getCandidates(vimperator.mode, candidate_command).length > 0) + else if (vimperator.mappings.getCandidates(vimperator.mode, candidateCommand).length > 0) { vimperator.input.buffer += key; } @@ -729,8 +729,8 @@ vimperator.Events = function () //{{{ event.stopPropagation(); } - var motion_map = (vimperator.input.pendingMotionMap && vimperator.input.pendingMotionMap.names[0]) || ""; - vimperator.statusline.updateInputBuffer(motion_map + vimperator.input.buffer); + var motionMap = (vimperator.input.pendingMotionMap && vimperator.input.pendingMotionMap.names[0]) || ""; + vimperator.statusline.updateInputBuffer(motionMap + vimperator.input.buffer); return false; }, diff --git a/content/find.js b/content/find.js index 0a36661f..06925712 100644 --- a/content/find.js +++ b/content/find.js @@ -40,16 +40,16 @@ the terms of any one of the MPL, the GPL or the LGPL. vimperator.Search = function () //{{{ { // FIXME: - //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 backwards = false; // currently searching backwards - var search_string = ""; // current search string (without modifiers) - var search_pattern = ""; // current search string (includes modifiers) - var last_search_pattern = ""; // the last searched pattern (includes modifiers) - var last_search_string = ""; // the last searched string (without modifiers) - var last_search_backwards = false; // like "backwards", but for the last search, so if you cancel a search with this is not set - var case_sensitive = false; // search string is case sensitive - var links_only = false; // search is limited to link text only + //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 backwards = false; // currently searching backwards + var searchString = ""; // current search string (without modifiers) + var searchPattern = ""; // current search string (includes modifiers) + var lastSearchPattern = ""; // the last searched pattern (includes modifiers) + var lastSearchString = ""; // the last searched string (without modifiers) + var lastSearchBackwards = false; // like "backwards", but for the last search, so if you cancel a search with this is not set + var caseSensitive = false; // search string is case sensitive + var linksOnly = false; // search is limited to link text only // Event handlers for search - closure is needed vimperator.registerCallback("change", vimperator.modes.SEARCH_FORWARD, function (command) { vimperator.search.searchKeyPressed(command); }); @@ -60,7 +60,7 @@ vimperator.Search = function () //{{{ vimperator.registerCallback("submit", vimperator.modes.SEARCH_BACKWARD, function (command) { vimperator.search.searchSubmitted(command); }); vimperator.registerCallback("cancel", vimperator.modes.SEARCH_BACKWARD, function () { vimperator.search.searchCanceled(); }); - // set search_string, search_pattern, case_sensitive, links_only + // set searchString, searchPattern, caseSensitive, linksOnly function processUserPattern(pattern) { // strip off pattern terminator and offset @@ -69,32 +69,32 @@ vimperator.Search = function () //{{{ else pattern = pattern.replace(/\/.*/, ""); - search_pattern = pattern; + searchPattern = pattern; // links only search - \l wins if both modifiers specified if (/\\l/.test(pattern)) - links_only = false; + linksOnly = false; else if (/\L/.test(pattern)) - links_only = true; + linksOnly = true; else if (vimperator.options["linksearch"]) - links_only = true; + linksOnly = true; else - links_only = false; + linksOnly = false; // strip links-only modifiers pattern = pattern.replace(/(\\)?\\[lL]/g, function ($0, $1) { return $1 ? $0 : ""; }); // case sensitivity - \c wins if both modifiers specified if (/\c/.test(pattern)) - case_sensitive = false; + caseSensitive = false; else if (/\C/.test(pattern)) - case_sensitive = true; + caseSensitive = true; else if (vimperator.options["ignorecase"] && vimperator.options["smartcase"] && /[A-Z]/.test(pattern)) - case_sensitive = true; + caseSensitive = true; else if (vimperator.options["ignorecase"]) - case_sensitive = false; + caseSensitive = false; else - case_sensitive = true; + caseSensitive = true; // strip case-sensitive modifiers pattern = pattern.replace(/(\\)?\\[cC]/g, function ($0, $1) { return $1 ? $0 : ""; }); @@ -102,7 +102,7 @@ vimperator.Search = function () //{{{ // remove any modifer escape \ pattern = pattern.replace(/\\(\\[cClL])/g, "$1"); - search_string = pattern; + searchString = pattern; } return { @@ -133,11 +133,11 @@ vimperator.Search = function () //{{{ processUserPattern(str); - fastFind.caseSensitive = case_sensitive; - found = fastFind.find(search_string, links_only) != Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND; + fastFind.caseSensitive = caseSensitive; + found = fastFind.find(searchString, linksOnly) != Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND; if (!found) - vimperator.echoerr("E486: Pattern not found: " + search_pattern); + vimperator.echoerr("E486: Pattern not found: " + searchPattern); return found; }, @@ -148,15 +148,15 @@ vimperator.Search = function () //{{{ // this hack is needed to make n/N work with the correct string, if // we typed /foo after the original search. Since searchString is // readonly we have to call find() again to update it. - if (getBrowser().fastFind.searchString != last_search_string) - this.find(last_search_string, false); + if (getBrowser().fastFind.searchString != lastSearchString) + this.find(lastSearchString, false); - var up = reverse ? !last_search_backwards : last_search_backwards; - var result = getBrowser().fastFind.findAgain(up, links_only); + var up = reverse ? !lastSearchBackwards : lastSearchBackwards; + var result = getBrowser().fastFind.findAgain(up, linksOnly); if (result == Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND) { - vimperator.echoerr("E486: Pattern not found: " + last_search_pattern); + vimperator.echoerr("E486: Pattern not found: " + lastSearchPattern); } else if (result == Components.interfaces.nsITypeAheadFind.FIND_WRAPPED) { @@ -171,10 +171,10 @@ vimperator.Search = function () //{{{ } else { - vimperator.echo((up ? "?" : "/") + last_search_pattern, null, vimperator.commandline.FORCE_SINGLELINE); + vimperator.echo((up ? "?" : "/") + lastSearchPattern, null, vimperator.commandline.FORCE_SINGLELINE); if (vimperator.options["hlsearch"]) - this.highlight(last_search_string); + this.highlight(lastSearchString); } }, @@ -186,22 +186,22 @@ vimperator.Search = function () //{{{ }, // Called when the enter key is pressed to trigger a search - // use forced_direction if you call this function directly - searchSubmitted: function (command, forced_backward) + // use forcedBackward if you call this function directly + searchSubmitted: function (command, forcedBackward) { - if (typeof forced_backward === "boolean") - backwards = forced_backward; + if (typeof forcedBackward === "boolean") + backwards = forcedBackward; // use the last pattern if none specified if (!command) - command = last_search_pattern; + command = lastSearchPattern; this.clear(); this.find(command, backwards); - last_search_backwards = backwards; - last_search_pattern = command.replace(backwards ? /\?.*/ : /\/.*/, ""); // XXX - last_search_string = search_string; + lastSearchBackwards = backwards; + lastSearchPattern = command.replace(backwards ? /\?.*/ : /\/.*/, ""); // XXX + lastSearchString = searchString; // TODO: move to find() when reverse incremental searching is kludged in // need to find again for reverse searching @@ -209,7 +209,7 @@ vimperator.Search = function () //{{{ setTimeout(function () { self.findAgain(false); }, 0); if (vimperator.options["hlsearch"]) - this.highlight(search_string); + this.highlight(searchString); vimperator.modes.reset(); }, @@ -230,9 +230,9 @@ vimperator.Search = function () //{{{ return; if (!text) - text = last_search_string; + text = lastSearchString; - gFindBar._setCaseSensitivity(case_sensitive); + gFindBar._setCaseSensitivity(caseSensitive); gFindBar._highlightDoc("white", "black", text); // TODO: seems fast enough for now...just @@ -246,7 +246,7 @@ vimperator.Search = function () //{{{ })(window.content); // recreate selection since _highlightDoc collapses the selection backwards - getBrowser().fastFind.findAgain(false, links_only); + getBrowser().fastFind.findAgain(false, linksOnly); // TODO: remove highlighting from non-link matches (HTML - A/AREA with href attribute; XML - Xlink [type="simple"]) }, diff --git a/content/help.js b/content/help.js index 28f71680..d227ba19 100644 --- a/content/help.js +++ b/content/help.js @@ -72,10 +72,10 @@ vimperator.help = function (section, easter) //{{{ ret += ''; // the actual help text with the first line in bold - if (command.short_help) + if (command.shortHelp) { ret += ''; - ret += command.short_help; // the help description + ret += command.shortHelp; // the help description ret += "
"; if (func) // for options we print default values here, e.g. { @@ -95,9 +95,9 @@ vimperator.help = function (section, easter) //{{{ var names = command.names; for (var j=0; j < names.length; j++) { - var cmd_name = names[j]; - cmd_name = vimperator.util.escapeHTML(cmd_name); - ret += '' + beg + cmd_name + end + '
'; + var cmdName = names[j]; + cmdName = vimperator.util.escapeHTML(cmdName); + ret += '' + beg + cmdName + end + '
'; } ret += ''; @@ -114,17 +114,17 @@ vimperator.help = function (section, easter) //{{{ ret = command.type + ' (default: '; if (command.type == "boolean") { - if (command.default_value == true) + if (command.defaultValue == true) ret += "on"; else ret += "off"; } else { - if (typeof command.default_value == "string" && command.default_value.length == 0) + if (typeof command.defaultValue == "string" && command.defaultValue.length == 0) ret += "''"; else - ret += command.default_value; + ret += command.defaultValue; } ret += ")
"; diff --git a/content/hints.js b/content/hints.js index 1299f988..e1cd0501 100644 --- a/content/hints.js +++ b/content/hints.js @@ -39,7 +39,7 @@ vimperator.Hints = function () //{{{ // hints[] = [elem, text, span, imgspan, elem.style.backgroundColor, elem.style.color] var hints = []; - var valid_hints = []; // store the indices of the "hints" array with valid elements + var validHints = []; // store the indices of the "hints" array with valid elements var escapeNumbers = false ; // escape mode for numbers. true -> treated as hint-text var activeTimeout = null; // needed for hinttimeout > 0 @@ -57,7 +57,7 @@ vimperator.Hints = function () //{{{ hintNumber = 0; usedTabKey = false; hints = []; - valid_hints = []; + validHints = []; canUpdate = false; docs = []; escapeNumbers = false; @@ -78,11 +78,11 @@ vimperator.Hints = function () //{{{ // for javascript links function openHint(where) { - if (valid_hints.length < 1) + if (validHints.length < 1) return false; var x = 1, y = 1; - var elem = valid_hints[hintNumber - 1] || valid_hints[0]; + var elem = validHints[hintNumber - 1] || validHints[0]; var elemTagName = elem.localName.toLowerCase(); elem.focus(); if (elemTagName == "frame" || elemTagName == "iframe") @@ -102,10 +102,10 @@ vimperator.Hints = function () //{{{ function focusHint() { - if (valid_hints.length < 1) + if (validHints.length < 1) return false; - var elem = valid_hints[hintNumber - 1] || valid_hints[0]; + var elem = validHints[hintNumber - 1] || validHints[0]; var doc = window.content.document; var elemTagName = elem.localName.toLowerCase(); if (elemTagName == "frame" || elemTagName == "iframe") @@ -135,10 +135,10 @@ vimperator.Hints = function () //{{{ function yankHint(text) { - if (valid_hints.length < 1) + if (validHints.length < 1) return false; - var elem = valid_hints[hintNumber - 1] || valid_hints[0]; + var elem = validHints[hintNumber - 1] || validHints[0]; if (text) var loc = elem.textContent; else @@ -148,12 +148,12 @@ vimperator.Hints = function () //{{{ vimperator.echo("Yanked " + loc, vimperator.commandline.FORCE_SINGLELINE); } - function saveHint(skip_prompt) + function saveHint(skipPrompt) { - if (valid_hints.length < 1) + if (validHints.length < 1) return false; - var elem = valid_hints[hintNumber - 1] || valid_hints[0]; + var elem = validHints[hintNumber - 1] || validHints[0]; var doc = elem.ownerDocument; var url = makeURLAbsolute(elem.baseURI, elem.href); var text = elem.textContent; @@ -161,7 +161,7 @@ vimperator.Hints = function () //{{{ try { urlSecurityCheck(url, doc.nodePrincipal); - saveURL(url, text, null, true, skip_prompt, makeURI(url, doc.characterSet)); + saveURL(url, text, null, true, skipPrompt, makeURI(url, doc.characterSet)); } catch (e) { @@ -247,11 +247,11 @@ vimperator.Hints = function () //{{{ // TODO: make it aware of imgspans function showActiveHint(newID, oldID) { - var oldElem = valid_hints[oldID - 1]; + var oldElem = validHints[oldID - 1]; if (oldElem) oldElem.style.backgroundColor = "yellow"; - var newElem = valid_hints[newID - 1]; + var newElem = validHints[newID - 1]; if (newElem) newElem.style.backgroundColor = "#88FF00"; } @@ -267,9 +267,9 @@ vimperator.Hints = function () //{{{ var elem, tagname, text, rect, span, imgspan; var hintnum = 1; - var find_tokens = hintString.split(/ +/); + var findTokens = hintString.split(/ +/); var activeHint = hintNumber || 1; - valid_hints = []; + validHints = []; for (var j = 0; j < docs.length; j++) { @@ -287,9 +287,9 @@ vimperator.Hints = function () //{{{ span = hints[i][2]; imgspan = hints[i][3]; - for (var k = 0; k < find_tokens.length; k++) + for (var k = 0; k < findTokens.length; k++) { - if (text.indexOf(find_tokens[k]) < 0) + if (text.indexOf(findTokens[k]) < 0) { span.style.display = "none"; if (imgspan) @@ -331,7 +331,7 @@ vimperator.Hints = function () //{{{ elem.style.color = "black"; span.textContent = "" + (hintnum++); span.style.display = "inline"; - valid_hints.push(elem); + validHints.push(elem); } } @@ -341,7 +341,7 @@ vimperator.Hints = function () //{{{ function removeHints(timeout) { - var firstElem = valid_hints[0] || null; + var firstElem = validHints[0] || null; var firstElemBgColor = ""; var firstElemColor = ""; @@ -411,7 +411,7 @@ vimperator.Hints = function () //{{{ function processHints(followFirst) { - if (valid_hints.length == 0) + if (validHints.length == 0) { vimperator.beep(); return false; @@ -419,18 +419,18 @@ vimperator.Hints = function () //{{{ if (!followFirst) { - var first_href = valid_hints[0].getAttribute("href") || null; - if (first_href) + var firstHref = validHints[0].getAttribute("href") || null; + if (firstHref) { - if (valid_hints.some(function (e) { return e.getAttribute("href") != first_href; })) + if (validHints.some(function (e) { return e.getAttribute("href") != firstHref; })) return false; } - else if (valid_hints.length > 1) + else if (validHints.length > 1) return false; } var activeNum = hintNumber || 1; - var loc = valid_hints[activeNum - 1].href || ""; + var loc = validHints[activeNum - 1].href || ""; switch (submode) { case ";": focusHint(); break; @@ -502,13 +502,13 @@ vimperator.Hints = function () //{{{ canUpdate = true; showHints(); - if (valid_hints.length == 0) + if (validHints.length == 0) { vimperator.beep(); vimperator.modes.reset(); return false; } - else if (valid_hints.length == 1) + else if (validHints.length == 1) { processHints(true); return false; @@ -554,13 +554,13 @@ vimperator.Hints = function () //{{{ var oldID = hintNumber; if (key == "") { - if (++hintNumber > valid_hints.length) + if (++hintNumber > validHints.length) hintNumber = 1; } else { if (--hintNumber < 1) - hintNumber = valid_hints.length; + hintNumber = validHints.length; } showActiveHint(hintNumber, oldID); return; @@ -638,7 +638,7 @@ vimperator.Hints = function () //{{{ } showActiveHint(hintNumber, oldHintNumber || 1); - if (hintNumber == 0 || hintNumber > valid_hints.length) + if (hintNumber == 0 || hintNumber > validHints.length) { vimperator.beep(); return; @@ -646,7 +646,7 @@ vimperator.Hints = function () //{{{ // if we write a numeric part like 3, but we have 45 hints, only follow // the hint after a timeout, as the user might have wanted to follow link 34 - if (hintNumber > 0 && hintNumber * 10 <= valid_hints.length) + if (hintNumber > 0 && hintNumber * 10 <= validHints.length) { var timeout = vimperator.options["hinttimeout"]; if (timeout > 0) diff --git a/content/io.js b/content/io.js index 6a3f1da6..a0c400b1 100644 --- a/content/io.js +++ b/content/io.js @@ -29,7 +29,7 @@ the terms of any one of the MPL, the GPL or the LGPL. vimperator.IO = function () { - var environment_service = Components.classes["@mozilla.org/process/environment;1"] + var environmentService = Components.classes["@mozilla.org/process/environment;1"] .getService(Components.interfaces.nsIEnvironment); return { @@ -54,30 +54,30 @@ vimperator.IO = function () // expand "~" to VIMPERATOR_HOME or HOME (USERPROFILE or HOMEDRIVE\HOMEPATH on Windows if HOME is not set) if (/^~/.test(path)) { - var home = environment_service.get("VIMPERATOR_HOME"); + var home = environmentService.get("VIMPERATOR_HOME"); if (!home) - home = environment_service.get("HOME"); + home = environmentService.get("HOME"); if (WINDOWS && !home) - home = environment_service.get("USERPROFILE") || - environment_service.get("HOMEDRIVE") + environment_service.get("HOMEPATH"); + home = environmentService.get("USERPROFILE") || + environmentService.get("HOMEDRIVE") + environmentService.get("HOMEPATH"); path = path.replace("~", home); } // expand any $ENV vars - var env_vars = path.match(/\$\w+\b/g); // this is naive but so is Vim and we like to be compatible + var envVars = path.match(/\$\w+\b/g); // this is naive but so is Vim and we like to be compatible - if (env_vars) + if (envVars) { var expansion; - for (var i = 0; i < env_vars.length; i++) + for (var i = 0; i < envVars.length; i++) { - expansion = environment_service.get(env_vars[i].replace("$", "")); + expansion = environmentService.get(envVars[i].replace("$", "")); if (expansion) - path = path.replace(env_vars[i], expansion); + path = path.replace(envVars[i], expansion); } } @@ -86,30 +86,30 @@ vimperator.IO = function () getPluginDir: function () { - var plugin_dir; + var pluginDir; if (navigator.platform == "Win32") - plugin_dir = "~/vimperator/plugin"; + pluginDir = "~/vimperator/plugin"; else - plugin_dir = "~/.vimperator/plugin"; + pluginDir = "~/.vimperator/plugin"; - plugin_dir = this.getFile(this.expandPath(plugin_dir)); + pluginDir = this.getFile(this.expandPath(pluginDir)); - return plugin_dir.exists() && plugin_dir.isDirectory() ? plugin_dir : null; + return pluginDir.exists() && pluginDir.isDirectory() ? pluginDir : null; }, getRCFile: function () { - var rc_file1 = this.getFile(this.expandPath("~/.vimperatorrc")); - var rc_file2 = this.getFile(this.expandPath("~/_vimperatorrc")); + var rcFile1 = this.getFile(this.expandPath("~/.vimperatorrc")); + var rcFile2 = this.getFile(this.expandPath("~/_vimperatorrc")); if (navigator.platform == "Win32") - [rc_file1, rc_file2] = [rc_file2, rc_file1] + [rcFile1, rcFile2] = [rcFile2, rcFile1] - if (rc_file1.exists() && rc_file1.isFile()) - return rc_file1; - else if (rc_file2.exists() && rc_file2.isFile()) - return rc_file2; + if (rcFile1.exists() && rcFile1.isFile()) + return rcFile1; + else if (rcFile2.exists() && rcFile2.isFile()) + return rcFile2; else return null; }, @@ -133,12 +133,12 @@ vimperator.IO = function () createInstance(Components.interfaces.nsILocalFile); if (navigator.platform == "Win32") { - var dir = environment_service.get("TMP") || environment_service.get("TEMP") || "C:\\"; + var dir = environmentService.get("TMP") || environmentService.get("TEMP") || "C:\\"; file.initWithPath(dir + "\\vimperator.tmp"); } else { - var dir = environment_service.get("TMP") || environment_service.get("TEMP") || "/tmp/"; + var dir = environmentService.get("TMP") || environmentService.get("TEMP") || "/tmp/"; file.initWithPath(dir + "/vimperator.tmp"); } diff --git a/content/mappings.js b/content/mappings.js index dd645143..fe36d567 100644 --- a/content/mappings.js +++ b/content/mappings.js @@ -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. }}} ***** END LICENSE BLOCK *****/ -vimperator.Map = function (modes, cmds, action, extra_info) //{{{ +vimperator.Map = function (modes, cmds, action, extraInfo) //{{{ { if (!modes || (!cmds || !cmds.length) || !action) return null; @@ -37,12 +37,12 @@ vimperator.Map = function (modes, cmds, action, extra_info) //{{{ this.usage = [this.names[0]]; - if (extra_info) + if (extraInfo) { - this.flags = extra_info.flags || 0; + this.flags = extraInfo.flags || 0; - if (extra_info.usage) - this.usage = extra_info.usage; + if (extraInfo.usage) + this.usage = extraInfo.usage; else { this.usage = this.names[0]; // only the first command name @@ -53,15 +53,15 @@ vimperator.Map = function (modes, cmds, action, extra_info) //{{{ this.usage = [this.usage]; // FIXME: usage an array - needed for the help } - this.help = extra_info.help || null; - this.short_help = extra_info.short_help || null; + this.help = extraInfo.help || null; + this.shortHelp = extraInfo.shortHelp || null; - this.rhs = extra_info.rhs || null; + this.rhs = extraInfo.rhs || null; // TODO: are these limited to HINTS mode? // Only set for hints maps - this.cancel_mode = extra_info.cancel_mode || false; - this.always_active = extra_info.always_active || false; + this.cancelMode = extraInfo.cancelMode || false; + this.alwaysActive = extraInfo.alwaysActive || false; } }; @@ -206,11 +206,11 @@ vimperator.Mappings = function () //{{{ hasMap: function (mode, cmd) { - var user_maps = user[mode]; + var userMaps = user[mode]; - for (var i = 0; i < user_maps.length; i++) + for (var i = 0; i < userMaps.length; i++) { - if (user_maps[i].names.indexOf(cmd) != -1) + if (userMaps[i].names.indexOf(cmd) != -1) return true; } @@ -322,7 +322,7 @@ vimperator.Mappings = function () //{{{ vimperator.modes.COMMAND_LINE, vimperator.modes.CARET, vimperator.modes.TEXTAREA]; - var any_non_insertmode = [vimperator.modes.NORMAL, + var anyNoninsertMode = [vimperator.modes.NORMAL, vimperator.modes.VISUAL, vimperator.modes.HINTS, vimperator.modes.CARET, @@ -336,22 +336,22 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map(anymode, [""], function () { vimperator.help(null); }, { - short_help: "Open help window", + shortHelp: "Open help window", help: "The default section is shown, if you need help for a specific topic, try :help <F1>." } )); addDefaultMap(new vimperator.Map(anymode, ["", ""], vimperator.events.onEscape, { - short_help: "Focus content", + shortHelp: "Focus content", help: "Exits any command line or hint mode and returns to browser mode.
" + "Also focuses the web page, in case a form field has focus and eats our key presses." } )); - addDefaultMap(new vimperator.Map(any_non_insertmode, [":"], + addDefaultMap(new vimperator.Map(anyNoninsertMode, [":"], function () { vimperator.commandline.open(":", "", vimperator.modes.EX); }, { - short_help: "Start command line mode", + shortHelp: "Start command line mode", help: "In command line mode, you can perform extended commands, which may require arguments." } )); @@ -363,7 +363,7 @@ vimperator.Mappings = function () //{{{ vimperator.options.setFirefoxPref("accessibility.browsewithcaret", true); }, { - short_help: "Start caret mode", + shortHelp: "Start caret mode", help: "This mode resembles the Vim normal mode where you see a text cursor and can move around. " + "If you want to select text in this mode, press v to start its Visual mode." } @@ -371,7 +371,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map(anymode, [""], function () { vimperator.modes.passAllKeys = true; }, { - short_help: "Temporarily quit Vimperator mode", + shortHelp: "Temporarily quit Vimperator mode", help: "Disable all Vimperator keys except <Esc> and pass them to the next event handler.
" + "This is especially useful, if JavaScript controlled forms like the RichEdit form fields of GMail don't work anymore.
" + "To exit this mode, press <Esc>. If you also need to pass <Esc>" + @@ -381,7 +381,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map(anymode, [""], function () { vimperator.modes.passNextKey = true; }, { - short_help: "Pass through next key", + shortHelp: "Pass through next key", help: "If you need to pass a certain key to a JavaScript form field or another extension prefix the key with <C-v>.
" + "Also works to unshadow Firefox shortcuts like <C-o> which are otherwise hidden in Vimperator.
" + "When Vimperator mode is temporarily disabled with <C-q>, <C-v> will pass the next key to Vimperator instead of the web page." @@ -390,14 +390,14 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], [""], BrowserStop, { - short_help: "Stop loading", + shortHelp: "Stop loading", help: "Stops loading the current web page." } )); addDefaultMap(new vimperator.Map(anymode, [""], function () { return; }, { - short_help: "Do nothing", + shortHelp: "Do nothing", help: "This command is useful for disabling a specific mapping. " + ":map <C-n> <Nop> will prevent <C-n> from doing anything." } @@ -406,7 +406,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["]f"], function (count) { vimperator.buffer.shiftFrameFocus(count > 1 ? count : 1, true); }, { - short_help: "Focus next frame", + shortHelp: "Focus next frame", help: "Transfers keyboard focus to the [count]th next frame in order. The newly focused frame is briefly colored red. Does not wrap.", flags: vimperator.Mappings.flags.COUNT } @@ -414,7 +414,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["[f"], function (count) { vimperator.buffer.shiftFrameFocus(count > 1 ? count : 1, false); }, { - short_help: "Focus previous frame", + shortHelp: "Focus previous frame", help: "Transfers keyboard focus to the [count]th previous frame in order. The newly focused frame is briefly colored red. Does not wrap.", flags: vimperator.Mappings.flags.COUNT } @@ -422,7 +422,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["]n"], function (count) { vimperator.buffer.followDocumentRelationship("next"); }, { - short_help: "go to 'next' or '>' if it exists. Beep otherwise.", + shortHelp: "go to 'next' or '>' if it exists. Beep otherwise.", help: "Opens link labeled with next or >. Useful when browsing forums or documentation. Change nextpattern to modify its behaviour. It follows relations between files too.", flags: vimperator.Mappings.flags.COUNT } @@ -430,7 +430,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["]p"], function (count) { vimperator.buffer.followDocumentRelationship("previous"); }, { - short_help: "go to 'prev', 'previous' or '<' if it exists. Beep otherwise.", + shortHelp: "go to 'prev', 'previous' or '<' if it exists. Beep otherwise.", help: "Opens link labeled with prev, previous or <. Useful when browsing forums or documentation. Change nextpattern to modify its behaviour. It follows relations between files too.", flags: vimperator.Mappings.flags.COUNT } @@ -444,28 +444,28 @@ vimperator.Mappings = function () //{{{ vimperator.commandline.open(":", "bmark " + vimperator.buffer.URL + title, vimperator.modes.EX); }, { - short_help: "Open a prompt to bookmark the current URL", + shortHelp: "Open a prompt to bookmark the current URL", help: "Look at :bmark for more information." } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["A"], function () { vimperator.bookmarks.toggle(vimperator.buffer.URL); }, { - short_help: "Toggle bookmarked state of current URL", + shortHelp: "Toggle bookmarked state of current URL", help: "Add/remove a bookmark for the current location, depending if it already is bookmarked or not." } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["b"], function () { vimperator.commandline.open(":", "buffer! ", vimperator.modes.EX); }, { - short_help: "Open a prompt to switch buffers", + shortHelp: "Open a prompt to switch buffers", help: "Typing the corresponding number switches to this buffer." } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["B"], function () { vimperator.buffer.list(true); }, { - short_help: "Toggle buffer list", + shortHelp: "Toggle buffer list", help: "Toggles the display of the buffer list which shows all opened tabs.
" + "WARNING: This mapping may be removed/changed in future." } @@ -473,7 +473,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gb"], function (count) { vimperator.buffer.switchTo(null, null, count, false); }, { - short_help: "Repeat last :buffer[!] command", + shortHelp: "Repeat last :buffer[!] command", help: "This is useful to quickly jump between buffers which have a similar URL or title.", flags: vimperator.Mappings.flags.COUNT } @@ -481,7 +481,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gB"], function (count) { vimperator.buffer.switchTo(null, null, count, true); }, { - short_help: "Repeat last :buffer[!] command in reverse direction", + shortHelp: "Repeat last :buffer[!] command in reverse direction", help: "Just like gb but in the other direction.", flags: vimperator.Mappings.flags.COUNT } @@ -489,7 +489,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["d"], function (count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, false, 0); }, { - short_help: "Delete current buffer (=tab)", + shortHelp: "Delete current buffer (=tab)", help: "Count is supported, 2d removes the current and next tab and the one to the right is selected. " + "Does not wrap if [count] is larger than available tabs to the right.", flags: vimperator.Mappings.flags.COUNT @@ -498,7 +498,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["D"], function (count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, true, 0); }, { - short_help: "Delete current buffer (=tab)", + shortHelp: "Delete current buffer (=tab)", help: "Count is supported, 2D removes the current and previous tab and the one to the left is selected. " + "Does not wrap if [count] is larger than available tabs to the left.", flags: vimperator.Mappings.flags.COUNT @@ -507,7 +507,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gh"], BrowserHome, { - short_help: "Go home", + shortHelp: "Go home", help: "Opens the homepage in the current tab." } )); @@ -519,7 +519,7 @@ vimperator.Mappings = function () //{{{ vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB); }, { - short_help: "Go home in a new tab", + shortHelp: "Go home in a new tab", help: "Opens the homepage in a new tab. " + "Whether the new tab is activated or not depends on the 'activate' option.
" } @@ -533,13 +533,13 @@ vimperator.Mappings = function () //{{{ vimperator.beep(); }, { - short_help: "Focus last used input field" + shortHelp: "Focus last used input field" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["go"], function (arg) { vimperator.quickmarks.jumpTo(arg, vimperator.CURRENT_TAB); }, { - short_help: "Jump to a QuickMark in the current tab", + shortHelp: "Jump to a QuickMark in the current tab", usage: ["go{a-zA-Z0-9}"], help: "Open any QuickMark in the current tab. You can mark any URLs with M{a-zA-Z0-9}. " + "These QuickMarks are persistent across browser sessions.", @@ -554,7 +554,7 @@ vimperator.Mappings = function () //{{{ vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB); }, { - short_help: "Jump to a QuickMark in a new tab", + shortHelp: "Jump to a QuickMark in a new tab", usage: ["gn{a-zA-Z0-9}"], help: "Works like go{a-zA-Z0-9} but opens the QuickMark in a new tab. " + "Whether the new tab is activated or not depends on the 'activate' option.
" + @@ -570,14 +570,14 @@ vimperator.Mappings = function () //{{{ vimperator.NEW_BACKGROUND_TAB : vimperator.NEW_TAB); }, { - short_help: "Open (put) a URL based on the current clipboard contents in a new buffer", + shortHelp: "Open (put) a URL based on the current clipboard contents in a new buffer", help: "Works like P, but inverts the 'activate' option." } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gt", "", "", ""], function (count) { vimperator.tabs.select(count > 0 ? count - 1: "+1", count > 0 ? false : true); }, { - short_help: "Go to the next tab", + shortHelp: "Go to the next tab", help: "Cycles to the first tab, when the last is selected.
Count is supported: 3gt goes to the third tab.", flags: vimperator.Mappings.flags.COUNT } @@ -585,7 +585,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gT", "", "", ""], function (count) { vimperator.tabs.select("-" + (count < 1 ? 1 : count), true); }, { - short_help: "Go {count} pages back", + shortHelp: "Go {count} pages back", help: "Wraps around from the first tab to the last tab.
Count is supported: 3gT goes three tabs back.", flags: vimperator.Mappings.flags.COUNT } @@ -612,7 +612,7 @@ vimperator.Mappings = function () //{{{ vimperator.tabs.select(index); }, { - short_help: "Select the alternate tab", + shortHelp: "Select the alternate tab", usage: [""], help: "The alternate tab is the last selected tab. This provides a quick method of toggling between two tabs." } @@ -629,7 +629,7 @@ vimperator.Mappings = function () //{{{ vimperator.marks.add(arg); }, { - short_help: "Set mark at the cursor position", + shortHelp: "Set mark at the cursor position", usage: ["m{a-zA-Z}"], help: "Marks a-z are local to the buffer, whereas A-Z are valid between buffers.", flags: vimperator.Mappings.flags.ARGUMENT @@ -638,7 +638,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["'", "`"], function (arg) { vimperator.marks.jumpTo(arg); }, { - short_help: "Jump to the mark in the current buffer", + shortHelp: "Jump to the mark in the current buffer", usage: ["'{a-zA-Z}"], help: "Marks a-z are local to the buffer, whereas A-Z are valid between buffers.", flags: vimperator.Mappings.flags.ARGUMENT @@ -656,7 +656,7 @@ vimperator.Mappings = function () //{{{ vimperator.quickmarks.add(arg, vimperator.buffer.URL); }, { - short_help: "Add new QuickMark for current URL", + shortHelp: "Add new QuickMark for current URL", usage: ["M{a-zA-Z0-9}"], help: "You can go to a marked URL in the current tab with go{a-zA-Z0-9} or in a new tab with gn{a-zA-Z0-9}. " + "These QuickMarks are persistent across browser sessions.", @@ -666,21 +666,21 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["o"], function () { vimperator.commandline.open(":", "open ", vimperator.modes.EX); }, { - short_help: "Open one or more URLs in the current tab", + shortHelp: "Open one or more URLs in the current tab", help: "See :open for more details." } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["O"], function () { vimperator.commandline.open(":", "open " + vimperator.buffer.URL, vimperator.modes.EX); }, { - short_help: "Open one or more URLs in the current tab, based on current location", + shortHelp: "Open one or more URLs in the current tab, based on current location", help: "Works like o, but preselects current URL in the :open query." } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["p", ""], function () { vimperator.open(readFromClipboard()); }, { - short_help: "Open (put) a URL based on the current clipboard contents in the current buffer", + shortHelp: "Open (put) a URL based on the current clipboard contents in the current buffer", help: "You can also just select (for non-X11 users: copy) some non-URL text, and search for it with the default search engine or keyword (specified by the 'defsearch' option) with p." } )); @@ -692,7 +692,7 @@ vimperator.Mappings = function () //{{{ vimperator.NEW_TAB : vimperator.NEW_BACKGROUND_TAB); }, { - short_help: "Open (put) a URL based on the current clipboard contents in a new buffer", + shortHelp: "Open (put) a URL based on the current clipboard contents in a new buffer", help: "Works like p, but opens a new tab.
" + "Whether the new buffer is activated, depends on the 'activate' option." } @@ -700,7 +700,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], [""], function (count) { vimperator.commands.redraw(); }, { - short_help: "Redraw the screen", + shortHelp: "Redraw the screen", help: "Works like :redraw.", flags: vimperator.Mappings.flags.COUNT } @@ -708,21 +708,21 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["r"], function () { vimperator.tabs.reload(getBrowser().mCurrentTab, false); }, { - short_help: "Reload", + shortHelp: "Reload", help: "Forces reloading of the current page." } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["R"], function () { vimperator.tabs.reload(getBrowser().mCurrentTab, true); }, { - short_help: "Reload while skipping the cache", + shortHelp: "Reload while skipping the cache", help: "Forces reloading of the current page skipping the cache." } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["t"], function () { vimperator.commandline.open(":", "tabopen ", vimperator.modes.EX); }, { - short_help: "Open one or more URLs in a new tab", + shortHelp: "Open one or more URLs in a new tab", help: "Like o but open URLs in a new tab.
" + "See :tabopen for more details." } @@ -730,14 +730,14 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["T"], function () { vimperator.commandline.open(":", "tabopen " + vimperator.buffer.URL, vimperator.modes.EX); }, { - short_help: "Open one or more URLs in a new tab, based on current location", + shortHelp: "Open one or more URLs in a new tab, based on current location", help: "Works like t, but preselects current URL in the :tabopen query." } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["u"], function (count) { vimperator.commands.undo("", false, count); }, { - short_help: "Undo closing of a tab", + shortHelp: "Undo closing of a tab", help: "If a count is given, don't close the last but the [count]th last tab.", flags: vimperator.Mappings.flags.COUNT } @@ -750,7 +750,7 @@ vimperator.Mappings = function () //{{{ vimperator.echo("Yanked " + url, vimperator.commandline.FORCE_SINGLELINE); }, { - short_help: "Yank current location to the clipboard", + shortHelp: "Yank current location to the clipboard", help: "When running in X11 the location is also put into the selection, which can be pasted with the middle mouse button." } )); @@ -761,7 +761,7 @@ vimperator.Mappings = function () //{{{ vimperator.copyToClipboard(sel); }, { - short_help: "Copy selected text", + shortHelp: "Copy selected text", help: "The currently selected text is copied to the system clipboard." } )); @@ -769,7 +769,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["zi", "+"], function (count) { vimperator.buffer.zoomIn(count > 1 ? count : 1, false); }, { - short_help: "Enlarge text zoom of current web page", + shortHelp: "Enlarge text zoom of current web page", help: "Mnemonic: zoom in", flags: vimperator.Mappings.flags.COUNT } @@ -777,7 +777,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["zm"], function (count) { vimperator.buffer.zoomIn((count > 1 ? count : 1) * 3, false); }, { - short_help: "Enlarge text zoom of current web page by a larger amount", + shortHelp: "Enlarge text zoom of current web page by a larger amount", help: "Mnemonic: zoom more", flags: vimperator.Mappings.flags.COUNT } @@ -785,7 +785,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["zo", "-"], function (count) { vimperator.buffer.zoomOut(count > 1 ? count : 1, false); }, { - short_help: "Reduce text zoom of current web page", + shortHelp: "Reduce text zoom of current web page", help: "Mnemonic: zoom out", flags: vimperator.Mappings.flags.COUNT } @@ -793,7 +793,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["zr"], function (count) { vimperator.buffer.zoomOut((count > 1 ? count : 1) * 3, false); }, { - short_help: "Reduce text zoom of current web page by a larger amount", + shortHelp: "Reduce text zoom of current web page by a larger amount", help: "Mnemonic: zoom reduce", flags: vimperator.Mappings.flags.COUNT } @@ -801,7 +801,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["zz"], function (count) { vimperator.buffer.textZoom = count > 1 ? count : 100; }, { - short_help: "Set text zoom value of current web page", + shortHelp: "Set text zoom value of current web page", help: "Zoom value can be between 1 and 2000%. If it is omitted, text zoom is reset to 100%.", flags: vimperator.Mappings.flags.COUNT } @@ -809,7 +809,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["zI"], function (count) { vimperator.buffer.zoomIn(count > 1 ? count : 1, true); }, { - short_help: "Enlarge full zoom of current web page", + shortHelp: "Enlarge full zoom of current web page", help: "Mnemonic: zoom in", flags: vimperator.Mappings.flags.COUNT } @@ -817,7 +817,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["zM"], function (count) { vimperator.buffer.zoomIn((count > 1 ? count : 1) * 3, true); }, { - short_help: "Enlarge full zoom of current web page by a larger amount", + shortHelp: "Enlarge full zoom of current web page by a larger amount", help: "Mnemonic: zoom more", flags: vimperator.Mappings.flags.COUNT } @@ -825,7 +825,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["zO"], function (count) { vimperator.buffer.zoomOut(count > 1 ? count : 1, true); }, { - short_help: "Reduce full zoom of current web page", + shortHelp: "Reduce full zoom of current web page", help: "Mnemonic: zoom out", flags: vimperator.Mappings.flags.COUNT } @@ -833,7 +833,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["zR"], function (count) { vimperator.buffer.zoomOut((count > 1 ? count : 1) * 3, true); }, { - short_help: "Reduce full zoom of current web page by a larger amount", + shortHelp: "Reduce full zoom of current web page by a larger amount", help: "Mnemonic: zoom reduce", flags: vimperator.Mappings.flags.COUNT } @@ -841,7 +841,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["zZ"], function (count) { vimperator.buffer.fullZoom = count > 1 ? count : 100; }, { - short_help: "Set full zoom value of current web page", + shortHelp: "Set full zoom value of current web page", help: "Zoom value can be between 1 and 2000%. If it is omitted, full zoom is reset to 100%.", flags: vimperator.Mappings.flags.COUNT } @@ -850,14 +850,14 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["ZQ"], function () { vimperator.quit(false); }, { - short_help: "Quit and don't save the session", + shortHelp: "Quit and don't save the session", help: "Works like :qall." } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["ZZ"], function () { vimperator.quit(true); }, { - short_help: "Quit and save the session", + shortHelp: "Quit and save the session", help: "Quit Vimperator, no matter how many tabs/windows are open. The session is stored.
" + "Works like :xall." } @@ -867,20 +867,20 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["0", "^"], function () { vimperator.buffer.scrollStart(); }, { - short_help: "Scroll to the absolute left of the document", + shortHelp: "Scroll to the absolute left of the document", help: "Unlike in Vim, 0 and ^ work exactly the same way." } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["$"], function () { vimperator.buffer.scrollEnd(); }, { - short_help: "Scroll to the absolute right of the document" + shortHelp: "Scroll to the absolute right of the document" } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gg", ""], function (count) { vimperator.buffer.scrollToPercentile(count > 0 ? count : 0); }, { - short_help: "Goto the top of the document", + shortHelp: "Goto the top of the document", help: "When used with [count] like in 35gg, it scrolls to 35% of the document.", flags: vimperator.Mappings.flags.COUNT } @@ -888,7 +888,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["G", ""], function (count) { vimperator.buffer.scrollToPercentile(count >= 0 ? count : 100); }, { - short_help: "Goto the end of the document", + shortHelp: "Goto the end of the document", help: "When used with [count] like in 35G, it scrolls to 35% of the document.", flags: vimperator.Mappings.flags.COUNT } @@ -896,7 +896,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["h", ""], function (count) { vimperator.buffer.scrollColumns(-(count > 1 ? count : 1)); }, { - short_help: "Scroll document to the left", + shortHelp: "Scroll document to the left", help: "Count is supported: 10h will move 10 times as much to the left.
" + "If the document cannot scroll more, a beep is emitted (unless 'visualbell' is set).", flags: vimperator.Mappings.flags.COUNT @@ -905,7 +905,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["j", "", ""], function (count) { vimperator.buffer.scrollLines(count > 1 ? count : 1); }, { - short_help: "Scroll document down", + shortHelp: "Scroll document down", help: "Count is supported: 10j will move 10 times as much down.
" + "If the document cannot scroll more, a beep is emitted (unless 'visualbell' is set).", flags: vimperator.Mappings.flags.COUNT @@ -914,7 +914,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["k", "", ""], function (count) { vimperator.buffer.scrollLines(-(count > 1 ? count : 1)); }, { - short_help: "Scroll document up", + shortHelp: "Scroll document up", help: "Count is supported: 10k will move 10 times as much up.
" + "If the document cannot scroll more, a beep is emitted (unless 'visualbell' is set).", flags: vimperator.Mappings.flags.COUNT @@ -939,7 +939,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], [""], function (count) { scrollByScrollSize(count, 1); }, { - short_help: "Scroll window downwards in the buffer", + shortHelp: "Scroll window downwards in the buffer", help: "The number of lines is set by the 'scroll' option which defaults to half a page. " + "If [count] is given 'scroll' is first set to this value.", flags: vimperator.Mappings.flags.COUNT @@ -948,7 +948,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], [""], function (count) { scrollByScrollSize(count, -1); }, { - short_help: "Scroll window upwards in the buffer", + shortHelp: "Scroll window upwards in the buffer", help: "The number of lines is set by the 'scroll' option which defaults to half a page. " + "If [count] is given 'scroll' is first set to this value.", flags: vimperator.Mappings.flags.COUNT @@ -957,7 +957,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["l", ""], function (count) { vimperator.buffer.scrollColumns(count > 1 ? count : 1); }, { - short_help: "Scroll document to the right", + shortHelp: "Scroll document to the right", help: "Count is supported: 10l will move 10 times as much to the right.
" + "If the document cannot scroll more, a beep is emitted (unless 'visualbell' is set).", flags: vimperator.Mappings.flags.COUNT @@ -966,7 +966,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["", "", ""], function (count) { vimperator.buffer.scrollPages(-(count > 1 ? count : 1)); }, { - short_help: "Scroll up a full page", + shortHelp: "Scroll up a full page", help: "Scroll window [count] pages Backwards (upwards) in the buffer.", flags: vimperator.Mappings.flags.COUNT } @@ -974,7 +974,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["", "", ""], function (count) { vimperator.buffer.scrollPages(count > 1 ? count : 1); }, { - short_help: "Scroll down a full page", + shortHelp: "Scroll down a full page", help: "Scroll window [count] pages Forwards (downwards) in the buffer.", flags: vimperator.Mappings.flags.COUNT } @@ -984,7 +984,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], [""], function (count) { vimperator.buffer.pageInfo(false); }, { - short_help: "Print the current file name", + shortHelp: "Print the current file name", help: "Also shows some additional file information like file size or the last modified date. " + "If {count} is given print the current file name with full path.", flags: vimperator.Mappings.flags.COUNT @@ -993,7 +993,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["g"], function (count) { vimperator.buffer.pageInfo(true); }, { - short_help: "Print file information", + shortHelp: "Print file information", help: "Same as :pa[geinfo]." } )); @@ -1003,7 +1003,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], [""], function (count) { vimperator.history.stepTo(-(count > 1 ? count : 1)); }, { - short_help: "Go to an older position in the jump list", + shortHelp: "Go to an older position in the jump list", help: "The jump list is just the browser history for now.", flags: vimperator.Mappings.flags.COUNT } @@ -1011,7 +1011,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], [""], function (count) { vimperator.history.stepTo(count > 1 ? count : 1); }, { - short_help: "Go to a newer position in the jump list", + shortHelp: "Go to a newer position in the jump list", help: "The jump list is just the browser history for now.", flags: vimperator.Mappings.flags.COUNT } @@ -1019,7 +1019,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["H", "", ""], function (count) { vimperator.history.stepTo(-(count > 1 ? count : 1)); }, { - short_help: "Go back in the browser history", + shortHelp: "Go back in the browser history", help: "Count is supported: 3H goes back 3 steps.", flags: vimperator.Mappings.flags.COUNT } @@ -1027,7 +1027,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["L", "", ""], function (count) { vimperator.history.stepTo(count > 1 ? count : 1); }, { - short_help: "Go forward in the browser history", + shortHelp: "Go forward in the browser history", help: "Count is supported: 3L goes forward 3 steps.", flags: vimperator.Mappings.flags.COUNT } @@ -1065,7 +1065,7 @@ vimperator.Mappings = function () //{{{ vimperator.open(gocmd); }, { - short_help: "Go to parent directory", + shortHelp: "Go to parent directory", help: "Count is supported: 2gu on http://www.example.com/dir1/dir2/file.htm would open http://www.example.com/dir1/.", flags: vimperator.Mappings.flags.COUNT } @@ -1073,7 +1073,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["gU", ""], function () { vimperator.open("..."); }, { - short_help: "Go to the root of the website", + shortHelp: "Go to the root of the website", help: "gU on http://www.example.com/dir1/dir2/file.htm opens http://www.example.com/.
" + "When browsing a local directory, it goes to the root document." } @@ -1083,7 +1083,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["f"], function () { vimperator.hints.show(vimperator.modes.QUICK_HINT); }, { - short_help: "Start QuickHint mode", + shortHelp: "Start QuickHint mode", usage: ["f{hint}"], help: "In QuickHint mode, every hintable item (according to the 'hinttags' XPath query) is assigned a unique number (FIXME: numbers shown, but not usable yet).
" + "You can now either type this number or type any part of the URL which you want to follow, and it is followed as soon as it can be uniquely identified. " + @@ -1094,7 +1094,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["F"], function () { vimperator.hints.show(vimperator.modes.QUICK_HINT, "t"); }, { - short_help: "Start QuickHint mode, but open link in a new tab", + shortHelp: "Start QuickHint mode, but open link in a new tab", usage: ["F{hint}"], help: "Like normal QuickHint mode (activated with f) but opens the link in a new tab." } @@ -1102,7 +1102,7 @@ vimperator.Mappings = function () //{{{ // addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["F"], // function () { vimperator.echo("Always HINT mode not available anymore"); }, // { -// short_help: "Start AlwaysHint mode (CURRENTLY DISABLED)", +// shortHelp: "Start AlwaysHint mode (CURRENTLY DISABLED)", // help: "In AlwaysHint mode, every hintable item (according to the 'hinttags' XPath query) is assigned a label.
" + // "If you then press the keys for a label, it is followed as soon as it can be uniquely identified. Labels stay active after following a hint in this mode, press <Esc> to stop this mode.
" + // "This hint mode is especially useful for browsing large sites like Forums as hints are automatically regenerated when switching to a new document.
" + @@ -1120,7 +1120,7 @@ vimperator.Mappings = function () //{{{ vimperator.hints.show(vimperator.modes.EXTENDED_HINT, arg); }, { - short_help: "Start an extended hint mode", + shortHelp: "Start an extended hint mode", usage: [";{mode}{hint}"], help: "ExtendedHint mode is useful, since in this mode you can yank link locations, open them in a new window or save images.
" + "If you want to yank the location of hint 24, press ;y to start this hint mode. " + @@ -1155,7 +1155,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["/"], function () { vimperator.search.openSearchDialog(vimperator.modes.SEARCH_FORWARD); }, { - short_help: "Search forward for a pattern", + shortHelp: "Search forward for a pattern", usage: ["/{pattern}[/]"], help: "Search forward for the first occurrence of {pattern}.
" + "If \"\\c\" appears anywhere in the pattern the whole pattern is handled as though 'ignorecase' is on. " + @@ -1167,7 +1167,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["?"], function () { vimperator.search.openSearchDialog(vimperator.modes.SEARCH_BACKWARD); }, { - short_help: "Search backwards for a pattern", + shortHelp: "Search backwards for a pattern", usage: ["?{pattern}[?]"], help: "Search backward for the first occurrence of {pattern}.
" + "If \"\\c\" appears anywhere in the pattern the whole pattern is handled as though 'ignorecase' is on. " + @@ -1180,14 +1180,14 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["n"], function () { vimperator.search.findAgain(false); }, { - short_help: "Find next", + shortHelp: "Find next", help: "Repeat the last search 1 time (until count is supported)." } )); addDefaultMap(new vimperator.Map([vimperator.modes.NORMAL], ["N"], function () { vimperator.search.findAgain(true); }, { - short_help: "Find previous", + shortHelp: "Find previous", help: "Repeat the last search 1 time (until count is supported) in the opposite direction." } )); @@ -1200,64 +1200,64 @@ vimperator.Mappings = function () //{{{ // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], ["o"], // function () { vimperator.hints.openHints(false, false); }, // { -// cancel_mode: true, -// always_active: false +// cancelMode: true, +// alwaysActive: false // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], ["t"], // function () { vimperator.hints.openHints(true, false); }, // { -// cancel_mode: true, -// always_active: false +// cancelMode: true, +// alwaysActive: false // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [""], // function () { vimperator.hints.openHints(false, true ); }, // { -// cancel_mode: true, -// always_active: false +// cancelMode: true, +// alwaysActive: false // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], ["s"], // function () { vimperator.hints.saveHints(true); }, // { -// cancel_mode: true, -// always_active: false +// cancelMode: true, +// alwaysActive: false // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], ["a"], // function () { vimperator.hints.saveHints(false); }, // { -// cancel_mode: true, -// always_active: false +// cancelMode: true, +// alwaysActive: false // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], ["y"], // function () { vimperator.hints.yankUrlHints(); }, // { -// cancel_mode: true, -// always_active: false +// cancelMode: true, +// alwaysActive: false // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], ["Y"], // function () { vimperator.hints.yankTextHints(); }, // { -// cancel_mode: true, -// always_active: false +// cancelMode: true, +// alwaysActive: false // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [","], // function () { vimperator.input.buffer += ","; vimperator.hints.setCurrentState(0); }, // { -// cancel_mode: false, -// always_active: true +// cancelMode: false, +// alwaysActive: true // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [":"], // function () { vimperator.commandline.open(":", "", vimperator.modes.EX); }, // { -// cancel_mode: false, -// always_active: true +// cancelMode: false, +// alwaysActive: true // } // )); // @@ -1265,78 +1265,78 @@ vimperator.Mappings = function () //{{{ // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [""], // function (count) { vimperator.buffer.scrollLines(count > 1 ? count : 1); }, // { -// cancel_mode: false, -// always_active: true, +// cancelMode: false, +// alwaysActive: true, // flags: vimperator.Mappings.flags.COUNT // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [""], // function (count) { vimperator.buffer.scrollLines(-(count > 1 ? count : 1)); }, // { -// cancel_mode: false, -// always_active: true, +// cancelMode: false, +// alwaysActive: true, // flags: vimperator.Mappings.flags.COUNT // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [""], // function () { vimperator.buffer.scrollTop(); }, // { -// cancel_mode: false, -// always_active: true +// cancelMode: false, +// alwaysActive: true // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [""], // function () { vimperator.buffer.scrollBottom(); }, // { -// cancel_mode: false, -// always_active: true +// cancelMode: false, +// alwaysActive: true // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], ["", ""], // function (count) { vimperator.buffer.scrollPages(-(count > 1 ? count : 1)); }, // { -// cancel_mode: false, -// always_active: true, +// cancelMode: false, +// alwaysActive: true, // flags: vimperator.Mappings.flags.COUNT // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], ["", ""], // function (count) { vimperator.buffer.scrollPages(count > 1 ? count : 1); }, // { -// cancel_mode: false, -// always_active: true, +// cancelMode: false, +// alwaysActive: true, // flags: vimperator.Mappings.flags.COUNT // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [""], // function () { vimperator.buffer.scrollColumns(-(count > 1 ? count : 1)); }, // { -// cancel_mode: false, -// always_active: true, +// cancelMode: false, +// alwaysActive: true, // flags: vimperator.Mappings.flags.COUNT // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [""], // function () { vimperator.buffer.scrollLines(count > 1 ? count : 1); }, // { -// cancel_mode: false, -// always_active: true, +// cancelMode: false, +// alwaysActive: true, // flags: vimperator.Mappings.flags.COUNT // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [""], // function () { vimperator.buffer.scrollLines(-(count > 1 ? count : 1)); }, // { -// cancel_mode: false, -// always_active: true, +// cancelMode: false, +// alwaysActive: true, // flags: vimperator.Mappings.flags.COUNT // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [""], // function () { vimperator.buffer.scrollColumns(count > 1 ? count : 1); }, // { -// cancel_mode: false, -// always_active: true, +// cancelMode: false, +// alwaysActive: true, // flags: vimperator.Mappings.flags.COUNT // } // )); @@ -1345,15 +1345,15 @@ vimperator.Mappings = function () //{{{ // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [""], // function () { vimperator.tabs.select("+1", true); }, // { -// cancel_mode: true, -// always_active: true +// cancelMode: true, +// alwaysActive: true // } // )); // same as gt, but no count supported // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [""], // function () { vimperator.tabs.select("-1", true); }, // { -// cancel_mode: true, -// always_active: true +// cancelMode: true, +// alwaysActive: true // } // )); // @@ -1361,63 +1361,63 @@ vimperator.Mappings = function () //{{{ // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [""], // function (count) { vimperator.history.stepTo(count > 0 ? -count : -1); }, // { -// cancel_mode: false, -// always_active: true, +// cancelMode: false, +// alwaysActive: true, // flags: vimperator.Mappings.flags.COUNT // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [""], // function (count) { vimperator.history.stepTo(count > 1 ? count : 1); }, // { -// cancel_mode: false, -// always_active: true, +// cancelMode: false, +// alwaysActive: true, // flags: vimperator.Mappings.flags.COUNT // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [""], // function (count) { vimperator.history.stepTo(count > 0 ? -count : -1); }, // { -// cancel_mode: false, -// always_active: true, +// cancelMode: false, +// alwaysActive: true, // flags: vimperator.Mappings.flags.COUNT // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [""], // function (count) { vimperator.history.stepTo(count > 1 ? count : 1); }, // { -// cancel_mode: false, -// always_active: true, +// cancelMode: false, +// alwaysActive: true, // flags: vimperator.Mappings.flags.COUNT // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [""], // function () { vimperator.tabs.remove(getBrowser().mCurrentTab, vimperator.input.count, false, 0); }, // { -// cancel_mode: true, -// always_active: true +// cancelMode: true, +// alwaysActive: true // } // )); // -// // cancel_mode hint mode keys +// // cancelMode hint mode keys // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [""], // function () { ; }, // { -// cancel_mode: true, -// always_active: true +// cancelMode: true, +// alwaysActive: true // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [""], // function () { ; }, // { -// cancel_mode: true, -// always_active: true +// cancelMode: true, +// alwaysActive: true // } // )); // addDefaultMap(new vimperator.Map([vimperator.modes.HINTS], [""], // function () { ; }, // { -// cancel_mode: true, -// always_active: true +// cancelMode: true, +// alwaysActive: true // } // )); @@ -1436,7 +1436,7 @@ vimperator.Mappings = function () //{{{ addDefaultMap(new vimperator.Map([vimperator.modes.CARET, vimperator.modes.TEXTAREA], ["v"], function (count) { vimperator.modes.set(vimperator.modes.VISUAL, vimperator.mode); }, { - short_help: "Start visual mode", + shortHelp: "Start visual mode", help: "Works for caret mode and textarea mode." } )); diff --git a/content/modes.js b/content/modes.js index 56bc337c..1d149551 100644 --- a/content/modes.js +++ b/content/modes.js @@ -75,12 +75,12 @@ vimperator.modes = (function () // Usually you should only indicate to leave a special mode linke HINTS // by calling vimperator.modes.reset() and adding the stuff which is needed // for its cleanup here - function handleModeChange(oldmode, newmode) + function handleModeChange(oldMode, newMode) { // TODO: fix v.log() to work verbosity level - // vimperator.log("switching from mode " + oldmode + " to mode " + newmode, 7); + // vimperator.log("switching from mode " + oldMode + " to mode " + newMode, 7); - switch (oldmode) + switch (oldMode) { case vimperator.modes.TEXTAREA: case vimperator.modes.INSERT: @@ -88,7 +88,7 @@ vimperator.modes = (function () break; case vimperator.modes.VISUAL: - if (newmode == vimperator.modes.CARET) + if (newMode == vimperator.modes.CARET) { // clear any selection made var selection = window.content.getSelection(); @@ -111,7 +111,7 @@ vimperator.modes = (function () break; } - if (newmode == vimperator.modes.NORMAL) + if (newMode == vimperator.modes.NORMAL) { // XXX: why this code? var value = vimperator.options.getFirefoxPref("accessibility.browsewithcaret", false); @@ -169,21 +169,21 @@ vimperator.modes = (function () // helper function to set both modes in one go // if silent == true, you also need to take care of the mode handling changes yourself - set: function (main_mode, extended_mode, silent) + set: function (mainMode, extendedMode, silent) { // if a main mode is set, the extended is always cleared - if (typeof main_mode === "number") + if (typeof mainMode === "number") { - if (!silent && main_mode != main) - handleModeChange(main, main_mode); + if (!silent && mainMode != main) + handleModeChange(main, mainMode); - main = main_mode; - if (!extended_mode) + main = mainMode; + if (!extendedMode) extended = vimperator.modes.NONE; } - if (typeof extended_mode === "number") - extended = extended_mode; + if (typeof extendedMode === "number") + extended = extendedMode; if (!silent) this.show(); diff --git a/content/options.js b/content/options.js index 21bc1c48..f45ec960 100644 --- a/content/options.js +++ b/content/options.js @@ -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. }}} ***** END LICENSE BLOCK *****/ -vimperator.Option = function (names, type, extra_info) //{{{ +vimperator.Option = function (names, type, extraInfo) //{{{ { if (!names || !type) return null; @@ -38,29 +38,29 @@ vimperator.Option = function (names, type, extra_info) //{{{ this.usage = this.names; this.type = type; - if (extra_info) + if (extraInfo) { - if (extra_info.usage) - this.usage = extra_info.usage; + if (extraInfo.usage) + this.usage = extraInfo.usage; - this.help = extra_info.help || null; - this.short_help = extra_info.short_help || null; + this.help = extraInfo.help || null; + this.shortHelp = extraInfo.shortHelp || null; // "", 0 are valid default values - if (extra_info.default_value !== undefined) - this.default_value = extra_info.default_value; + if (extraInfo.defaultValue !== undefined) + this.defaultValue = extraInfo.defaultValue; else - this.default_value = null; + this.defaultValue = null; - value = this.default_value; + value = this.defaultValue; - if (extra_info.setter) - this.setter = extra_info.setter; - if (extra_info.getter) - this.getter = extra_info.getter; + if (extraInfo.setter) + this.setter = extraInfo.setter; + if (extraInfo.getter) + this.getter = extraInfo.getter; - this.completer = extra_info.completer || null; - this.validator = extra_info.validator || null; + this.completer = extraInfo.completer || null; + this.validator = extraInfo.validator || null; } // add noOPTION variant of boolean OPTION to this.names @@ -85,9 +85,9 @@ vimperator.Option = function (names, type, extra_info) //{{{ } ); this.__defineSetter__("value", - function (new_value) + function (newValue) { - value = new_value; + value = newValue; if (this.setter) this.setter.call(this, value); } @@ -116,7 +116,7 @@ vimperator.Option = function (names, type, extra_info) //{{{ this.reset = function () { - this.value = this.default_value; + this.value = this.defaultValue; }; }; //}}} @@ -126,13 +126,13 @@ vimperator.Options = function () //{{{ ////////////////////// PRIVATE SECTION ///////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - var firefox_prefs = Components.classes["@mozilla.org/preferences-service;1"] + var firefoxPrefs = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch); - var vimperator_prefs = firefox_prefs.getBranch("extensions.vimperator."); + var vimperatorPrefs = firefoxPrefs.getBranch("extensions.vimperator."); var options = []; // save if we already changed a GUI related option, used for setInitialGUI - var guioptions_done = false, showtabline_done = false, laststatus_done = false; + var guioptionsDone = false, showtablineDone = false, laststatusDone = false; function optionsIterator() { @@ -142,14 +142,14 @@ vimperator.Options = function () //{{{ throw StopIteration; } - function storePreference(name, value, vimperator_branch) + function storePreference(name, value, vimperatorBranch) { var branch; - if (vimperator_branch) - branch = vimperator_prefs; + if (vimperatorBranch) + branch = vimperatorPrefs; else - branch = firefox_prefs; + branch = firefoxPrefs; switch (typeof value) { @@ -167,23 +167,23 @@ vimperator.Options = function () //{{{ } } - function loadPreference(name, forced_default, vimperator_branch) + function loadPreference(name, forcedDefault, vimperatorBranch) { - var default_value = null; - if (forced_default != null) // this argument sets defaults for non-user settable options (like comp_history) - default_value = forced_default; + var defaultValue = null; + if (forcedDefault != null) // this argument sets defaults for non-user settable options (like comp_history) + defaultValue = forcedDefault; - if (vimperator_branch) + if (vimperatorBranch) { - branch = vimperator_prefs; + branch = vimperatorPrefs; - if (!forced_default) // this argument sets defaults for non-user settable options (like comp_history) + if (!forcedDefault) // this argument sets defaults for non-user settable options (like comp_history) { for (var i = 0; i < options.length; i++) { if (options[i].name == name) // only first name is searched { - default_value = options[i].default_value; + defaultValue = options[i].defaultValue; break; } } @@ -191,12 +191,12 @@ vimperator.Options = function () //{{{ } else { - branch = firefox_prefs; + branch = firefoxPrefs; } try { - switch (typeof default_value) + switch (typeof defaultValue) { case "string": return branch.getCharPref(name); @@ -205,12 +205,12 @@ vimperator.Options = function () //{{{ case "boolean": return branch.getBoolPref(name); default: - return default_value; + return defaultValue; } } catch (e) { - return default_value; + return defaultValue; } } @@ -226,7 +226,7 @@ vimperator.Options = function () //{{{ document.getElementById("PersonalToolbar").collapsed = value.indexOf("b") > -1 ? false : true; document.getElementById("PersonalToolbar").hidden = value.indexOf("b") > -1 ? false : true; - guioptions_done = true; + guioptionsDone = true; } function setLastStatus(value) @@ -246,7 +246,7 @@ vimperator.Options = function () //{{{ document.getElementById("status-bar").hidden = false; } - laststatus_done = true; + laststatusDone = true; } function setShowTabline(value) @@ -270,7 +270,7 @@ vimperator.Options = function () //{{{ tabs.collapsed = false; } - showtabline_done = true; + showtablineDone = true; } function setTitleString(value) @@ -297,9 +297,9 @@ vimperator.Options = function () //{{{ // // work around firefox popup blocker - var popup_allowed_events = loadPreference("dom.popup_allowed_events", "change click dblclick mouseup reset submit"); - if (!/keypress/.test(popup_allowed_events)) - storePreference("dom.popup_allowed_events", popup_allowed_events + " keypress"); + var popupAllowedEvents = loadPreference("dom.popup_allowed_events", "change click dblclick mouseup reset submit"); + if (!/keypress/.test(popupAllowedEvents)) + storePreference("dom.popup_allowed_events", popupAllowedEvents + " keypress"); // TODO: shouldn't we be resetting these in destroy() as well? // we have our own typeahead find implementation @@ -341,11 +341,11 @@ vimperator.Options = function () //{{{ { // reset some modified firefox prefs if (loadPreference("dom.popup_allowed_events", "change click dblclick mouseup reset submit") - == popup_allowed_events + " keypress") - storePreference("dom.popup_allowed_events", popup_allowed_events); + == popupAllowedEvents + " keypress") + storePreference("dom.popup_allowed_events", popupAllowedEvents); }, - list: function (only_non_default) + list: function (onlyNondefault) { // TODO: columns like Vim? var list = ":" + vimperator.util.escapeHTML(vimperator.commandline.getCommand()) + "
" + @@ -356,9 +356,9 @@ vimperator.Options = function () //{{{ { name = options[i].name; value = options[i].value; - def = options[i].default_value; + def = options[i].defaultValue; - if (only_non_default && value == def) + if (onlyNondefault && value == def) continue; if (options[i].type == "boolean") @@ -390,11 +390,11 @@ vimperator.Options = function () //{{{ // this hack is only needed, because we need to do asynchronous loading of the .vimperatorrc setInitialGUI: function () { - if (!guioptions_done) + if (!guioptionsDone) this.get("guioptions").reset(); - if (!laststatus_done) + if (!laststatusDone) this.get("laststatus").reset(); - if (!showtabline_done) + if (!showtablineDone) this.get("showtabline").reset(); }, @@ -405,9 +405,9 @@ vimperator.Options = function () //{{{ return storePreference(name, value, true); }, - getPref: function (name, forced_default) + getPref: function (name, forcedDefault) { - return loadPreference(name, forced_default, true); + return loadPreference(name, forcedDefault, true); }, setFirefoxPref: function (name, value) @@ -415,9 +415,9 @@ vimperator.Options = function () //{{{ return storePreference(name, value); }, - getFirefoxPref: function (name, forced_default) + getFirefoxPref: function (name, forcedDefault) { - return loadPreference(name, forced_default); + return loadPreference(name, forcedDefault); } }; @@ -433,7 +433,7 @@ vimperator.Options = function () //{{{ optionManager.add(new vimperator.Option(["activate", "act"], "stringlist", { - short_help: "Define when tabs are automatically activated", + shortHelp: "Define when tabs are automatically activated", help: "Available items:
" + "
    " + "
  • homepage: gH mapping
  • " + @@ -441,7 +441,7 @@ vimperator.Options = function () //{{{ "
  • tabopen: :tabopen[!] command
  • " + "
  • paste: P and gP mappings
  • " + "
", - default_value: "homepage,quickmark,tabopen,paste", + defaultValue: "homepage,quickmark,tabopen,paste", validator: function (value) { return value.split(",").every(function (item) { return /^(homepage|quickmark|tabopen|paste|)$/.test(item); }); @@ -450,7 +450,7 @@ vimperator.Options = function () //{{{ )); optionManager.add(new vimperator.Option(["complete", "cpt"], "charlist", { - short_help: "Items which are completed at the :[tab]open prompt", + shortHelp: "Items which are completed at the :[tab]open prompt", help: "Available items:
" + "
    " + "
  • s: Search engines and keyword URLs
  • " + @@ -460,52 +460,52 @@ vimperator.Options = function () //{{{ "
" + "The order is important, so :set complete=bs would list bookmarks first, and then any available quick searches.
" + "Add 'sort' to the 'wildoptions' option if you want all entries sorted.", - default_value: "sfbh", + defaultValue: "sfbh", validator: function (value) { return !/[^sfbh]/.test(value); } } )); optionManager.add(new vimperator.Option(["defsearch", "ds"], "string", { - short_help: "Set the default search engine", + shortHelp: "Set the default search engine", help: "The default search engine is used in the :[tab]open [arg] command " + "if [arg] neither looks like a URL or like a specified search engine/keyword.", - default_value: "google" + defaultValue: "google" } )); optionManager.add(new vimperator.Option(["editor"], "string", { - short_help: "Set the external text editor", + shortHelp: "Set the external text editor", help: "Sets the editor to run when <C-i> " + "is pressed in INSERT and TEXTAREA modes. Note that Vimperator will " + "not behave correctly if the editor forks its own process, such as with "+ "gvim without the -f argument.", - default_value: "gvim -f" + defaultValue: "gvim -f" } )); optionManager.add(new vimperator.Option(["extendedhinttags", "eht"], "string", { - short_help: "XPath string of hintable elements activated by ';'", - default_value: DEFAULT_HINTTAGS + shortHelp: "XPath string of hintable elements activated by ';'", + defaultValue: DEFAULT_HINTTAGS } )); optionManager.add(new vimperator.Option(["focusedhintstyle", "fhs"], "string", { - short_help: "CSS specification of focused hints", - default_value: "z-index:5000; font-family:monospace; font-size:12px; color:ButtonText; background-color:ButtonShadow; " + + shortHelp: "CSS specification of focused hints", + defaultValue: "z-index:5000; font-family:monospace; font-size:12px; color:ButtonText; background-color:ButtonShadow; " + "border-color:ButtonShadow; border-width:1px; border-style:solid; padding:0px 1px 0px 1px; position:absolute;" } )); optionManager.add(new vimperator.Option(["fullscreen", "fs"], "boolean", { - short_help: "Show the current window fullscreen", + shortHelp: "Show the current window fullscreen", setter: function (value) { window.fullScreen = value; }, getter: function () { return window.fullScreen; }, - default_value: false + defaultValue: false } )); optionManager.add(new vimperator.Option(["guioptions", "go"], "charlist", { - short_help: "Show or hide the menu, toolbar and scrollbars", + shortHelp: "Show or hide the menu, toolbar and scrollbars", help: "Supported characters:
" + "
    " + "
  • m: menubar
  • " + @@ -513,68 +513,68 @@ vimperator.Options = function () //{{{ "
  • b: bookmark bar
  • " + "
", setter: function (value) { setGuiOptions(value); }, - default_value: "", + defaultValue: "", validator: function (value) { return !/[^mTb]/.test(value); } } )); optionManager.add(new vimperator.Option(["hinttimeout", "hto"], "number", { - short_help: "Automatically follow non unique numerical hint after {arg} ms", + shortHelp: "Automatically follow non unique numerical hint after {arg} ms", help: "Set to 0 (the default) to only follow numeric hints after pressing <Return> or when the hint is unique.", - default_value: 0, + defaultValue: 0, validator: function (value) { return value >= 0; } } )); optionManager.add(new vimperator.Option(["hintstyle", "hs"], "string", { - short_help: "CSS specification of unfocused hints", - default_value: "z-index:5000; font-family:monospace; font-size:12px; color:white; background-color:red; " + + shortHelp: "CSS specification of unfocused hints", + defaultValue: "z-index:5000; font-family:monospace; font-size:12px; color:white; background-color:red; " + "border-color:ButtonShadow; border-width:0px; border-style:solid; padding:0px 1px 0px 1px; position:absolute;" } )); optionManager.add(new vimperator.Option(["hinttags", "ht"], "string", { - short_help: "XPath string of hintable elements activated by 'f' and 'F'", - default_value: DEFAULT_HINTTAGS + shortHelp: "XPath string of hintable elements activated by 'f' and 'F'", + defaultValue: DEFAULT_HINTTAGS } )); optionManager.add(new vimperator.Option(["hlsearch", "hls"], "boolean", { - short_help: "Highlight previous search pattern matches", + shortHelp: "Highlight previous search pattern matches", setter: function (value) { if (value) vimperator.search.highlight(); else vimperator.search.clear(); }, - default_value: false + defaultValue: false } )); optionManager.add(new vimperator.Option(["hlsearchstyle", "hlss"], "string", { - short_help: "CSS specification of highlighted search items", - default_value: "color: black; background-color: yellow; padding: 0; display: inline;" + shortHelp: "CSS specification of highlighted search items", + defaultValue: "color: black; background-color: yellow; padding: 0; display: inline;" } )); optionManager.add(new vimperator.Option(["ignorecase", "ic"], "boolean", { - short_help: "Ignore case in search patterns", - default_value: true + shortHelp: "Ignore case in search patterns", + defaultValue: true } )); optionManager.add(new vimperator.Option(["incsearch", "is"], "boolean", { - short_help: "Show where the search pattern matches as it is typed", + shortHelp: "Show where the search pattern matches as it is typed", help: "NOTE: Incremental searching currently only works in the forward direction.", - default_value: true + defaultValue: true } )); optionManager.add(new vimperator.Option(["insertmode", "im"], "boolean", { - short_help: "Use Insert mode as the default for text areas", + shortHelp: "Use Insert mode as the default for text areas", help: "Makes Vimperator work in a way that Insert mode is the default mode for text areas. " + "Useful if you want to use Vimperator as a modeless editor, keeping the known Firefox interface for editing text areas.", - default_value: true + defaultValue: true } )); optionManager.add(new vimperator.Option(["laststatus", "ls"], "number", { - short_help: "Show the status line", + shortHelp: "Show the status line", help: "Determines when the last window will have a status line. " + "Possible values:
" + "
    " + @@ -583,27 +583,27 @@ vimperator.Options = function () //{{{ "
  • 2: always
  • " + "
" + "NOTE: laststatus=1 not implemented yet.", - default_value: 2, + defaultValue: 2, setter: function (value) { setLastStatus(value); }, validator: function (value) { return (value >= 0 && value <= 2); } } )); optionManager.add(new vimperator.Option(["linksearch", "lks"], "boolean", { - short_help: "Limit the search to hyperlink text", + shortHelp: "Limit the search to hyperlink text", help: "This includes (X)HTML elements with an \"href\" atrribute and XLink \"simple\" links.", - default_value: false + defaultValue: false } )); optionManager.add(new vimperator.Option(["more"], "boolean", { - short_help: "Pause the message list window when more than one screen of listings is displayed", - default_value: true + shortHelp: "Pause the message list window when more than one screen of listings is displayed", + defaultValue: true } )); optionManager.add(new vimperator.Option(["pageinfo", "pa"], "charlist", { - short_help: "Desired info on :pa[geinfo]", + shortHelp: "Desired info on :pa[geinfo]", help: "Available items:
" + "
    " + "
  • g: general info
  • " + @@ -611,13 +611,13 @@ vimperator.Options = function () //{{{ "
  • m: meta tags
  • " + "
" + "The order matters", - default_value: "gfm", + defaultValue: "gfm", validator: function (value) { return !(/[^gfm]/.test(value) || value.length > 3 || value.length < 1); } } )); optionManager.add(new vimperator.Option(["popups", "pps"], "number", { - short_help: "Where to show requested popup windows", + shortHelp: "Where to show requested popup windows", help: "Define where to show requested popup windows. Does not apply to windows which are opened by middle clicking a link, they always open in a new tab. " + "Possible values:
" + "
    " + @@ -627,48 +627,48 @@ vimperator.Options = function () //{{{ "
  • 3: Always open in a new window
  • " + "
" + "NOTE: This option does not change the popup blocker of Firefox in any way.", - default_value: 1, + defaultValue: 1, setter: function (value) { setPopups(value); }, validator: function (value) { return (value >= 0 && value <= 3); } } )); optionManager.add(new vimperator.Option(["preload"], "boolean", { - short_help: "Speed up first time history/bookmark completion", + shortHelp: "Speed up first time history/bookmark completion", help: "History access can be quite slow for a large history. Vimperator maintains a cache to speed it up significantly on subsequent access.
" + "In order to also speed up first time access, it is cached at startup, if this option is set (recommended).", - default_value: true + defaultValue: true } )); optionManager.add(new vimperator.Option(["previewheight", "pvh"], "number", { - short_help: "Default height for preview window", + shortHelp: "Default height for preview window", help: "Value must be between 1 and 50. If the value is too high, completions may cover the command-line. " + "Close the preview window with :pclose.
" + "NOTE: Option currently disabled", - default_value: 10, + defaultValue: 10, validator: function (value) { return (value >= 1 && value <= 50); } } )); optionManager.add(new vimperator.Option(["scroll", "scr"], "number", { - short_help: "Number of lines to scroll with C-u and C-d commands", + shortHelp: "Number of lines to scroll with C-u and C-d commands", help: "The number of lines scrolled defaults to half the window size. " + "When a {count} is specified to the <C-u> or <C-d> commands this is used to set the value of 'scroll' and also used for the current command. " + "The value can be reset to half the window height with :set scroll=0.", - default_value: 0, + defaultValue: 0, validator: function (value) { return value >= 0; } } )); optionManager.add(new vimperator.Option(["showmode", "smd"], "boolean", { - short_help: "Show the current mode in the command line", - default_value: true + shortHelp: "Show the current mode in the command line", + defaultValue: true } )); optionManager.add(new vimperator.Option(["showstatuslinks", "ssli"], "number", { - short_help: "Show the destination of the link under the cursor in the status bar", + shortHelp: "Show the destination of the link under the cursor in the status bar", help: "Also links which are focused by keyboard commands like <Tab> are shown. " + "Possible values:
" + "
    " + @@ -676,13 +676,13 @@ vimperator.Options = function () //{{{ "
  • 1: Show the link in the status line
  • " + "
  • 2: Show the link in the command line
  • " + "
", - default_value: 1, + defaultValue: 1, validator: function (value) { return (value >= 0 && value <= 2); } } )); optionManager.add(new vimperator.Option(["showtabline", "stal"], "number", { - short_help: "Control when to show the tab bar of opened web pages", + shortHelp: "Control when to show the tab bar of opened web pages", help: "Possible values:
" + "
    " + "
  • 0: Never show tab bar
  • " + @@ -690,55 +690,55 @@ vimperator.Options = function () //{{{ "
  • 2: Always show tab bar
  • " + "
", setter: function (value) { setShowTabline(value); }, - default_value: 2, + defaultValue: 2, validator: function (value) { return (value >= 0 && value <= 2); } } )); optionManager.add(new vimperator.Option(["smartcase", "scs"], "boolean", { - short_help: "Override the 'ignorecase' option if the pattern contains uppercase characters", + shortHelp: "Override the 'ignorecase' option if the pattern contains uppercase characters", help: "This is only used if the 'ignorecase' option is set.", - default_value: true + defaultValue: true } )); optionManager.add(new vimperator.Option(["titlestring"], "string", { - short_help: "Change the title of the browser window", + shortHelp: "Change the title of the browser window", help: "Vimperator changes the browser title from \"Title of web page - Mozilla Firefox\" to " + "\"Title of web page - Vimperator\".
If you don't like that, you can restore it with: " + ":set titlestring=Mozilla Firefox.", setter: function (value) { setTitleString(value); }, - default_value: "Vimperator" + defaultValue: "Vimperator" } )); optionManager.add(new vimperator.Option(["usermode", "um"], "boolean", { - short_help: "Show current website with a minimal style sheet to make it easily accessible", + shortHelp: "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 :setlocal part", setter: function (value) { getMarkupDocumentViewer().authorStyleDisabled = value; }, getter: function () { return getMarkupDocumentViewer().authorStyleDisabled; }, - default_value: false + defaultValue: false } )); optionManager.add(new vimperator.Option(["verbose", "vbs"], "number", { - short_help: "Define which type of messages are logged", + shortHelp: "Define which type of messages are logged", 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 :javascript!.
" + "The highest value is 9, being the most verbose mode.", - default_value: 0, + defaultValue: 0, validator: function (value) { return (value >= 0 && value <= 9); } } )); optionManager.add(new vimperator.Option(["visualbell", "vb"], "boolean", { - short_help: "Use visual bell instead of beeping on errors", + shortHelp: "Use visual bell instead of beeping on errors", setter: function (value) { vimperator.options.setFirefoxPref("accessibility.typeaheadfind.enablesound", !value); }, - default_value: false + defaultValue: false } )); optionManager.add(new vimperator.Option(["wildmode", "wim"], "stringlist", { - short_help: "Define how command line completion works", + shortHelp: "Define how command line completion works", help: "It is a comma-separated list of parts, where each part specifies " + "what to do for each consecutive use of the completion key. The first part " + "specifies the behavior for the first use of the completion key, the second part " + @@ -753,7 +753,7 @@ vimperator.Options = function () //{{{ "'list:longest'When more than one match, list all matches and complete till the longest common string." + "" + "When there is only a single match, it is fully completed regardless of the case.", - default_value: "list:full", + defaultValue: "list:full", validator: function (value) { return value.split(",").every(function (item) { return /^(full|longest|list|list:full|list:longest|)$/.test(item); }); @@ -762,30 +762,30 @@ vimperator.Options = function () //{{{ )); optionManager.add(new vimperator.Option(["wildoptions", "wop"], "stringlist", { - short_help: "Change how command line completion is done", + shortHelp: "Change how command line completion is done", help: "A list of words that change how command line completion is done.
" + "Currently only one word is allowed:
" + "" + "" + "
sortAlways sorts completion list, overriding the 'complete' option.
", - default_value: "", + defaultValue: "", validator: function (value) { return /^(sort|)$/.test(value); } } )); optionManager.add(new vimperator.Option(["nextpattern"], "stringlist", { - short_help: "String to search when looking for 'next' page in document relation", + shortHelp: "String to search when looking for 'next' page in document relation", help: "Change it to make it look for another string in links when pressing ]n
" + "This value is case insensitive", - default_value: "\\bnext,^>$" + defaultValue: "\\bnext,^>$" } )); optionManager.add(new vimperator.Option(["previouspattern"], "stringlist", { - short_help: "String to search when looking for 'prev' page in document relation", + shortHelp: "String to search when looking for 'prev' page in document relation", help: "Change it to make it look for another string in links when pressing ]p
" + "This value is case insensitive", - default_value: "\\bprev,previous\\b,^<$" + defaultValue: "\\bprev,previous\\b,^<$" } )); //}}} @@ -795,7 +795,7 @@ vimperator.Options = function () //{{{ setShowTabline(0); setGuiOptions(""); setLastStatus(0); - guioptions_done = showtabline_done = laststatus_done = false; + guioptionsDone = showtablineDone = laststatusDone = false; setTitleString(optionManager.titlestring); setPopups(optionManager.popups); diff --git a/content/tabs.js b/content/tabs.js index aab8d792..cb5ef4e5 100644 --- a/content/tabs.js +++ b/content/tabs.js @@ -145,9 +145,9 @@ vimperator.Tabs = function () //{{{ getBrowser().moveTabTo(tab, index); }, - // quit_on_last_tab = 1: quit without saving session - // quit_on_last_tab = 2: quit and save session - remove: function (tab, count, focus_left_tab, quit_on_last_tab) + // quitOnLastTab = 1: quit without saving session + // quitOnLastTab = 2: quit and save session + remove: function (tab, count, focusLeftTab, quitOnLastTab) { function removeOrBlankTab (tab) { @@ -169,26 +169,26 @@ vimperator.Tabs = function () //{{{ if (count < 1) count = 1; - if (quit_on_last_tab >= 1 && getBrowser().mTabs.length <= count) + if (quitOnLastTab >= 1 && getBrowser().mTabs.length <= count) { if (vimperator.windows.length > 1) window.close(); else - vimperator.quit(quit_on_last_tab == 2); + vimperator.quit(quitOnLastTab == 2); return; } var index = this.index(tab); - if (focus_left_tab) + if (focusLeftTab) { - var last_removed_tab = 0; + var lastRemovedTab = 0; for (var i = index; i > index - count && i >= 0; i--) { removeOrBlankTab(this.getTab(i)); - last_removed_tab = i > 0 ? i : 1; + lastRemovedTab = i > 0 ? i : 1; } - getBrowser().mTabContainer.selectedIndex = last_removed_tab - 1; + getBrowser().mTabContainer.selectedIndex = lastRemovedTab - 1; } else { @@ -226,9 +226,9 @@ vimperator.Tabs = function () //{{{ alternates = [this.getTab(), alternates[0]]; }, - reload: function (tab, bypass_cache) + reload: function (tab, bypassCache) { - if (bypass_cache) + if (bypassCache) { const nsIWebNavigation = Components.interfaces.nsIWebNavigation; const flags = nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE; @@ -240,15 +240,15 @@ vimperator.Tabs = function () //{{{ } }, - reloadAll: function (bypass_cache) + reloadAll: function (bypassCache) { - if (bypass_cache) + if (bypassCache) { for (var i = 0; i < getBrowser().mTabs.length; i++) { try { - this.reload(getBrowser().mTabs[i], bypass_cache); + this.reload(getBrowser().mTabs[i], bypassCache); } catch (e) { diff --git a/content/ui.js b/content/ui.js index d8e75f11..7ca37211 100644 --- a/content/ui.js +++ b/content/ui.js @@ -37,9 +37,10 @@ vimperator.CommandLine = function () //{{{ //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ + const UNINITIALIZED = -2; // notifies us, if we need to start history/tab-completion from the beginning - var completionlist = new vimperator.InformationList("vimperator-completion", { min_items: 2, max_items: 10 }); + var completionlist = new vimperator.InformationList("vimperator-completion", { minItems: 2, maxItems: 10 }); var completions = []; // TODO: clean this up when it's not 3am... @@ -87,75 +88,75 @@ vimperator.CommandLine = function () //{{{ }; history.load(); - var history_index = UNINITIALIZED; - var history_start = ""; + var historyIndex = UNINITIALIZED; + var historyStart = ""; // for the example command "open sometext| othertext" (| is the cursor pos): - var completion_start_index = 0; // will be 5 because we want to complete arguments for the :open command - var completion_prefix = ""; // will be: "open sometext" - var completion_postfix = ""; // will be: " othertext" + var completionStartIndex = 0; // will be 5 because we want to complete arguments for the :open command + var completionPrefix = ""; // will be: "open sometext" + var completionPostfix = ""; // will be: " othertext" - var wild_index = 0; // keep track how often we press in a row - var completion_index = UNINITIALIZED; + var wildIndex = 0; // keep track how often we press in a row + var completionIndex = UNINITIALIZED; - // the containing box for the prompt_widget and command_widget - var commandline_widget = document.getElementById("vimperator-commandline"); + // the containing box for the promptWidget and commandWidget + var commandlineWidget = document.getElementById("vimperator-commandline"); // the prompt for the current command, for example : or /. Can be blank - var prompt_widget = document.getElementById("vimperator-commandline-prompt"); + var promptWidget = document.getElementById("vimperator-commandline-prompt"); // the command bar which contains the current command - var command_widget = document.getElementById("vimperator-commandline-command"); + var commandWidget = document.getElementById("vimperator-commandline-command"); // the widget used for multiline output - var multiline_output_widget = document.getElementById("vimperator-multiline-output"); - multiline_output_widget.contentDocument.body.setAttribute("style", "margin: 0px; font-family: -moz-fixed;"); // get rid of the default border - multiline_output_widget.contentDocument.body.innerHTML = ""; + var multilineOutputWidget = document.getElementById("vimperator-multiline-output"); + multilineOutputWidget.contentDocument.body.setAttribute("style", "margin: 0px; font-family: -moz-fixed;"); // get rid of the default border + multilineOutputWidget.contentDocument.body.innerHTML = ""; // the widget used for multiline intput - var multiline_input_widget = document.getElementById("vimperator-multiline-input"); + var multilineInputWidget = document.getElementById("vimperator-multiline-input"); // we need to save the mode which were in before opening the command line // this is then used if we focus the command line again without the "official" // way of calling "open" - var cur_extended_mode = null; // the extended mode which we last openend the command line for - var cur_prompt = null; - var cur_command = null; - var old_mode = null; // when we leave the command prompt this mode is restored - var old_extended_mode = null; + var currentExtendedMode = null; // the extended mode which we last openend the command line for + var currentPrompt = null; + var currentCommand = null; + var oldMode = null; // when we leave the command prompt this mode is restored + var oldExtendedMode = null; // save the arguments for the inputMultiline method which are needed in the event handler - var multiline_regexp = null; - var multiline_callback = null; + var multilineRegexp = null; + var multilineCallback = null; function setHighlightGroup(group) { - commandline_widget.setAttribute("class", group); + commandlineWidget.setAttribute("class", group); } // sets the prompt - for example, : or / function setPrompt(pmt) { - prompt_widget.value = pmt; + promptWidget.value = pmt; if (pmt) { - prompt_widget.size = pmt.length; - prompt_widget.collapsed = false; + promptWidget.size = pmt.length; + promptWidget.collapsed = false; } else { - prompt_widget.collapsed = true; + promptWidget.collapsed = true; } } // sets the command - e.g. 'tabopen', 'open http://example.com/' function setCommand(cmd) { - command_widget.value = cmd; + commandWidget.value = cmd; } - function setLine(str, highlight_group) + function setLine(str, highlightGroup) { - setHighlightGroup(highlight_group); + setHighlightGroup(highlightGroup); setPrompt(""); setCommand(str); } @@ -163,55 +164,55 @@ vimperator.CommandLine = function () //{{{ // TODO: extract CSS // : resize upon a window resize // : echoed lines longer than v-c-c.width should wrap and use MOW - function setMultiline(str, highlight_group) + function setMultiline(str, highlightGroup) { - multiline_input_widget.collapsed = true; + multilineInputWidget.collapsed = true; - var output = "
" + str + "
"; - if (!multiline_output_widget.collapsed) + var output = "
" + str + "
"; + if (!multilineOutputWidget.collapsed) { // FIXME: need to make sure an open MOW is closed when commands // that don't generate output are executed - output = multiline_output_widget.contentDocument.body.innerHTML + output; - multiline_output_widget.collapsed = true; + output = multilineOutputWidget.contentDocument.body.innerHTML + output; + multilineOutputWidget.collapsed = true; } - var font_size = document.defaultView.getComputedStyle(document.getElementById("main-window"), null).getPropertyValue("font-size"); - multiline_output_widget.contentDocument.body.setAttribute("style", "font-size: " + font_size); + var fontSize = document.defaultView.getComputedStyle(document.getElementById("main-window"), null).getPropertyValue("font-size"); + multilineOutputWidget.contentDocument.body.setAttribute("style", "font-size: " + fontSize); - multiline_output_widget.contentDocument.body.innerHTML = output; - multiline_output_widget.contentDocument.body.id = "vimperator-multiline-output-content"; + multilineOutputWidget.contentDocument.body.innerHTML = output; + multilineOutputWidget.contentDocument.body.id = "vimperator-multiline-output-content"; - var stylesheet = multiline_output_widget.contentDocument.createElement("link"); + var stylesheet = multilineOutputWidget.contentDocument.createElement("link"); stylesheet.setAttribute("rel", "Stylesheet"); stylesheet.setAttribute("href", "chrome://vimperator/skin/vimperator.css"); - multiline_output_widget.contentDocument.getElementsByTagName("head")[0].appendChild(stylesheet); + multilineOutputWidget.contentDocument.getElementsByTagName("head")[0].appendChild(stylesheet); - var available_height = getBrowser().mPanelContainer.boxObject.height; - var content_height = multiline_output_widget.contentDocument.height; - var height = content_height < available_height ? content_height : available_height; + var availableHeight = getBrowser().mPanelContainer.boxObject.height; + var contentHeight = multilineOutputWidget.contentDocument.height; + var height = contentHeight < availableHeight ? contentHeight : availableHeight; - multiline_output_widget.height = height + "px"; - multiline_output_widget.collapsed = false; + multilineOutputWidget.height = height + "px"; + multilineOutputWidget.collapsed = false; - if (vimperator.options["more"] && multiline_output_widget.contentWindow.scrollMaxY > 0) + if (vimperator.options["more"] && multilineOutputWidget.contentWindow.scrollMaxY > 0) { // start the last executed command's output at the top of the screen - var elements = multiline_output_widget.contentDocument.getElementsByClassName("ex-command-output"); + var elements = multilineOutputWidget.contentDocument.getElementsByClassName("ex-command-output"); elements[elements.length - 1].scrollIntoView(true); - if (multiline_output_widget.contentWindow.scrollY >= multiline_output_widget.contentWindow.scrollMaxY) + if (multilineOutputWidget.contentWindow.scrollY >= multilineOutputWidget.contentWindow.scrollMaxY) setLine("Press ENTER or type command to continue", vimperator.commandline.HL_QUESTION); else setLine("-- More --", vimperator.commandline.HL_QUESTION); } else { - multiline_output_widget.contentWindow.scrollTo(0, content_height); + multilineOutputWidget.contentWindow.scrollTo(0, contentHeight); setLine("Press ENTER or type command to continue", vimperator.commandline.HL_QUESTION); } - multiline_output_widget.contentWindow.focus(); + multilineOutputWidget.contentWindow.focus(); vimperator.modes.set(vimperator.modes.COMMAND_LINE, vimperator.modes.OUTPUT_MULTILINE); } @@ -221,7 +222,7 @@ vimperator.CommandLine = function () //{{{ // XXX: faster/better method? var lines = 0; - var str = multiline_input_widget.value; + var str = multilineInputWidget.value; for (var i = 0; i < str.length; i++) { if (str[i] == "\n") @@ -229,7 +230,7 @@ vimperator.CommandLine = function () //{{{ } if (lines == 0) lines = 1; - multiline_input_widget.setAttribute("rows", lines.toString()); + multilineInputWidget.setAttribute("rows", lines.toString()); } /////////////////////////////////////////////////////////////////////////////}}} @@ -255,35 +256,35 @@ vimperator.CommandLine = function () //{{{ getCommand: function () { - return command_widget.value; + return commandWidget.value; }, - open: function (prompt, cmd, ext_mode) + open: function (prompt, cmd, extendedMode) { // save the current prompts, we need it later if the command widget // receives focus without calling the this.open() method - cur_prompt = prompt || ""; - cur_command = cmd || ""; - cur_extended_mode = ext_mode || null; + currentPrompt = prompt || ""; + currentCommand = cmd || ""; + currentExtendedMode = extendedMode || null; - history_index = UNINITIALIZED; - completion_index = UNINITIALIZED; + historyIndex = UNINITIALIZED; + completionIndex = UNINITIALIZED; // save the mode, because we need to restore it - old_mode = vimperator.mode; - old_extended_mode = vimperator.mode.extended; - vimperator.modes.set(vimperator.modes.COMMAND_LINE, cur_extended_mode); + oldMode = vimperator.mode; + oldExtendedMode = vimperator.mode.extended; + vimperator.modes.set(vimperator.modes.COMMAND_LINE, currentExtendedMode); setHighlightGroup(this.HL_NORMAL); - setPrompt(cur_prompt); - setCommand(cur_command); + setPrompt(currentPrompt); + setCommand(currentCommand); - command_widget.focus(); + commandWidget.focus(); }, // normally used when pressing esc, does not execute a command close: function () { - var res = vimperator.triggerCallback("cancel", cur_extended_mode); + var res = vimperator.triggerCallback("cancel", currentExtendedMode); history.add(this.getCommand()); vimperator.statusline.updateProgress(""); // we may have a "match x of y" visible this.clear(); @@ -291,8 +292,8 @@ vimperator.CommandLine = function () //{{{ clear: function () { - multiline_input_widget.collapsed = true; - multiline_output_widget.collapsed = true; + multilineInputWidget.collapsed = true; + multilineOutputWidget.collapsed = true; completionlist.hide(); setLine("", this.HL_NORMAL); @@ -300,20 +301,20 @@ vimperator.CommandLine = function () //{{{ // TODO: add :messages entry // vimperator.echo uses different order of flags as it omits the hightlight group, change v.commandline.echo argument order? --mst - echo: function (str, highlight_group, flags) + echo: function (str, highlightGroup, flags) { var focused = document.commandDispatcher.focusedElement; - if (focused && focused == command_widget.inputField || focused == multiline_input_widget.inputField) + if (focused && focused == commandWidget.inputField || focused == multilineInputWidget.inputField) return false; - highlight_group = highlight_group || this.HL_NORMAL; + highlightGroup = highlightGroup || this.HL_NORMAL; var where = setLine; if (flags & this.FORCE_MULTILINE) where = setMultiline; else if (flags & this.FORCE_SINGLELINE) where = setLine; - else if (!multiline_output_widget.collapsed) + else if (!multilineOutputWidget.collapsed) { if (flags & this.DISALLOW_MULTILINE) where = null; @@ -324,9 +325,9 @@ vimperator.CommandLine = function () //{{{ where = setMultiline; if (where) - where(str, highlight_group); + where(str, highlightGroup); - cur_extended_mode = null; + currentExtendedMode = null; return true; }, @@ -338,29 +339,29 @@ vimperator.CommandLine = function () //{{{ // 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 setLine(str, this.HL_QUESTION); - command_widget.focus(); + commandWidget.focus(); return "not implemented"; }, // reads a multi line input and returns the string once the last line matches - // @param until_regexp - inputMultiline: function (until_regexp, callback_func) + // @param untilRegexp + inputMultiline: function (untilRegexp, callbackFunc) { // save the mode, because we need to restore it - old_mode = vimperator.mode; - old_extended_mode = vimperator.mode.extended; + oldMode = vimperator.mode; + oldExtendedMode = vimperator.mode.extended; vimperator.modes.set(vimperator.modes.COMMAND_LINE, vimperator.modes.INPUT_MULTILINE); // save the arguments, they are needed in the event handler onEvent - multiline_regexp = until_regexp; - multiline_callback = callback_func; + multilineRegexp = untilRegexp; + multilineCallback = callbackFunc; - multiline_input_widget.collapsed = false; - multiline_input_widget.value = ""; + multilineInputWidget.collapsed = false; + multilineInputWidget.value = ""; autosizeMultilineInputWidget(); setTimeout(function () { - multiline_input_widget.focus(); + multilineInputWidget.focus(); }, 10); }, @@ -375,21 +376,21 @@ vimperator.CommandLine = function () //{{{ if (vimperator.mode == vimperator.modes.COMMAND_LINE && !(vimperator.modes.extended & vimperator.modes.INPUT_MULTILINE) && !(vimperator.modes.extended & vimperator.modes.OUTPUT_MULTILINE)) - command_widget.inputField.focus(); + commandWidget.inputField.focus(); }, 0); } else if (event.type == "focus") { - if (!cur_extended_mode && event.target == command_widget.inputField) + if (!currentExtendedMode && event.target == commandWidget.inputField) event.target.blur(); } else if (event.type == "input") { - vimperator.triggerCallback("change", cur_extended_mode, command); + vimperator.triggerCallback("change", currentExtendedMode, command); } else if (event.type == "keypress") { - if (!cur_extended_mode) + if (!currentExtendedMode) return; var key = vimperator.events.toString(event); @@ -398,7 +399,7 @@ vimperator.CommandLine = function () //{{{ // user pressing ESCAPE is handled in the global onEscape if (vimperator.events.isAcceptKey(key)) { - var mode = cur_extended_mode; // save it here, as setMode() resets it + var mode = currentExtendedMode; // save it here, as setMode() resets it history.add(command); vimperator.modes.reset(true); //FIXME: use mode stack completionlist.hide(); @@ -417,47 +418,47 @@ vimperator.CommandLine = function () //{{{ event.stopPropagation(); // always reset the tab completion if we use up/down keys - completion_index = UNINITIALIZED; + completionIndex = UNINITIALIZED; // save 'start' position for iterating through the history - if (history_index == UNINITIALIZED) + if (historyIndex == UNINITIALIZED) { - history_index = lines.length; - history_start = command; + historyIndex = lines.length; + historyStart = command; } // search the history for the first item matching the current // commandline string - while (history_index >= -1 && history_index <= lines.length) + while (historyIndex >= -1 && historyIndex <= lines.length) { - key == "" ? history_index-- : history_index++; + key == "" ? historyIndex-- : historyIndex++; // user pressed DOWN when there is no newer history item - if (history_index == lines.length) + if (historyIndex == lines.length) { - setCommand(history_start); - vimperator.triggerCallback("change", cur_extended_mode, this.getCommand()); + setCommand(historyStart); + vimperator.triggerCallback("change", currentExtendedMode, this.getCommand()); return; } // cannot go past history start/end - if (history_index <= -1) + if (historyIndex <= -1) { - history_index = 0; + historyIndex = 0; vimperator.beep(); break; } - if (history_index >= lines.length + 1) + if (historyIndex >= lines.length + 1) { - history_index = lines.length; + historyIndex = lines.length; vimperator.beep(); break; } - if (lines[history_index].indexOf(history_start) == 0) + if (lines[historyIndex].indexOf(historyStart) == 0) { - setCommand(lines[history_index]); - vimperator.triggerCallback("change", cur_extended_mode, this.getCommand()); + setCommand(lines[historyIndex]); + vimperator.triggerCallback("change", currentExtendedMode, this.getCommand()); return; } } @@ -467,21 +468,21 @@ vimperator.CommandLine = function () //{{{ else if (key == "" || key == "") { //always reset our completion history so up/down keys will start with new values - history_index = UNINITIALIZED; + historyIndex = UNINITIALIZED; // we need to build our completion list first - if (completion_index == UNINITIALIZED) + if (completionIndex == UNINITIALIZED) { - completion_start_index = 0; + completionStartIndex = 0; - completion_index = -1; - wild_index = 0; + completionIndex = -1; + wildIndex = 0; - completion_prefix = command.substring(0, command_widget.selectionStart); - completion_postfix = command.substring(command_widget.selectionStart); - var res = vimperator.triggerCallback("complete", cur_extended_mode, completion_prefix); + completionPrefix = command.substring(0, commandWidget.selectionStart); + completionPostfix = command.substring(commandWidget.selectionStart); + var res = vimperator.triggerCallback("complete", currentExtendedMode, completionPrefix); if (res) - [completion_start_index, completions] = res; + [completionStartIndex, completions] = res; // sort the completion list if (/\bsort\b/.test(vimperator.options["wildoptions"])) @@ -507,21 +508,21 @@ vimperator.CommandLine = function () //{{{ } var wim = vimperator.options["wildmode"].split(/,/); - var has_list = false; + var hasList = false; var longest = false; var full = false; - var wildtype = wim[wild_index++] || wim[wim.length - 1]; - if (wildtype == "list" || wildtype == "list:full" || wildtype == "list:longest") - has_list = true; - if (wildtype == "longest" || wildtype == "list:longest") + var wildType = wim[wildIndex++] || wim[wim.length - 1]; + if (wildType == "list" || wildType == "list:full" || wildType == "list:longest") + hasList = true; + if (wildType == "longest" || wildType == "list:longest") longest = true; - else if (wildtype == "full" || wildtype == "list:full") + else if (wildType == "full" || wildType == "list:full") full = true; // show the list - if (has_list) + if (hasList) { - if (completion_index < 0) + if (completionIndex < 0) completionlist.show(completions); else completionlist.show(); @@ -531,48 +532,48 @@ vimperator.CommandLine = function () //{{{ { if (event.shiftKey) { - completion_index--; - if (completion_index < -1) - completion_index = completions.length -1; + completionIndex--; + if (completionIndex < -1) + completionIndex = completions.length -1; } else { - completion_index++; - if (completion_index >= completions.length) - completion_index = -1; + completionIndex++; + if (completionIndex >= completions.length) + completionIndex = -1; } - vimperator.statusline.updateProgress("match " + (completion_index + 1) + " of " + completions.length); + vimperator.statusline.updateProgress("match " + (completionIndex + 1) + " of " + completions.length); // if the list is hidden, this function does nothing - completionlist.selectItem(completion_index); + completionlist.selectItem(completionIndex); } - if (completion_index == -1 && !longest) // wrapped around matches, reset command line + if (completionIndex == -1 && !longest) // wrapped around matches, reset command line { if (full && completions.length > 1) { - setCommand(completion_prefix + completion_postfix); + setCommand(completionPrefix + completionPostfix); } } else { if (longest && completions.length > 1) - var compl = vimperator.completion.get_longest_substring(); + var compl = vimperator.completion.getLongestSubstring(); else if (full) - var compl = completions[completion_index][0]; + var compl = completions[completionIndex][0]; else if (completions.length == 1) var compl = completions[0][0]; if (compl) { - setCommand(command.substring(0, completion_start_index) + compl + completion_postfix); - command_widget.selectionStart = command_widget.selectionEnd = completion_start_index + compl.length; + setCommand(command.substring(0, completionStartIndex) + compl + completionPostfix); + commandWidget.selectionStart = commandWidget.selectionEnd = completionStartIndex + compl.length; // Start a new completion in the next iteration. Useful for commands like :source // RFC: perhaps the command can indicate whether the completion should be restarted // Needed for :source to grab another set of completions after a file/directory has been filled out if (completions.length == 1 && !full) - completion_index = UNINITIALIZED; + completionIndex = UNINITIALIZED; } } @@ -583,19 +584,19 @@ vimperator.CommandLine = function () //{{{ else if (key == "") { // reset the tab completion - completion_index = history_index = UNINITIALIZED; + completionIndex = historyIndex = UNINITIALIZED; // and blur the command line if there is no text left if (command.length == 0) { - vimperator.triggerCallback("cancel", cur_extended_mode); + vimperator.triggerCallback("cancel", currentExtendedMode); vimperator.modes.reset(); // FIXME: use mode stack } } else // any other key { // reset the tab completion - completion_index = history_index = UNINITIALIZED; + completionIndex = historyIndex = UNINITIALIZED; } } }, @@ -607,25 +608,25 @@ vimperator.CommandLine = function () //{{{ var key = vimperator.events.toString(event); if (vimperator.events.isAcceptKey(key)) { - var text = multiline_input_widget.value.substr(0, multiline_input_widget.selectionStart); - if (text.match(multiline_regexp)) + var text = multilineInputWidget.value.substr(0, multilineInputWidget.selectionStart); + if (text.match(multilineRegexp)) { - text = text.replace(multiline_regexp, ""); - vimperator.modes.set(old_mode, old_extended_mode); - multiline_input_widget.collapsed = true; - multiline_callback.call(this, text); + text = text.replace(multilineRegexp, ""); + vimperator.modes.set(oldMode, oldExtendedMode); + multilineInputWidget.collapsed = true; + multilineCallback.call(this, text); } } else if (vimperator.events.isCancelKey(key)) { - vimperator.modes.set(old_mode, old_extended_mode); - multiline_input_widget.collapsed = true; + vimperator.modes.set(oldMode, oldExtendedMode); + multilineInputWidget.collapsed = true; } } else if (event.type == "blur") { if (vimperator.modes.extended & vimperator.modes.INPUT_MULTILINE) - setTimeout(function () { multiline_input_widget.inputField.focus(); }, 0); + setTimeout(function () { multilineInputWidget.inputField.focus(); }, 0); } else if (event.type == "input") { @@ -637,12 +638,12 @@ vimperator.CommandLine = function () //{{{ // allow a down motion after an up rather than closing onMultilineOutputEvent: function (event) { - var win = multiline_output_widget.contentWindow; + var win = multilineOutputWidget.contentWindow; - var show_more_help_prompt = false; - var show_more_prompt = false; - var close_window = false; - var pass_event = false; + var showMoreHelpPrompt = false; + var showMorePrompt = false; + var closeWindow = false; + var passEvent = false; function isScrollable() { return !win.scrollMaxY == 0; } @@ -665,7 +666,7 @@ vimperator.CommandLine = function () //{{{ if (vimperator.options["more"] && isScrollable()) win.scrollByLines(1); else - pass_event = true; + passEvent = true; break; case "": @@ -674,7 +675,7 @@ vimperator.CommandLine = function () //{{{ if (vimperator.options["more"] && isScrollable() && !atEnd()) win.scrollByLines(1); else - close_window = true; // don't propagate the event for accept keys + closeWindow = true; // don't propagate the event for accept keys break; // up a line @@ -684,9 +685,9 @@ vimperator.CommandLine = function () //{{{ if (vimperator.options["more"] && isScrollable()) win.scrollByLines(-1); else if (vimperator.options["more"] && !isScrollable()) - show_more_prompt = true; + showMorePrompt = true; else - pass_event = true; + passEvent = true; break; // half page down @@ -694,14 +695,14 @@ vimperator.CommandLine = function () //{{{ if (vimperator.options["more"] && isScrollable()) win.scrollBy(0, win.innerHeight / 2); else - pass_event = true; + passEvent = true; break; case "": if (event.originalTarget.className == "hl-URL buffer-list") { vimperator.tabs.select(parseInt(event.originalTarget.parentNode.parentNode.firstChild.textContent, 10) - 1); - close_window = true; + closeWindow = true; break; } else if (event.originalTarget.localName.toLowerCase() == "a") @@ -737,7 +738,7 @@ vimperator.CommandLine = function () //{{{ if (vimperator.options["more"] && isScrollable()) win.scrollByPages(1); else - pass_event = true; + passEvent = true; break; case "": @@ -745,7 +746,7 @@ vimperator.CommandLine = function () //{{{ if (vimperator.options["more"] && isScrollable() && !atEnd()) win.scrollByPages(1); else - pass_event = true; + passEvent = true; break; // half page up @@ -754,7 +755,7 @@ vimperator.CommandLine = function () //{{{ if (vimperator.options["more"] && isScrollable()) win.scrollBy(0, -(win.innerHeight / 2)); else - pass_event = true; + passEvent = true; break; // page up @@ -762,16 +763,16 @@ vimperator.CommandLine = function () //{{{ if (vimperator.options["more"] && isScrollable()) win.scrollByPages(-1); else if (vimperator.options["more"] && !isScrollable()) - show_more_prompt = true; + showMorePrompt = true; else - pass_event = true; + passEvent = true; break; case "": if (vimperator.options["more"] && isScrollable()) win.scrollByPages(-1); else - pass_event = true; + passEvent = true; break; // top of page @@ -779,9 +780,9 @@ vimperator.CommandLine = function () //{{{ if (vimperator.options["more"] && isScrollable()) win.scrollTo(0, 0); else if (vimperator.options["more"] && !isScrollable()) - show_more_prompt = true; + showMorePrompt = true; else - pass_event = true; + passEvent = true; break; // bottom of page @@ -789,7 +790,7 @@ vimperator.CommandLine = function () //{{{ if (vimperator.options["more"] && isScrollable() && !atEnd()) win.scrollTo(0, win.scrollMaxY); else - pass_event = true; + passEvent = true; break; // copy text to clipboard @@ -799,31 +800,31 @@ vimperator.CommandLine = function () //{{{ // close the window case "q": - close_window = true; + closeWindow = true; break; // unmapped key default: if (!vimperator.options["more"] || !isScrollable() || atEnd() || vimperator.events.isCancelKey(key)) - pass_event = true; + passEvent = true; else - show_more_help_prompt = true; + showMoreHelpPrompt = true; } - if (pass_event || close_window) + if (passEvent || closeWindow) { // FIXME: use mode stack vimperator.modes.reset(); this.clear(); - if (pass_event) + if (passEvent) vimperator.events.onKeyPress(event); } else // set update the prompt string { - if (show_more_help_prompt) + if (showMoreHelpPrompt) setLine("-- More -- SPACE/d/j: screen/page/line down, b/u/k: up, q: quit", this.HL_MOREMSG); - else if (show_more_prompt || (vimperator.options["more"] && isScrollable() && !atEnd())) + else if (showMorePrompt || (vimperator.options["more"] && isScrollable() && !atEnd())) setLine("-- More --", this.HL_MOREMSG); else setLine("Press ENTER or type command to continue", this.HL_QUESTION); @@ -853,36 +854,36 @@ vimperator.InformationList = function (id, options) //{{{ /////////////////////////////////////////////////////////////////////////////{{{ const CONTEXT_LINES = 3; - var max_items = 10; - var min_items = 1; - var incremental_fill = true; // make display faster, but does not show scrollbar + var maxItems = 10; + var minItems = 1; + var incrementalFill = true; // make display faster, but does not show scrollbar if (options) { - if (options.max_items) max_items = options.max_items; - if (options.min_items) min_items = options.min_items; - if (options.incremental_fill) incremental_fill = options.incremental_fill; + if (options.maxItems) maxItems = options.maxItems; + if (options.minItems) minItems = options.minItems; + if (options.incrementalFill) incrementalFill = options.incrementalFill; } var widget = document.getElementById(id); var completions = null; // a reference to the Array of completions - var list_offset = 0; // how many items is the displayed list shifted from the internal tab index - var list_index = 0; // list_offset + list_index = completions[item] + var listOffset = 0; // how many items is the displayed list shifted from the internal tab index + var listIndex = 0; // listOffset + listIndex = completions[item] // add a single completion item to the list - function addItem(completion_item, at_beginning) + function addItem(completionItem, atBeginning) { var item = document.createElement("listitem"); var cell1 = document.createElement("listcell"); var cell2 = document.createElement("listcell"); - cell1.setAttribute("label", completion_item[0]); - cell2.setAttribute("label", completion_item[1]); + cell1.setAttribute("label", completionItem[0]); + cell2.setAttribute("label", completionItem[1]); cell2.setAttribute("style", "color:green; font-family: sans"); item.appendChild(cell1); item.appendChild(cell2); - if (at_beginning == true) + if (atBeginning == true) { var items = widget.getElementsByTagName("listitem"); if (items.length > 0) @@ -897,7 +898,7 @@ vimperator.InformationList = function (id, options) //{{{ /** * uses the entries in completions to fill the listbox * - * @param startindex: start at this index and show max_items + * @param startindex: start at this index and show maxItems * @returns the number of items */ function fill(startindex) @@ -911,7 +912,7 @@ vimperator.InformationList = function (id, options) //{{{ widget.removeChild(items[0]); } - if (!incremental_fill) + if (!incrementalFill) { for (i in completions) addItem(completions[i], false); @@ -919,15 +920,15 @@ vimperator.InformationList = function (id, options) //{{{ } // find start index - if (startindex + max_items > complength) - startindex = complength - max_items; + if (startindex + maxItems > complength) + startindex = complength - maxItems; if (startindex < 0) startindex = 0; - list_offset = startindex; - list_index = -1; + listOffset = startindex; + listIndex = -1; - for (var i = startindex; i < complength && i < startindex + max_items; i++) + for (var i = startindex; i < complength && i < startindex + maxItems; i++) { addItem(completions[i], false); } @@ -950,7 +951,7 @@ vimperator.InformationList = function (id, options) //{{{ */ show: function (compl) { - //max_items = vimperator.options["previewheight"]; + //maxItems = vimperator.options["previewheight"]; if (compl) { @@ -959,9 +960,9 @@ vimperator.InformationList = function (id, options) //{{{ } var length = completions.length; - if (length > max_items) - length = max_items; - if (length >= min_items) + if (length > maxItems) + length = maxItems; + if (length >= minItems) { widget.setAttribute("rows", length.toString()); widget.hidden = false; @@ -992,47 +993,47 @@ vimperator.InformationList = function (id, options) //{{{ if (widget.hidden) return; - if (!incremental_fill) + if (!incrementalFill) { widget.selectedIndex = index; return; } // find start index - var new_offset = 0; - if (index >= list_offset + max_items - CONTEXT_LINES) - new_offset = index - max_items + CONTEXT_LINES + 1; - else if (index <= list_offset + CONTEXT_LINES) - new_offset = index - CONTEXT_LINES; + var newOffset = 0; + if (index >= listOffset + maxItems - CONTEXT_LINES) + newOffset = index - maxItems + CONTEXT_LINES + 1; + else if (index <= listOffset + CONTEXT_LINES) + newOffset = index - CONTEXT_LINES; else - new_offset = list_offset; + newOffset = listOffset; - if (new_offset + max_items > completions.length) - new_offset = completions.length - max_items; - if (new_offset < 0) - new_offset = 0; + if (newOffset + maxItems > completions.length) + newOffset = completions.length - maxItems; + if (newOffset < 0) + newOffset = 0; // for speed reason: just remove old item, and add the new one at the end of the list var items = widget.getElementsByTagName("listitem"); - if (new_offset == list_offset + 1) + if (newOffset == listOffset + 1) { widget.removeChild(items[0]); addItem(completions[index + CONTEXT_LINES], false); } - else if (new_offset == list_offset - 1) + else if (newOffset == listOffset - 1) { widget.removeChild(items[items.length-1]); addItem(completions[index - CONTEXT_LINES], true); } - else if (new_offset == list_offset) + else if (newOffset == listOffset) { // do nothing } else - fill(new_offset); + fill(newOffset); - list_offset = new_offset; - widget.selectedIndex = index - list_offset; + listOffset = newOffset; + widget.selectedIndex = index - listOffset; }, onEvent: function (event) @@ -1059,15 +1060,15 @@ vimperator.StatusLine = function () //{{{ ////////////////////// PRIVATE SECTION ///////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - var status_bar = document.getElementById("status-bar"); + var statusBar = document.getElementById("status-bar"); // our status bar fields - var statusline_widget = document.getElementById("vimperator-statusline"); - var url_widget = document.getElementById("vimperator-statusline-field-url"); - var inputbuffer_widget = document.getElementById("vimperator-statusline-field-inputbuffer"); - var progress_widget = document.getElementById("vimperator-statusline-field-progress"); - var tabcount_widget = document.getElementById("vimperator-statusline-field-tabcount"); - var bufferposition_widget = document.getElementById("vimperator-statusline-field-bufferposition"); + var statuslineWidget = document.getElementById("vimperator-statusline"); + var urlWidget = document.getElementById("vimperator-statusline-field-url"); + var inputBufferWidget = document.getElementById("vimperator-statusline-field-inputbuffer"); + var progressWidget = document.getElementById("vimperator-statusline-field-progress"); + var tabCountWidget = document.getElementById("vimperator-statusline-field-tabcount"); + var bufferPositionWidget = document.getElementById("vimperator-statusline-field-bufferposition"); /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// @@ -1077,22 +1078,22 @@ vimperator.StatusLine = function () //{{{ setClass: function (type) { - var highlight_group; + var highlightGroup; switch (type) { case "secure": - highlight_group = "hl-StatusLineSecure"; + highlightGroup = "hl-StatusLineSecure"; break; case "broken": - highlight_group = "hl-StatusLineBroken"; + highlightGroup = "hl-StatusLineBroken"; break; case "insecure": - highlight_group = "hl-StatusLine"; + highlightGroup = "hl-StatusLine"; break; } - status_bar.setAttribute("class", "chromeclass-status " + highlight_group); + statusBar.setAttribute("class", "chromeclass-status " + highlightGroup); }, // update all fields of the statusline @@ -1110,7 +1111,7 @@ vimperator.StatusLine = function () //{{{ { if (typeof url == "string") { - url_widget.value = url; + urlWidget.value = url; return; } @@ -1137,7 +1138,7 @@ vimperator.StatusLine = function () //{{{ if (modified) url += " [" + modified + "]"; - url_widget.value = url; + urlWidget.value = url; }, updateInputBuffer: function (buffer) @@ -1145,7 +1146,7 @@ vimperator.StatusLine = function () //{{{ if (!buffer || typeof buffer != "string") buffer = ""; - inputbuffer_widget.value = buffer; + inputBufferWidget.value = buffer; }, updateProgress: function (progress) @@ -1154,39 +1155,39 @@ vimperator.StatusLine = function () //{{{ progress = ""; if (typeof progress == "string") - progress_widget.value = progress; + progressWidget.value = progress; else if (typeof progress == "number") { - var progress_str = ""; + var progressStr = ""; if (progress <= 0) - progress_str = "[ Loading... ]"; + progressStr = "[ Loading... ]"; else if (progress < 1) { - progress_str = "["; + progressStr = "["; var done = Math.floor(progress * 20); for (var i = 0; i < done; i++) - progress_str += "="; + progressStr += "="; - progress_str += ">"; + progressStr += ">"; for (var i = 19; i > done; i--) - progress_str += " "; + progressStr += " "; - progress_str += "]"; + progressStr += "]"; } - progress_widget.value = progress_str; + progressWidget.value = progressStr; } }, // you can omit either of the 2 arguments - updateTabCount: function (cur_index, total_tabs) + updateTabCount: function (currentIndex, totalTabs) { - if (!cur_index || typeof cur_index != "number") - cur_index = vimperator.tabs.index() + 1; - if (!total_tabs || typeof cur_index != "number") - total_tabs = vimperator.tabs.count; + if (!currentIndex || typeof currentIndex != "number") + currentIndex = vimperator.tabs.index() + 1; + if (!totalTabs || typeof currentIndex != "number") + totalTabs = vimperator.tabs.count; - tabcount_widget.value = "[" + cur_index + "/" + total_tabs + "]"; + tabCountWidget.value = "[" + currentIndex + "/" + totalTabs + "]"; }, // percent is given between 0 and 1 @@ -1198,15 +1199,15 @@ vimperator.StatusLine = function () //{{{ percent = win.scrollMaxY == 0 ? -1 : win.scrollY / win.scrollMaxY; } - var bufferposition_str = ""; + var bufferPositionStr = ""; percent = Math.round(percent * 100); - if (percent < 0) bufferposition_str = "All"; - else if (percent == 0) bufferposition_str = "Top"; - else if (percent < 10) bufferposition_str = " " + percent + "%"; - else if (percent >= 100) bufferposition_str = "Bot"; - else bufferposition_str = percent + "%"; + if (percent < 0) bufferPositionStr = "All"; + else if (percent == 0) bufferPositionStr = "Top"; + else if (percent < 10) bufferPositionStr = " " + percent + "%"; + else if (percent >= 100) bufferPositionStr = "Bot"; + else bufferPositionStr = percent + "%"; - bufferposition_widget.value = bufferposition_str; + bufferPositionWidget.value = bufferPositionStr; } }; diff --git a/content/util.js b/content/util.js index c39c91e0..e55a7aa4 100644 --- a/content/util.js +++ b/content/util.js @@ -27,6 +27,7 @@ the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ vimperator.util = { + escapeHTML: function (str) { // XXX: the following code is _much_ slower than a simple .replace() @@ -39,9 +40,9 @@ vimperator.util = { }, // TODO: use :highlight color groups - // if "process_strings" is true, any passed strings will be surrounded by " and + // if "processStrings" is true, any passed strings will be surrounded by " and // any line breaks are displayed as \n - colorize: function (arg, process_strings) + colorize: function (arg, processStrings) { var type = typeof arg; @@ -54,7 +55,7 @@ vimperator.util = { } else if (type == "string") { - if (process_strings) + if (processStrings) arg = '"' + vimperator.util.escapeHTML(arg.replace(/\n/, "\\n")) + '"'; return "" + arg + ""; @@ -97,7 +98,7 @@ vimperator.util = { begin: for (var url = 0; url < urls.length; url++) { - var new_url = vimperator.buffer.URL; + var newURL = vimperator.buffer.URL; var matches; // strip each 'URL' - makes things simpler later on @@ -108,13 +109,13 @@ vimperator.util = { if (matches = urls[url].match(/^(?:\.$|\.\/(\S*))/)) { var tail = matches[1] || ""; - urls[url] = new_url.replace(/(.+\/)[^\/]*/, "$1" + tail); // NOTE: escape / in character sets so as not to break Vim syntax highlighting + urls[url] = newURL.replace(/(.+\/)[^\/]*/, "$1" + tail); // NOTE: escape / in character sets so as not to break Vim syntax highlighting continue; } else if (matches = urls[url].match(/^(?:\.\.$|\.\.\/(\S*))/)) { var tail = matches[1] || ""; - urls[url] = new_url.replace(/(.+\/)[^\/]*/, "$1../" + tail); + urls[url] = newURL.replace(/(.+\/)[^\/]*/, "$1../" + tail); continue; } else if (matches = urls[url].match(/^(?:\.\.\.$|\.\.\.\/(\S*))/)) @@ -142,18 +143,18 @@ vimperator.util = { // like the comments below ;-) // check if the first word is a search engine - var search_url = vimperator.bookmarks.getSearchURL(text, alias); - if (search_url/* && search_url.length >= 1*/) + var searchURL = vimperator.bookmarks.getSearchURL(text, alias); + if (searchURL/* && searchURL.length >= 1*/) { - urls[url] = search_url; + urls[url] = searchURL; continue; } else // the first word was not a search engine, search for the whole string in the default engine { - search_url = vimperator.bookmarks.getSearchURL(urls[url], null); - if (search_url/* && search_url.length >= 1*/) + searchURL = vimperator.bookmarks.getSearchURL(urls[url], null); + if (searchURL/* && searchURL.length >= 1*/) { - urls[url] = search_url; + urls[url] = searchURL; continue; } } @@ -206,6 +207,7 @@ vimperator.util = { return strNum[0] + " " + unitVal[unitIndex]; } + }; // vim: set fdm=marker sw=4 ts=4 et: diff --git a/content/vimperator.js b/content/vimperator.js index 7d36c349..8e12aca6 100644 --- a/content/vimperator.js +++ b/content/vimperator.js @@ -33,11 +33,11 @@ const vimperator = (function () //{{{ /////////////////////////////////////////////////////////////////////////////{{{ // our services - var sound_service = Components.classes["@mozilla.org/sound;1"] + var soundService = Components.classes["@mozilla.org/sound;1"] .getService(Components.interfaces.nsISound); - var console_service = Components.classes["@mozilla.org/consoleservice;1"] + var consoleService = Components.classes["@mozilla.org/consoleservice;1"] .getService(Components.interfaces.nsIConsoleService); - var environment_service = Components.classes["@mozilla.org/process/environment;1"] + var environmentService = Components.classes["@mozilla.org/process/environment;1"] .getService(Components.interfaces.nsIEnvironment); var callbacks = []; @@ -107,7 +107,7 @@ const vimperator = (function () //{{{ } else { - sound_service.beep(); + soundService.beep(); } }, @@ -296,7 +296,7 @@ const vimperator = (function () //{{{ if (typeof msg == "object") msg = this.objectToString(msg, false); - console_service.logStringMessage("vimperator: " + msg); + consoleService.logStringMessage("vimperator: " + msg); }, // open one or more URLs @@ -369,9 +369,9 @@ const vimperator = (function () //{{{ }, // quit vimperator, no matter how many tabs/windows are open - quit: function (save_session) + quit: function (saveSession) { - if (save_session) + if (saveSession) vimperator.options.setFirefoxPref("browser.startup.page", 3); // start with saved session else vimperator.options.setFirefoxPref("browser.startup.page", 1); // start with default homepage session @@ -428,7 +428,7 @@ const vimperator = (function () //{{{ } catch (e) { - var dirs = environment_service.get("PATH").split(WINDOWS ? ";" : ":"); + var dirs = environmentService.get("PATH").split(WINDOWS ? ";" : ":"); for (var i = 0; i < dirs.length; i++) { var path = dirs[i] + (WINDOWS ? "\\" : "/") + program; @@ -522,16 +522,16 @@ const vimperator = (function () //{{{ else { var heredoc = ""; - var heredoc_end = null; // the string which ends the heredoc + var heredocEnd = null; // the string which ends the heredoc str.split("\n").forEach(function (line) { - if (heredoc_end) // we already are in a heredoc + if (heredocEnd) // we already are in a heredoc { - if (heredoc_end.test(line)) + if (heredocEnd.test(line)) { eval("with(vimperator){" + heredoc + "}"); heredoc = ""; - heredoc_end = null; + heredocEnd = null; } else { @@ -548,7 +548,7 @@ const vimperator = (function () //{{{ var matches = args.match(/(.*)<<\s*([^\s]+)$/); if (matches) { - heredoc_end = new RegExp("^" + matches[2] + "$", "m"); + heredocEnd = new RegExp("^" + matches[2] + "$", "m"); if (matches[1]) heredoc = matches[1] + "\n"; } @@ -596,9 +596,9 @@ const vimperator = (function () //{{{ vimperator.log("Loading module search...", 3); vimperator.search = vimperator.Search(); vimperator.log("Loading module preview window...", 3); - vimperator.previewwindow = vimperator.InformationList("vimperator-previewwindow", { incremental_fill: false, max_items: 10 }); + vimperator.previewwindow = vimperator.InformationList("vimperator-previewwindow", { incrementalFill: false, maxItems: 10 }); vimperator.log("Loading module buffer window...", 3); - vimperator.bufferwindow = vimperator.InformationList("vimperator-bufferwindow", { incremental_fill: false, max_items: 10 }); + vimperator.bufferwindow = vimperator.InformationList("vimperator-bufferwindow", { incrementalFill: false, maxItems: 10 }); vimperator.log("Loading module mappings...", 3); vimperator.mappings = vimperator.Mappings(); vimperator.log("Loading module statusline...", 3); @@ -650,20 +650,20 @@ const vimperator = (function () //{{{ // make sourcing asynchronous, otherwise commands that open new tabs won't work setTimeout(function () { - var rc_file = vimperator.io.getRCFile(); + var rcFile = vimperator.io.getRCFile(); - if (rc_file) - vimperator.source(rc_file.path, true); + if (rcFile) + vimperator.source(rcFile.path, true); else vimperator.log("No user RC file found", 3); // also source plugins in ~/.vimperator/plugin/ try { - var plugin_dir = vimperator.io.getPluginDir(); - if (plugin_dir) + var pluginDir = vimperator.io.getPluginDir(); + if (pluginDir) { - var files = vimperator.io.readDirectory(plugin_dir.path); + var files = vimperator.io.readDirectory(pluginDir.path); vimperator.log("Sourcing plugin directory...", 3); files.forEach(function (file) { if (!file.isDirectory() && /\.(js|vimp)$/i.test(file.path))