From 3bceee772172849b18fa1eaa8d0e5744a152130d Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Fri, 22 Jun 2007 10:42:37 +0000 Subject: [PATCH] normalise fold markers --- chrome/content/vimperator/bookmarks.js | 60 ++++----- chrome/content/vimperator/commands.js | 90 +++++++------ chrome/content/vimperator/completion.js | 56 ++++---- chrome/content/vimperator/file.js | 23 ++-- chrome/content/vimperator/find.js | 22 ++-- chrome/content/vimperator/help.js | 4 +- chrome/content/vimperator/hints.js | 162 ++++++++++++------------ chrome/content/vimperator/mappings.js | 9 +- chrome/content/vimperator/options.js | 8 +- chrome/content/vimperator/ui.js | 60 +++++---- chrome/content/vimperator/vimperator.js | 103 ++++++++------- 11 files changed, 311 insertions(+), 286 deletions(-) diff --git a/chrome/content/vimperator/bookmarks.js b/chrome/content/vimperator/bookmarks.js index c17afa55..467a609b 100644 --- a/chrome/content/vimperator/bookmarks.js +++ b/chrome/content/vimperator/bookmarks.js @@ -2,7 +2,7 @@ * also includes methods for dealing with * keywords and search engines */ -function Bookmarks()//{{{ +function Bookmarks() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -11,7 +11,7 @@ function Bookmarks()//{{{ getService(Components.interfaces.nsIBrowserSearchService); const rdf_service = Components.classes["@mozilla.org/rdf/rdf-service;1"]. getService( Components.interfaces.nsIRDFService ); - + var bookmarks = null; var keywords = null; @@ -76,36 +76,36 @@ function Bookmarks()//{{{ * @returns number of deleted bookmarks */ this.remove = function(url) - { + { var deleted = 0; if(!url) return 0; - // gNC_NS for trunk, NC_NS for 1.X - //try { var pNC_NS; pNC_NS = gNC_NS;} catch (err) { pNC_NS = NC_NS;} + // gNC_NS for trunk, NC_NS for 1.X + //try { var pNC_NS; pNC_NS = gNC_NS;} catch (err) { pNC_NS = NC_NS;} if (!BMSVC || !BMDS || !RDF || !gNC_NS) // defined from firefox - return 0; + return 0; var curfolder = RDF.GetResource("NC:BookmarksRoot"); - var urlArc = RDF.GetResource(gNC_NS + "URL"); + var urlArc = RDF.GetResource(gNC_NS + "URL"); var urlLiteral = RDF.GetLiteral(url); if (BMDS.hasArcIn(urlLiteral, urlArc)) - { - var bmResources, bmResource, title, uri, type, ptype; - bmResources = BMSVC.GetSources(urlArc, urlLiteral, true); + { + var bmResources, bmResource, title, uri, type, ptype; + bmResources = BMSVC.GetSources(urlArc, urlLiteral, true); while (bmResources.hasMoreElements()) - { - bmResource = bmResources.getNext(); - type = BookmarksUtils.resolveType(bmResource); - if (type != "ImmutableBookmark") { - ptype = BookmarksUtils.resolveType(BMSVC.getParent(bmResource)); + { + bmResource = bmResources.getNext(); + type = BookmarksUtils.resolveType(bmResource); + if (type != "ImmutableBookmark") { + ptype = BookmarksUtils.resolveType(BMSVC.getParent(bmResource)); // alert(type); // if ( type == "Folder") // store the current folder // curfolder = bmResource; if ( (type == "Bookmark" || type == "IEFavorite") && ptype != "Livemark") - { - title = BookmarksUtils.getProperty(bmResource, gNC_NS + "Name"); - uri = BookmarksUtils.getProperty(bmResource, gNC_NS + "URL"); + { + title = BookmarksUtils.getProperty(bmResource, gNC_NS + "Name"); + uri = BookmarksUtils.getProperty(bmResource, gNC_NS + "URL"); if (uri == url) { @@ -113,16 +113,16 @@ function Bookmarks()//{{{ RDFC.RemoveElement(bmResource, true); deleted++; } - } - } - } - } + } + } + } + } // also update bookmark cache, if we removed at least one bookmark if(deleted > 0) load(); - return deleted; + return deleted; } /* also ensures that each search engine has a vimperator-friendly alias */ @@ -262,9 +262,9 @@ function Bookmarks()//{{{ return res; } //}}} -}//}}} +} //}}} -function History()//{{{ +function History() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -345,9 +345,9 @@ function History()//{{{ return true; }; //}}} -}//}}} +} //}}} -function Marks()//{{{ +function Marks() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -408,7 +408,7 @@ function Marks()//{{{ } return ok; } - + /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ @@ -520,13 +520,13 @@ function Marks()//{{{ } return this; } - + // TODO: show marks like vim does (when the multiline echo impl is done) or in the preview windwo right now this.list = function() { return this; } //}}} -}//}}} +} //}}} // vim: set fdm=marker sw=4 ts=4 et: diff --git a/chrome/content/vimperator/commands.js b/chrome/content/vimperator/commands.js index 4e7bc333..fc4eeca8 100644 --- a/chrome/content/vimperator/commands.js +++ b/chrome/content/vimperator/commands.js @@ -27,7 +27,7 @@ the terms of any one of the MPL, the GPL or the LGPL. }}} ***** END LICENSE BLOCK *****/ /* [command, action, cancel_hint_mode, always_active] */ -var g_hint_mappings = [ /*{{{*/ +var g_hint_mappings = [ //{{{ /* hint action keys */ ["o", "hah.openHints(false, false);", true, false], ["t", "hah.openHints(true, false);", true, false], @@ -64,9 +64,9 @@ var g_hint_mappings = [ /*{{{*/ ["", "", true, true], ["", "", true, true], ["", "", true, true] -]; /*}}}*/ +]; //}}} -function Command(specs, action, extra_info)//{{{ +function Command(specs, action, extra_info) //{{{ { if (!specs || !action) return null; @@ -129,7 +129,7 @@ function Command(specs, action, extra_info)//{{{ this.completer = extra_info.completer || null; } -}//}}} +} Command.prototype.execute = function(args, special, count, modifiers) { @@ -176,9 +176,9 @@ Command.prototype.toString = function() "\n\taction: " + this.action + "\n\tcompleter: " + this.completer + "\n}" -} +} //}}} -function Commands()//{{{ +function Commands() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -767,10 +767,10 @@ function Commands()//{{{ help: "{value} can be between 25 and 500%. If it is omitted, zoom is reset to 100%." } )); -//}}} -}//}}} + //}}} +} //}}} -function execute_command(count, cmd, special, args, modifiers) // {{{ +function execute_command(count, cmd, special, args, modifiers) //{{{ { if (!cmd) return; @@ -795,7 +795,11 @@ function execute_command(count, cmd, special, args, modifiers) // {{{ // valid command, call it: command.execute(args, special, count, modifiers); -} // }}} +} //}}} + +/////////////////////////////////////////////////////////////////////}}} +// Ex command parsing and execution //////////////////////////////////// +/////////////////////////////////////////////////////////////////////{{{ // return [null, null, null, null, heredoc_tag || false]; // [count, cmd, special, args] = match; @@ -852,9 +856,11 @@ function execute(string) return execute_command.apply(this, tokens); } -//////////////////////////////////////////////////////////////////////// -// navigation functions /////////////////////////////////////////// {{{1 -//////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////}}} +// navigation functions //////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////{{{ + function stepInHistory(steps) { var index = getWebNavigation().sessionHistory.index + steps; @@ -893,11 +899,10 @@ function historyGoToEnd() getWebNavigation().gotoIndex(max); } +/////////////////////////////////////////////////////////////////////}}} +// url functions /////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////{{{ - -//////////////////////////////////////////////////////////////////////// -// url functions ////////////////////////////////////////////////// {{{1 -//////////////////////////////////////////////////////////////////////// function openURLs(str) { var urls = stringToURLs(str); @@ -1027,9 +1032,9 @@ function isDirectory(url) return false; } -//////////////////////////////////////////////////////////////////////// -// frame related functions //////////////////////////////////////// {{{1 -//////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////}}} +// frame related functions ///////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////{{{ // TODO: allow callback for filtering out unwanted frames? User defined? function focusNextFrame(count, forward) @@ -1040,7 +1045,7 @@ function focusNextFrame(count, forward) // find all frames - depth-first search (function(frame) - { + { if (frame.document.body.localName.toLowerCase() == "body") frames.push(frame); for (var i = 0; i < frame.frames.length; i++) @@ -1122,9 +1127,10 @@ function focusNextFrame(count, forward) } } -//////////////////////////////////////////////////////////////////////// -// location handling ////////////////////////////////////////////// {{{1 -//////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////}}} +// location handling /////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////{{{ + function getCurrentLocation() { return window.content.document.location.href; @@ -1182,8 +1188,9 @@ function getCurrentLinkLocation() } //////////////////////////////////////////////////////////////////////// -// high level bookmark/history related functions ////////////////// {{{1 -//////////////////////////////////////////////////////////////////////// +// high level bookmark/history related functions /////////////////////// +/////////////////////////////////////////////////////////////////////{{{ + // takes: -t "foo" -T "tag1,tag2", myurl // converts that string to a useful url and title, and calls addBookmark function bmadd(str) @@ -1246,9 +1253,10 @@ function hsshow(filter, fullmode) } -//////////////////////////////////////////////////////////////////////// -// url marks functions //////////////////////////////////////////// {{{1 -//////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////}}} +// url marks functions ///////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////{{{ + /* vimperator has a concept of URL marks * these provide quick access to URLs with a single character * @@ -1276,9 +1284,10 @@ function show_url_marks(mark) } -//////////////////////////////////////////////////////////////////////// -// tab/buffer related functions /////////////////////////////////// {{{1 -//////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////}}} +// tab/buffer related functions //////////////////////////////////////// +/////////////////////////////////////////////////////////////////////{{{ + function tab() { execute(arguments[0], null, null, {inTab: true}); @@ -1320,9 +1329,10 @@ function updateBufferList() vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex); } -//////////////////////////////////////////////////////////////////////// -// scrolling ////////////////////////////////////////////////////// {{{1 -//////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////}}} +// scrolling /////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////{{{ + function scrollBufferRelative(right, down) { var win = document.commandDispatcher.focusedWindow; @@ -1371,7 +1381,7 @@ function scrollBufferAbsolute(horizontal, vertical) } //////////////////////////////////////////////////////////////////////// -// zooming //////////////////////////////////////////////////////// {{{1 +// zooming //////////////////////////////////////////////////////////{{{ //////////////////////////////////////////////////////////////////////// /* also used to zoom out, when factor is negative */ @@ -1439,10 +1449,9 @@ function zoom_to(value) vimperator.echo("Zoom value: " + value + "%"); } - - +//}}} //////////////////////////////////////////////////////////////////////// -// misc helper functions ////////////////////////////////////////// {{{1 +// misc helper functions ////////////////////////////////////////////{{{ //////////////////////////////////////////////////////////////////////// function copyToClipboard(str) @@ -1659,7 +1668,7 @@ function source(filename, silent) function getEnv(variable) { var environment = Components.classes["@mozilla.org/process/environment;1"] - .getService(Components.interfaces.nsIEnvironment); + .getService(Components.interfaces.nsIEnvironment); return environment.get(variable); } @@ -1726,5 +1735,6 @@ function evaluateXPath(expression, doc, ordered) ); return res; } +//}}} // vim: set fdm=marker sw=4 ts=4 et: diff --git a/chrome/content/vimperator/completion.js b/chrome/content/vimperator/completion.js index 489fb779..884da702 100644 --- a/chrome/content/vimperator/completion.js +++ b/chrome/content/vimperator/completion.js @@ -6,7 +6,7 @@ var g_substrings = []; * used for the 'longest' setting for wildmode * */ -function get_longest_substring()/*{{{*/ +function get_longest_substring() //{{{ { if (g_substrings.length == 0) return ''; @@ -18,11 +18,11 @@ function get_longest_substring()/*{{{*/ } //alert(longest); return longest; -}/*}}}*/ +} //}}} // function uses smartcase // list = [ [['com1', 'com2'], 'text'], [['com3', 'com4'], 'text'] ] -function build_longest_common_substring(list, filter)/*{{{*/ +function build_longest_common_substring(list, filter) //{{{ { var filtered = []; //var filter_length = filter.length; @@ -65,10 +65,10 @@ function build_longest_common_substring(list, filter)/*{{{*/ } } return filtered; -}/*}}}*/ +} //}}} /* this function is case sensitive */ -function build_longest_starting_substring(list, filter)/*{{{*/ +function build_longest_starting_substring(list, filter) //{{{ { var filtered = []; //var filter_length = filter.length; @@ -95,7 +95,7 @@ function build_longest_starting_substring(list, filter)/*{{{*/ } } return filtered; -}/*}}}*/ +} //}}} /* * filter a list of urls @@ -104,7 +104,7 @@ function build_longest_starting_substring(list, filter)/*{{{*/ * depending on the 'complete' option * if the 'complete' argument is passed like "h", it temproarily overrides the complete option */ -function get_url_completions(filter, complete)/*{{{*/ +function get_url_completions(filter, complete) //{{{ { var completions = new Array(); g_substrings = []; @@ -124,10 +124,10 @@ function get_url_completions(filter, complete)/*{{{*/ } return completions; -}/*}}}*/ +} //}}} /* discard all entries in the 'urls' array, which don't match 'filter */ -function filter_url_array(urls, filter)/*{{{*/ +function filter_url_array(urls, filter) //{{{ { var filtered = []; // completions which don't match the url but just the description @@ -184,9 +184,9 @@ function filter_url_array(urls, filter)/*{{{*/ } return filtered.concat(additional_completions); -}/*}}}*/ +} //}}} -function get_search_completions(filter)/*{{{*/ +function get_search_completions(filter) //{{{ { var engines = vimperator.bookmarks.getSearchEngines().concat(vimperator.bookmarks.getKeywords()); @@ -197,21 +197,21 @@ function get_search_completions(filter)/*{{{*/ return [[$_[0]], $_[1]]; }); return build_longest_common_substring(mapped, filter); -}/*}}}*/ +} //}}} -function get_history_completions(filter) +function get_history_completions(filter) //{{{ { var items = vimperator.history.get(); return filter_url_array(items, filter); -} +} //}}} -function get_bookmark_completions(filter) +function get_bookmark_completions(filter) //{{{ { var bookmarks = vimperator.bookmarks.get(); return filter_url_array(bookmarks, filter); -} +} //}}} -function get_file_completions(filter)/*{{{*/ +function get_file_completions(filter) //{{{ { //var completions = new Array(); /* This is now also used as part of the url completion, so the substrings shouldn't be cleared for that case */ @@ -249,9 +249,9 @@ function get_file_completions(filter)/*{{{*/ }); return build_longest_starting_substring(mapped, new_filter); -}/*}}}*/ +} //}}} -function get_help_completions(filter)/*{{{*/ +function get_help_completions(filter) //{{{ { var help_array = [[["introduction"], "Introductory text"], [["mappings"], "Normal mode commands"], @@ -280,9 +280,9 @@ function get_help_completions(filter)/*{{{*/ }); return build_longest_common_substring(help_array, filter); -}/*}}}*/ +} //}}} -function get_command_completions(filter)/*{{{*/ +function get_command_completions(filter) //{{{ { //g_completions = []; g_substrings = []; @@ -297,9 +297,9 @@ function get_command_completions(filter)/*{{{*/ for (var command in vimperator.commands) completions.push([command.long_names, command.short_help]); return build_longest_starting_substring(completions, filter); -}/*}}}*/ +} //}}} -function get_options_completions(filter, unfiltered)/*{{{*/ +function get_options_completions(filter, unfiltered) //{{{ { g_substrings = []; var options_completions = []; @@ -379,9 +379,9 @@ function get_options_completions(filter, unfiltered)/*{{{*/ } return options_completions; -}/*}}}*/ +} //}}} -function get_buffer_completions(filter)/*{{{*/ +function get_buffer_completions(filter) //{{{ { g_substrings = []; var items = []; @@ -415,9 +415,9 @@ function get_buffer_completions(filter)/*{{{*/ return [$_[0][0], $_[1]]; }); return build_longest_common_substring(items, filter); -}/*}}}*/ +} //}}} -function exTabCompletion(str) +function exTabCompletion(str) //{{{ { var [count, cmd, special, args] = tokenize_ex(str); var completions = new Array; @@ -448,6 +448,6 @@ function exTabCompletion(str) } } return [start, completions]; -} +} //}}} // vim: set fdm=marker sw=4 ts=4 et: diff --git a/chrome/content/vimperator/file.js b/chrome/content/vimperator/file.js index 5c48cceb..d1ad7b2b 100644 --- a/chrome/content/vimperator/file.js +++ b/chrome/content/vimperator/file.js @@ -46,7 +46,7 @@ function fopen (path, mode, perms, tmp) return new LocalFile(path, mode, perms, tmp); } -function LocalFile(file, mode, perms, tmp) +function LocalFile(file, mode, perms, tmp) // {{{ { const classes = Components.classes; const interfaces = Components.interfaces; @@ -55,13 +55,13 @@ function LocalFile(file, mode, perms, tmp) const FILEIN_CTRID = "@mozilla.org/network/file-input-stream;1"; const FILEOUT_CTRID = "@mozilla.org/network/file-output-stream;1"; const SCRIPTSTREAM_CTRID = "@mozilla.org/scriptableinputstream;1"; - + const nsIFile = interfaces.nsIFile; const nsILocalFile = interfaces.nsILocalFile; const nsIFileOutputStream = interfaces.nsIFileOutputStream; const nsIFileInputStream = interfaces.nsIFileInputStream; const nsIScriptableInputStream = interfaces.nsIScriptableInputStream; - + if (typeof perms == "undefined") perms = 0666 & ~(PERM_IWOTH | PERM_IWGRP); @@ -82,7 +82,7 @@ function LocalFile(file, mode, perms, tmp) throw "Invalid mode ``" + mode + "''"; } } - + if (typeof file == "string") { this.localFile = classes[LOCALFILE_CTRID].createInstance(nsILocalFile); @@ -102,14 +102,14 @@ function LocalFile(file, mode, perms, tmp) } this.path = this.localFile.path; - + if (mode & (MODE_WRONLY | MODE_RDWR)) { - this.outputStream = + this.outputStream = classes[FILEOUT_CTRID].createInstance(nsIFileOutputStream); this.outputStream.init(this.localFile, mode, perms, 0); } - + if (mode & (MODE_RDONLY | MODE_RDWR)) { var is = classes[FILEIN_CTRID].createInstance(nsIFileInputStream); @@ -117,7 +117,7 @@ function LocalFile(file, mode, perms, tmp) this.inputStream = classes[SCRIPTSTREAM_CTRID].createInstance(nsIScriptableInputStream); this.inputStream.init(is); - } + } } @@ -126,7 +126,7 @@ function fo_write(buf) { if (!("outputStream" in this)) throw "file not open for writing."; - + return this.outputStream.write(buf, buf.length); } @@ -154,8 +154,8 @@ function fo_read(max) max = av; if (!av) - return null; - + return null; + var rv = this.inputStream.read(max); return rv; } @@ -174,5 +174,6 @@ function fo_close() { return this.outputStream.flush(); } +//}}} // vim: set fdm=marker sw=4 ts=4 et: diff --git a/chrome/content/vimperator/find.js b/chrome/content/vimperator/find.js index 4d75ce24..e61016c3 100644 --- a/chrome/content/vimperator/find.js +++ b/chrome/content/vimperator/find.js @@ -1,4 +1,4 @@ -/***** BEGIN LICENSE BLOCK ***** +/***** BEGIN LICENSE BLOCK ***** {{{ Version: MPL 1.1/GPL 2.0/LGPL 2.1 The contents of this file are subject to the Mozilla Public License Version @@ -26,7 +26,7 @@ decision by deleting the provisions above and replace them with the notice and other provisions required by the GPL or the LGPL. If you do not delete 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 *****/ +}}} ***** END LICENSE BLOCK *****/ // Finder for vimperator // Author: Nigel McNie @@ -175,7 +175,7 @@ function highlightFind(str, color, wrapped, dir, pt) selectionRange = retRange.cloneRange(); // highlightAllBut(str, retRange, color); } else { - + } return selectionRange; @@ -185,7 +185,7 @@ function highlightFind(str, color, wrapped, dir, pt) function clearHighlight() { gFindBar.highlightDoc(); - var win = window._content; + var win = window._content; var doc = win.document; if (!document) return; @@ -214,7 +214,7 @@ function abs_point (node) { var orig = node; var pt = {}; try { - pt.x = node.offsetLeft; + pt.x = node.offsetLeft; pt.y = node.offsetTop; // Find imagemap's coordinates @@ -241,7 +241,7 @@ function abs_point (node) { // Vimperator searcher // make sure you only create this object when the "vimperator" object is ready //Vimperator.prototype.search = new function() -function Search() +function Search() //{{{ { var self = this; // needed for callbacks since "this" is the "vimperator" object in a callback this.gWin = null; @@ -319,7 +319,7 @@ function Search() } // Called when the user types a key in the search dialog. Triggers a find attempt - this.searchKeyPressed = function(command) { + this.searchKeyPressed = function(command) { if (command != "") { var str = vimperator.commandline.getCommand(); this.find(str, true, this.lastFindState()["point"]); @@ -408,7 +408,7 @@ function Search() this.lastFindState = function() { return this.gFindState[this.gFindState.length - 1]; } - + // Adds a find state to the stack of such states. This is done every time a find is successful this.addFindState = function(screenX, screenY, searchStr, wrapped, point, range, selection, direction) { var state = new Array(); @@ -422,7 +422,7 @@ function Search() state["direction"] = direction; this.gFindState.push(state); } - + // Finds text in a page this.find = function(str, dir, pt) { @@ -434,7 +434,7 @@ function Search() // Should we wrap this time? var wrapped = this.lastFindState()["wrapped"]; var point = pt; - if (this.lastFindState()["wrapped"] == false + if (this.lastFindState()["wrapped"] == false && this.lastFindState()["range"] == null && this.lastFindState()["search-str"] == str && this.lastFindState()["direction"] == dir) { @@ -457,7 +457,7 @@ function Search() point, matchRange, matchRange, dir); } } -} +} //}}} // @TODO should be moved into commands.js vimperator.commands.add(new Command(["noh[lsearch]"], diff --git a/chrome/content/vimperator/help.js b/chrome/content/vimperator/help.js index 0c1c2668..67bd1fd8 100644 --- a/chrome/content/vimperator/help.js +++ b/chrome/content/vimperator/help.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 *****/ -function help(section, easter) +function help(section, easter) //{{{ { if (easter) { @@ -264,6 +264,6 @@ function help(section, easter) // horizontal offset is annoying, set it to 0 (use pos[0] if you want horizontal offset) window.content.scrollTo(0, pos[1]); } -} +} //}}} // vim: set fdm=marker sw=4 ts=4 et: diff --git a/chrome/content/vimperator/hints.js b/chrome/content/vimperator/hints.js index 2fab63e3..e766bd88 100644 --- a/chrome/content/vimperator/hints.js +++ b/chrome/content/vimperator/hints.js @@ -1,4 +1,4 @@ -/** +/***** BEGIN LICENSE BLOCK ***** {{{ * * Mozilla Public License Notice * @@ -20,9 +20,9 @@ * Contributor(s): Pekka Sillanpaa, Paul Stone * adapted for vimperator use by: Martin Stubenschrott * - */ +}}} ***** END LICENSE BLOCK *****/ -function hit_a_hint() +function hit_a_hint() //{{{ { const HINT_PREFIX = 'hah_hint_'; // prefix for the hint id @@ -39,12 +39,12 @@ function hit_a_hint() var linkNumString = ""; // the typed link number is in this string var linkCount = 0; var state = 0; // 0: empty or processing, 1: a full hint was parsed - + var wins; // frame array - + // each hint element is a clone of this element var hintElemSpan; - + //////////////////////////////////////////////////////////////////////////////// // configuration and initialization related functions //////////////////////////////////////////////////////////////////////////////// @@ -54,17 +54,17 @@ function hit_a_hint() // isHahModeEnabled = false; // hintedElem = null; // } - + //////////////////////////////////////////////////////////////////////////////// // hint activating and loading related functions //////////////////////////////////////////////////////////////////////////////// - + function startCoordLoader(doc) { win = doc.defaultView; if (!win) return; - + if (win.winId != null) { window.clearTimeout(win.coordLoaderId); @@ -73,31 +73,31 @@ function hit_a_hint() { if (!wins) wins = new Array(); - - win.winId = wins.length; + + win.winId = wins.length; wins.push(win); } // logMessage("winId:"+win.winId); win.res = evaluateXPath(vimperator.options["hinttags"], doc); win.coordLoaderId = window.setTimeout("hah.loadCoord(" + win.winId + ", 0);", 1); } - + this.loadCoord = function(winId, i) { win = wins[winId]; var elem = win.res.snapshotItem(i); - + if (elem) genElemCoords(elem); - + i++; - + if (i < win.res.snapshotLength && !isHahModeEnabled) window.setTimeout("hah.loadCoord(" + winId + ", "+ i +");", 1); else win.coordLoaderId = null; }; - + function genElemCoords(elem) { if (typeof(elem.validCoord) != "undefined") @@ -105,7 +105,7 @@ function hit_a_hint() if (elem.validCoord == elem.ownerDocument.validCoords) return; } - + if (elem.offsetParent) { genElemCoords(elem.offsetParent); @@ -119,7 +119,7 @@ function hit_a_hint() } elem.validCoord = elem.ownerDocument.validCoords; } - + function createHints(win) { if (!win) @@ -127,31 +127,31 @@ function hit_a_hint() win = window._content; linkCount = 0; } - + var area = new Array(4); area[0] = win.pageXOffset - 5; area[1] = win.pageYOffset - 5; area[2] = area[0] + win.innerWidth; area[3] = area[1] + win.innerHeight; - + var doc = win.document; var res = evaluateXPath(vimperator.options["hinttags"], doc); - + var elem, i; - + hintElemSpan = doc.createElement('SPAN'); hintElemSpan.style.cssText = vimperator.options["hintstyle"]; hintElemSpan.setAttribute('name', 'hah_hint'); - + var hintContainer = doc.getElementById('hah_hints'); - + if (hintContainer == null) { genHintContainer(doc); hintContainer = doc.getElementById('hah_hints'); } hintContainer.valid_hint_count = 0; // none of these hints should be visible initially - + var hints = hintContainer.childNodes; var maxhints = vimperator.options["maxhints"]; for (i = 0; i < res.snapshotLength; i++) @@ -162,22 +162,22 @@ function hit_a_hint() elem = res.snapshotItem(i); genElemCoords(elem); - + // for extended hint mode, show all - even currently hidden - hints //if (hintmode == HINT_MODE_QUICK && (elem.absoTop < area[1] || elem.absoTop > area[3] || if (vimperator.hasMode(vimperator.modes.QUICK_HINT) && (elem.absoTop < area[1] || elem.absoTop > area[3] || elem.absoLeft > area[2] || elem.absoLeft < area[0])) continue; - + // XXX: what does that do // if (elem.offsetWidth == 0 && elem.offsetHeight == 0) // continue; - + var cs = doc.defaultView.getComputedStyle(elem, null); - + if (cs.getPropertyValue("visibility") == "hidden") continue; - + if (linkCount < hints.length) hintElem = hints[linkCount]; else // need to attach this new hintElem to the hint container @@ -185,22 +185,22 @@ function hit_a_hint() hintElem = hintElemSpan.cloneNode(false); hintContainer.appendChild(hintElem); } - + hintElem.style.display = 'none'; hintElem.style.top = elem.absoTop + "px"; hintElem.style.left = elem.absoLeft + "px"; hintElem.refElem = elem; - + hintContainer.valid_hint_count++; // one more visible hint in this frame linkCount++; // and one more total hint } - + doc.coordsInvalidated = false; - + // recursively create hints for (i = 0; i < win.frames.length; i++) createHints(win.frames[i]); - + } function showHints(win, off) @@ -245,7 +245,7 @@ function hit_a_hint() for (j = 0; j < win.frames.length; j++) showHints(win.frames[j], offset); } - + /* removes all visible hints from doc * or from current document, if win == null */ @@ -253,22 +253,22 @@ function hit_a_hint() { if (!win) win = window.content; - + var doc = win.document; var res = evaluateXPath("//HINTS/SPAN", doc) var elem, i; - + for (i = 0; i < res.snapshotLength; i++) { elem = res.snapshotItem(i); - setHintStyle(elem, vimperator.options["hintstyle"]); + setHintStyle(elem, vimperator.options["hintstyle"]); elem.style.display = 'none'; } - + for (i = 0; i < win.frames.length; i++) removeHints(win.frames[i]); } - + function onResize(event) { if(event) @@ -279,7 +279,7 @@ function hit_a_hint() invalidateCoords(doc); startCoordLoader(doc); } - + function invalidateCoords(doc) { if (!doc.coordsInvalidated) @@ -297,19 +297,19 @@ function hit_a_hint() // logMessage(doc.validCoords); } } - + function getHintById(id, win) { if (!win) win = window._content; - + var doc = win.document; var elem, i; - + //var hintId = parseInt(id, nums.length); //elem = doc.getElementById(prefix + hintId); elem = doc.getElementById(HINT_PREFIX + id); - + if (elem) { return elem; @@ -319,18 +319,18 @@ function hit_a_hint() for (i = 0; i < win.frames.length; i++) { elem = getHintById(id, win.frames[i]); - if (elem) + if (elem) return elem; } } return null; } - + function formatHint(hintNum) { var hintCharacters = vimperator.options["hintchars"]; var str = hintNum.toString(hintCharacters.length); // turn hintNum into a base(length) number - + // map the number onto the chars in the numbers string var result = ''; // make all links the same length @@ -343,15 +343,15 @@ function hit_a_hint() result += hintCharacters.charAt(0).toUpperCase(); hintLength--; } - + for (var i = 0; i < str.length; i++) result += (hintCharacters.charAt(parseInt(str[i], hintCharacters.length))).toUpperCase(); return result; } - + function setHintStyle(hintElem, styleString) - { + { if (hintElem && hintElem.style) { xTemp = hintElem.style.left; @@ -361,13 +361,13 @@ function hit_a_hint() hintElem.style.top = yTemp; } } - + function changeHintFocus(linkNumString, oldLinkNumString) { var styleString = vimperator.options["hintstyle"]; var styleStringFocus = vimperator.options["focusedhintstyle"]; var hintElem; - + if (oldLinkNumString.length > 0) { hintElem = getHintById(oldLinkNumString); @@ -376,16 +376,16 @@ function hit_a_hint() if (linkNumString.length > 0) { hintElem = getHintById(linkNumString); - setHintStyle(hintElem, styleStringFocus); + setHintStyle(hintElem, styleStringFocus); if(hintElem) setMouseOverElement(hintElem.refElem); } } - + //////////////////////////////////////////////////////////////////////////////// // basic functionality //////////////////////////////////////////////////////////////////////////////// - + /** * Enables the HaH-mode by showing the hints and prepare to input the * hint numbers @@ -404,13 +404,13 @@ function hit_a_hint() linkCount = 0; linkNumString = ''; isHahModeEnabled = true; - + createHints(); showHints(null, 0); - + return true; }; - + /** * Disables the HaH-mode by hiding the hints and disabling the input mode * @@ -434,7 +434,7 @@ function hit_a_hint() hintedElems = []; // if (!silent && vimperator.options["showmode"]) // vimperator.echo(''); - + removeHints(win); return 0; }; @@ -443,17 +443,17 @@ function hit_a_hint() { linkNumString = ''; state = 0; - + while(hintedElems.length > 0) { var elem = hintedElems.pop(); if (!elem) return 0; // reset style attribute - setHintStyle(elem, vimperator.options["hintstyle"]); + setHintStyle(elem, vimperator.options["hintstyle"]); } }; - + this.reshowHints = function() { @@ -466,8 +466,8 @@ function hit_a_hint() showHints(null, 0); } }; - - + + // this function 'click' an element, which also works // for javascript links this.openHints = function(new_tab, new_window) @@ -480,7 +480,7 @@ function hit_a_hint() if (!elem) return 0; - setHintStyle(elem, vimperator.options["hintstyle"]); + setHintStyle(elem, vimperator.options["hintstyle"]); elem = elem.refElem; var elemTagName = elem.tagName; elem.focus(); @@ -559,7 +559,7 @@ function hit_a_hint() function setMouseOverElement(elem) { var doc = window.document; - + if (elem.tagName == 'FRAME' || elem.tagName == 'IFRAME') { elem.contentWindow.focus(); @@ -569,7 +569,7 @@ function hit_a_hint() { //elem.focus(); } - + var evt = doc.createEvent('MouseEvents'); var x = 0; var y = 0; @@ -580,15 +580,15 @@ function hit_a_hint() x = Number(coords[0]); y = Number(coords[1]); } - + evt.initMouseEvent('mouseover', true, true, doc.defaultView, 1, x, y, 0, 0, 0, 0, 0, 0, 0, null); elem.dispatchEvent(evt); } - + //////////////////////////////////////////////////////////////////////////////// // event handlers //////////////////////////////////////////////////////////////////////////////// - + // returns nr. of fully parsed links when a new hint has been found, // otherwise 0 if current state is part of a hint, or -1 if an error occured // (like we have typed keys which never can become a hint @@ -599,7 +599,7 @@ function hit_a_hint() // reset state to show that we are in processing mode state = 0; - + var num = String.fromCharCode(event.charCode).toUpperCase(); var hintCharacters = vimperator.options["hintchars"]; if (num != null && hintCharacters.toUpperCase().indexOf(num) > -1) @@ -633,38 +633,38 @@ function hit_a_hint() // an unparseable or wrong key return -1; } - + function genHintContainer(doc) { if (doc.getElementsByTagName('HINTS').length > 0) return; - + hints = doc.createElement('HINTS'); hints.id = "hah_hints"; hints.valid_hint_count = 0; // initially 0 elements are usable as hints doc.body.appendChild(hints); } - + function initDoc(event) { doc = event.originalTarget; genHintContainer(doc); isHahModeEnabled = false; hintedElems = []; - + if (!doc.validCoords) doc.validCoords = true; else doc.validCoords = false; - + // XXX: prepend a ! ? if (doc.coordsInvalidated) doc.coordsInvalidated = true; else doc.coordsInvalidated = false; - + startCoordLoader(doc); - + //if (hintmode == HINT_MODE_ALWAYS) if (vimperator.hasMode(vimperator.modes.ALWAYS_HINT)) { @@ -681,7 +681,7 @@ function hit_a_hint() window.document.addEventListener("pageshow", initDoc, null); window.addEventListener("resize", onResize, null); -} +} //}}} var hah = new hit_a_hint(); diff --git a/chrome/content/vimperator/mappings.js b/chrome/content/vimperator/mappings.js index 18636001..43a7d804 100644 --- a/chrome/content/vimperator/mappings.js +++ b/chrome/content/vimperator/mappings.js @@ -1,4 +1,3 @@ -// TODO: document function Map(mode, cmds, act, extra_info) //{{{ { if (!mode || (!cmds || !cmds.length) || !act) @@ -56,7 +55,7 @@ Map.prototype.toString = function() "\n}" } //}}} -function Mappings()//{{{ +function Mappings() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -664,7 +663,7 @@ function Mappings()//{{{ //}}} // TODO: Convert these to the new mappings model - var hint_maps = [ + var hint_maps = [ //{{{ /* hint action keys */ ["o", "hah.openHints(false, false);", true, false], ["t", "hah.openHints(true, false);", true, false], @@ -701,7 +700,7 @@ function Mappings()//{{{ ["", "", true, true], ["", "", true, true], ["", "", true, true] - ]; -}//}}} + ]; //}}} +} //}}} // vim: set fdm=marker sw=4 ts=4 et: diff --git a/chrome/content/vimperator/options.js b/chrome/content/vimperator/options.js index 7e90fd39..4472b547 100644 --- a/chrome/content/vimperator/options.js +++ b/chrome/content/vimperator/options.js @@ -1,4 +1,4 @@ -function Option(names, type, extra_info)//{{{ +function Option(names, type, extra_info) //{{{ { if (!names || !type) return null; @@ -79,9 +79,9 @@ function Option(names, type, extra_info)//{{{ "\n\tvalidator: " + this.validator + "\n}" } -}//}}} +} //}}} -function Options()//{{{ +function Options() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// @@ -484,6 +484,6 @@ function Options()//{{{ setShowTabline(this.showtabline); setGuiOptions(this.guioptions); setTitleString(this.titlestring); -}//}}} +} //}}} // vim: set fdm=marker sw=4 ts=4 et: diff --git a/chrome/content/vimperator/ui.js b/chrome/content/vimperator/ui.js index 33910a16..e8be7008 100644 --- a/chrome/content/vimperator/ui.js +++ b/chrome/content/vimperator/ui.js @@ -1,6 +1,5 @@ // XXX: move somehere else! - -function multiliner(line, prev_match, heredoc) +function multiliner(line, prev_match, heredoc) //{{{ { var end = true; var match = tokenize_ex(line, prev_match[4]); @@ -39,8 +38,7 @@ function multiliner(line, prev_match, heredoc) } } return [prev_match, heredoc, end]; -} - +} //}}} /* * This class is used for prompting of user input and echoing of messages @@ -48,11 +46,12 @@ function multiliner(line, prev_match, heredoc) * it consists of a prompt and command field * be sure to only create objects of this class when the chrome is ready */ -function CommandLine () +function CommandLine() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ + const UNINITIALIZED = -2; // notifies us, if we need to start history/tab-completion from the beginning const HISTORY_SIZE = 500; @@ -148,9 +147,9 @@ function CommandLine () history = history.slice(HISTORY_SIZE / 10); } - //////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ this.getCommand = function() { @@ -240,7 +239,7 @@ function CommandLine () vimperator.setMode(old_mode || vimperator.modes.NORMAL, old_extended_mode || null, silent); cur_command = command; - // don't add the echoed command to the history, on pressing , the + // don't add the echoed command to the history, on pressing , the // command is saved right into the kepress handler if(!echo_allowed) addToHistory(command); @@ -265,7 +264,7 @@ function CommandLine () { //event.stopPropagation(); // XXX: doesnt seem to work //event.preventDefault(); // so we need to use the hack below --mst - + // NOTE: echo_allowed is a misleading name here, actually this flag is set // so that we don't save a history entry if the user clicks into the text field echo_allowed = true; @@ -319,7 +318,7 @@ function CommandLine () else if (key == "" || key == "") { //always reset the tab completion if we use up/down keys - completion_index = UNINITIALIZED; + completion_index = UNINITIALIZED; /* save 'start' position for iterating through the history */ if (history_index == UNINITIALIZED) @@ -366,7 +365,7 @@ function CommandLine () history_index = UNINITIALIZED; // we need to build our completion list first - if (completion_index == UNINITIALIZED) + if (completion_index == UNINITIALIZED) { completion_start_index = 0; @@ -501,7 +500,8 @@ function CommandLine () { Options.setPref("commandline_history", history.join("\n")); } -} + //}}} +} //}}} /** * The list which is used for the completion box, the preview window and the buffer preview window @@ -509,11 +509,15 @@ function CommandLine () * @param id: the id of the the XUL widget which we want to fill * @param options: an optional hash which modifies the behavior of the list */ -function InformationList(id, options) +function InformationList(id, options) //{{{ { + //////////////////////////////////////////////////////////////////////////////// + ////////////////////// PRIVATE SECTION ///////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ + const CONTEXT_LINES = 3; - var max_items = 10; - var min_items = 1; + var max_items = 10; + var min_items = 1; var incremental_fill = true; // make display faster, but does not show scrollbar if(options) @@ -555,7 +559,7 @@ function InformationList(id, options) /** * uses the entries in completions to fill the listbox - * + * * @param startindex: start at this index and show max_items * @returns the number of items */ @@ -591,10 +595,10 @@ function InformationList(id, options) return (i-startindex); } - //////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////// - + /////////////////////////////////////////////////////////////////////////////{{{ + /** * Show the completion list window * @@ -702,13 +706,15 @@ function InformationList(id, options) else return false; } -} + //}}} +} //}}} -function StatusLine() +function StatusLine() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ + // our status bar fields var statusline_widget = document.getElementById("vimperator-statusline"); var url_widget = document.getElementById("vimperator-statusline-field-url"); @@ -717,9 +723,10 @@ function StatusLine() var tabcount_widget = document.getElementById("vimperator-statusline-field-tabcount"); var bufferposition_widget = document.getElementById("vimperator-statusline-field-bufferposition"); - //////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ + // use names for the color or "transparent" to remove color information this.setColor = function(color) { @@ -808,6 +815,7 @@ function StatusLine() bufferposition_widget.value = bufferposition_str; }; -} + //}}} +} //}}} // vim: set fdm=marker sw=4 ts=4 et: diff --git a/chrome/content/vimperator/vimperator.js b/chrome/content/vimperator/vimperator.js index f82695f2..48fec5f2 100644 --- a/chrome/content/vimperator/vimperator.js +++ b/chrome/content/vimperator/vimperator.js @@ -35,15 +35,16 @@ var popup_allowed_events; // need to change and reset this firefox pref XXX: mov window.addEventListener("load", init, false); //////////////////////////////////////////////////////////////////////// -// init/uninit //////////////////////////////////////////////////// {{{1 -//////////////////////////////////////////////////////////////////////// -function init() +// init/uninit ///////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////{{{ + +function init() //{{{ { window.dump("in init\n"); // init the main object vimperator = new Vimperator; vimperator.log("Initializing vimperator object...", 1); - + // these inner classes are created here, because outside the init() // function, the chrome:// is not ready vimperator.log("Loading module options...", 3); @@ -109,7 +110,7 @@ function init() setTimeout(function() { help(null, null, null, { inTab: true }); Options.setPref("firsttime", false); - }, 1000); + }, 1000); } gURLBar.blur(); @@ -127,9 +128,9 @@ function init() window.addEventListener("unload", unload, false); vimperator.log("Vimperator fully initialized", 1); -} +} //}}} -function unload() +function unload() //{{{ { /*** save our preferences ***/ vimperator.commandline.destroy(); @@ -140,15 +141,15 @@ function unload() if (Options.getFirefoxPref('dom.popup_allowed_events', 'change click dblclick mouseup reset submit') == popup_allowed_events + " keypress") Options.setFirefoxPref('dom.popup_allowed_events', popup_allowed_events); -} +} //}}} +//}}} - - -function Vimperator() //{{{1 +function Vimperator() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ + this.modes = { // actually not private, but Firefox complains if this doesn't come first // main modes NONE: 0, @@ -213,9 +214,10 @@ function Vimperator() //{{{1 vimperator.echo("-- " + str_mode + str_extended + " --"); } - //////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ + this.version = "###VERSION### CVS (created: ###DATE###)"; /////////////// callbacks //////////////////////////// @@ -344,13 +346,14 @@ function Vimperator() //{{{1 } this.log(string, level); } -} + //}}} +} //}}} -function Events() //{{{1 +function Events() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// CONSTRUCTOR ///////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ // this handler is for middle click only in the content //window.addEventListener("mousedown", onVimperatorKeypress, true); @@ -373,7 +376,7 @@ function Events() //{{{1 updateBufferList(); vimperator.setMode(); // trick to reshow the mode in the command line }, false); - tabcontainer.addEventListener("TabSelect", function(event) { + tabcontainer.addEventListener("TabSelect", function(event) { vimperator.statusline.updateTabCount(); updateBufferList(); vimperator.setMode(); // trick to reshow the mode in the command line @@ -395,9 +398,10 @@ function Events() //{{{1 //alert("titlechanged"); }, null); - //////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PRIVATE SECTION ///////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ + function onPageLoad(event) { if (event.originalTarget instanceof HTMLDocument) @@ -410,7 +414,7 @@ function Events() //{{{1 // when you click on a link inside a frameset, because asyncUpdateUI // is not triggered there (firefox bug?) setTimeout(vimperator.statusline.updateUrl, 10); - return; + return; } // code which should happen for all (also background) newly loaded tabs goes here: @@ -431,9 +435,10 @@ function Events() //{{{1 } } - //////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ + this.destroy = function() { // BIG TODO: removeEventListeners() to avoid mem leaks @@ -475,7 +480,7 @@ function Events() //{{{1 // XXX: for now only, later: input mappings if form element focused if (isFormElemFocused()) return false; - + // handle Escape-one-key mode (Ctrl-v) if (vimperator.hasMode(vimperator.modes.ESCAPE_ONE_KEY) && !vimperator.hasMode(vimperator.modes.ESCAPE_ALL_KEYS)) { @@ -718,11 +723,11 @@ function Events() //{{{1 vimperator.statusline.updateProgress(); // if this is not delayed we get the wrong position of the old buffer - setTimeout(function() { vimperator.statusline.updateBufferPosition(); }, 100); + setTimeout(function() { vimperator.statusline.updateBufferPosition(); }, 100); }, // called at the very end of a page load asyncUpdateUI: function() - { + { setTimeout(vimperator.statusline.updateUrl, 100); }, setOverLink : function(link, b) @@ -735,7 +740,7 @@ function Events() //{{{1 else if (ssli == 2) vimperator.echo("Link: " + link); } - + if (link == "") { if (ssli == 1) @@ -759,14 +764,14 @@ function Events() //{{{1 .getInterface(Components.interfaces.nsIXULWindow) .XULBrowserWindow = window.XULBrowserWindow; getBrowser().addProgressListener(this.progressListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL); - -} + //}}} +} //}}} // this function converts the given event to // a keycode which can be used in mappings // e.g. pressing ctrl+n would result in the string "" // null if unknown key -KeyboardEvent.prototype.toString = function () +KeyboardEvent.prototype.toString = function() //{{{ { var key = String.fromCharCode(this.charCode); var modifier = ""; @@ -853,18 +858,18 @@ KeyboardEvent.prototype.toString = function () } else // a key like F1 is always enclosed in < and > return "<" + modifier + key + ">"; -} +} //}}} /** provides functions for working with tabs * XXX: ATTENTION: We are planning to move to the FUEL API once we switch to * Firefox 3.0, then this class should go away and their tab methods should be used * @deprecated */ -function Tabs() //{{{1 +function Tabs() //{{{ { //////////////////////////////////////////////////////////////////////////////// ////////////////////// PRIVATE SECTION ///////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ /** @param spec can either be: * - an absolute integer * - "" for the current tab @@ -907,9 +912,9 @@ function Tabs() //{{{1 return position; } - //////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// PUBLIC SECTION ////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////{{{ // @returns the index of the currently selected tab starting with 0 this.index = function(tab) { @@ -1004,43 +1009,44 @@ function Tabs() //{{{1 /* XXX: disabled until we find a better way where to update the titles, right now * it has O(n^2) complexity on firefox start when we load 50 tabs * (c) by hrist - + window.addEventListener("TabMove", function() { vimperator.statusline.updateTabCount(); vimperator.tabs.updateTitles(); }, false); window.addEventListener("TabOpen", function() { vimperator.statusline.updateTabCount(); vimperator.tabs.updateTitles(); }, false); window.addEventListener("TabClose", function() { vimperator.statusline.updateTabCount(); vimperator.tabs.updateTitles(); }, false); this.updateTitles = function(forceclear) - { + { for(var i=0;i < vimperator.tabs.count();i++) - { + { var old_title = getBrowser().mTabContainer.childNodes[i].getAttribute("label"); var split_title = old_title.match(/^(\d+:\s+)(.*)/); if(forceclear) - { + { for(var i=0;i