minibuffer-annotation-mode provides an extra label to the right of the
minibuffer input; this will be used to provide information during
hints interaction in a subsequent patch.

Thanks to John Foerch for suggestions.
---
 content/minibuffer-annotation.css |    3 ++
 modules/minibuffer.js             |   40 +++++++++++++++++++++++++++++++++++++
 style/default/minibuffer.css      |   11 ++++++++++
 3 files changed, 54 insertions(+), 0 deletions(-)
 create mode 100644 content/minibuffer-annotation.css

diff --git a/content/minibuffer-annotation.css 
b/content/minibuffer-annotation.css
new file mode 100644
index 0000000..4c5b5e8
--- /dev/null
+++ b/content/minibuffer-annotation.css
@@ -0,0 +1,3 @@
+#minibuffer-input {
+    -moz-binding: 
url("chrome://conkeror-gui/content/annotated-textbox.xml#annotated-textbox");
+}
diff --git a/modules/minibuffer.js b/modules/minibuffer.js
index 6b19305..ab4b1e8 100644
--- a/modules/minibuffer.js
+++ b/modules/minibuffer.js
@@ -447,4 +447,44 @@ function minibuffer_abort (window) {
 interactive("minibuffer-abort", null, function (I) { 
minibuffer_abort(I.window); });
 
 
+/**
+ * Provide an annotation label during minibuffer input.
+ */
+
+const minibuffer_annotation_stylesheet = 
"chrome://conkeror-gui/content/minibuffer-annotation.css";
+
+var minibuffer_annotation_mode = {
+    users: [],
+    enabled: false,
+
+    register: function (user) {
+        this.users.push(user);
+        this._switch_if_needed();
+    },
+
+    unregister: function (user) {
+        var i = this.users.indexOf(user);
+        if (i > -1)
+            this.users.splice(i, 1);
+        this._switch_if_needed();
+    },
+
+    _switch_if_needed: function (user) {
+        if (this.enabled && this.users.length == 0)
+            this._disable();
+        if (!this.enabled && this.users.length != 0)
+            this._enable();
+    },
+
+    _enable: function () {
+        register_user_stylesheet(minibuffer_annotation_stylesheet);
+        this.enabled = true;
+    },
+
+    _disable: function () {
+        unregister_user_stylesheet(minibuffer_annotation_stylesheet);
+        this.enabled = false;
+    }
+}
+
 provide("minibuffer");
diff --git a/style/default/minibuffer.css b/style/default/minibuffer.css
index 253559e..1c476ba 100644
--- a/style/default/minibuffer.css
+++ b/style/default/minibuffer.css
@@ -10,6 +10,17 @@
   background-color: -moz-field !important;
 }
 
+#minibuffer-input .textbox-input-box {
+  width: 5em;
+}
+
+#minibuffer-input [anonid="annotation"] {
+  font-style: oblique;
+}
+
+#minibuffer-input [anonid="strut"] {
+  padding-right: 1em !important;
+}
 
 /* mode text widgets */
 
-- 
1.7.9.1

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

Reply via email to