Information is displayed on the right of the minibuffer during a
hints interaction to aid in selection of the desired link.

This display replaces the previous URL panel feature; it is now
enabled by setting hints_display_info=true.

The url panel was previously placed above the minibuffer, which
unnecessarily obscures part of the content buffer.  This change avoids
that problem, fixing http://bugs.conkeror.org/issue343.

TODO:

Allow the minibuffer input area to grow as needed for the typed input.

Integrate the display properly into the minibuffer implementation by
making it an additional minibuffermode.

Possibly enable the display by default or remove the variable
altogether.
---
 content/minibuffer.css             |    1 +
 content/minibuffer.xul             |    3 +-
 contrib/config/common.js           |    2 +-
 modules/hints.js                   |   62 ++++++++++++++++++------------------
 style/default/hints--url-panel.css |   11 ------
 style/default/minibuffer.css       |    6 +++
 style/default/panel.css            |    6 +++
 style/default/theme.json           |    2 +-
 8 files changed, 48 insertions(+), 45 deletions(-)
 delete mode 100644 style/default/hints--url-panel.css
 create mode 100644 style/default/panel.css

diff --git a/content/minibuffer.css b/content/minibuffer.css
index 17ee1b2..2e52eb7 100644
--- a/content/minibuffer.css
+++ b/content/minibuffer.css
@@ -9,6 +9,7 @@
 
 #minibuffer[minibuffermode="message"] #minibuffer-prompt,
 #minibuffer[minibuffermode="message"] #minibuffer-input,
+#minibuffer[minibuffermode="message"] #minibuffer-info,
 #minibuffer[minibuffermode="input"] #minibuffer-message,
 #minibuffer[minibuffermode="input"] #minibuffer-mode-indicator {
   visibility: collapse;
diff --git a/content/minibuffer.xul b/content/minibuffer.xul
index 34fc442..8f8b3e0 100644
--- a/content/minibuffer.xul
+++ b/content/minibuffer.xul
@@ -15,7 +15,8 @@ COPYING file.
     <hbox id="minibuffer" minibuffermode="message">
       <label class="minibuffer" id="minibuffer-message" flex="1" crop="right" 
value=""/>
       <label class="minibuffer" id="minibuffer-prompt" crop="left" value=""/>
-      <textbox class="plain" id="minibuffer-input" flex="1"/>
+      <textbox class="plain" id="minibuffer-input" flex="1" minwidth="50pt"/>
+      <label class="plain" id="minibuffer-info" flex="1" crop="right" 
collapsed="true"/>
     </hbox>
   </window>
 </overlay>
diff --git a/contrib/config/common.js b/contrib/config/common.js
index d993293..2c69405 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_display_info = true;
 
 
 // default directory for downloads and shell commands.
diff --git a/modules/hints.js b/modules/hints.js
index c985b70..bec21d3 100644
--- a/modules/hints.js
+++ b/modules/hints.js
@@ -420,22 +420,22 @@ hint_manager.prototype = {
     }
 };
 
-/**
- * Show panel with currently selected URL.
- */
-function hints_url_panel (hints, window) {
-    var g = new dom_generator(window.document, XUL_NS);
+function hints_info_display (hints, window) {
+    this.hints = hints;
+    this.input = window.minibuffer.input_element;
+    this.info = window.document.getElementById("minibuffer-info");
 
-    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);
+    this.input.setAttribute("flex", "0");
+    this.input.setAttribute("width", this.input.getAttribute("minwidth"));
+    this.info.setAttribute("collapsed", "false");
+}
+hints_info_display.prototype = {
+    constructor: hints_info_display,
 
-    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"))
             {
@@ -456,18 +456,18 @@ function hints_url_panel (hints, window) {
                 } catch (e) {}
             }
        }
-        url_value.value = s.join(" ");
-    };
-
-    p.destroy = function () {
-        this.parentNode.removeChild(this);
-    };
+        this.info.value = s.join(" ");
+    },
 
-    return p;
-}
+    destroy: function () {
+        this.info.value = "";
+        this.info.setAttribute("collapsed", "true");
+        this.input.setAttribute("flex", "1");
+    }
+};
 
-define_variable("hints_display_url_panel", false,
-    "When selecting a hint, the URL can be displayed in a panel above "+
+define_variable("hints_display_info", false,
+    "When selecting a hint, the URL can be displayed in "+
     "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.");
@@ -484,8 +484,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_display_info)
+       this.info_display = new hints_info_display(this, buffer.window);
     this.original_prompt = arguments.$prompt;
     this.continuation = continuation;
     this.auto_exit = arguments.$auto ? true : false;
@@ -509,8 +509,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.info_display)
+            this.info_display.update();
     },
     clear_auto_exit_timer: function () {
         var window = this.minibuffer.window;
@@ -527,8 +527,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.info_display)
+            this.info_display.destroy();
         basic_minibuffer_state.prototype.destroy.call(this);
     },
     update_minibuffer: function (m) {
@@ -536,8 +536,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.info_display)
+            this.info_display.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/minibuffer.css b/style/default/minibuffer.css
index 253559e..a614c82 100644
--- a/style/default/minibuffer.css
+++ b/style/default/minibuffer.css
@@ -10,6 +10,12 @@
   background-color: -moz-field !important;
 }
 
+#minibuffer-info {
+  background-color: -moz-field !important;
+  font-style: oblique;
+  margin: 0px !important;
+  padding-left: 0.5em !important;
+}
 
 /* mode text widgets */
 
diff --git a/style/default/panel.css b/style/default/panel.css
new file mode 100644
index 0000000..f55d682
--- /dev/null
+++ b/style/default/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;
+}
diff --git a/style/default/theme.json b/style/default/theme.json
index 28682cb..1145447 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",
+      "panel.css",
       "eye-guide.css"
   ]
 }
-- 
1.7.7

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

Reply via email to