mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-11 07:04:32 +02:00
* Did add a tweak to the concept for height only: autoAdjustHeight can be used where it makes sense
* See also: #159
This commit is contained in:
parent
6d4b8abc9c
commit
611a52e946
4 changed files with 29 additions and 105 deletions
44
core/view.js
44
core/view.js
|
@ -37,21 +37,16 @@ function View(options) {
|
|||
enigAssert(_.isObject(options));
|
||||
enigAssert(_.isObject(options.client));
|
||||
|
||||
var self = this;
|
||||
this.client = options.client;
|
||||
this.cursor = options.cursor || 'show';
|
||||
this.cursorStyle = options.cursorStyle || 'default';
|
||||
|
||||
this.client = options.client;
|
||||
|
||||
this.cursor = options.cursor || 'show';
|
||||
this.cursorStyle = options.cursorStyle || 'default';
|
||||
|
||||
this.acceptsFocus = options.acceptsFocus || false;
|
||||
this.acceptsInput = options.acceptsInput || false;
|
||||
|
||||
this.position = { x : 0, y : 0 };
|
||||
this.dimens = { height : 1, width : 0 };
|
||||
|
||||
this.textStyle = options.textStyle || 'normal';
|
||||
this.focusTextStyle = options.focusTextStyle || this.textStyle;
|
||||
this.acceptsFocus = options.acceptsFocus || false;
|
||||
this.acceptsInput = options.acceptsInput || false;
|
||||
this.autoAdjustHeight = _.get(options, 'dimens.height') ? false : _.get(options, 'autoAdjustHeight', true);
|
||||
this.position = { x : 0, y : 0 };
|
||||
this.textStyle = options.textStyle || 'normal';
|
||||
this.focusTextStyle = options.focusTextStyle || this.textStyle;
|
||||
|
||||
if(options.id) {
|
||||
this.setId(options.id);
|
||||
|
@ -61,15 +56,8 @@ function View(options) {
|
|||
this.setPosition(options.position);
|
||||
}
|
||||
|
||||
if(_.isObject(options.autoScale)) {
|
||||
this.autoScale = options.autoScale;
|
||||
} else {
|
||||
this.autoScale = { height : true, width : true };
|
||||
}
|
||||
|
||||
if(options.dimens) {
|
||||
this.setDimension(options.dimens);
|
||||
this.autoScale = { height : false, width : false };
|
||||
} else {
|
||||
this.dimens = {
|
||||
width : options.width || 0,
|
||||
|
@ -105,7 +93,7 @@ function View(options) {
|
|||
};
|
||||
|
||||
this.hideCusor = function() {
|
||||
self.client.term.rawWrite(ansi.hideCursor());
|
||||
this.client.term.rawWrite(ansi.hideCursor());
|
||||
};
|
||||
|
||||
this.restoreCursor = function() {
|
||||
|
@ -148,25 +136,23 @@ View.prototype.setPosition = function(pos) {
|
|||
|
||||
View.prototype.setDimension = function(dimens) {
|
||||
enigAssert(_.isObject(dimens) && _.isNumber(dimens.height) && _.isNumber(dimens.width));
|
||||
|
||||
this.dimens = dimens;
|
||||
this.autoScale = { height : false, width : false };
|
||||
this.dimens = dimens;
|
||||
this.autoAdjustHeight = false;
|
||||
};
|
||||
|
||||
View.prototype.setHeight = function(height) {
|
||||
height = parseInt(height) || 1;
|
||||
height = Math.min(height, this.client.term.termHeight);
|
||||
|
||||
this.dimens.height = height;
|
||||
this.autoScale.height = false;
|
||||
this.dimens.height = height;
|
||||
this.autoAdjustHeight = false;
|
||||
};
|
||||
|
||||
View.prototype.setWidth = function(width) {
|
||||
width = parseInt(width) || 1;
|
||||
width = Math.min(width, this.client.term.termWidth);
|
||||
|
||||
this.dimens.width = width;
|
||||
this.autoScale.width = false;
|
||||
this.dimens.width = width;
|
||||
};
|
||||
|
||||
View.prototype.getSGR = function() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue