Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

typo virt to vert

  • Loading branch information...
commit 16f012fd1097d38f5d13218d2d0829b257c9b885 1 parent 3441edf
@crcn authored
View
30 examples/table2.js
@@ -0,0 +1,30 @@
+var celery = require('../lib');
+
+var objects = [ { name: 'bean.cupboard.scaffold',
+ hasUpdates: ' ',
+ published: 'published: 2 hours ago' },
+ { name: 'teamdigest',
+ hasUpdates: ' ',
+ published: 'published: 2 hours ago' }];
+
+
+celery.drawTable(objects, {
+ columns: [{
+ width: 33,
+ name: 'name'
+ },
+ {
+ name: 'hasUpdates',
+ width: 33,
+ },
+ {
+ name: 'published',
+ width:33
+ }],
+
+ horz: '-',
+ vert: '|'
+
+});
+
+celery.open();
View
51 lib/modules/table.js
@@ -19,29 +19,28 @@ exports.plugin = function(cli)
windowWidth = ops.windowWidth,
columnIndex = ops.columnIndex,
columns = ops.columns,
- virt;
+ vert;
+
//last element? fill in the rest
if(columnIndex == columns.length-1)
{
columnWidth = windowWidth - currentWidth;
- virt = '';
+ vert = '';
}
else
{
- virt = ops.virt;
+ vert = ops.vert;
}
- var maxWidth = columnWidth-virt.length;
-
-
+ var maxWidth = columnWidth - vert.length;
buffer.split('\n').forEach(function(line, index)
{
//padding of whitespace
var lineLength = line.length,
- padding = Math.max(maxWidth - lineLength, 0);
+ padding = Math.max(columnWidth - lineLength, 0);
if(lineLength > maxWidth)
@@ -62,7 +61,7 @@ exports.plugin = function(cli)
newLines.push(line.substr(start, maxWidth));
start = i;
}
-
+
return addLines({
buffer: newLines.join('\n'),
@@ -70,7 +69,7 @@ exports.plugin = function(cli)
currentWidth: currentWidth,
align: ops.align,
windowWidth: windowWidth,
- virt: virt,
+ vert: vert,
lines: lines,
columnIndex: columnIndex,
columns: columns
@@ -97,6 +96,7 @@ exports.plugin = function(cli)
break;
}
+
if(!lines[index])
{
@@ -104,16 +104,17 @@ exports.plugin = function(cli)
for(var i = 0, n = columnIndex; i < n; i++)
{
- buffer += cli.utils.padLeft(virt, columns[i].width-virt.length, ' ');
+ buffer += cli.utils.padLeft(vert, columns[i].width-vert.length, ' ');
}
lines[index] = buffer;
}
+
- lines[index] += colStr + virt;
+ lines[index] += colStr + vert;
});
}
@@ -124,7 +125,7 @@ exports.plugin = function(cli)
var windowWidth = ops.width || cli.columns(),
columns = ops.columns,
colArray = [],
- virt = ops.virtical || ops.virt || ' ',
+ vert = ops.vertical || ops.vert || ' ',
horz = ops.horizontal || ops.horz || '',
ellipsis = ops.ellipsis;
@@ -134,9 +135,10 @@ exports.plugin = function(cli)
if(ops.border)
{
- if(virt == ' ') virt = ' | ';
+ if(vert == ' ') vert = ' | ';
if(horz == '') horz = '';
}
+
var tableWidth = 0,
@@ -208,13 +210,25 @@ exports.plugin = function(cli)
};
}
- if(!columnInfo.width) columnInfo.width = Math.round(100/n);
+ if(!columnInfo.width) columnInfo.width = Math.round(100/n) + '%';
columnName = columnInfo.name;
-
- columnWidth = Math.min(columnInfo.width, Math.round((columnInfo.width/tableWidth) * windowWidth));
+ //percent
+ if(true || typeof columnInfo.width == 'string')
+ {
+
+ //var cw = columnInfo.width.substr(0, columnInfo.width.length-1);
+
+ columnWidth = Math.min(columnInfo.width, Math.round((columnInfo.width/tableWidth) * windowWidth));
+
+ }
+ else
+ {
+ columnWidth = columnInfo.width;
+ }
+
//the string element. could be from a method, prop, or it's undefined
var str = (columnInfo.get ? columnInfo.get(object) : object[columnName] || 'Undefined').toString();
@@ -227,7 +241,7 @@ exports.plugin = function(cli)
currentWidth: currentWidth,
align: columnInfo.align,
windowWidth: windowWidth,
- virt: virt,
+ vert: vert,
ellipsis: ellipsis,
columnIndex: i,
columns: colArray
@@ -238,11 +252,10 @@ exports.plugin = function(cli)
}
- if(horz.length) console.log(cli.utils.repeat(horz,windowWidth));
+ if(horz.length) console.log(cli.utils.repeat(horz, windowWidth));
lines.forEach(function(line)
{
-
console.log(line);
});
});
View
1  lib/utils.js
@@ -21,6 +21,7 @@ exports.fill = function(leftChar, ln, rightChar, rn)
return exports.repeat(leftChar, ln) + exports.repeat(rightChar, rn);
}
+
exports.repeat = function(char, n)
{
var buffer = '';
View
29 project.tmproj
@@ -2,15 +2,17 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
+ <key>currentDocument</key>
+ <string>lib/utils.js</string>
<key>documents</key>
<array>
<dict>
+ <key>expanded</key>
+ <true/>
<key>name</key>
<string>project</string>
<key>regexFolderFilter</key>
<string>!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
- <key>selected</key>
- <true/>
<key>sourceDirectory</key>
<string></string>
</dict>
@@ -18,8 +20,29 @@
<key>fileHierarchyDrawerWidth</key>
<integer>200</integer>
<key>metaData</key>
- <dict/>
+ <dict>
+ <key>lib/utils.js</key>
+ <dict>
+ <key>caret</key>
+ <dict>
+ <key>column</key>
+ <integer>0</integer>
+ <key>line</key>
+ <integer>22</integer>
+ </dict>
+ <key>firstVisibleColumn</key>
+ <integer>0</integer>
+ <key>firstVisibleLine</key>
+ <integer>0</integer>
+ </dict>
+ </dict>
+ <key>openDocuments</key>
+ <array>
+ <string>lib/utils.js</string>
+ </array>
<key>showFileHierarchyDrawer</key>
<true/>
+ <key>windowFrame</key>
+ <string>{{0, 4}, {1230, 874}}</string>
</dict>
</plist>
Please sign in to comment.
Something went wrong with that request. Please try again.