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

normalise fold markers

This commit is contained in:
Doug Kearns
2007-06-22 10:42:37 +00:00
parent e962dce8af
commit 3bceee7721
11 changed files with 311 additions and 286 deletions

View File

@@ -2,7 +2,7 @@
* also includes methods for dealing with * also includes methods for dealing with
* keywords and search engines * keywords and search engines
*/ */
function Bookmarks()//{{{ function Bookmarks() //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -11,7 +11,7 @@ function Bookmarks()//{{{
getService(Components.interfaces.nsIBrowserSearchService); getService(Components.interfaces.nsIBrowserSearchService);
const rdf_service = Components.classes["@mozilla.org/rdf/rdf-service;1"]. const rdf_service = Components.classes["@mozilla.org/rdf/rdf-service;1"].
getService( Components.interfaces.nsIRDFService ); getService( Components.interfaces.nsIRDFService );
var bookmarks = null; var bookmarks = null;
var keywords = null; var keywords = null;
@@ -76,36 +76,36 @@ function Bookmarks()//{{{
* @returns number of deleted bookmarks * @returns number of deleted bookmarks
*/ */
this.remove = function(url) this.remove = function(url)
{ {
var deleted = 0; var deleted = 0;
if(!url) if(!url)
return 0; return 0;
// gNC_NS for trunk, NC_NS for 1.X // gNC_NS for trunk, NC_NS for 1.X
//try { var pNC_NS; pNC_NS = gNC_NS;} catch (err) { pNC_NS = NC_NS;} //try { var pNC_NS; pNC_NS = gNC_NS;} catch (err) { pNC_NS = NC_NS;}
if (!BMSVC || !BMDS || !RDF || !gNC_NS) // defined from firefox if (!BMSVC || !BMDS || !RDF || !gNC_NS) // defined from firefox
return 0; return 0;
var curfolder = RDF.GetResource("NC:BookmarksRoot"); 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); var urlLiteral = RDF.GetLiteral(url);
if (BMDS.hasArcIn(urlLiteral, urlArc)) if (BMDS.hasArcIn(urlLiteral, urlArc))
{ {
var bmResources, bmResource, title, uri, type, ptype; var bmResources, bmResource, title, uri, type, ptype;
bmResources = BMSVC.GetSources(urlArc, urlLiteral, true); bmResources = BMSVC.GetSources(urlArc, urlLiteral, true);
while (bmResources.hasMoreElements()) while (bmResources.hasMoreElements())
{ {
bmResource = bmResources.getNext(); bmResource = bmResources.getNext();
type = BookmarksUtils.resolveType(bmResource); type = BookmarksUtils.resolveType(bmResource);
if (type != "ImmutableBookmark") { if (type != "ImmutableBookmark") {
ptype = BookmarksUtils.resolveType(BMSVC.getParent(bmResource)); ptype = BookmarksUtils.resolveType(BMSVC.getParent(bmResource));
// alert(type); // alert(type);
// if ( type == "Folder") // store the current folder // if ( type == "Folder") // store the current folder
// curfolder = bmResource; // curfolder = bmResource;
if ( (type == "Bookmark" || type == "IEFavorite") && ptype != "Livemark") if ( (type == "Bookmark" || type == "IEFavorite") && ptype != "Livemark")
{ {
title = BookmarksUtils.getProperty(bmResource, gNC_NS + "Name"); title = BookmarksUtils.getProperty(bmResource, gNC_NS + "Name");
uri = BookmarksUtils.getProperty(bmResource, gNC_NS + "URL"); uri = BookmarksUtils.getProperty(bmResource, gNC_NS + "URL");
if (uri == url) if (uri == url)
{ {
@@ -113,16 +113,16 @@ function Bookmarks()//{{{
RDFC.RemoveElement(bmResource, true); RDFC.RemoveElement(bmResource, true);
deleted++; deleted++;
} }
} }
} }
} }
} }
// also update bookmark cache, if we removed at least one bookmark // also update bookmark cache, if we removed at least one bookmark
if(deleted > 0) if(deleted > 0)
load(); load();
return deleted; return deleted;
} }
/* also ensures that each search engine has a vimperator-friendly alias */ /* also ensures that each search engine has a vimperator-friendly alias */
@@ -262,9 +262,9 @@ function Bookmarks()//{{{
return res; return res;
} }
//}}} //}}}
}//}}} } //}}}
function History()//{{{ function History() //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -345,9 +345,9 @@ function History()//{{{
return true; return true;
}; };
//}}} //}}}
}//}}} } //}}}
function Marks()//{{{ function Marks() //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -408,7 +408,7 @@ function Marks()//{{{
} }
return ok; return ok;
} }
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
@@ -520,13 +520,13 @@ function Marks()//{{{
} }
return this; return this;
} }
// TODO: show marks like vim does (when the multiline echo impl is done) or in the preview windwo right now // TODO: show marks like vim does (when the multiline echo impl is done) or in the preview windwo right now
this.list = function() this.list = function()
{ {
return this; return this;
} }
//}}} //}}}
}//}}} } //}}}
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -27,7 +27,7 @@ the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
/* [command, action, cancel_hint_mode, always_active] */ /* [command, action, cancel_hint_mode, always_active] */
var g_hint_mappings = [ /*{{{*/ var g_hint_mappings = [ //{{{
/* hint action keys */ /* hint action keys */
["o", "hah.openHints(false, false);", true, false], ["o", "hah.openHints(false, false);", true, false],
["t", "hah.openHints(true, false);", true, false], ["t", "hah.openHints(true, false);", true, false],
@@ -64,9 +64,9 @@ var g_hint_mappings = [ /*{{{*/
["<C-g>", "", true, true], ["<C-g>", "", true, true],
["<C-[>", "", true, true], ["<C-[>", "", true, true],
["<Esc>", "", true, true] ["<Esc>", "", true, true]
]; /*}}}*/ ]; //}}}
function Command(specs, action, extra_info)//{{{ function Command(specs, action, extra_info) //{{{
{ {
if (!specs || !action) if (!specs || !action)
return null; return null;
@@ -129,7 +129,7 @@ function Command(specs, action, extra_info)//{{{
this.completer = extra_info.completer || null; this.completer = extra_info.completer || null;
} }
}//}}} }
Command.prototype.execute = function(args, special, count, modifiers) Command.prototype.execute = function(args, special, count, modifiers)
{ {
@@ -176,9 +176,9 @@ Command.prototype.toString = function()
"\n\taction: " + this.action + "\n\taction: " + this.action +
"\n\tcompleter: " + this.completer + "\n\tcompleter: " + this.completer +
"\n}" "\n}"
} } //}}}
function Commands()//{{{ function Commands() //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// 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%." 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) if (!cmd)
return; return;
@@ -795,7 +795,11 @@ function execute_command(count, cmd, special, args, modifiers) // {{{
// valid command, call it: // valid command, call it:
command.execute(args, special, count, modifiers); command.execute(args, special, count, modifiers);
} // }}} } //}}}
/////////////////////////////////////////////////////////////////////}}}
// Ex command parsing and execution ////////////////////////////////////
/////////////////////////////////////////////////////////////////////{{{
// return [null, null, null, null, heredoc_tag || false]; // return [null, null, null, null, heredoc_tag || false];
// [count, cmd, special, args] = match; // [count, cmd, special, args] = match;
@@ -852,9 +856,11 @@ function execute(string)
return execute_command.apply(this, tokens); return execute_command.apply(this, tokens);
} }
////////////////////////////////////////////////////////////////////////
// navigation functions /////////////////////////////////////////// {{{1 /////////////////////////////////////////////////////////////////////}}}
//////////////////////////////////////////////////////////////////////// // navigation functions ////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////{{{
function stepInHistory(steps) function stepInHistory(steps)
{ {
var index = getWebNavigation().sessionHistory.index + steps; var index = getWebNavigation().sessionHistory.index + steps;
@@ -893,11 +899,10 @@ function historyGoToEnd()
getWebNavigation().gotoIndex(max); getWebNavigation().gotoIndex(max);
} }
/////////////////////////////////////////////////////////////////////}}}
// url functions ///////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////{{{
////////////////////////////////////////////////////////////////////////
// url functions ////////////////////////////////////////////////// {{{1
////////////////////////////////////////////////////////////////////////
function openURLs(str) function openURLs(str)
{ {
var urls = stringToURLs(str); var urls = stringToURLs(str);
@@ -1027,9 +1032,9 @@ function isDirectory(url)
return false; return false;
} }
//////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////}}}
// frame related functions //////////////////////////////////////// {{{1 // frame related functions /////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////{{{
// TODO: allow callback for filtering out unwanted frames? User defined? // TODO: allow callback for filtering out unwanted frames? User defined?
function focusNextFrame(count, forward) function focusNextFrame(count, forward)
@@ -1040,7 +1045,7 @@ function focusNextFrame(count, forward)
// find all frames - depth-first search // find all frames - depth-first search
(function(frame) (function(frame)
{ {
if (frame.document.body.localName.toLowerCase() == "body") if (frame.document.body.localName.toLowerCase() == "body")
frames.push(frame); frames.push(frame);
for (var i = 0; i < frame.frames.length; i++) for (var i = 0; i < frame.frames.length; i++)
@@ -1122,9 +1127,10 @@ function focusNextFrame(count, forward)
} }
} }
//////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////}}}
// location handling ////////////////////////////////////////////// {{{1 // location handling ///////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////{{{
function getCurrentLocation() function getCurrentLocation()
{ {
return window.content.document.location.href; 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 // takes: -t "foo" -T "tag1,tag2", myurl
// converts that string to a useful url and title, and calls addBookmark // converts that string to a useful url and title, and calls addBookmark
function bmadd(str) 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 /* vimperator has a concept of URL marks
* these provide quick access to URLs with a single character * 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() function tab()
{ {
execute(arguments[0], null, null, {inTab: true}); execute(arguments[0], null, null, {inTab: true});
@@ -1320,9 +1329,10 @@ function updateBufferList()
vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex); vimperator.bufferwindow.selectItem(getBrowser().mTabContainer.selectedIndex);
} }
//////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////}}}
// scrolling ////////////////////////////////////////////////////// {{{1 // scrolling ///////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////{{{
function scrollBufferRelative(right, down) function scrollBufferRelative(right, down)
{ {
var win = document.commandDispatcher.focusedWindow; 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 */ /* also used to zoom out, when factor is negative */
@@ -1439,10 +1449,9 @@ function zoom_to(value)
vimperator.echo("Zoom value: " + value + "%"); vimperator.echo("Zoom value: " + value + "%");
} }
//}}}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// misc helper functions ////////////////////////////////////////// {{{1 // misc helper functions ////////////////////////////////////////////{{{
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
function copyToClipboard(str) function copyToClipboard(str)
@@ -1659,7 +1668,7 @@ function source(filename, silent)
function getEnv(variable) function getEnv(variable)
{ {
var environment = Components.classes["@mozilla.org/process/environment;1"] var environment = Components.classes["@mozilla.org/process/environment;1"]
.getService(Components.interfaces.nsIEnvironment); .getService(Components.interfaces.nsIEnvironment);
return environment.get(variable); return environment.get(variable);
} }
@@ -1726,5 +1735,6 @@ function evaluateXPath(expression, doc, ordered)
); );
return res; return res;
} }
//}}}
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -6,7 +6,7 @@ var g_substrings = [];
* used for the 'longest' setting for wildmode * used for the 'longest' setting for wildmode
* *
*/ */
function get_longest_substring()/*{{{*/ function get_longest_substring() //{{{
{ {
if (g_substrings.length == 0) if (g_substrings.length == 0)
return ''; return '';
@@ -18,11 +18,11 @@ function get_longest_substring()/*{{{*/
} }
//alert(longest); //alert(longest);
return longest; return longest;
}/*}}}*/ } //}}}
// function uses smartcase // function uses smartcase
// list = [ [['com1', 'com2'], 'text'], [['com3', 'com4'], 'text'] ] // list = [ [['com1', 'com2'], 'text'], [['com3', 'com4'], 'text'] ]
function build_longest_common_substring(list, filter)/*{{{*/ function build_longest_common_substring(list, filter) //{{{
{ {
var filtered = []; var filtered = [];
//var filter_length = filter.length; //var filter_length = filter.length;
@@ -65,10 +65,10 @@ function build_longest_common_substring(list, filter)/*{{{*/
} }
} }
return filtered; return filtered;
}/*}}}*/ } //}}}
/* this function is case sensitive */ /* this function is case sensitive */
function build_longest_starting_substring(list, filter)/*{{{*/ function build_longest_starting_substring(list, filter) //{{{
{ {
var filtered = []; var filtered = [];
//var filter_length = filter.length; //var filter_length = filter.length;
@@ -95,7 +95,7 @@ function build_longest_starting_substring(list, filter)/*{{{*/
} }
} }
return filtered; return filtered;
}/*}}}*/ } //}}}
/* /*
* filter a list of urls * filter a list of urls
@@ -104,7 +104,7 @@ function build_longest_starting_substring(list, filter)/*{{{*/
* depending on the 'complete' option * depending on the 'complete' option
* if the 'complete' argument is passed like "h", it temproarily overrides 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(); var completions = new Array();
g_substrings = []; g_substrings = [];
@@ -124,10 +124,10 @@ function get_url_completions(filter, complete)/*{{{*/
} }
return completions; return completions;
}/*}}}*/ } //}}}
/* discard all entries in the 'urls' array, which don't match 'filter */ /* 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 = []; var filtered = [];
// completions which don't match the url but just the description // 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); return filtered.concat(additional_completions);
}/*}}}*/ } //}}}
function get_search_completions(filter)/*{{{*/ function get_search_completions(filter) //{{{
{ {
var engines = vimperator.bookmarks.getSearchEngines().concat(vimperator.bookmarks.getKeywords()); var engines = vimperator.bookmarks.getSearchEngines().concat(vimperator.bookmarks.getKeywords());
@@ -197,21 +197,21 @@ function get_search_completions(filter)/*{{{*/
return [[$_[0]], $_[1]]; return [[$_[0]], $_[1]];
}); });
return build_longest_common_substring(mapped, filter); return build_longest_common_substring(mapped, filter);
}/*}}}*/ } //}}}
function get_history_completions(filter) function get_history_completions(filter) //{{{
{ {
var items = vimperator.history.get(); var items = vimperator.history.get();
return filter_url_array(items, filter); return filter_url_array(items, filter);
} } //}}}
function get_bookmark_completions(filter) function get_bookmark_completions(filter) //{{{
{ {
var bookmarks = vimperator.bookmarks.get(); var bookmarks = vimperator.bookmarks.get();
return filter_url_array(bookmarks, filter); return filter_url_array(bookmarks, filter);
} } //}}}
function get_file_completions(filter)/*{{{*/ function get_file_completions(filter) //{{{
{ {
//var completions = new Array(); //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 */ /* 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); return build_longest_starting_substring(mapped, new_filter);
}/*}}}*/ } //}}}
function get_help_completions(filter)/*{{{*/ function get_help_completions(filter) //{{{
{ {
var help_array = [[["introduction"], "Introductory text"], var help_array = [[["introduction"], "Introductory text"],
[["mappings"], "Normal mode commands"], [["mappings"], "Normal mode commands"],
@@ -280,9 +280,9 @@ function get_help_completions(filter)/*{{{*/
}); });
return build_longest_common_substring(help_array, filter); return build_longest_common_substring(help_array, filter);
}/*}}}*/ } //}}}
function get_command_completions(filter)/*{{{*/ function get_command_completions(filter) //{{{
{ {
//g_completions = []; //g_completions = [];
g_substrings = []; g_substrings = [];
@@ -297,9 +297,9 @@ function get_command_completions(filter)/*{{{*/
for (var command in vimperator.commands) for (var command in vimperator.commands)
completions.push([command.long_names, command.short_help]); completions.push([command.long_names, command.short_help]);
return build_longest_starting_substring(completions, filter); return build_longest_starting_substring(completions, filter);
}/*}}}*/ } //}}}
function get_options_completions(filter, unfiltered)/*{{{*/ function get_options_completions(filter, unfiltered) //{{{
{ {
g_substrings = []; g_substrings = [];
var options_completions = []; var options_completions = [];
@@ -379,9 +379,9 @@ function get_options_completions(filter, unfiltered)/*{{{*/
} }
return options_completions; return options_completions;
}/*}}}*/ } //}}}
function get_buffer_completions(filter)/*{{{*/ function get_buffer_completions(filter) //{{{
{ {
g_substrings = []; g_substrings = [];
var items = []; var items = [];
@@ -415,9 +415,9 @@ function get_buffer_completions(filter)/*{{{*/
return [$_[0][0], $_[1]]; return [$_[0][0], $_[1]];
}); });
return build_longest_common_substring(items, filter); return build_longest_common_substring(items, filter);
}/*}}}*/ } //}}}
function exTabCompletion(str) function exTabCompletion(str) //{{{
{ {
var [count, cmd, special, args] = tokenize_ex(str); var [count, cmd, special, args] = tokenize_ex(str);
var completions = new Array; var completions = new Array;
@@ -448,6 +448,6 @@ function exTabCompletion(str)
} }
} }
return [start, completions]; return [start, completions];
} } //}}}
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -46,7 +46,7 @@ function fopen (path, mode, perms, tmp)
return new LocalFile(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 classes = Components.classes;
const interfaces = Components.interfaces; 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 FILEIN_CTRID = "@mozilla.org/network/file-input-stream;1";
const FILEOUT_CTRID = "@mozilla.org/network/file-output-stream;1"; const FILEOUT_CTRID = "@mozilla.org/network/file-output-stream;1";
const SCRIPTSTREAM_CTRID = "@mozilla.org/scriptableinputstream;1"; const SCRIPTSTREAM_CTRID = "@mozilla.org/scriptableinputstream;1";
const nsIFile = interfaces.nsIFile; const nsIFile = interfaces.nsIFile;
const nsILocalFile = interfaces.nsILocalFile; const nsILocalFile = interfaces.nsILocalFile;
const nsIFileOutputStream = interfaces.nsIFileOutputStream; const nsIFileOutputStream = interfaces.nsIFileOutputStream;
const nsIFileInputStream = interfaces.nsIFileInputStream; const nsIFileInputStream = interfaces.nsIFileInputStream;
const nsIScriptableInputStream = interfaces.nsIScriptableInputStream; const nsIScriptableInputStream = interfaces.nsIScriptableInputStream;
if (typeof perms == "undefined") if (typeof perms == "undefined")
perms = 0666 & ~(PERM_IWOTH | PERM_IWGRP); perms = 0666 & ~(PERM_IWOTH | PERM_IWGRP);
@@ -82,7 +82,7 @@ function LocalFile(file, mode, perms, tmp)
throw "Invalid mode ``" + mode + "''"; throw "Invalid mode ``" + mode + "''";
} }
} }
if (typeof file == "string") if (typeof file == "string")
{ {
this.localFile = classes[LOCALFILE_CTRID].createInstance(nsILocalFile); this.localFile = classes[LOCALFILE_CTRID].createInstance(nsILocalFile);
@@ -102,14 +102,14 @@ function LocalFile(file, mode, perms, tmp)
} }
this.path = this.localFile.path; this.path = this.localFile.path;
if (mode & (MODE_WRONLY | MODE_RDWR)) if (mode & (MODE_WRONLY | MODE_RDWR))
{ {
this.outputStream = this.outputStream =
classes[FILEOUT_CTRID].createInstance(nsIFileOutputStream); classes[FILEOUT_CTRID].createInstance(nsIFileOutputStream);
this.outputStream.init(this.localFile, mode, perms, 0); this.outputStream.init(this.localFile, mode, perms, 0);
} }
if (mode & (MODE_RDONLY | MODE_RDWR)) if (mode & (MODE_RDONLY | MODE_RDWR))
{ {
var is = classes[FILEIN_CTRID].createInstance(nsIFileInputStream); var is = classes[FILEIN_CTRID].createInstance(nsIFileInputStream);
@@ -117,7 +117,7 @@ function LocalFile(file, mode, perms, tmp)
this.inputStream = this.inputStream =
classes[SCRIPTSTREAM_CTRID].createInstance(nsIScriptableInputStream); classes[SCRIPTSTREAM_CTRID].createInstance(nsIScriptableInputStream);
this.inputStream.init(is); this.inputStream.init(is);
} }
} }
@@ -126,7 +126,7 @@ function fo_write(buf)
{ {
if (!("outputStream" in this)) if (!("outputStream" in this))
throw "file not open for writing."; throw "file not open for writing.";
return this.outputStream.write(buf, buf.length); return this.outputStream.write(buf, buf.length);
} }
@@ -154,8 +154,8 @@ function fo_read(max)
max = av; max = av;
if (!av) if (!av)
return null; return null;
var rv = this.inputStream.read(max); var rv = this.inputStream.read(max);
return rv; return rv;
} }
@@ -174,5 +174,6 @@ function fo_close()
{ {
return this.outputStream.flush(); return this.outputStream.flush();
} }
//}}}
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -1,4 +1,4 @@
/***** BEGIN LICENSE BLOCK ***** /***** BEGIN LICENSE BLOCK ***** {{{
Version: MPL 1.1/GPL 2.0/LGPL 2.1 Version: MPL 1.1/GPL 2.0/LGPL 2.1
The contents of this file are subject to the Mozilla Public License Version 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 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 provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL. the terms of any one of the MPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
// Finder for vimperator // Finder for vimperator
// Author: Nigel McNie <http://nigel.mcnie.name/> // Author: Nigel McNie <http://nigel.mcnie.name/>
@@ -175,7 +175,7 @@ function highlightFind(str, color, wrapped, dir, pt)
selectionRange = retRange.cloneRange(); selectionRange = retRange.cloneRange();
// highlightAllBut(str, retRange, color); // highlightAllBut(str, retRange, color);
} else { } else {
} }
return selectionRange; return selectionRange;
@@ -185,7 +185,7 @@ function highlightFind(str, color, wrapped, dir, pt)
function clearHighlight() function clearHighlight()
{ {
gFindBar.highlightDoc(); gFindBar.highlightDoc();
var win = window._content; var win = window._content;
var doc = win.document; var doc = win.document;
if (!document) if (!document)
return; return;
@@ -214,7 +214,7 @@ function abs_point (node) {
var orig = node; var orig = node;
var pt = {}; var pt = {};
try { try {
pt.x = node.offsetLeft; pt.x = node.offsetLeft;
pt.y = node.offsetTop; pt.y = node.offsetTop;
// Find imagemap's coordinates // Find imagemap's coordinates
@@ -241,7 +241,7 @@ function abs_point (node) {
// Vimperator searcher // Vimperator searcher
// make sure you only create this object when the "vimperator" object is ready // make sure you only create this object when the "vimperator" object is ready
//Vimperator.prototype.search = new function() //Vimperator.prototype.search = new function()
function Search() function Search() //{{{
{ {
var self = this; // needed for callbacks since "this" is the "vimperator" object in a callback var self = this; // needed for callbacks since "this" is the "vimperator" object in a callback
this.gWin = null; this.gWin = null;
@@ -319,7 +319,7 @@ function Search()
} }
// Called when the user types a key in the search dialog. Triggers a find attempt // 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 != "") { if (command != "") {
var str = vimperator.commandline.getCommand(); var str = vimperator.commandline.getCommand();
this.find(str, true, this.lastFindState()["point"]); this.find(str, true, this.lastFindState()["point"]);
@@ -408,7 +408,7 @@ function Search()
this.lastFindState = function() { this.lastFindState = function() {
return this.gFindState[this.gFindState.length - 1]; 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 // 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) { this.addFindState = function(screenX, screenY, searchStr, wrapped, point, range, selection, direction) {
var state = new Array(); var state = new Array();
@@ -422,7 +422,7 @@ function Search()
state["direction"] = direction; state["direction"] = direction;
this.gFindState.push(state); this.gFindState.push(state);
} }
// Finds text in a page // Finds text in a page
this.find = function(str, dir, pt) this.find = function(str, dir, pt)
{ {
@@ -434,7 +434,7 @@ function Search()
// Should we wrap this time? // Should we wrap this time?
var wrapped = this.lastFindState()["wrapped"]; var wrapped = this.lastFindState()["wrapped"];
var point = pt; var point = pt;
if (this.lastFindState()["wrapped"] == false if (this.lastFindState()["wrapped"] == false
&& this.lastFindState()["range"] == null && this.lastFindState()["range"] == null
&& this.lastFindState()["search-str"] == str && this.lastFindState()["search-str"] == str
&& this.lastFindState()["direction"] == dir) { && this.lastFindState()["direction"] == dir) {
@@ -457,7 +457,7 @@ function Search()
point, matchRange, matchRange, dir); point, matchRange, matchRange, dir);
} }
} }
} } //}}}
// @TODO should be moved into commands.js // @TODO should be moved into commands.js
vimperator.commands.add(new Command(["noh[lsearch]"], vimperator.commands.add(new Command(["noh[lsearch]"],

View File

@@ -26,7 +26,7 @@ the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
function help(section, easter) function help(section, easter) //{{{
{ {
if (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) // horizontal offset is annoying, set it to 0 (use pos[0] if you want horizontal offset)
window.content.scrollTo(0, pos[1]); window.content.scrollTo(0, pos[1]);
} }
} } //}}}
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -1,4 +1,4 @@
/** /***** BEGIN LICENSE BLOCK ***** {{{
* *
* Mozilla Public License Notice * Mozilla Public License Notice
* *
@@ -20,9 +20,9 @@
* Contributor(s): Pekka Sillanpaa, Paul Stone * Contributor(s): Pekka Sillanpaa, Paul Stone
* adapted for vimperator use by: Martin Stubenschrott * 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 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 linkNumString = ""; // the typed link number is in this string
var linkCount = 0; var linkCount = 0;
var state = 0; // 0: empty or processing, 1: a full hint was parsed var state = 0; // 0: empty or processing, 1: a full hint was parsed
var wins; // frame array var wins; // frame array
// each hint element is a clone of this element // each hint element is a clone of this element
var hintElemSpan; var hintElemSpan;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// configuration and initialization related functions // configuration and initialization related functions
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -54,17 +54,17 @@ function hit_a_hint()
// isHahModeEnabled = false; // isHahModeEnabled = false;
// hintedElem = null; // hintedElem = null;
// } // }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// hint activating and loading related functions // hint activating and loading related functions
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
function startCoordLoader(doc) function startCoordLoader(doc)
{ {
win = doc.defaultView; win = doc.defaultView;
if (!win) if (!win)
return; return;
if (win.winId != null) if (win.winId != null)
{ {
window.clearTimeout(win.coordLoaderId); window.clearTimeout(win.coordLoaderId);
@@ -73,31 +73,31 @@ function hit_a_hint()
{ {
if (!wins) if (!wins)
wins = new Array(); wins = new Array();
win.winId = wins.length; win.winId = wins.length;
wins.push(win); wins.push(win);
} }
// logMessage("winId:"+win.winId); // logMessage("winId:"+win.winId);
win.res = evaluateXPath(vimperator.options["hinttags"], doc); win.res = evaluateXPath(vimperator.options["hinttags"], doc);
win.coordLoaderId = window.setTimeout("hah.loadCoord(" + win.winId + ", 0);", 1); win.coordLoaderId = window.setTimeout("hah.loadCoord(" + win.winId + ", 0);", 1);
} }
this.loadCoord = function(winId, i) this.loadCoord = function(winId, i)
{ {
win = wins[winId]; win = wins[winId];
var elem = win.res.snapshotItem(i); var elem = win.res.snapshotItem(i);
if (elem) if (elem)
genElemCoords(elem); genElemCoords(elem);
i++; i++;
if (i < win.res.snapshotLength && !isHahModeEnabled) if (i < win.res.snapshotLength && !isHahModeEnabled)
window.setTimeout("hah.loadCoord(" + winId + ", "+ i +");", 1); window.setTimeout("hah.loadCoord(" + winId + ", "+ i +");", 1);
else else
win.coordLoaderId = null; win.coordLoaderId = null;
}; };
function genElemCoords(elem) function genElemCoords(elem)
{ {
if (typeof(elem.validCoord) != "undefined") if (typeof(elem.validCoord) != "undefined")
@@ -105,7 +105,7 @@ function hit_a_hint()
if (elem.validCoord == elem.ownerDocument.validCoords) if (elem.validCoord == elem.ownerDocument.validCoords)
return; return;
} }
if (elem.offsetParent) if (elem.offsetParent)
{ {
genElemCoords(elem.offsetParent); genElemCoords(elem.offsetParent);
@@ -119,7 +119,7 @@ function hit_a_hint()
} }
elem.validCoord = elem.ownerDocument.validCoords; elem.validCoord = elem.ownerDocument.validCoords;
} }
function createHints(win) function createHints(win)
{ {
if (!win) if (!win)
@@ -127,31 +127,31 @@ function hit_a_hint()
win = window._content; win = window._content;
linkCount = 0; linkCount = 0;
} }
var area = new Array(4); var area = new Array(4);
area[0] = win.pageXOffset - 5; area[0] = win.pageXOffset - 5;
area[1] = win.pageYOffset - 5; area[1] = win.pageYOffset - 5;
area[2] = area[0] + win.innerWidth; area[2] = area[0] + win.innerWidth;
area[3] = area[1] + win.innerHeight; area[3] = area[1] + win.innerHeight;
var doc = win.document; var doc = win.document;
var res = evaluateXPath(vimperator.options["hinttags"], doc); var res = evaluateXPath(vimperator.options["hinttags"], doc);
var elem, i; var elem, i;
hintElemSpan = doc.createElement('SPAN'); hintElemSpan = doc.createElement('SPAN');
hintElemSpan.style.cssText = vimperator.options["hintstyle"]; hintElemSpan.style.cssText = vimperator.options["hintstyle"];
hintElemSpan.setAttribute('name', 'hah_hint'); hintElemSpan.setAttribute('name', 'hah_hint');
var hintContainer = doc.getElementById('hah_hints'); var hintContainer = doc.getElementById('hah_hints');
if (hintContainer == null) if (hintContainer == null)
{ {
genHintContainer(doc); genHintContainer(doc);
hintContainer = doc.getElementById('hah_hints'); hintContainer = doc.getElementById('hah_hints');
} }
hintContainer.valid_hint_count = 0; // none of these hints should be visible initially hintContainer.valid_hint_count = 0; // none of these hints should be visible initially
var hints = hintContainer.childNodes; var hints = hintContainer.childNodes;
var maxhints = vimperator.options["maxhints"]; var maxhints = vimperator.options["maxhints"];
for (i = 0; i < res.snapshotLength; i++) for (i = 0; i < res.snapshotLength; i++)
@@ -162,22 +162,22 @@ function hit_a_hint()
elem = res.snapshotItem(i); elem = res.snapshotItem(i);
genElemCoords(elem); genElemCoords(elem);
// for extended hint mode, show all - even currently hidden - hints // for extended hint mode, show all - even currently hidden - hints
//if (hintmode == HINT_MODE_QUICK && (elem.absoTop < area[1] || elem.absoTop > area[3] || //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] || if (vimperator.hasMode(vimperator.modes.QUICK_HINT) && (elem.absoTop < area[1] || elem.absoTop > area[3] ||
elem.absoLeft > area[2] || elem.absoLeft < area[0])) elem.absoLeft > area[2] || elem.absoLeft < area[0]))
continue; continue;
// XXX: what does that do // XXX: what does that do
// if (elem.offsetWidth == 0 && elem.offsetHeight == 0) // if (elem.offsetWidth == 0 && elem.offsetHeight == 0)
// continue; // continue;
var cs = doc.defaultView.getComputedStyle(elem, null); var cs = doc.defaultView.getComputedStyle(elem, null);
if (cs.getPropertyValue("visibility") == "hidden") if (cs.getPropertyValue("visibility") == "hidden")
continue; continue;
if (linkCount < hints.length) if (linkCount < hints.length)
hintElem = hints[linkCount]; hintElem = hints[linkCount];
else // need to attach this new hintElem to the hint container else // need to attach this new hintElem to the hint container
@@ -185,22 +185,22 @@ function hit_a_hint()
hintElem = hintElemSpan.cloneNode(false); hintElem = hintElemSpan.cloneNode(false);
hintContainer.appendChild(hintElem); hintContainer.appendChild(hintElem);
} }
hintElem.style.display = 'none'; hintElem.style.display = 'none';
hintElem.style.top = elem.absoTop + "px"; hintElem.style.top = elem.absoTop + "px";
hintElem.style.left = elem.absoLeft + "px"; hintElem.style.left = elem.absoLeft + "px";
hintElem.refElem = elem; hintElem.refElem = elem;
hintContainer.valid_hint_count++; // one more visible hint in this frame hintContainer.valid_hint_count++; // one more visible hint in this frame
linkCount++; // and one more total hint linkCount++; // and one more total hint
} }
doc.coordsInvalidated = false; doc.coordsInvalidated = false;
// recursively create hints // recursively create hints
for (i = 0; i < win.frames.length; i++) for (i = 0; i < win.frames.length; i++)
createHints(win.frames[i]); createHints(win.frames[i]);
} }
function showHints(win, off) function showHints(win, off)
@@ -245,7 +245,7 @@ function hit_a_hint()
for (j = 0; j < win.frames.length; j++) for (j = 0; j < win.frames.length; j++)
showHints(win.frames[j], offset); showHints(win.frames[j], offset);
} }
/* removes all visible hints from doc /* removes all visible hints from doc
* or from current document, if win == null * or from current document, if win == null
*/ */
@@ -253,22 +253,22 @@ function hit_a_hint()
{ {
if (!win) if (!win)
win = window.content; win = window.content;
var doc = win.document; var doc = win.document;
var res = evaluateXPath("//HINTS/SPAN", doc) var res = evaluateXPath("//HINTS/SPAN", doc)
var elem, i; var elem, i;
for (i = 0; i < res.snapshotLength; i++) for (i = 0; i < res.snapshotLength; i++)
{ {
elem = res.snapshotItem(i); elem = res.snapshotItem(i);
setHintStyle(elem, vimperator.options["hintstyle"]); setHintStyle(elem, vimperator.options["hintstyle"]);
elem.style.display = 'none'; elem.style.display = 'none';
} }
for (i = 0; i < win.frames.length; i++) for (i = 0; i < win.frames.length; i++)
removeHints(win.frames[i]); removeHints(win.frames[i]);
} }
function onResize(event) function onResize(event)
{ {
if(event) if(event)
@@ -279,7 +279,7 @@ function hit_a_hint()
invalidateCoords(doc); invalidateCoords(doc);
startCoordLoader(doc); startCoordLoader(doc);
} }
function invalidateCoords(doc) function invalidateCoords(doc)
{ {
if (!doc.coordsInvalidated) if (!doc.coordsInvalidated)
@@ -297,19 +297,19 @@ function hit_a_hint()
// logMessage(doc.validCoords); // logMessage(doc.validCoords);
} }
} }
function getHintById(id, win) function getHintById(id, win)
{ {
if (!win) if (!win)
win = window._content; win = window._content;
var doc = win.document; var doc = win.document;
var elem, i; var elem, i;
//var hintId = parseInt(id, nums.length); //var hintId = parseInt(id, nums.length);
//elem = doc.getElementById(prefix + hintId); //elem = doc.getElementById(prefix + hintId);
elem = doc.getElementById(HINT_PREFIX + id); elem = doc.getElementById(HINT_PREFIX + id);
if (elem) if (elem)
{ {
return elem; return elem;
@@ -319,18 +319,18 @@ function hit_a_hint()
for (i = 0; i < win.frames.length; i++) for (i = 0; i < win.frames.length; i++)
{ {
elem = getHintById(id, win.frames[i]); elem = getHintById(id, win.frames[i]);
if (elem) if (elem)
return elem; return elem;
} }
} }
return null; return null;
} }
function formatHint(hintNum) function formatHint(hintNum)
{ {
var hintCharacters = vimperator.options["hintchars"]; var hintCharacters = vimperator.options["hintchars"];
var str = hintNum.toString(hintCharacters.length); // turn hintNum into a base(length) number var str = hintNum.toString(hintCharacters.length); // turn hintNum into a base(length) number
// map the number onto the chars in the numbers string // map the number onto the chars in the numbers string
var result = ''; var result = '';
// make all links the same length // make all links the same length
@@ -343,15 +343,15 @@ function hit_a_hint()
result += hintCharacters.charAt(0).toUpperCase(); result += hintCharacters.charAt(0).toUpperCase();
hintLength--; hintLength--;
} }
for (var i = 0; i < str.length; i++) for (var i = 0; i < str.length; i++)
result += (hintCharacters.charAt(parseInt(str[i], hintCharacters.length))).toUpperCase(); result += (hintCharacters.charAt(parseInt(str[i], hintCharacters.length))).toUpperCase();
return result; return result;
} }
function setHintStyle(hintElem, styleString) function setHintStyle(hintElem, styleString)
{ {
if (hintElem && hintElem.style) if (hintElem && hintElem.style)
{ {
xTemp = hintElem.style.left; xTemp = hintElem.style.left;
@@ -361,13 +361,13 @@ function hit_a_hint()
hintElem.style.top = yTemp; hintElem.style.top = yTemp;
} }
} }
function changeHintFocus(linkNumString, oldLinkNumString) function changeHintFocus(linkNumString, oldLinkNumString)
{ {
var styleString = vimperator.options["hintstyle"]; var styleString = vimperator.options["hintstyle"];
var styleStringFocus = vimperator.options["focusedhintstyle"]; var styleStringFocus = vimperator.options["focusedhintstyle"];
var hintElem; var hintElem;
if (oldLinkNumString.length > 0) if (oldLinkNumString.length > 0)
{ {
hintElem = getHintById(oldLinkNumString); hintElem = getHintById(oldLinkNumString);
@@ -376,16 +376,16 @@ function hit_a_hint()
if (linkNumString.length > 0) if (linkNumString.length > 0)
{ {
hintElem = getHintById(linkNumString); hintElem = getHintById(linkNumString);
setHintStyle(hintElem, styleStringFocus); setHintStyle(hintElem, styleStringFocus);
if(hintElem) if(hintElem)
setMouseOverElement(hintElem.refElem); setMouseOverElement(hintElem.refElem);
} }
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// basic functionality // basic functionality
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/** /**
* Enables the HaH-mode by showing the hints and prepare to input the * Enables the HaH-mode by showing the hints and prepare to input the
* hint numbers * hint numbers
@@ -404,13 +404,13 @@ function hit_a_hint()
linkCount = 0; linkCount = 0;
linkNumString = ''; linkNumString = '';
isHahModeEnabled = true; isHahModeEnabled = true;
createHints(); createHints();
showHints(null, 0); showHints(null, 0);
return true; return true;
}; };
/** /**
* Disables the HaH-mode by hiding the hints and disabling the input mode * Disables the HaH-mode by hiding the hints and disabling the input mode
* *
@@ -434,7 +434,7 @@ function hit_a_hint()
hintedElems = []; hintedElems = [];
// if (!silent && vimperator.options["showmode"]) // if (!silent && vimperator.options["showmode"])
// vimperator.echo(''); // vimperator.echo('');
removeHints(win); removeHints(win);
return 0; return 0;
}; };
@@ -443,17 +443,17 @@ function hit_a_hint()
{ {
linkNumString = ''; linkNumString = '';
state = 0; state = 0;
while(hintedElems.length > 0) while(hintedElems.length > 0)
{ {
var elem = hintedElems.pop(); var elem = hintedElems.pop();
if (!elem) if (!elem)
return 0; return 0;
// reset style attribute // reset style attribute
setHintStyle(elem, vimperator.options["hintstyle"]); setHintStyle(elem, vimperator.options["hintstyle"]);
} }
}; };
this.reshowHints = function() this.reshowHints = function()
{ {
@@ -466,8 +466,8 @@ function hit_a_hint()
showHints(null, 0); showHints(null, 0);
} }
}; };
// this function 'click' an element, which also works // this function 'click' an element, which also works
// for javascript links // for javascript links
this.openHints = function(new_tab, new_window) this.openHints = function(new_tab, new_window)
@@ -480,7 +480,7 @@ function hit_a_hint()
if (!elem) if (!elem)
return 0; return 0;
setHintStyle(elem, vimperator.options["hintstyle"]); setHintStyle(elem, vimperator.options["hintstyle"]);
elem = elem.refElem; elem = elem.refElem;
var elemTagName = elem.tagName; var elemTagName = elem.tagName;
elem.focus(); elem.focus();
@@ -559,7 +559,7 @@ function hit_a_hint()
function setMouseOverElement(elem) function setMouseOverElement(elem)
{ {
var doc = window.document; var doc = window.document;
if (elem.tagName == 'FRAME' || elem.tagName == 'IFRAME') if (elem.tagName == 'FRAME' || elem.tagName == 'IFRAME')
{ {
elem.contentWindow.focus(); elem.contentWindow.focus();
@@ -569,7 +569,7 @@ function hit_a_hint()
{ {
//elem.focus(); //elem.focus();
} }
var evt = doc.createEvent('MouseEvents'); var evt = doc.createEvent('MouseEvents');
var x = 0; var x = 0;
var y = 0; var y = 0;
@@ -580,15 +580,15 @@ function hit_a_hint()
x = Number(coords[0]); x = Number(coords[0]);
y = Number(coords[1]); y = Number(coords[1]);
} }
evt.initMouseEvent('mouseover', true, true, doc.defaultView, 1, x, y, 0, 0, 0, 0, 0, 0, 0, null); evt.initMouseEvent('mouseover', true, true, doc.defaultView, 1, x, y, 0, 0, 0, 0, 0, 0, 0, null);
elem.dispatchEvent(evt); elem.dispatchEvent(evt);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// event handlers // event handlers
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// returns nr. of fully parsed links when a new hint has been found, // 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 // 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 // (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 // reset state to show that we are in processing mode
state = 0; state = 0;
var num = String.fromCharCode(event.charCode).toUpperCase(); var num = String.fromCharCode(event.charCode).toUpperCase();
var hintCharacters = vimperator.options["hintchars"]; var hintCharacters = vimperator.options["hintchars"];
if (num != null && hintCharacters.toUpperCase().indexOf(num) > -1) if (num != null && hintCharacters.toUpperCase().indexOf(num) > -1)
@@ -633,38 +633,38 @@ function hit_a_hint()
// an unparseable or wrong key // an unparseable or wrong key
return -1; return -1;
} }
function genHintContainer(doc) function genHintContainer(doc)
{ {
if (doc.getElementsByTagName('HINTS').length > 0) if (doc.getElementsByTagName('HINTS').length > 0)
return; return;
hints = doc.createElement('HINTS'); hints = doc.createElement('HINTS');
hints.id = "hah_hints"; hints.id = "hah_hints";
hints.valid_hint_count = 0; // initially 0 elements are usable as hints hints.valid_hint_count = 0; // initially 0 elements are usable as hints
doc.body.appendChild(hints); doc.body.appendChild(hints);
} }
function initDoc(event) function initDoc(event)
{ {
doc = event.originalTarget; doc = event.originalTarget;
genHintContainer(doc); genHintContainer(doc);
isHahModeEnabled = false; isHahModeEnabled = false;
hintedElems = []; hintedElems = [];
if (!doc.validCoords) if (!doc.validCoords)
doc.validCoords = true; doc.validCoords = true;
else else
doc.validCoords = false; doc.validCoords = false;
// XXX: prepend a ! ? // XXX: prepend a ! ?
if (doc.coordsInvalidated) if (doc.coordsInvalidated)
doc.coordsInvalidated = true; doc.coordsInvalidated = true;
else else
doc.coordsInvalidated = false; doc.coordsInvalidated = false;
startCoordLoader(doc); startCoordLoader(doc);
//if (hintmode == HINT_MODE_ALWAYS) //if (hintmode == HINT_MODE_ALWAYS)
if (vimperator.hasMode(vimperator.modes.ALWAYS_HINT)) if (vimperator.hasMode(vimperator.modes.ALWAYS_HINT))
{ {
@@ -681,7 +681,7 @@ function hit_a_hint()
window.document.addEventListener("pageshow", initDoc, null); window.document.addEventListener("pageshow", initDoc, null);
window.addEventListener("resize", onResize, null); window.addEventListener("resize", onResize, null);
} } //}}}
var hah = new hit_a_hint(); var hah = new hit_a_hint();

View File

@@ -1,4 +1,3 @@
// TODO: document
function Map(mode, cmds, act, extra_info) //{{{ function Map(mode, cmds, act, extra_info) //{{{
{ {
if (!mode || (!cmds || !cmds.length) || !act) if (!mode || (!cmds || !cmds.length) || !act)
@@ -56,7 +55,7 @@ Map.prototype.toString = function()
"\n}" "\n}"
} //}}} } //}}}
function Mappings()//{{{ function Mappings() //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -664,7 +663,7 @@ function Mappings()//{{{
//}}} //}}}
// TODO: Convert these to the new mappings model // TODO: Convert these to the new mappings model
var hint_maps = [ var hint_maps = [ //{{{
/* hint action keys */ /* hint action keys */
["o", "hah.openHints(false, false);", true, false], ["o", "hah.openHints(false, false);", true, false],
["t", "hah.openHints(true, false);", true, false], ["t", "hah.openHints(true, false);", true, false],
@@ -701,7 +700,7 @@ function Mappings()//{{{
["<C-g>", "", true, true], ["<C-g>", "", true, true],
["<C-[>", "", true, true], ["<C-[>", "", true, true],
["<Esc>", "", true, true] ["<Esc>", "", true, true]
]; ]; //}}}
}//}}} } //}}}
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -1,4 +1,4 @@
function Option(names, type, extra_info)//{{{ function Option(names, type, extra_info) //{{{
{ {
if (!names || !type) if (!names || !type)
return null; return null;
@@ -79,9 +79,9 @@ function Option(names, type, extra_info)//{{{
"\n\tvalidator: " + this.validator + "\n\tvalidator: " + this.validator +
"\n}" "\n}"
} }
}//}}} } //}}}
function Options()//{{{ function Options() //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
@@ -484,6 +484,6 @@ function Options()//{{{
setShowTabline(this.showtabline); setShowTabline(this.showtabline);
setGuiOptions(this.guioptions); setGuiOptions(this.guioptions);
setTitleString(this.titlestring); setTitleString(this.titlestring);
}//}}} } //}}}
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -1,6 +1,5 @@
// XXX: move somehere else! // XXX: move somehere else!
function multiliner(line, prev_match, heredoc) //{{{
function multiliner(line, prev_match, heredoc)
{ {
var end = true; var end = true;
var match = tokenize_ex(line, prev_match[4]); var match = tokenize_ex(line, prev_match[4]);
@@ -39,8 +38,7 @@ function multiliner(line, prev_match, heredoc)
} }
} }
return [prev_match, heredoc, end]; return [prev_match, heredoc, end];
} } //}}}
/* /*
* This class is used for prompting of user input and echoing of messages * 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 * it consists of a prompt and command field
* be sure to only create objects of this class when the chrome is ready * be sure to only create objects of this class when the chrome is ready
*/ */
function CommandLine () function CommandLine() //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{
const UNINITIALIZED = -2; // notifies us, if we need to start history/tab-completion from the beginning const UNINITIALIZED = -2; // notifies us, if we need to start history/tab-completion from the beginning
const HISTORY_SIZE = 500; const HISTORY_SIZE = 500;
@@ -148,9 +147,9 @@ function CommandLine ()
history = history.slice(HISTORY_SIZE / 10); history = history.slice(HISTORY_SIZE / 10);
} }
//////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{
this.getCommand = function() this.getCommand = function()
{ {
@@ -240,7 +239,7 @@ function CommandLine ()
vimperator.setMode(old_mode || vimperator.modes.NORMAL, old_extended_mode || null, silent); vimperator.setMode(old_mode || vimperator.modes.NORMAL, old_extended_mode || null, silent);
cur_command = command; cur_command = command;
// don't add the echoed command to the history, on pressing <cr>, the // don't add the echoed command to the history, on pressing <cr>, the
// command is saved right into the kepress handler // command is saved right into the kepress handler
if(!echo_allowed) if(!echo_allowed)
addToHistory(command); addToHistory(command);
@@ -265,7 +264,7 @@ function CommandLine ()
{ {
//event.stopPropagation(); // XXX: doesnt seem to work //event.stopPropagation(); // XXX: doesnt seem to work
//event.preventDefault(); // so we need to use the hack below --mst //event.preventDefault(); // so we need to use the hack below --mst
// NOTE: echo_allowed is a misleading name here, actually this flag is set // 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 // so that we don't save a history entry if the user clicks into the text field
echo_allowed = true; echo_allowed = true;
@@ -319,7 +318,7 @@ function CommandLine ()
else if (key == "<Up>" || key == "<Down>") else if (key == "<Up>" || key == "<Down>")
{ {
//always reset the tab completion if we use up/down keys //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 */ /* save 'start' position for iterating through the history */
if (history_index == UNINITIALIZED) if (history_index == UNINITIALIZED)
@@ -366,7 +365,7 @@ function CommandLine ()
history_index = UNINITIALIZED; history_index = UNINITIALIZED;
// we need to build our completion list first // we need to build our completion list first
if (completion_index == UNINITIALIZED) if (completion_index == UNINITIALIZED)
{ {
completion_start_index = 0; completion_start_index = 0;
@@ -501,7 +500,8 @@ function CommandLine ()
{ {
Options.setPref("commandline_history", history.join("\n")); Options.setPref("commandline_history", history.join("\n"));
} }
} //}}}
} //}}}
/** /**
* The list which is used for the completion box, the preview window and the buffer preview window * 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 id: the id of the the XUL widget which we want to fill
* @param options: an optional hash which modifies the behavior of the list * @param options: an optional hash which modifies the behavior of the list
*/ */
function InformationList(id, options) function InformationList(id, options) //{{{
{ {
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
const CONTEXT_LINES = 3; const CONTEXT_LINES = 3;
var max_items = 10; var max_items = 10;
var min_items = 1; var min_items = 1;
var incremental_fill = true; // make display faster, but does not show scrollbar var incremental_fill = true; // make display faster, but does not show scrollbar
if(options) if(options)
@@ -555,7 +559,7 @@ function InformationList(id, options)
/** /**
* uses the entries in completions to fill the listbox * 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 max_items
* @returns the number of items * @returns the number of items
*/ */
@@ -591,10 +595,10 @@ function InformationList(id, options)
return (i-startindex); return (i-startindex);
} }
//////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{
/** /**
* Show the completion list window * Show the completion list window
* *
@@ -702,13 +706,15 @@ function InformationList(id, options)
else else
return false; return false;
} }
} //}}}
} //}}}
function StatusLine() function StatusLine() //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{
// our status bar fields // our status bar fields
var statusline_widget = document.getElementById("vimperator-statusline"); var statusline_widget = document.getElementById("vimperator-statusline");
var url_widget = document.getElementById("vimperator-statusline-field-url"); 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 tabcount_widget = document.getElementById("vimperator-statusline-field-tabcount");
var bufferposition_widget = document.getElementById("vimperator-statusline-field-bufferposition"); var bufferposition_widget = document.getElementById("vimperator-statusline-field-bufferposition");
//////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{
// use names for the color or "transparent" to remove color information // use names for the color or "transparent" to remove color information
this.setColor = function(color) this.setColor = function(color)
{ {
@@ -808,6 +815,7 @@ function StatusLine()
bufferposition_widget.value = bufferposition_str; bufferposition_widget.value = bufferposition_str;
}; };
} //}}}
} //}}}
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -35,15 +35,16 @@ var popup_allowed_events; // need to change and reset this firefox pref XXX: mov
window.addEventListener("load", init, false); window.addEventListener("load", init, false);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// init/uninit //////////////////////////////////////////////////// {{{1 // init/uninit /////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////{{{
function init()
function init() //{{{
{ {
window.dump("in init\n"); window.dump("in init\n");
// init the main object // init the main object
vimperator = new Vimperator; vimperator = new Vimperator;
vimperator.log("Initializing vimperator object...", 1); vimperator.log("Initializing vimperator object...", 1);
// these inner classes are created here, because outside the init() // these inner classes are created here, because outside the init()
// function, the chrome:// is not ready // function, the chrome:// is not ready
vimperator.log("Loading module options...", 3); vimperator.log("Loading module options...", 3);
@@ -109,7 +110,7 @@ function init()
setTimeout(function() { setTimeout(function() {
help(null, null, null, { inTab: true }); help(null, null, null, { inTab: true });
Options.setPref("firsttime", false); Options.setPref("firsttime", false);
}, 1000); }, 1000);
} }
gURLBar.blur(); gURLBar.blur();
@@ -127,9 +128,9 @@ function init()
window.addEventListener("unload", unload, false); window.addEventListener("unload", unload, false);
vimperator.log("Vimperator fully initialized", 1); vimperator.log("Vimperator fully initialized", 1);
} } //}}}
function unload() function unload() //{{{
{ {
/*** save our preferences ***/ /*** save our preferences ***/
vimperator.commandline.destroy(); vimperator.commandline.destroy();
@@ -140,15 +141,15 @@ function unload()
if (Options.getFirefoxPref('dom.popup_allowed_events', 'change click dblclick mouseup reset submit') if (Options.getFirefoxPref('dom.popup_allowed_events', 'change click dblclick mouseup reset submit')
== popup_allowed_events + " keypress") == popup_allowed_events + " keypress")
Options.setFirefoxPref('dom.popup_allowed_events', popup_allowed_events); Options.setFirefoxPref('dom.popup_allowed_events', popup_allowed_events);
} } //}}}
//}}}
function Vimperator() //{{{
function Vimperator() //{{{1
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{
this.modes = { // actually not private, but Firefox complains if this doesn't come first this.modes = { // actually not private, but Firefox complains if this doesn't come first
// main modes // main modes
NONE: 0, NONE: 0,
@@ -213,9 +214,10 @@ function Vimperator() //{{{1
vimperator.echo("-- " + str_mode + str_extended + " --"); vimperator.echo("-- " + str_mode + str_extended + " --");
} }
//////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{
this.version = "###VERSION### CVS (created: ###DATE###)"; this.version = "###VERSION### CVS (created: ###DATE###)";
/////////////// callbacks //////////////////////////// /////////////// callbacks ////////////////////////////
@@ -344,13 +346,14 @@ function Vimperator() //{{{1
} }
this.log(string, level); this.log(string, level);
} }
} //}}}
} //}}}
function Events() //{{{1 function Events() //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// CONSTRUCTOR ///////////////////////////////////////////// ////////////////////// CONSTRUCTOR /////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{
// this handler is for middle click only in the content // this handler is for middle click only in the content
//window.addEventListener("mousedown", onVimperatorKeypress, true); //window.addEventListener("mousedown", onVimperatorKeypress, true);
@@ -373,7 +376,7 @@ function Events() //{{{1
updateBufferList(); updateBufferList();
vimperator.setMode(); // trick to reshow the mode in the command line vimperator.setMode(); // trick to reshow the mode in the command line
}, false); }, false);
tabcontainer.addEventListener("TabSelect", function(event) { tabcontainer.addEventListener("TabSelect", function(event) {
vimperator.statusline.updateTabCount(); vimperator.statusline.updateTabCount();
updateBufferList(); updateBufferList();
vimperator.setMode(); // trick to reshow the mode in the command line vimperator.setMode(); // trick to reshow the mode in the command line
@@ -395,9 +398,10 @@ function Events() //{{{1
//alert("titlechanged"); //alert("titlechanged");
}, null); }, null);
//////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{
function onPageLoad(event) function onPageLoad(event)
{ {
if (event.originalTarget instanceof HTMLDocument) if (event.originalTarget instanceof HTMLDocument)
@@ -410,7 +414,7 @@ function Events() //{{{1
// when you click on a link inside a frameset, because asyncUpdateUI // when you click on a link inside a frameset, because asyncUpdateUI
// is not triggered there (firefox bug?) // is not triggered there (firefox bug?)
setTimeout(vimperator.statusline.updateUrl, 10); setTimeout(vimperator.statusline.updateUrl, 10);
return; return;
} }
// code which should happen for all (also background) newly loaded tabs goes here: // code which should happen for all (also background) newly loaded tabs goes here:
@@ -431,9 +435,10 @@ function Events() //{{{1
} }
} }
//////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{
this.destroy = function() this.destroy = function()
{ {
// BIG TODO: removeEventListeners() to avoid mem leaks // 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 // XXX: for now only, later: input mappings if form element focused
if (isFormElemFocused()) if (isFormElemFocused())
return false; return false;
// handle Escape-one-key mode (Ctrl-v) // handle Escape-one-key mode (Ctrl-v)
if (vimperator.hasMode(vimperator.modes.ESCAPE_ONE_KEY) && !vimperator.hasMode(vimperator.modes.ESCAPE_ALL_KEYS)) 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(); vimperator.statusline.updateProgress();
// if this is not delayed we get the wrong position of the old buffer // 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 // called at the very end of a page load
asyncUpdateUI: function() asyncUpdateUI: function()
{ {
setTimeout(vimperator.statusline.updateUrl, 100); setTimeout(vimperator.statusline.updateUrl, 100);
}, },
setOverLink : function(link, b) setOverLink : function(link, b)
@@ -735,7 +740,7 @@ function Events() //{{{1
else if (ssli == 2) else if (ssli == 2)
vimperator.echo("Link: " + link); vimperator.echo("Link: " + link);
} }
if (link == "") if (link == "")
{ {
if (ssli == 1) if (ssli == 1)
@@ -759,14 +764,14 @@ function Events() //{{{1
.getInterface(Components.interfaces.nsIXULWindow) .getInterface(Components.interfaces.nsIXULWindow)
.XULBrowserWindow = window.XULBrowserWindow; .XULBrowserWindow = window.XULBrowserWindow;
getBrowser().addProgressListener(this.progressListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL); getBrowser().addProgressListener(this.progressListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
//}}}
} } //}}}
// this function converts the given event to // this function converts the given event to
// a keycode which can be used in mappings // a keycode which can be used in mappings
// e.g. pressing ctrl+n would result in the string "<C-n>" // e.g. pressing ctrl+n would result in the string "<C-n>"
// null if unknown key // null if unknown key
KeyboardEvent.prototype.toString = function () KeyboardEvent.prototype.toString = function() //{{{
{ {
var key = String.fromCharCode(this.charCode); var key = String.fromCharCode(this.charCode);
var modifier = ""; var modifier = "";
@@ -853,18 +858,18 @@ KeyboardEvent.prototype.toString = function ()
} }
else // a key like F1 is always enclosed in < and > else // a key like F1 is always enclosed in < and >
return "<" + modifier + key + ">"; return "<" + modifier + key + ">";
} } //}}}
/** provides functions for working with tabs /** provides functions for working with tabs
* XXX: ATTENTION: We are planning to move to the FUEL API once we switch to * 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 * Firefox 3.0, then this class should go away and their tab methods should be used
* @deprecated * @deprecated
*/ */
function Tabs() //{{{1 function Tabs() //{{{
{ {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{
/** @param spec can either be: /** @param spec can either be:
* - an absolute integer * - an absolute integer
* - "" for the current tab * - "" for the current tab
@@ -907,9 +912,9 @@ function Tabs() //{{{1
return position; return position;
} }
//////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{
// @returns the index of the currently selected tab starting with 0 // @returns the index of the currently selected tab starting with 0
this.index = function(tab) this.index = function(tab)
{ {
@@ -1004,43 +1009,44 @@ function Tabs() //{{{1
/* XXX: disabled until we find a better way where to update the titles, right now /* 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 * it has O(n^2) complexity on firefox start when we load 50 tabs
* (c) by hrist * (c) by hrist
window.addEventListener("TabMove", function() { vimperator.statusline.updateTabCount(); vimperator.tabs.updateTitles(); }, false); window.addEventListener("TabMove", function() { vimperator.statusline.updateTabCount(); vimperator.tabs.updateTitles(); }, false);
window.addEventListener("TabOpen", 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); window.addEventListener("TabClose", function() { vimperator.statusline.updateTabCount(); vimperator.tabs.updateTitles(); }, false);
this.updateTitles = function(forceclear) this.updateTitles = function(forceclear)
{ {
for(var i=0;i < vimperator.tabs.count();i++) for(var i=0;i < vimperator.tabs.count();i++)
{ {
var old_title = getBrowser().mTabContainer.childNodes[i].getAttribute("label"); var old_title = getBrowser().mTabContainer.childNodes[i].getAttribute("label");
var split_title = old_title.match(/^(\d+:\s+)(.*)/); var split_title = old_title.match(/^(\d+:\s+)(.*)/);
if(forceclear) if(forceclear)
{ {
for(var i=0;i<vimperator.tabs.count();i++) for(var i=0;i<vimperator.tabs.count();i++)
getBrowser().mTabContainer.childNodes[i].setAttribute("label", split_title[2]); getBrowser().mTabContainer.childNodes[i].setAttribute("label", split_title[2]);
return; return;
} }
var numbertabs = vimperator.options["numbertabs"]; var numbertabs = vimperator.options["numbertabs"];
if(numbertabs) if(numbertabs)
{ {
if(split_title) if(split_title)
{ {
var new_title = (i+1) + ": "+ split_title[2]; var new_title = (i+1) + ": "+ split_title[2];
} }
else var new_title = (i+1) + ": " + old_title; else var new_title = (i+1) + ": " + old_title;
getBrowser().mTabContainer.childNodes[i].setAttribute("label", new_title); getBrowser().mTabContainer.childNodes[i].setAttribute("label", new_title);
} }
else getBrowser().mTabContainer.childNodes[i].setAttribute("label", split_title[2]); else getBrowser().mTabContainer.childNodes[i].setAttribute("label", split_title[2]);
} }
} }
*/ */
} //}}}
} //}}}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// DOM related helper functions /////////////////////////////////// {{{1 // DOM related helper functions ////////////////////////////////////////
//////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////{{{
function isFormElemFocused() function isFormElemFocused()
{ {
var elt = document.commandDispatcher.focusedElement; var elt = document.commandDispatcher.focusedElement;
@@ -1059,5 +1065,6 @@ function isFormElemFocused()
return false; return false;
} }
//}}}
// vim: set fdm=marker sw=4 ts=4 et: // vim: set fdm=marker sw=4 ts=4 et: