Skip to content

Commit 27f9069

Browse files
committed
refactoring statusline.js
* new class StatusField * each fields to be StatusField instance * add fields easily from a plugin
1 parent 29346ec commit 27f9069

File tree

8 files changed

+259
-151
lines changed

8 files changed

+259
-151
lines changed

common/content/bookmarks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,14 @@ const Bookmarks = Module("bookmarks", {
151151
if (self.isBookmark(itemId)) {
152152
let bmark = loadBookmark(readBookmark(itemId));
153153
storage.fireEvent(name, "add", bmark);
154-
statusline.updateBookmark();
154+
statusline.updateField("bookmark");
155155
}
156156
}
157157
},
158158
onItemRemoved: function onItemRemoved(itemId, folder, index) {
159159
if (deleteBookmark(itemId)) {
160160
storage.fireEvent(name, "remove", itemId);
161-
statusline.updateBookmark();
161+
statusline.updateField("bookmark");
162162
}
163163
},
164164
onItemChanged: function onItemChanged(itemId, property, isAnnotation, value) {

common/content/buffer.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ const Buffer = Module("buffer", {
161161

162162
// called when the active document is scrolled
163163
_updateBufferPosition: function _updateBufferPosition() {
164-
statusline.updateBufferPosition();
164+
statusline.updateField("position");
165165
// modes.show();
166166
},
167167

@@ -254,9 +254,9 @@ const Buffer = Module("buffer", {
254254
// happens when the users switches tabs
255255
onLocationChange: function onLocationChange() {
256256
onLocationChange.superapply(this, arguments);
257-
statusline.updateUrl();
258-
statusline.updateBookmark();
259-
statusline.updateHistory();
257+
statusline.updateField("location");
258+
statusline.updateField("bookmark");
259+
statusline.updateField("history");
260260

261261
// This is a bit scary but we trigger ignore mode when the new URL is in the list
262262
// of pages with ignored keys and then exit it on a new page but ONLY, if:
@@ -273,7 +273,7 @@ const Buffer = Module("buffer", {
273273
autocommands.trigger("LocationChange", { url: buffer.URL });
274274

275275
// if this is not delayed we get the position of the old buffer
276-
setTimeout(function () { statusline.updateBufferPosition(); }, 250);
276+
setTimeout(function () { statusline.updateField("position"); }, 250);
277277
},
278278
// called at the very end of a page load
279279
asyncUpdateUI: function asyncUpdateUI() {
@@ -284,17 +284,17 @@ const Buffer = Module("buffer", {
284284
let ssli = options["showstatuslinks"];
285285
if (link && ssli) {
286286
if (ssli == 1) {
287-
statusline.updateUrl("Link: " + link);
288-
statusline.updateBookmark(link);
287+
statusline.updateField("location", "Link: " + link);
288+
statusline.updateField("bookmark", link);
289289
}
290290
else if (ssli == 2)
291291
liberator.echo("Link: " + link, commandline.DISALLOW_MULTILINE);
292292
}
293293

294294
if (link == "") {
295295
if (ssli == 1) {
296-
statusline.updateUrl();
297-
statusline.updateBookmark();
296+
statusline.updateField("location");
297+
statusline.updateField("bookmark");
298298
}
299299
else if (ssli == 2)
300300
modes.show();

common/content/events.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ const Events = Module("events", {
10611061
finally {
10621062
let motionMap = (this._input.pendingMotionMap && this._input.pendingMotionMap.names[0]) || "";
10631063
if (!(modes.extended & modes.HINTS))
1064-
statusline.updateInputBuffer(motionMap + this._input.buffer);
1064+
statusline.updateField("input", motionMap + this._input.buffer);
10651065
}
10661066
},
10671067

common/content/hints.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const Hints = Module("hints", {
8282
* Reset hints, so that they can be cleanly used again.
8383
*/
8484
_reset: function () {
85-
statusline.updateInputBuffer("");
85+
statusline.updateField("input", "");
8686
this._hintString = "";
8787
this._hintNumber = 0;
8888
this._usedTabKey = false;
@@ -103,7 +103,7 @@ const Hints = Module("hints", {
103103
* Display the current status to the user.
104104
*/
105105
_updateStatusline: function () {
106-
statusline.updateInputBuffer((hints.escNumbers ? mappings.getMapLeader() : "") + (this._hintNumber ? this._num2chars(this._hintNumber) : ""));
106+
statusline.updateField("input", (hints.escNumbers ? mappings.getMapLeader() : "") + (this._hintNumber ? this._num2chars(this._hintNumber) : ""));
107107
},
108108

109109
/**

common/content/liberator.xul

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,14 @@
8787
<toolbaritem id="liberator-message-toolbar" flex="1">
8888
<label class="plain" collapsed="false" id="liberator-message" flex="1" crop="end" liberator:highlight="Normal"/>
8989
</toolbaritem>
90-
<toolbaritem id="liberator-status-toolbar" flex="10000000" >
91-
<label flex="1" class="plain" id="liberator-status" crop="center" style="text-align: end;" liberator:highlight="StatusLine"/>
90+
<toolbaritem id="liberator-status" flex="10000000" liberator:highlight="StatusLine">
91+
<spacer liberatorPosition="-1" flex="10000000"/>
92+
<label id="liberator-status-input"/>
93+
<label id="liberator-status-location" flex="1" crop="center"/>
94+
<label id="liberator-status-history"/>
95+
<label id="liberator-status-bookmark"/>
96+
<label id="liberator-status-tabcount"/>
97+
<label id="liberator-status-position"/>
9298
</toolbaritem>
9399
</toolbar>
94100
<hbox id="liberator-commandline" class="liberator-container" liberator:highlight="CmdLine">

0 commit comments

Comments
 (0)