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) => {
|
(next) => {
|
||||||
const confListView = this.viewControllers.confList.getView(MciViewIds.confList);
|
const confListView = this.viewControllers.confList.getView(MciViewIds.confList);
|
||||||
if(!confListView) {
|
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 => {
|
confListView.on('index update', idx => {
|
||||||
|
|
|
@ -241,6 +241,10 @@ exports.getModule = class SSHServerModule extends LoginServerModule {
|
||||||
|
|
||||||
createServer() {
|
createServer() {
|
||||||
const config = Config();
|
const config = Config();
|
||||||
|
if(true != config.loginServers.ssh.enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const serverConf = {
|
const serverConf = {
|
||||||
hostKeys : [
|
hostKeys : [
|
||||||
{
|
{
|
||||||
|
@ -269,6 +273,10 @@ exports.getModule = class SSHServerModule extends LoginServerModule {
|
||||||
|
|
||||||
listen() {
|
listen() {
|
||||||
const config = Config();
|
const config = Config();
|
||||||
|
if(true != config.loginServers.ssh.enabled) {
|
||||||
|
return true; // no server, but not an error
|
||||||
|
}
|
||||||
|
|
||||||
const port = parseInt(config.loginServers.ssh.port);
|
const port = parseInt(config.loginServers.ssh.port);
|
||||||
if(isNaN(port)) {
|
if(isNaN(port)) {
|
||||||
Log.error( { server : ModuleInfo.name, port : config.loginServers.ssh.port }, 'Cannot load server (invalid 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 MenuView = require('./menu_view.js').MenuView;
|
||||||
const ansi = require('./ansi_term.js');
|
const ansi = require('./ansi_term.js');
|
||||||
const strUtil = require('./string_util.js');
|
const strUtil = require('./string_util.js');
|
||||||
|
const { pipeToAnsi } = require('./color_codes.js');
|
||||||
|
const formatString = require('./string_format');
|
||||||
|
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
@ -36,40 +38,47 @@ function SpinnerMenuView(options) {
|
||||||
this.emit('index update', this.focusedItemIndex);
|
this.emit('index update', this.focusedItemIndex);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.drawItem = function() {
|
this.drawItem = function(index) {
|
||||||
var item = self.items[this.focusedItemIndex];
|
const item = this.items[index];
|
||||||
if(!item) {
|
if(!item) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.client.term.write(ansi.goto(this.position.row, this.position.col));
|
const cached = this.getRenderCacheItem(index, this.hasFocus);
|
||||||
this.client.term.write(self.hasFocus ? self.getFocusSGR() : self.getSGR());
|
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(
|
text = `${sgr}${strUtil.pad(text, this.dimens.width, this.fillChar, this.justify)}`;
|
||||||
strUtil.pad(text, this.dimens.width + 1, 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);
|
util.inherits(SpinnerMenuView, MenuView);
|
||||||
|
|
||||||
SpinnerMenuView.prototype.redraw = function() {
|
SpinnerMenuView.prototype.redraw = function() {
|
||||||
SpinnerMenuView.super_.prototype.redraw.call(this);
|
SpinnerMenuView.super_.prototype.redraw.call(this);
|
||||||
|
|
||||||
//this.cachePositions();
|
|
||||||
this.drawItem(this.focusedItemIndex);
|
this.drawItem(this.focusedItemIndex);
|
||||||
};
|
};
|
||||||
|
|
||||||
SpinnerMenuView.prototype.setFocus = function(focused) {
|
SpinnerMenuView.prototype.setFocus = function(focused) {
|
||||||
SpinnerMenuView.super_.prototype.setFocus.call(this, focused);
|
SpinnerMenuView.super_.prototype.setFocus.call(this, focused);
|
||||||
|
|
||||||
this.redraw();
|
this.redraw();
|
||||||
};
|
};
|
||||||
|
|
||||||
SpinnerMenuView.prototype.setFocusItemIndex = function(index) {
|
SpinnerMenuView.prototype.setFocusItemIndex = function(index) {
|
||||||
SpinnerMenuView.super_.prototype.setFocusItemIndex.call(this, index); // sets this.focusedItemIndex
|
SpinnerMenuView.super_.prototype.setFocusItemIndex.call(this, index); // sets this.focusedItemIndex
|
||||||
|
|
||||||
this.updateSelection(); // will redraw
|
this.updateSelection(); // will redraw
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -103,16 +112,3 @@ SpinnerMenuView.prototype.getData = function() {
|
||||||
const item = this.getItem(this.focusedItemIndex);
|
const item = this.getItem(this.focusedItemIndex);
|
||||||
return _.isString(item.data) ? item.data : 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