Previously when the space allocated to the minibuffer input filled up,
its text would be truncated. Now the hints information display (if
enabled) will move over to make more room.
The implementation makes a deck of the input textbox with a "shadow"
label, and updates the label with the input text, so its width
controls the input width. The label is placed in a box with hidden
overflow; this prevents wide text from expanding the minibuffer, thus
causing re-layout of the content buffer. The hints information is
given a much larger flex value than the input, so that as the
minibuffer fills, the hints information will be truncated before the
input. To ensure that the shadow label width matches the minibuffer
input, the text styles are copied to the label; that code is based on
the Searchbar Autosizer extension for Firefox. The shadow label has
right padding which acts as a spacer between the input and hints
information and also allows room for the cursor. This replaces the
left padding in the hints information, because that does not allow for
the text cursor and neither does it flex as needed.
The implementation is more heavy weight than desired. It would have
been preferred to have the textbox expand as needed by itself, but
there doesn't seem to be a way to do that. The next best thing would
be to query the width of the text, but there doesn't seem to be any
way to do that either. An attempt was made to do all the resizing by
hand, using a shadow label in a zero width box, but that was even
clunkier than the current approach.
Development note: To check that the shadow label matches the input,
change the deck to a stack and add the following style attribute to
minibuffer-input-shadow.
style="color: red; font-style: oblique;"
---
content/minibuffer.css | 2 +-
content/minibuffer.xul | 9 +++++++--
modules/hints.js | 14 ++++++++++++--
style/default/minibuffer.css | 5 ++++-
4 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/content/minibuffer.css b/content/minibuffer.css
index 2e52eb7..f0c5338 100644
--- a/content/minibuffer.css
+++ b/content/minibuffer.css
@@ -8,7 +8,7 @@
**/
#minibuffer[minibuffermode="message"] #minibuffer-prompt,
-#minibuffer[minibuffermode="message"] #minibuffer-input,
+#minibuffer[minibuffermode="message"] #minibuffer-input-deck,
#minibuffer[minibuffermode="message"] #minibuffer-info,
#minibuffer[minibuffermode="input"] #minibuffer-message,
#minibuffer[minibuffermode="input"] #minibuffer-mode-indicator {
diff --git a/content/minibuffer.xul b/content/minibuffer.xul
index 6d0d06a..b7b8f2a 100644
--- a/content/minibuffer.xul
+++ b/content/minibuffer.xul
@@ -15,8 +15,13 @@ 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"/>
- <label class="plain" id="minibuffer-info" flex="1" crop="right"
collapsed="true"/>
+ <deck id="minibuffer-input-deck" flex="1">
+ <textbox class="plain" id="minibuffer-input"/>
+ <hbox style="overflow: hidden">
+ <label class="plain" id="minibuffer-input-shadow"/>
+ </hbox>
+ </deck>
+ <label class="plain" id="minibuffer-info" flex="1000" crop="right"
collapsed="true"/>
</hbox>
</window>
</overlay>
diff --git a/modules/hints.js b/modules/hints.js
index 28e9011..fda1731 100644
--- a/modules/hints.js
+++ b/modules/hints.js
@@ -424,14 +424,23 @@ hint_manager.prototype = {
function hints_info (hints, window) {
this.hints = hints;
this.input = window.minibuffer.input_element;
+ this.shadow = window.document.getElementById("minibuffer-input-shadow");
this.info = window.document.getElementById("minibuffer-info");
- this.input.setAttribute("flex", "0");
+ this.set_shadow_styles(window);
this.info.setAttribute("collapsed", "false");
}
hints_info.prototype = {
constructor: hints_info,
+ set_shadow_styles: function(window) {
+ var style = window.getComputedStyle(this.input, '');
+ for each (var s in ['fontSize', 'fontSizeAdjust', 'fontStretch',
+ 'fontStyle', 'fontVariant', 'fontWeight',
+ 'letterSpacing', 'wordSpacing'])
+ this.shadow.style[s] = style[s];
+ },
+
update: function () {
var s = [];
if (this.hints.manager && this.hints.manager.last_selected_hint) {
@@ -457,12 +466,13 @@ hints_info.prototype = {
}
}
this.info.value = s.join(" ");
+ this.shadow.value = this.hints.typed_string;
},
destroy: function () {
- this.input.setAttribute("flex", "1");
this.info.setAttribute("collapsed", "true");
this.info.value = "";
+ this.shadow.value = "";
}
};
diff --git a/style/default/minibuffer.css b/style/default/minibuffer.css
index 3a32c20..0e1018f 100644
--- a/style/default/minibuffer.css
+++ b/style/default/minibuffer.css
@@ -11,11 +11,14 @@
width: 5em;
}
+#minibuffer-input-shadow {
+ padding-right: 1em !important;
+}
+
#minibuffer-info {
background-color: -moz-field !important;
font-style: oblique;
margin: 0px !important;
- padding-left: 1em !important;
}
/* mode text widgets */
--
1.7.7.3
_______________________________________________
Conkeror mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/conkeror