Merge branch '0.0.9-alpha' of ssh://numinibsd/git/base/enigma-bbs into user-interruptions
This commit is contained in:
commit
23c30533c7
|
@ -73,7 +73,7 @@ exports.getModule = class MessageConfListModule extends MenuModule {
|
|||
(next) => {
|
||||
const confListView = this.viewControllers.confList.getView(MciViewIds.confList);
|
||||
if(!confListView) {
|
||||
return cb(Errors.MissingMci(`Missing conf list MCI ${MciViewIds.confList}`));
|
||||
return next(Errors.MissingMci(`Missing conf list MCI ${MciViewIds.confList}`));
|
||||
}
|
||||
|
||||
confListView.on('index update', idx => {
|
||||
|
|
|
@ -241,6 +241,10 @@ exports.getModule = class SSHServerModule extends LoginServerModule {
|
|||
|
||||
createServer() {
|
||||
const config = Config();
|
||||
if(true != config.loginServers.ssh.enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const serverConf = {
|
||||
hostKeys : [
|
||||
{
|
||||
|
@ -269,6 +273,10 @@ exports.getModule = class SSHServerModule extends LoginServerModule {
|
|||
|
||||
listen() {
|
||||
const config = Config();
|
||||
if(true != config.loginServers.ssh.enabled) {
|
||||
return true; // no server, but not an error
|
||||
}
|
||||
|
||||
const port = parseInt(config.loginServers.ssh.port);
|
||||
if(isNaN(port)) {
|
||||
Log.error( { server : ModuleInfo.name, port : config.loginServers.ssh.port }, 'Cannot load server (invalid port)' );
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
const MenuView = require('./menu_view.js').MenuView;
|
||||
const ansi = require('./ansi_term.js');
|
||||
const strUtil = require('./string_util.js');
|
||||
const { pipeToAnsi } = require('./color_codes.js');
|
||||
const formatString = require('./string_format');
|
||||
|
||||
const util = require('util');
|
||||
const assert = require('assert');
|
||||
|
@ -36,40 +38,47 @@ function SpinnerMenuView(options) {
|
|||
this.emit('index update', this.focusedItemIndex);
|
||||
};
|
||||
|
||||
this.drawItem = function() {
|
||||
var item = self.items[this.focusedItemIndex];
|
||||
this.drawItem = function(index) {
|
||||
const item = this.items[index];
|
||||
if(!item) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.client.term.write(ansi.goto(this.position.row, this.position.col));
|
||||
this.client.term.write(self.hasFocus ? self.getFocusSGR() : self.getSGR());
|
||||
const cached = this.getRenderCacheItem(index, this.hasFocus);
|
||||
if(cached) {
|
||||
return this.client.term.write(`${ansi.goto(this.position.row, this.position.col)}${cached}`);
|
||||
}
|
||||
|
||||
var text = strUtil.stylizeString(item.text, item.focused ? self.focusTextStyle : self.textStyle);
|
||||
let text;
|
||||
let sgr;
|
||||
if(this.complexItems) {
|
||||
text = pipeToAnsi(formatString(this.hasFocus && this.focusItemFormat ? this.focusItemFormat : this.itemFormat, item));
|
||||
sgr = this.focusItemFormat ? '' : (this.hasFocus ? this.getFocusSGR() : self.getSGR());
|
||||
} else {
|
||||
text = strUtil.stylizeString(item.text, this.hasFocus ? self.focusTextStyle : self.textStyle);
|
||||
sgr = this.hasFocus ? this.getFocusSGR() : this.getSGR();
|
||||
}
|
||||
|
||||
self.client.term.write(
|
||||
strUtil.pad(text, this.dimens.width + 1, this.fillChar, this.justify));
|
||||
};
|
||||
text = `${sgr}${strUtil.pad(text, this.dimens.width, this.fillChar, this.justify)}`;
|
||||
this.client.term.write(`${ansi.goto(this.position.row, this.position.col)}${text}`);
|
||||
this.setRenderCacheItem(index, text, this.hasFocus);
|
||||
}
|
||||
}
|
||||
|
||||
util.inherits(SpinnerMenuView, MenuView);
|
||||
|
||||
SpinnerMenuView.prototype.redraw = function() {
|
||||
SpinnerMenuView.super_.prototype.redraw.call(this);
|
||||
|
||||
//this.cachePositions();
|
||||
this.drawItem(this.focusedItemIndex);
|
||||
};
|
||||
|
||||
SpinnerMenuView.prototype.setFocus = function(focused) {
|
||||
SpinnerMenuView.super_.prototype.setFocus.call(this, focused);
|
||||
|
||||
this.redraw();
|
||||
};
|
||||
|
||||
SpinnerMenuView.prototype.setFocusItemIndex = function(index) {
|
||||
SpinnerMenuView.super_.prototype.setFocusItemIndex.call(this, index); // sets this.focusedItemIndex
|
||||
|
||||
this.updateSelection(); // will redraw
|
||||
};
|
||||
|
||||
|
@ -103,16 +112,3 @@ SpinnerMenuView.prototype.getData = function() {
|
|||
const item = this.getItem(this.focusedItemIndex);
|
||||
return _.isString(item.data) ? item.data : this.focusedItemIndex;
|
||||
};
|
||||
|
||||
SpinnerMenuView.prototype.setItems = function(items) {
|
||||
SpinnerMenuView.super_.prototype.setItems.call(this, items);
|
||||
|
||||
var longest = 0;
|
||||
for(var i = 0; i < this.items.length; ++i) {
|
||||
if(longest < this.items[i].text.length) {
|
||||
longest = this.items[i].text.length;
|
||||
}
|
||||
}
|
||||
|
||||
this.dimens.width = longest;
|
||||
};
|
Loading…
Reference in New Issue