forked from yaronn/blessed-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
2,402 additions
and
923 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"env": { | ||
"es6": true, | ||
"node": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"parserOptions": { | ||
"ecmaVersion": 2015 | ||
}, | ||
"rules": { | ||
"brace-style": "error", | ||
"no-irregular-whitespace":"error", | ||
"no-octal-escape": "error", | ||
"no-octal": "error", | ||
"no-proto":"error", | ||
"strict":["error", "global"], | ||
"no-undef":"error", | ||
"no-use-before-define": "off", | ||
"indent": ["error", 2] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,40 @@ | ||
"use strict"; | ||
var utils = require('../utils') | ||
|
||
var widgetSpacing = 0 | ||
|
||
function Grid(options) { | ||
if (!options.screen) throw "Error: A screen property must be specified in the grid options.\r\n" + | ||
if (!options.screen) throw "Error: A screen property must be specified in the grid options.\r\n" + | ||
"Note: Release 2.0.0 has breaking changes. Please refer to the README or to https://github.com/yaronn/blessed-contrib/issues/39" | ||
this.options = options | ||
this.options.dashboardMargin = this.options.dashboardMargin || 0 | ||
this.cellWidth = ((100 - this.options.dashboardMargin*2) / this.options.cols) | ||
this.cellHeight = ((100 - this.options.dashboardMargin*2) / this.options.rows) | ||
this.options = options | ||
this.options.dashboardMargin = this.options.dashboardMargin || 0 | ||
this.cellWidth = ((100 - this.options.dashboardMargin*2) / this.options.cols) | ||
this.cellHeight = ((100 - this.options.dashboardMargin*2) / this.options.rows) | ||
} | ||
|
||
Grid.prototype.set = function(row, col, rowSpan, colSpan, obj, opts) { | ||
|
||
if (obj instanceof Grid) { | ||
throw "Error: A Grid is not allowed to be nested inside another grid.\r\n" + | ||
if (obj instanceof Grid) { | ||
throw "Error: A Grid is not allowed to be nested inside another grid.\r\n" + | ||
"Note: Release 2.0.0 has breaking changes. Please refer to the README or to https://github.com/yaronn/blessed-contrib/issues/39" | ||
} | ||
|
||
var top = row * this.cellHeight + this.options.dashboardMargin | ||
var left = col * this.cellWidth + this.options.dashboardMargin | ||
|
||
//var options = JSON.parse(JSON.stringify(opts)); | ||
var options = {} | ||
options = utils.MergeRecursive(options, opts) | ||
options.top = top + '%' | ||
options.left = left + '%' | ||
options.width = (this.cellWidth * colSpan - widgetSpacing) + "%" | ||
options.height = (this.cellHeight * rowSpan - widgetSpacing) + "%" | ||
if (!this.options.hideBorder) | ||
options.border = {type: "line", fg: this.options.color || "cyan"} | ||
var instance = obj(options) | ||
this.options.screen.append(instance) | ||
return instance | ||
} | ||
|
||
var top = row * this.cellHeight + this.options.dashboardMargin | ||
var left = col * this.cellWidth + this.options.dashboardMargin | ||
|
||
//var options = JSON.parse(JSON.stringify(opts)); | ||
var options = {} | ||
options = utils.MergeRecursive(options, opts) | ||
options.top = top + '%' | ||
options.left = left + '%' | ||
options.width = (this.cellWidth * colSpan - widgetSpacing) + "%" | ||
options.height = (this.cellHeight * rowSpan - widgetSpacing) + "%" | ||
if (!this.options.hideBorder) | ||
options.border = {type: "line", fg: this.options.color || "cyan"} | ||
|
||
var instance = obj(options) | ||
this.options.screen.append(instance) | ||
return instance | ||
} | ||
|
||
module.exports = Grid | ||
module.exports = Grid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.