* Just some notes

This commit is contained in:
Bryan Ashby 2015-05-04 22:04:36 -06:00
parent 6dfda0e6d4
commit a01f5d2f24
3 changed files with 27 additions and 3 deletions

View File

@ -8,6 +8,7 @@ var miscUtil = require('./misc_util.js');
var util = require('util'); var util = require('util');
var assert = require('assert'); var assert = require('assert');
var _ = require('lodash');
exports.VerticalMenuView = VerticalMenuView; exports.VerticalMenuView = VerticalMenuView;
@ -18,6 +19,29 @@ function VerticalMenuView(options) {
var self = this; var self = this;
//
// :TODO: view.setDimens() would set autoSize to false. Otherwise, we cna scale @ setItems()
// topViewIndex = top visibile item
// itemsInView = height * (1 + itemSpacing)
this.calculateDimens2 = function() {
if(this.autoSize) {
self.dimens = self.dimens || {};
if(!_.isNumber(this.dimens.height) || this.dimens.height < 1) {
this.dimens.height = 1;
}
var l = 0;
self.items.forEach(function item(i) {
if(i.text.length > l) {
l = Math.min(l.text.length, self.client.term.termWidth - self.position.y);
}
});
self.dimens.width = l;
}
};
this.calculateDimens = function() { this.calculateDimens = function() {
if(!self.dimens || !self.dimens.width) { if(!self.dimens || !self.dimens.width) {
var l = 0; var l = 0;

View File

@ -68,8 +68,8 @@ function View(options) {
options.dimens = { width : 1, height : 1 }; options.dimens = { width : 1, height : 1 };
} }
options.dimens.width = options.dimens.width || 1; //options.dimens.width = options.dimens.width || 1;
options.dimens.height = options.dimens.height || 1; //options.dimens.height = options.dimens.height || 1;
this.ansiSGR = options.ansiSGR || ansi.getSGRFromGraphicRendition( { fg : 39, bg : 49 }, true); this.ansiSGR = options.ansiSGR || ansi.getSGRFromGraphicRendition( { fg : 39, bg : 49 }, true);
this.ansiFocusSGR = options.ansiFocusSGR || this.ansiSGR; this.ansiFocusSGR = options.ansiFocusSGR || this.ansiSGR;