* Most everything converted to new 'key press' system. Still WIP, some cleanup & probably a few keys to add for various BBS style terminals

This commit is contained in:
Bryan Ashby 2015-06-05 16:20:26 -06:00
parent dd0568f207
commit 8a17ca694e
13 changed files with 329 additions and 189 deletions

View file

@ -22,7 +22,7 @@ var VIEW_SPECIAL_KEY_MAP_DEFAULT = {
home : [ 'home' ],
left : [ 'left arrow' ],
right : [ 'right arrow' ],
clearLine : [ 'end of medium' ],
clearLine : [ 'ctrl + y' ],
};
function View(options) {
@ -177,7 +177,7 @@ View.prototype.setFocus = function(focused) {
this.hasFocus = focused;
this.restoreCursor();
};
/*
View.prototype.onKeyPress = function(key, isSpecial) {
assert(this.hasFocus, 'View does not have focus');
assert(this.acceptsInput, 'View does not accept input');
@ -195,6 +195,26 @@ View.prototype.onSpecialKeyPress = function(keyName) {
this.emit('action', 'next');
}
};
*/
View.prototype.onKeyPress = function(ch, key) {
assert(this.hasFocus, 'View does not have focus');
assert(this.acceptsInput, 'View does not accept input');
if(key) {
assert(this.specialKeyMap, 'No special key map defined');
if(this.isSpecialKeyMapped('accept', key.name)) {
this.emit('action', 'accept');
} else if(this.isSpecialKeyMapped('next', key.name)) {
this.emit('action', 'next');
}
}
if(ch) {
assert(1 === ch.length);
}
};
View.prototype.getData = function() {
};