First pass formatting with Prettier
* Added .prettierrc.json * Added .prettierignore * Formatted
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
/* jslint node: true */
|
||||
'use strict';
|
||||
|
||||
const View = require('./view.js').View;
|
||||
const valueWithDefault = require('./misc_util.js').valueWithDefault;
|
||||
const isPrintable = require('./string_util.js').isPrintable;
|
||||
const stylizeString = require('./string_util.js').stylizeString;
|
||||
const View = require('./view.js').View;
|
||||
const valueWithDefault = require('./misc_util.js').valueWithDefault;
|
||||
const isPrintable = require('./string_util.js').isPrintable;
|
||||
const stylizeString = require('./string_util.js').stylizeString;
|
||||
|
||||
const _ = require('lodash');
|
||||
const _ = require('lodash');
|
||||
|
||||
module.exports = class KeyEntryView extends View {
|
||||
constructor(options) {
|
||||
@@ -15,12 +15,12 @@ module.exports = class KeyEntryView extends View {
|
||||
|
||||
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() );
|
||||
if (Array.isArray(options.keys)) {
|
||||
if (this.caseInsensitive) {
|
||||
this.keys = options.keys.map(k => k.toUpperCase());
|
||||
} else {
|
||||
this.keys = options.keys;
|
||||
}
|
||||
@@ -30,18 +30,22 @@ module.exports = class KeyEntryView extends View {
|
||||
onKeyPress(ch, key) {
|
||||
const drawKey = ch;
|
||||
|
||||
if(ch && this.caseInsensitive) {
|
||||
if (ch && this.caseInsensitive) {
|
||||
ch = ch.toUpperCase();
|
||||
}
|
||||
|
||||
if(drawKey && isPrintable(drawKey) && (!this.keys || this.keys.indexOf(ch) > -1)) {
|
||||
this.redraw(); // sets position
|
||||
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;
|
||||
|
||||
if(key && 'tab' === key.name && !this.eatTabKey) {
|
||||
if (key && 'tab' === key.name && !this.eatTabKey) {
|
||||
return this.emit('action', 'next', key);
|
||||
}
|
||||
|
||||
@@ -50,21 +54,21 @@ module.exports = class KeyEntryView extends View {
|
||||
}
|
||||
|
||||
setPropertyValue(propName, propValue) {
|
||||
switch(propName) {
|
||||
case 'eatTabKey' :
|
||||
if(_.isBoolean(propValue)) {
|
||||
switch (propName) {
|
||||
case 'eatTabKey':
|
||||
if (_.isBoolean(propValue)) {
|
||||
this.eatTabKey = propValue;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'caseInsensitive' :
|
||||
if(_.isBoolean(propValue)) {
|
||||
case 'caseInsensitive':
|
||||
if (_.isBoolean(propValue)) {
|
||||
this.caseInsensitive = propValue;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'keys' :
|
||||
if(Array.isArray(propValue)) {
|
||||
case 'keys':
|
||||
if (Array.isArray(propValue)) {
|
||||
this.keys = propValue;
|
||||
}
|
||||
break;
|
||||
@@ -73,5 +77,7 @@ module.exports = class KeyEntryView extends View {
|
||||
super.setPropertyValue(propName, propValue);
|
||||
}
|
||||
|
||||
getData() { return this.keyEntered; }
|
||||
};
|
||||
getData() {
|
||||
return this.keyEntered;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user