terminal-table
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -18,3 +18,4 @@ var Table = require("../"); | ||
align: "center", | ||
color: "blue" | ||
color: "blue", | ||
bg: "black" | ||
}); | ||
@@ -21,0 +22,0 @@ |
@@ -79,2 +79,3 @@ var eaw = require("eastasianwidth"); | ||
var color = this.getAttr(row, column, "color"); | ||
var bg = this.getAttr(row, column, "bg"); | ||
if(color){ | ||
@@ -92,3 +93,7 @@ str = colors[color](str); | ||
return this.pad(str, size, align === "right" ? 2 : align === "center" ? 1 : 0); | ||
str = this.pad(str, size, align === "right" ? 2 : align === "center" ? 1 : 0); | ||
if(bg){ | ||
str = colors[bg + "BG"](str); | ||
} | ||
return str; | ||
}; | ||
@@ -95,0 +100,0 @@ |
@@ -15,6 +15,9 @@ terminal-table | ||
## インストール | ||
```bash | ||
$ npm i terminal-table | ||
``` | ||
## 使い方 | ||
``` js | ||
var Table = require("<module-name>"); | ||
var Table = require("terminal-table"); | ||
var t = new Table(); | ||
@@ -51,7 +54,7 @@ | ||
- width - Array | ||
``` js | ||
new Table({ | ||
width: [10, "50%", "50%"] | ||
}); | ||
``` | ||
``` js | ||
new Table({ | ||
width: [10, "50%", "50%"] | ||
}); | ||
``` | ||
- leftPadding, rightPadding | ||
@@ -58,0 +61,0 @@ |
{ | ||
"name": "terminal-table", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "View a table in the terminal.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,6 +17,9 @@ terminal-table | ||
## Installation | ||
```bash | ||
$ npm i terminal-table | ||
``` | ||
## Usage | ||
``` js | ||
var Table = require("<module-name>"); | ||
var Table = require("terminal-table"); | ||
var t = new Table(); | ||
@@ -36,5 +39,8 @@ | ||
- borderStyle | ||
- 1: ascii | ||
- 2: unicode | ||
- 3: unicode bold | ||
- 1: ascii | ||
![screenshot](https://raw.githubusercontent.com/zaftzaft/terminal-table/master/img/border-style-1.png) | ||
- 2: unicode | ||
![screenshot](https://raw.githubusercontent.com/zaftzaft/terminal-table/master/img/border-style-2.png) | ||
- 3: unicode bold | ||
![screenshot](https://raw.githubusercontent.com/zaftzaft/terminal-table/master/img/border-style-3.png) | ||
- 0: user custom | ||
@@ -54,7 +60,7 @@ ``` js | ||
- width - Array | ||
``` js | ||
new Table({ | ||
width: [10, "50%", "50%"] | ||
}); | ||
``` | ||
``` js | ||
new Table({ | ||
width: [10, "50%", "50%"] | ||
}); | ||
``` | ||
- leftPadding, rightPadding | ||
@@ -68,5 +74,12 @@ | ||
- attr(row, column, { attrs }) | ||
- __attrs__ | ||
- align: `left`, `center`, `right` | ||
- color: from colors.js, e.g. `blue`, `red`... | ||
- bg: `blue`, `black`... | ||
- attrRange({ range }, { attrs }) | ||
- __range__ | ||
- row: [start, end] | ||
- column: [start, end] | ||
- removeCell(row, column) | ||
- removeRow(row) | ||
- removeColumn(column) |
49207
12
323
82