diff options
author | Jonas Westerlund <jonas.westerlund@me.com> | 2012-07-04 23:01:03 +0200 |
---|---|---|
committer | Nathan Rajlich <nathan@tootallnate.net> | 2012-07-06 19:28:35 -0700 |
commit | 0b0b72c2fab5bdf32f5476e47a1e7f2da9db2064 (patch) | |
tree | 6fb4d946e811f8d91b1337d8cd3d6c3ff54ec5c2 /lib/readline.js | |
parent | e5bb8391a84f62de2e7a818c142fbb2ad01ff9ba (diff) | |
download | android-node-v8-0b0b72c2fab5bdf32f5476e47a1e7f2da9db2064.tar.gz android-node-v8-0b0b72c2fab5bdf32f5476e47a1e7f2da9db2064.tar.bz2 android-node-v8-0b0b72c2fab5bdf32f5476e47a1e7f2da9db2064.zip |
Move function declaration to top-level
Gets rid of a strict mode error and a few levels of indentation.
Diffstat (limited to 'lib/readline.js')
-rw-r--r-- | lib/readline.js | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/lib/readline.js b/lib/readline.js index 1dc755fa26..3251ad2315 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -346,43 +346,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.call(self, group); group = []; } else { group.push(c); } } - handleGroup(group); + handleGroup.call(self, group); // If there is a common prefix to all matches, then apply that // portion. @@ -398,6 +372,32 @@ Interface.prototype._tabComplete = function() { }); }; +// this = Interface instance +function handleGroup(group) { + var self = this; + 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) { |