mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-07-30 22:46:17 +02:00
ENiGMA 1/2 WILL USE SPACES FROM THIS POINT ON VS TABS
* Really just to make GitHub formatting happy. Arg.
This commit is contained in:
parent
5ddf04c882
commit
e9787cee3e
135 changed files with 27397 additions and 27397 deletions
|
@ -9,69 +9,69 @@ const stylizeString = require('./string_util.js').stylizeString;
|
|||
const _ = require('lodash');
|
||||
|
||||
module.exports = class KeyEntryView extends View {
|
||||
constructor(options) {
|
||||
options.acceptsFocus = valueWithDefault(options.acceptsFocus, true);
|
||||
options.acceptsInput = valueWithDefault(options.acceptsInput, true);
|
||||
constructor(options) {
|
||||
options.acceptsFocus = valueWithDefault(options.acceptsFocus, true);
|
||||
options.acceptsInput = valueWithDefault(options.acceptsInput, true);
|
||||
|
||||
super(options);
|
||||
super(options);
|
||||
|
||||
this.eatTabKey = options.eatTabKey || true;
|
||||
this.caseInsensitive = options.caseInsensitive || true;
|
||||
this.eatTabKey = options.eatTabKey || true;
|
||||
this.caseInsensitive = options.caseInsensitive || true;
|
||||
|
||||
if(Array.isArray(options.keys)) {
|
||||
if(this.caseInsensitive) {
|
||||
this.keys = options.keys.map( k => k.toUpperCase() );
|
||||
} else {
|
||||
this.keys = options.keys;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(Array.isArray(options.keys)) {
|
||||
if(this.caseInsensitive) {
|
||||
this.keys = options.keys.map( k => k.toUpperCase() );
|
||||
} else {
|
||||
this.keys = options.keys;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onKeyPress(ch, key) {
|
||||
const drawKey = ch;
|
||||
onKeyPress(ch, key) {
|
||||
const drawKey = ch;
|
||||
|
||||
if(ch && this.caseInsensitive) {
|
||||
ch = ch.toUpperCase();
|
||||
}
|
||||
if(ch && this.caseInsensitive) {
|
||||
ch = ch.toUpperCase();
|
||||
}
|
||||
|
||||
if(drawKey && isPrintable(drawKey) && (!this.keys || this.keys.indexOf(ch) > -1)) {
|
||||
this.redraw(); // sets position
|
||||
this.client.term.write(stylizeString(ch, this.textStyle));
|
||||
}
|
||||
if(drawKey && isPrintable(drawKey) && (!this.keys || this.keys.indexOf(ch) > -1)) {
|
||||
this.redraw(); // sets position
|
||||
this.client.term.write(stylizeString(ch, this.textStyle));
|
||||
}
|
||||
|
||||
this.keyEntered = ch || key.name;
|
||||
this.keyEntered = ch || key.name;
|
||||
|
||||
if(key && 'tab' === key.name && !this.eatTabKey) {
|
||||
return this.emit('action', 'next', key);
|
||||
}
|
||||
if(key && 'tab' === key.name && !this.eatTabKey) {
|
||||
return this.emit('action', 'next', key);
|
||||
}
|
||||
|
||||
this.emit('action', 'accept');
|
||||
// NOTE: we don't call super here. KeyEntryView is a special snowflake.
|
||||
}
|
||||
this.emit('action', 'accept');
|
||||
// NOTE: we don't call super here. KeyEntryView is a special snowflake.
|
||||
}
|
||||
|
||||
setPropertyValue(propName, propValue) {
|
||||
switch(propName) {
|
||||
case 'eatTabKey' :
|
||||
if(_.isBoolean(propValue)) {
|
||||
this.eatTabKey = propValue;
|
||||
}
|
||||
break;
|
||||
setPropertyValue(propName, propValue) {
|
||||
switch(propName) {
|
||||
case 'eatTabKey' :
|
||||
if(_.isBoolean(propValue)) {
|
||||
this.eatTabKey = propValue;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'caseInsensitive' :
|
||||
if(_.isBoolean(propValue)) {
|
||||
this.caseInsensitive = propValue;
|
||||
}
|
||||
break;
|
||||
case 'caseInsensitive' :
|
||||
if(_.isBoolean(propValue)) {
|
||||
this.caseInsensitive = propValue;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'keys' :
|
||||
if(Array.isArray(propValue)) {
|
||||
this.keys = propValue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'keys' :
|
||||
if(Array.isArray(propValue)) {
|
||||
this.keys = propValue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
super.setPropertyValue(propName, propValue);
|
||||
}
|
||||
super.setPropertyValue(propName, propValue);
|
||||
}
|
||||
|
||||
getData() { return this.keyEntered; }
|
||||
getData() { return this.keyEntered; }
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue