During a hints interaction, conkeror can display the URL and other
information about the currently selected hint.  The information is now
displayed in the minibuffer, using minibuffer-annotation-mode.

This display replaces the previous URL panel feature; the content is
unchanged.  The new display looks better and it avoids obscuring part
of the content buffer, fixing http://bugs.conkeror.org/issue343.

This can be enabled by placing

  hints_minibuffer_annotation_mode(true);

in the rc; this replaces the former

  hints_display_url_panel=true;

Thanks to John Foerch for suggestions.
---
 contrib/config/common.js           |    2 +-
 modules/hints.js                   |   69 +++++++++++++++++++-----------------
 style/default/hints--url-panel.css |   11 ------
 style/default/theme.json           |    2 +-
 style/default/window--panel.css    |    6 +++
 5 files changed, 44 insertions(+), 46 deletions(-)
 delete mode 100644 style/default/hints--url-panel.css
 create mode 100644 style/default/window--panel.css

diff --git a/contrib/config/common.js b/contrib/config/common.js
index d993293..a9fa987 100644
--- a/contrib/config/common.js
+++ b/contrib/config/common.js
@@ -20,7 +20,7 @@ hints_ambiguous_auto_exit_delay = 500;
 
 // display properties of the current selected node during
 // the hints interaction.
-hints_display_url_panel = true;
+hints_minibuffer_annotation_mode(true);
 
 
 // default directory for downloads and shell commands.
diff --git a/modules/hints.js b/modules/hints.js
index acb8d73..4d69524 100644
--- a/modules/hints.js
+++ b/modules/hints.js
@@ -419,21 +419,20 @@ hint_manager.prototype = {
 };
 
 /**
- * Show panel with currently selected URL.
+ * Display the URL and other information for the currently selected node.
  */
-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.element("label", p, "class", "url-panel-value",
-                              "crop", "end", "flex", "1");
-    window.minibuffer.insert_before(p);
+function hints_minibuffer_annotation (hints, window) {
+    this.hints = hints;
+    this.input = window.minibuffer.input_element;
+    this.input.annotate = true;
+}
+hints_minibuffer_annotation.prototype = {
+    constructor: hints_minibuffer_annotation,
 
-    p.update = function () {
+    update: function () {
        var s = [];
-       if (hints.manager && hints.manager.last_selected_hint) {
-            var elem = hints.manager.last_selected_hint.elem;
+       if (this.hints.manager && this.hints.manager.last_selected_hint) {
+            var elem = this.hints.manager.last_selected_hint.elem;
             if (elem.hasAttribute("onmousedown") ||
                 elem.hasAttribute("onclick"))
             {
@@ -454,21 +453,25 @@ function hints_url_panel (hints, window) {
                 } catch (e) {}
             }
        }
-        url_value.value = s.join(" ");
-    };
-
-    p.destroy = function () {
-        this.parentNode.removeChild(this);
-    };
+        this.input.annotation = s.join(" ");
+    },
 
-    return p;
-}
+    destroy: function () {
+        this.input.annotate = false;
+    }
+};
 
-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.");
+define_global_mode("hints_minibuffer_annotation_mode",
+    function enable () {
+        minibuffer_annotation_mode.register(hints_minibuffer_annotation_mode);
+    },
+    function disable () {
+        
minibuffer_annotation_mode.unregister(hints_minibuffer_annotation_mode);
+    },
+    $doc = "When selecting a hint, display the URL in the minibuffer.  " +
+        "This is useful for confirming that the correct link is selected " +
+        "and that the URL is not evil.  This mode is most useful when " +
+        "hints_auto_exit_delay is long or disabled.");
 
 /**
  * keyword arguments:
@@ -482,8 +485,8 @@ function hints_minibuffer_state (minibuffer, continuation, 
buffer) {
     keywords(arguments, $keymap = hint_keymap, $auto);
     basic_minibuffer_state.call(this, minibuffer, $prompt = arguments.$prompt,
                                 $keymap = arguments.$keymap);
-    if (hints_display_url_panel)
-       this.url_panel = hints_url_panel(this, buffer.window);
+    if (hints_minibuffer_annotation_mode_enabled)
+       this.hints_minibuffer_annotation = new 
hints_minibuffer_annotation(this, buffer.window);
     this.original_prompt = arguments.$prompt;
     this.continuation = continuation;
     this.auto_exit = arguments.$auto ? true : false;
@@ -507,8 +510,8 @@ hints_minibuffer_state.prototype = {
                                             this.focused_frame, 
this.focused_element);
         }
         this.manager.update_valid_hints();
-        if (this.url_panel)
-            this.url_panel.update();
+        if (this.hints_minibuffer_annotation)
+            this.hints_minibuffer_annotation.update();
     },
     clear_auto_exit_timer: function () {
         var window = this.minibuffer.window;
@@ -525,8 +528,8 @@ hints_minibuffer_state.prototype = {
     destroy: function () {
         this.clear_auto_exit_timer();
         this.manager.remove();
-        if (this.url_panel)
-            this.url_panel.destroy();
+        if (this.hints_minibuffer_annotation)
+            this.hints_minibuffer_annotation.destroy();
         basic_minibuffer_state.prototype.destroy.call(this);
     },
     update_minibuffer: function (m) {
@@ -534,8 +537,8 @@ hints_minibuffer_state.prototype = {
             m.prompt = this.original_prompt + " #" + this.typed_number;
         else
             m.prompt = this.original_prompt;
-        if (this.url_panel)
-            this.url_panel.update();
+        if (this.hints_minibuffer_annotation)
+            this.hints_minibuffer_annotation.update();
     },
 
     handle_auto_exit: function (ambiguous) {
diff --git a/style/default/hints--url-panel.css 
b/style/default/hints--url-panel.css
deleted file mode 100644
index 8a41a11..0000000
--- a/style/default/hints--url-panel.css
+++ /dev/null
@@ -1,11 +0,0 @@
-
-@namespace 
url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";);
-
-.panel .panel-row-label {
-  font-weight: bold;
-}
-
-.panel .url-panel-label {
-  font-weight: bold;
-}
-
diff --git a/style/default/theme.json b/style/default/theme.json
index 28682cb..7c12726 100644
--- a/style/default/theme.json
+++ b/style/default/theme.json
@@ -5,7 +5,7 @@
       "mode-line.css",
       "tab-bar.css",
       "new-tabs.css",
-      "hints--url-panel.css",
+      "window--panel.css",
       "eye-guide.css"
   ]
 }
diff --git a/style/default/window--panel.css b/style/default/window--panel.css
new file mode 100644
index 0000000..f55d682
--- /dev/null
+++ b/style/default/window--panel.css
@@ -0,0 +1,6 @@
+
+@namespace 
url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";);
+
+.panel .panel-row-label {
+  font-weight: bold;
+}
-- 
1.7.9.1

_______________________________________________
Conkeror mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/conkeror

Reply via email to