Cleanup & prep for real-time interrupt

This commit is contained in:
Bryan Ashby 2018-11-14 22:04:29 -07:00
parent b3930d1999
commit cc9c143927
2 changed files with 18 additions and 10 deletions

View File

@ -42,14 +42,6 @@ exports.MenuModule = class MenuModule extends PluginModule {
this.detachViewControllers(); this.detachViewControllers();
} }
toggleInterruptionAndDisplayQueued(cb) {
this.enableInterruption();
this.displayQueuedInterruptions( () => {
this.disableInterruption();
return cb(null);
});
}
initSequence() { initSequence() {
const self = this; const self = this;
const mciData = {}; const mciData = {};
@ -185,6 +177,14 @@ exports.MenuModule = class MenuModule extends PluginModule {
} }
} }
toggleInterruptionAndDisplayQueued(cb) {
this.enableInterruption();
this.displayQueuedInterruptions( () => {
this.disableInterruption();
return cb(null);
});
}
displayQueuedInterruptions(cb) { displayQueuedInterruptions(cb) {
if(true !== this.interruptable) { if(true !== this.interruptable) {
return cb(null); return cb(null);
@ -193,7 +193,7 @@ exports.MenuModule = class MenuModule extends PluginModule {
async.whilst( async.whilst(
() => this.client.interruptQueue.hasItems(), () => this.client.interruptQueue.hasItems(),
next => { next => {
this.client.interruptQueue.display( (err, interruptItem) => { this.client.interruptQueue.displayNext( (err, interruptItem) => {
if(err) { if(err) {
return next(err); return next(err);
} }
@ -211,6 +211,10 @@ exports.MenuModule = class MenuModule extends PluginModule {
) )
} }
attemptInterruptNow(interruptItem, cb) {
return cb(null, false);
}
getSaveState() { getSaveState() {
// nothing in base // nothing in base
} }

View File

@ -43,12 +43,16 @@ module.exports = class UserInterruptQueue
return this.queue.length > 0; return this.queue.length > 0;
} }
display(cb) { displayNext(cb) {
const interruptItem = this.queue.pop(); const interruptItem = this.queue.pop();
if(!interruptItem) { if(!interruptItem) {
return cb(null); return cb(null);
} }
return interruptItem ? this.displayWithItem(interruptItem, cb) : cb(null);
}
displayWithItem(interruptItem, cb) {
if(interruptItem.cls) { if(interruptItem.cls) {
this.client.term.rawWrite(ANSI.clearScreen()); this.client.term.rawWrite(ANSI.clearScreen());
} else { } else {