Add SIGWINCH handler for readline
authorRyan Dahl <ry@tinyclouds.org>
Mon, 13 Sep 2010 04:23:53 +0000 (21:23 -0700)
committerRyan Dahl <ry@tinyclouds.org>
Mon, 13 Sep 2010 04:23:53 +0000 (21:23 -0700)
lib/readline.js

index 3ba30f3..6a4652c 100644 (file)
@@ -46,15 +46,21 @@ function Interface (output, completer) {
 
     this.history = [];
     this.historyIndex = -1;
+
+    exports.columns = process.binding('stdio').getColumns();
+
+    if (process.listeners("SIGWINCH").length === 0) {
+      process.on("SIGWINCH", function () {
+        exports.columns = process.binding('stdio').getColumns();
+      });
+    }
   }
 }
 
 inherits(Interface, EventEmitter);
 
 Interface.prototype.__defineGetter__("columns", function () {
-  if (this.enabled) {
-    return stdio.getColumns();
-  }
+  return exports.columns;
 });
 
 Interface.prototype.setPrompt = function (prompt, length) {