---
content/help.css | 8 ++--
modules/bindings/default/global.js | 1 +
modules/help.js | 92 +++++++++++++++++++++++++++++++++++-
3 files changed, 96 insertions(+), 5 deletions(-)
diff --git a/content/help.css b/content/help.css
index cfdb0c9..bcca7cf 100644
--- a/content/help.css
+++ b/content/help.css
@@ -2,14 +2,14 @@ body {
background-color: #eeeeee;
}
-body.describe-bindings {
+body.help-list {
padding: 0px;
margin: 0px;
}
-.describe-bindings table { border-collapse: collapse; margin: 0px; width:
100%; }
+.help-list table { border-collapse: collapse; margin: 0px; width: 100%; }
-.describe-bindings td {
+.help-list td {
border: 1px solid #999;
padding-left: .3em;
padding-right: .3em;
@@ -17,7 +17,7 @@ body.describe-bindings {
white-space: nowrap;
}
-.describe-bindings tr.even { background-color: #dddddd; }
+.help-list tr.even { background-color: #dddddd; }
.source-code-reference {
diff --git a/modules/bindings/default/global.js
b/modules/bindings/default/global.js
index 9f6f548..5eeccd8 100644
--- a/modules/bindings/default/global.js
+++ b/modules/bindings/default/global.js
@@ -21,6 +21,7 @@ define_key(default_global_keymap, "C-x 5 2", "make-window");
define_key(default_global_keymap, "C-x 5 0", "delete-window");
define_key(default_base_keymap, "C-h", default_help_keymap);
+define_key(default_help_keymap, "a", "apropos-command");
define_key(default_help_keymap, "b", "describe-bindings");
define_key(default_help_keymap, "f", "describe-command");
define_key(default_help_keymap, "v", "describe-variable");
diff --git a/modules/help.js b/modules/help.js
index 5b6b251..29e96e2 100644
--- a/modules/help.js
+++ b/modules/help.js
@@ -146,7 +146,7 @@ describe_bindings_buffer.prototype = {
var g = new help_document_generator(d);
g.add_help_stylesheet();
- d.body.setAttribute("class", "describe-bindings");
+ d.body.setAttribute("class", "help-list");
var table = d.createElementNS(XHTML_NS, "table");
for (var i = 0; i < list.length; ++i) {
@@ -206,6 +206,96 @@ interactive("describe-bindings", function (I)
{describe_bindings(I.buffer, I.bro
default_browse_targets["describe-bindings"] = "find-url";
+define_keywords("$command_list");
+function apropos_command_buffer(window, element) {
+ this.constructor_begin();
+ keywords(arguments);
+ special_buffer.call(this, window, element, forward_keywords(arguments));
+ this.command_list = arguments.$command_list;
+ this.constructor_end();
+}
+
+apropos_command_buffer.prototype = {
+
+ get keymap() {
+ return help_buffer_keymap;
+ },
+
+ title : "Apropos commands",
+
+ description : "*Apropos*",
+
+ generate : function () {
+ var d = this.top_document;
+ var list = this.command_list;
+ delete this.command_list;
+
+ var g = new help_document_generator(d);
+ g.add_help_stylesheet();
+
+ d.body.setAttribute("class", "help-list");
+
+ var table = d.createElementNS(XHTML_NS, "table");
+ for (var i = 0; i < list.length; ++i) {
+ var binding = list[i];
+ var tr = d.createElementNS(XHTML_NS, "tr");
+ tr.setAttribute("class", (i % 2 == 0) ? "even" : "odd");
+
+ var command_td = d.createElementNS(XHTML_NS,"td");
+ command_td.setAttribute("class", "command");
+
+ var shortdoc = "";
+ command_td.textContent = binding.name;
+ if (binding.cmd.shortdoc != null)
+ shortdoc = binding.cmd.shortdoc;
+ tr.appendChild(command_td);
+
+ var shortdoc_td = d.createElementNS(XHTML_NS, "td");
+ shortdoc_td.setAttribute("class", "help");
+ shortdoc_td.textContent = shortdoc;
+ tr.appendChild(shortdoc_td);
+
+ table.appendChild(tr);
+ }
+ d.body.appendChild(table);
+ },
+
+ __proto__: special_buffer.prototype
+};
+
+
+/* TODO: support regexps/etc. */
+function apropos_command(buffer, substring, target) {
+ var list = [];
+ interactive_commands.for_each(function (name, cmd) {
+ if (name.indexOf(substring) != -1) {
+ var binding = {name: name, cmd: cmd};
+ list.push(binding);
+ }
+ });
+ list.sort(function (a,b) {
+ if (a.name < b.name)
+ return -1;
+ if (a.name > b.name)
+ return 1;
+ return 0
+ });
+ create_buffer(buffer.window, buffer_creator(apropos_command_buffer,
+ $configuration =
buffer.configuration,
+ $command_list = list),
+ target);
+}
+
+interactive("apropos-command", "List commands whose names contain a given
substring.",
+ function (I) {
+ apropos_command(I.buffer,
+ (yield I.minibuffer.read($prompt = "Apropos command:",
+ $history = "apropos")),
+ I.browse_target("apropos-command"));
+});
+default_browse_targets["apropos-command"] = "find-url";
+
+
define_keywords("$command", "$bindings");
function describe_command_buffer(window, element) {
--
1.5.2.5
_______________________________________________
Conkeror mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/conkeror