[Conkeror] [PATCH] Optionally display a URL panel when selecting from hints.

David Kettler David.Kettler at dsto.defence.gov.au
Sun Oct 26 18:45:46 PDT 2008


When hints_display_url_panel is true and an item is being selected
using the hinting system, a panel is displayed above the minibuffer
showing the URL of the item that is being selected.  This is useful for
confirming that the correct link is selected and that the URL is not
undesirable in some way.
---

I'm not very familiar with javascript, XUL or the conkeror code.
Suggestions for improvements are welcome.

 content/conkeror.css |    4 ++++
 modules/hints.js     |   35 +++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/content/conkeror.css b/content/conkeror.css
index b5bc751..ad19ea7 100644
--- a/content/conkeror.css
+++ b/content/conkeror.css
@@ -88,6 +88,10 @@ tree.completions treechildren::-moz-tree-cell-text(current) {
   font-weight: bold;
 }
 
+.panel .url-panel-label {
+  font-weight: bold;
+}
+
 
 /* tab bar */
 
diff --git a/modules/hints.js b/modules/hints.js
index d36e080..9ea1454 100644
--- a/modules/hints.js
+++ b/modules/hints.js
@@ -328,6 +328,33 @@ hint_manager.prototype = {
     }
 };
 
+/* Show panel with currently selected URL below the minibuffer. */
+function hints_url_panel(hints, window) {
+    var g = new dom_generator(window.document, XUL_NS);
+
+    var p = g.element("hbox", "class", "panel url", "flex", "0");
+    g.element("label", p, "value", "URL:", "class", "url-panel-label");
+    var url_value = g.text("label", p, "class", "url-panel-value");
+    window.minibuffer.insert_before(p);
+
+    p.update = function() {
+	url_value.nodeValue = "";
+	if (hints.manager && hints.manager.last_selected_hint) {
+	    var elem = hints.manager.last_selected_hint.elem;
+	    if (elem instanceof Ci.nsIDOMHTMLAnchorElement)
+		url_value.nodeValue = elem;
+	}
+    }
+
+    p.destroy = function() {
+        this.parentNode.removeChild(this);
+    };
+
+    return p;
+}
+
+define_variable("hints_display_url_panel", false, "When selecting a hint, the URL can be displayed in a panel above the minibuffer.  This is useful for confirming that the correct link is selected and that the URL is not evil.  This option is most useful when hints_auto_exit_delay is long or disabled.");
+
 /**
  * keyword arguments:
  *
@@ -340,6 +367,8 @@ function hints_minibuffer_state(continuation, buffer)
 {
     keywords(arguments, $keymap = hint_keymap, $auto);
     basic_minibuffer_state.call(this, $prompt = arguments.$prompt);
+    if (hints_display_url_panel)
+	this.url_panel = hints_url_panel(this, buffer.window);
     this.original_prompt = arguments.$prompt;
     this.continuation = continuation;
     this.keymap = arguments.$keymap;
@@ -362,6 +391,8 @@ hints_minibuffer_state.prototype = {
                                             this.focused_frame, this.focused_element);
         }
         this.manager.update_valid_hints();
+        if (this.url_panel)
+            this.url_panel.update();
     },
     unload : function (window) {
         if (this.auto_exit_timer_ID) {
@@ -376,12 +407,16 @@ hints_minibuffer_state.prototype = {
             this.auto_exit_timer_ID = null;
         }
         this.manager.remove();
+        if (this.url_panel)
+            this.url_panel.destroy();
     },
     update_minibuffer : function (m) {
         if (this.typed_number.length > 0)
             m.prompt = this.original_prompt + " #" + this.typed_number;
         else
             m.prompt = this.original_prompt;
+        if (this.url_panel)
+            this.url_panel.update();
     },
 
     handle_auto_exit : function (m, delay) {
-- 
1.6.0.2.605.g208f6.dirty


-- 
IMPORTANT: This email remains the property of the Australian Defence
Organisation and is subject to the jurisdiction of section 70 of the
CRIMES ACT 1914. If you have received this email in error, you are
requested to contact the sender and delete the email.



More information about the Conkeror mailing list