/***** 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 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. (c) 2006-2007: Martin Stubenschrott Alternatively, the contents of this file may be used under the terms of either the GNU General Public License Version 2 or later (the "GPL"), or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), in which case the provisions of the GPL or the LGPL are applicable instead of those above. If you wish to allow use of your version of this file only under the terms of either the GPL or the LGPL, and not to allow others to use your version of this file under the terms of the MPL, indicate your 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 *****/ function help(section, easter) { if (easter) { echoerr("E478: Don't panic!"); return; } if ((arguments[3] && arguments[3].inTab) || !window.content.document.open) openURLsInNewTab("", true); var doc = window.content.document; // xxx: for firebug: :js Firebug.toggleBar(true) /* commands = array where help information is located * color = used for background of the table * beg = string which is printed before the commmand/setting/mapping name * end = string which is printed after the commmand/setting/mapping name * func = called with 'command', result is a string is prepended to the help text */ function makeHelpString(commands, color, beg, end, func) { var ret = ""; for (var i=0; i < commands.length; i++) { // the usage information for the command ret += ''; for (var j=0; j < commands[i][USAGE].length; j++) { var usage = commands[i][USAGE][j]; // keep
//usage = usage.replace(/<([^b][^r].*>)/g, "<$1"); //usage = usage.replace(/[^b][^r][^\/]>/g, ">"); usage = usage.replace(//g, ">"); usage = usage.replace(/\\n/g, "
"); // color {count} and [url] arguments in the usage, not nice and error prone but the regexp work (for now) usage = usage.replace(/(^|;|\n|\s|\]|\}|=|)({.*?}|\[.*?\])/gm, "$1$2"); // and the 'setting' in a different color usage = usage.replace(/^'(\w+)'/gm, "'$1'"); ret += "" +beg+ usage +end+ '
'; } ret += ''; // the actual help text with the first line in bold if (commands[i][SHORTHELP]) { ret += ""; ret += commands[i][SHORTHELP]; // the help description ret += "
"; if(func) // for settings whe print default values here, e.g. { ret += func.call(this, commands[i]); ret += "
"; } if (commands[i][HELP]) ret += commands[i][HELP]; // the help description } else ret += "Sorry, no help available"; // the tags which are printed on the top right //ret += '===================================='; ret += ''; for (var j=0; j < commands[i][COMMANDS].length; j++) { var cmd_name = commands[i][COMMANDS][j]; cmd_name = cmd_name.replace(//g, ">"); ret += '' +beg+ cmd_name +end+ '
'; } ret += ''; // add more space between entries if (i < commands.length-1) ret += '
'; } return ret; } function makeSettingsHelpString(command) { var ret = ""; ret = command[TYPE] + ' (default: '; if (command[TYPE] == "boolean") { if(command[DEFAULT] == true) ret += "on"; else ret += "off"; } else { if (typeof command[DEFAULT] == 'string' && command[DEFAULT].length == 0) ret += "''"; else ret += command[DEFAULT]; } ret += ")
"; return ret; } var header = '

Vimperator

' + '

First there was a Navigator, then there was an Explorer.
'+ 'Later it was time for a Konqueror. Now it\'s time for an Imperator, the VIMperator :)

'; var introduction = '

Introduction

' + '

Vimperator is a free browser add-on for Firefox, which makes it look and behave like the Vim text editor.
' + 'It has similar key bindings, and you could call it a modal webbrowser, as key bindings differ according to which mode you are in.

' + '

Warning: To provide the most authentic Vim experience, the Firefox menubar and toolbar were hidden.
'+ 'If you really need them, type: :set guioptions=mT to get it back.
' + 'If you don\'t like Vimperator at all, you can uninstall it by typing :addons and remove/disable it.
' + 'If you like it, but can\'t remember the shortcuts, press F1 or :help to get this help window back.

' + '

Since Vimperator\'s GUI is embedded into a toolbar, it may look too 3D-like with the default theme.
'+ 'For best experience, I therefore recommend the Whitehart theme.

' + '

Vimperator was written by Martin Stubenschrott. If you appreciate my work on Vimperator, you can either
'+ 'send me greetings, patches or make a donation: ' + '

' + '' + '' + '' + '' + '
' + 'Of course as a believer in free open source software, only make a donation if you really like Vimperator, and the money doesn\'t hurt - otherwise just use it, recommend it and like it :)

' var mappings = '

Mappings

'+ '

The denotion of modifier keys is like in Vim, so C- means the Control key, M- the Meta key, A- the Alt key and S- the Shift key.

'+ '

' mappings += makeHelpString(g_mappings, "#102663", "", "", null); mappings += '

'; if (section && section == 'holy-grail') mappings += 'You found it, Arthur!'; var commands = '

Commands

' commands += makeHelpString(g_commands, "#632610", ":", "", null); commands += '

'; if (section && section == '42') commands += '

What is the meaning of life, the universe and everything?
' + 'Douglas Adams, the only person who knew what this question really was about is
' + 'now dead, unfortunately. So now you might wonder what the meaning of death
' + 'is...

'; var settings = '

Settings

' settings += makeHelpString(g_settings, "#106326", "'", "'", makeSettingsHelpString); settings += '

'; var fulldoc = 'Vimperator help' + // XXX: stylesheet broken here? Have to add it in the vimperator.xul file ''+ '
' + // should change that to: white-space: pre-wrap; once CSS3 hits firefox header + introduction + mappings + commands + settings + '
' doc.open(); doc.write(fulldoc); doc.close(); function cumulativeOffset(element) { var valueT = 0, valueL = 0; if (!element) return [0, 0]; do { valueT += element.offsetTop || 0; valueL += element.offsetLeft || 0; element = element.offsetParent; } while (element); return [valueL, valueT]; } if (section) { var element = doc.getElementById(section); if (!element) { echoerr("E149: Sorry, no help for " + section); return; } var pos = cumulativeOffset(element); // horizontal offset is annyoing, set it to 0 (use pos[0] if you want horizontal offset) window.content.scrollTo(0, pos[1] - 50); // 50 pixel context lines } } // vim: set fdm=marker sw=4 ts=4 et: