diff options
author | isaacs <i@izs.me> | 2012-07-11 17:38:11 -0700 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-07-11 17:38:11 -0700 |
commit | 424cd5a02033b5f9bf027431614ca5f9183fa3b1 (patch) | |
tree | 369e5a49981a10f13b18b07a518f5e97a05460c3 /lib/readline.js | |
parent | 76104f3414f10bd5df1aa8cdc69cff9f73e64b9d (diff) | |
parent | 1d99441d3742045bdb7b8e8a8d013f81cdba8f40 (diff) | |
download | nodejs-424cd5a02033b5f9bf027431614ca5f9183fa3b1.tar.gz nodejs-424cd5a02033b5f9bf027431614ca5f9183fa3b1.tar.bz2 nodejs-424cd5a02033b5f9bf027431614ca5f9183fa3b1.zip |
Merge remote-tracking branch 'ry/v0.8' into v0.8-merge
Conflicts:
src/node_version.h
Diffstat (limited to 'lib/readline.js')
-rw-r--r-- | lib/readline.js | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/lib/readline.js b/lib/readline.js index 0161b4e29..c95bd4085 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -136,7 +136,7 @@ Interface.prototype.setPrompt = function(prompt, length) { } else { var lines = prompt.split(/[\r\n]/); var lastLine = lines[lines.length - 1]; - this._promptLength = Buffer.byteLength(lastLine); + this._promptLength = lastLine.length; } }; @@ -348,43 +348,17 @@ Interface.prototype._tabComplete = function() { return a.length > b.length ? a : b; }).length + 2; // 2 space padding var maxColumns = Math.floor(self.columns / width) || 1; - - function handleGroup(group) { - if (group.length == 0) { - return; - } - var minRows = Math.ceil(group.length / maxColumns); - for (var row = 0; row < minRows; row++) { - for (var col = 0; col < maxColumns; col++) { - var idx = row * maxColumns + col; - if (idx >= group.length) { - break; - } - var item = group[idx]; - self.output.write(item); - if (col < maxColumns - 1) { - for (var s = 0, itemLen = item.length; s < width - itemLen; - s++) { - self.output.write(' '); - } - } - } - self.output.write('\r\n'); - } - self.output.write('\r\n'); - } - var group = [], c; for (var i = 0, compLen = completions.length; i < compLen; i++) { c = completions[i]; if (c === '') { - handleGroup(group); + handleGroup(self, group, width, maxColumns); group = []; } else { group.push(c); } } - handleGroup(group); + handleGroup(self, group, width, maxColumns); // If there is a common prefix to all matches, then apply that // portion. @@ -400,6 +374,31 @@ Interface.prototype._tabComplete = function() { }); }; +// this = Interface instance +function handleGroup(self, group, width, maxColumns) { + if (group.length == 0) { + return; + } + var minRows = Math.ceil(group.length / maxColumns); + for (var row = 0; row < minRows; row++) { + for (var col = 0; col < maxColumns; col++) { + var idx = row * maxColumns + col; + if (idx >= group.length) { + break; + } + var item = group[idx]; + self.output.write(item); + if (col < maxColumns - 1) { + for (var s = 0, itemLen = item.length; s < width - itemLen; + s++) { + self.output.write(' '); + } + } + } + self.output.write('\r\n'); + } + self.output.write('\r\n'); +} function commonPrefix(strings) { if (!strings || strings.length == 0) { |