mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 00:27:57 +01:00
all help converted to asciidoc, now only somebody needs to file them in the correct place.
New vimperator.util.generateHelp(command) for generating asciidoc added.
This commit is contained in:
@@ -47,64 +47,9 @@ vimperator.help = function (section, easter) //{{{
|
||||
function makeHelpString(commands, beg, end, func)
|
||||
{
|
||||
var ret = "";
|
||||
var separator = '<tr class="separator"><td colspan="3"><hr/></td></tr>\n';
|
||||
for (var command in commands)
|
||||
{
|
||||
// the usage information for the command
|
||||
ret += '<tr class="description"><td class="usage" valign="top">';
|
||||
for (var j=0; j < command.usage.length; j++)
|
||||
{
|
||||
var usage = command.usage[j];
|
||||
ret += vimperator.util.generateHelp(command);
|
||||
|
||||
// keep <br/>
|
||||
//usage = usage.replace(/<([^b][^r].*>)/g, "<$1");
|
||||
//usage = usage.replace(/[^b][^r][^\/]>/g, ">");
|
||||
usage = vimperator.util.escapeHTML(usage);
|
||||
usage = usage.replace(/\\n/g, "<br/>");
|
||||
// color [count], [!], {arg} and [arg] in the usage, not nice and error prone but the regexp work (for now)
|
||||
usage = usage.replace(/({[^}]+})/g, "<span class=\"argument\">$1</span>"); // required args
|
||||
usage = usage.replace(/(^|[^A-Za-z])(\[[^!\]]+\])/g, "$1<span class=\"argument\">$2</span>"); // optional args
|
||||
usage = usage.replace(/\[!\]/, "<span class=\"argument\">[!]</span>"); // special
|
||||
// and the 'option' in a different color
|
||||
usage = usage.replace(/^'(\w+)'/gm, "'<span class=\"option\">$1</span>'");
|
||||
ret += "<code>" + beg + usage + end + '</code><br/>';
|
||||
}
|
||||
ret += '</td><td valign="top">';
|
||||
|
||||
// the actual help text with the first line in bold
|
||||
if (command.shortHelp)
|
||||
{
|
||||
ret += '<span class="shorthelp">';
|
||||
ret += command.shortHelp; // the help description
|
||||
ret += "</span><br/>";
|
||||
if (func) // for options we print default values here, e.g.
|
||||
{
|
||||
ret += func.call(this, command);
|
||||
ret += "<br/>";
|
||||
}
|
||||
if (command.help)
|
||||
{
|
||||
ret += command.help; // the help description
|
||||
ret += "<br/>";
|
||||
}
|
||||
}
|
||||
else
|
||||
ret += "Sorry, no help available";
|
||||
// the tags which are printed on the top right
|
||||
ret += '</td><td class="taglist" valign="top">';
|
||||
var names = command.names;
|
||||
for (var j=0; j < names.length; j++)
|
||||
{
|
||||
var cmdName = names[j];
|
||||
cmdName = vimperator.util.escapeHTML(cmdName);
|
||||
ret += '<code class="tag">' + beg + cmdName + end + '</code><br/>';
|
||||
}
|
||||
ret += '</td></tr>';
|
||||
|
||||
// add more space between entries
|
||||
ret += separator;
|
||||
}
|
||||
ret = ret.replace(new RegExp(separator + "$"), ""); // FIXME: far too tasty!
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -179,15 +124,15 @@ vimperator.help = function (section, easter) //{{{
|
||||
var mappings = '<span style="float: right"><code class="tag">mappings</code></span><h2 id="mappings">Mappings</h2>' +
|
||||
'<p>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.</p>' +
|
||||
'<table class="vimperator mappings">';
|
||||
mappings += makeHelpString(vimperator.mappings, "", "", null);
|
||||
mappings += '</table>';
|
||||
mappings = makeHelpString(vimperator.mappings, "", "", null);
|
||||
//mappings += '</table>';
|
||||
if (section && section == "holy-grail")
|
||||
mappings += '<div><p id="holy-grail">You found it, Arthur!</p></div>\n';
|
||||
|
||||
var commands = '<span style="float: right"><code class="tag">commands</code></span><h2 id="commands">Commands</h2>' +
|
||||
'<table class="vimperator commands">\n';
|
||||
commands += makeHelpString(vimperator.commands, ":", "", null);
|
||||
commands += '</table>';
|
||||
commands = makeHelpString(vimperator.commands, ":", "", null);
|
||||
//commands += '</table>';
|
||||
if (section && section == "42")
|
||||
commands += '<div><p id="42">What is the meaning of life, the universe and everything?<br/>' +
|
||||
'Douglas Adams, the only person who knew what this question really was about is<br/>' +
|
||||
@@ -214,6 +159,8 @@ vimperator.help = function (section, easter) //{{{
|
||||
options +
|
||||
'\n</div>\n</body>\n</html>';
|
||||
|
||||
dump(mappings + commands + "\n\n\n");
|
||||
|
||||
var doc = window.content.document;
|
||||
dump("before open\n");
|
||||
|
||||
|
||||
@@ -175,14 +175,6 @@ vimperator.util = { //{{{
|
||||
return urls;
|
||||
},
|
||||
|
||||
highlightURL: function (str, force)
|
||||
{
|
||||
if (force || /^[a-zA-Z]+:\/\//.test(str))
|
||||
return "<a class='hl-URL' href='#'>" + vimperator.util.escapeHTML(str) + "</a>";
|
||||
else
|
||||
return str;
|
||||
},
|
||||
|
||||
formatBytes: function (num, decimalPlaces, humanReadable)
|
||||
{
|
||||
const unitVal = ["Bytes", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
|
||||
@@ -214,6 +206,70 @@ vimperator.util = { //{{{
|
||||
strNum[0] += "." + strNum[1];
|
||||
|
||||
return strNum[0] + " " + unitVal[unitIndex];
|
||||
},
|
||||
|
||||
// generates an Asciidoc help entry, "command" can also be a mapping
|
||||
// TODO: must be refactored, once we get rid of command.usage
|
||||
generateHelp: function (command)
|
||||
{
|
||||
var start = "", end = "";
|
||||
if (command instanceof vimperator.Command)
|
||||
start = ":"
|
||||
else if (command instanceof vimperator.Option)
|
||||
start = end = "'"
|
||||
|
||||
var ret = "";
|
||||
var longHelp = false;
|
||||
if ((command.help && command.shortHelp) && (command.help.length + command.shortHelp.length) > 50)
|
||||
longHelp = true;
|
||||
|
||||
// the tags which are printed on the top right
|
||||
for (var j = command.names.length - 1; j >= 0; j--)
|
||||
ret += "|" + start + command.names[j] + end + "| ";
|
||||
|
||||
if (longHelp)
|
||||
ret += "+";
|
||||
|
||||
ret += "\n"
|
||||
|
||||
// the usage information for the command
|
||||
for (var j = 0; j < command.usage.length; j++)
|
||||
{
|
||||
var usage = command.usage[j].replace(/{/, "\\\\{").replace(/}/, "\\\\}");
|
||||
usage = usage.replace(/'/, "\\'").replace(/`/, "\\`");
|
||||
ret += "||" + start + usage + end + "||";
|
||||
if (command.usage[j].length > 15 || j < command.usage.length - 1)
|
||||
ret += " +";
|
||||
|
||||
ret += "\n";
|
||||
}
|
||||
ret += "________________________________________________________________________________\n"
|
||||
|
||||
// the actual help text
|
||||
if (command.shortHelp)
|
||||
{
|
||||
ret += command.shortHelp; // the help description
|
||||
if (command.help)
|
||||
{
|
||||
//ret += ". +\n";
|
||||
ret += ". " + command.help; // the help description
|
||||
}
|
||||
}
|
||||
else
|
||||
ret += "Sorry, no help available";
|
||||
|
||||
// add more space between entries
|
||||
ret += "\n________________________________________________________________________________\n\n\n";
|
||||
|
||||
return ret;
|
||||
},
|
||||
|
||||
highlightURL: function (str, force)
|
||||
{
|
||||
if (force || /^[a-zA-Z]+:\/\//.test(str))
|
||||
return "<a class='hl-URL' href='#'>" + vimperator.util.escapeHTML(str) + "</a>";
|
||||
else
|
||||
return str;
|
||||
}
|
||||
|
||||
}; //}}}
|
||||
|
||||
@@ -27,6 +27,7 @@ HEADER=<span style="float: right; padding-top: 10px;"><form action="https://www.
|
||||
\[arg1\]=<span class="argument">[arg1]</span>
|
||||
\[arg2\]=<span class="argument">[arg2]</span>
|
||||
\[url\]=<span class="argument">[url]</span>
|
||||
\[file\]=<span class="argument">[file]</span>
|
||||
\[!\]=<span class="argument">[!]</span>
|
||||
|
||||
# [macros]
|
||||
|
||||
@@ -4,13 +4,13 @@ HEADER
|
||||
|
||||
Vimperator can repeat a number of commands or record macros...
|
||||
|
||||
section:Macros[macros]
|
||||
section:Macros[+++macros+++]
|
||||
|
||||
TO BE WRITTEN...
|
||||
|
||||
|
||||
More commands:
|
||||
section:Profiling[profiling]
|
||||
|
||||
:time
|
||||
:time ...
|
||||
|
||||
// vim: set syntax=asciidoc:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -290,7 +290,7 @@ span.tag, span.hiddentag {
|
||||
font-weight: bold;
|
||||
color: rgb(255, 0, 255); /* magenta */
|
||||
padding-left: 15px;
|
||||
padding-top: -5px;
|
||||
/*padding-top: -5px;*/
|
||||
float: right;
|
||||
}
|
||||
/* inside a table cell means this tag is part of a section */
|
||||
@@ -330,5 +330,5 @@ fieldset.paypal {
|
||||
}
|
||||
.quoteblock {
|
||||
margin-left: 140px;
|
||||
padding-bottom: 20px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user