* Minor updates to HorizontalMenuView (WIP)
This commit is contained in:
parent
d346fe72ee
commit
1606437c27
|
@ -6,12 +6,17 @@ var ansi = require('./ansi_term.js');
|
||||||
var strUtil = require('./string_util.js');
|
var strUtil = require('./string_util.js');
|
||||||
|
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
|
var _ = require('lodash');
|
||||||
|
|
||||||
exports.HorizontalMenuView = HorizontalMenuView;
|
exports.HorizontalMenuView = HorizontalMenuView;
|
||||||
|
|
||||||
function HorizontalMenuView(options) {
|
function HorizontalMenuView(options) {
|
||||||
options.cursor = options.cursor || 'hide';
|
options.cursor = options.cursor || 'hide';
|
||||||
|
|
||||||
|
if(!_.isNumber(options.itemSpacing)) {
|
||||||
|
options.itemSpacing = 1;
|
||||||
|
}
|
||||||
|
|
||||||
MenuView.call(this, options);
|
MenuView.call(this, options);
|
||||||
|
|
||||||
this.dimens.height = 1; // always the case
|
this.dimens.height = 1; // always the case
|
||||||
|
@ -19,7 +24,7 @@ function HorizontalMenuView(options) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.getSpacer = function() {
|
this.getSpacer = function() {
|
||||||
return new Array(self.itemSpacing).join(' ');
|
return new Array(self.itemSpacing + 1).join(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.performAutoScale = function() {
|
this.performAutoScale = function() {
|
||||||
|
@ -56,14 +61,20 @@ function HorizontalMenuView(options) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.client.term.write(ansi.goto(item.row, self.itemColumns[index]));
|
//self.client.term.write(ansi.goto(item.row, self.itemColumns[index]));
|
||||||
self.client.term.write(index === self.focusedItemIndex ? self.getFocusSGR() : self.getSGR());
|
self.client.term.write(index === self.focusedItemIndex ? self.getFocusSGR() : self.getSGR());
|
||||||
|
|
||||||
var text = strUtil.stylizeString(item.text, item.focused ? self.focusTextStyle : self.textStyle);
|
var text = strUtil.stylizeString(item.text, item.focused ? self.focusTextStyle : self.textStyle);
|
||||||
|
|
||||||
var extraPad = self.getSpacer().length * 2;
|
var extraPad = self.getSpacer().length * 2;
|
||||||
|
var spacer = self.getSpacer();
|
||||||
|
|
||||||
self.client.term.write(
|
self.client.term.write(
|
||||||
strUtil.pad(text, text.length + extraPad, this.fillChar, 'center'));
|
ansi.goto(self.position.row, self.itemColumns[index]) +
|
||||||
|
(index === self.focusedItemIndex ? self.getFocusSGR() : self.getSGR()) +
|
||||||
|
strUtil.pad(text, text.length + extraPad, self.fillChar, 'center')
|
||||||
|
//spacer + text + spacer
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -409,7 +409,7 @@
|
||||||
"BT5HM1" : {
|
"BT5HM1" : {
|
||||||
"mci" : {
|
"mci" : {
|
||||||
"HM1" : {
|
"HM1" : {
|
||||||
"items" : [ "A Clockwork Orange", "Pulp Fiction", "Goonies" ]
|
"items" : [ "One", "Two", "Three" ]
|
||||||
},
|
},
|
||||||
"BT5" : {
|
"BT5" : {
|
||||||
"text" : "< Back",
|
"text" : "< Back",
|
||||||
|
|
Loading…
Reference in New Issue