[Conkeror] [PATCH 2/2] mode-line: provide a widget to show count of buffers currently loading

David Kettler kettler at internode.on.net
Fri Feb 6 20:49:09 PST 2009


This provides a count like (2 loading) in the mode-line.  When no
buffers are being loaded, the widget is blank.  This is useful as a
notifier when a buffer is visiting a web page that loads slowly.

I enable this and the buffer count with:
add_hook("mode_line_hook", mode_line_adder(loading_count_widget), true);
add_hook("mode_line_hook", mode_line_adder(buffer_count_widget), true);
---
 modules/mode-line.js |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/modules/mode-line.js b/modules/mode-line.js
index f07a8fa..74a4b27 100644
--- a/modules/mode-line.js
+++ b/modules/mode-line.js
@@ -206,6 +206,24 @@ buffer_count_widget.prototype.update = function () {
                       this.window.buffers.count + "]");
 };
 
+function loading_count_widget(window) {
+    this.name = "loading-count-widget";
+    text_widget.call(this, window);
+    var obj = this;
+    this.add_hook("content_buffer_started_loading_hook");
+    this.add_hook("content_buffer_finished_loading_hook");
+    this.add_hook("kill_buffer_hook");
+}
+loading_count_widget.prototype.__proto__ = text_widget.prototype;
+loading_count_widget.prototype.update = function () {
+    var count = 0;
+    for_each_buffer(function(b) {if (b.loading) count++;});
+    if (count)
+        this.view.text = "(" + count + " loading)";
+    else
+        this.view.text = "";
+};
+
 function mode_line_adder(widget_constructor) {
     if (!('mode_line_adder' in widget_constructor))
         widget_constructor.mode_line_adder = function (window) {
-- 
1.5.6.5



More information about the Conkeror mailing list