add ignoreLocked option to Screen.

This commit is contained in:
Christopher Jeffrey 2014-06-03 23:51:16 -05:00
parent ba3f0e0815
commit 6f91361197
2 changed files with 8 additions and 1 deletions

View File

@ -172,6 +172,9 @@ The screen on which every other node renders.
- **dump** - dump all output and input to desired file. can be used together
with `log` option if set as a boolean.
- **debug** - debug mode. enables usage of the `debug` method.
- **ignoreLocked** - Array of keys in their full format (e.g. `C-c`) to ignore
when keys are locked. Useful for creating a key that will *always* exit no
matter whether the keys are locked.
##### Properties:

View File

@ -281,6 +281,8 @@ function Screen(options) {
this.autoPadding = options.autoPadding;
this.tabc = Array((options.tabSize || 4) + 1).join(' ');
this.ignoreLocked = options.ignoreLocked || [];
this.dattr = ((0 << 18) | (0x1ff << 9)) | 0x1ff;
this.renders = 0;
@ -550,7 +552,9 @@ Screen.prototype._listenKeys = function(el) {
// checks to make sure grabKeys, lockKeys, and focused
// weren't changed, and handles those situations appropriately.
this.program.on('keypress', function(ch, key) {
if (self.lockKeys) return;
if (self.lockKeys && !~self.ignoreLocked.indexOf(key.full)) {
return;
}
var focused = self.focused
, grabKeys = self.grabKeys;