Removed additional cursor position reports.

This commit is contained in:
Nathan Byrd 2022-03-24 20:01:07 -05:00
parent 5cb239157c
commit 77e4425df6
3 changed files with 19 additions and 34 deletions

View File

@ -333,9 +333,6 @@ function display(client, art, options, cb) {
if(!mciInfo.id) { if(!mciInfo.id) {
++generatedId; ++generatedId;
} }
// mciCprQueue.push(mapKey);
// client.term.rawWrite(ansi.queryPos());
} }
}); });

View File

@ -56,7 +56,7 @@ exports.MenuModule = class MenuModule extends PluginModule {
initSequence() { initSequence() {
const self = this; const self = this;
const mciData = {}; const mciData = {};
let pausePosition; let pausePosition = {row: 0, column: 0};
const hasArt = () => { const hasArt = () => {
return _.isString(self.menuConfig.art) || return _.isString(self.menuConfig.art) ||
@ -84,19 +84,14 @@ exports.MenuModule = class MenuModule extends PluginModule {
self.client.log.trace('Could not display art', { art : self.menuConfig.art, reason : err.message } ); self.client.log.trace('Could not display art', { art : self.menuConfig.art, reason : err.message } );
} else { } else {
mciData.menu = artData.mciMap; mciData.menu = artData.mciMap;
pausePosition.row = artData.height + 1;
} }
return callback(null); // any errors are non-fatal return callback(null); // any errors are non-fatal
} }
); );
}, },
function moveToPromptLocation(callback) {
if(self.menuConfig.prompt) {
// :TODO: fetch and move cursor to prompt location, if supplied. See notes/etc. on placements
}
return callback(null);
},
function displayPromptArt(callback) { function displayPromptArt(callback) {
if(!_.isString(self.menuConfig.prompt)) { if(!_.isString(self.menuConfig.prompt)) {
return callback(null); return callback(null);
@ -106,30 +101,21 @@ exports.MenuModule = class MenuModule extends PluginModule {
return callback(Errors.MissingConfig('Prompt specified but no "promptConfig" block found')); return callback(Errors.MissingConfig('Prompt specified but no "promptConfig" block found'));
} }
self.displayAsset( self.displayAsset(
self.menuConfig.promptConfig.art, self.menuConfig.promptConfig.art,
self.menuConfig.config, self.menuConfig.config,
(err, artData) => { (err, promptArtData) => {
if(artData) { if(promptArtData) {
mciData.prompt = artData.mciMap; mciData.prompt = promptArtData.mciMap;
}
if(promptArtData.height != null) {
pausePosition.row = pausePosition.row + promptArtData.height;
} }
return callback(err); // pass err here; prompts *must* have art return callback(err); // pass err here; prompts *must* have art
} }
); );
}, },
function recordCursorPosition(callback) {
if(!self.shouldPause()) {
return callback(null); // cursor position not needed
}
self.client.once('cursor position report', pos => {
pausePosition = { row : pos[0], col : 1 };
self.client.log.trace('After art position recorded', pausePosition );
return callback(null);
});
self.client.term.rawWrite(ansi.queryPos());
},
function afterArtDisplayed(callback) { function afterArtDisplayed(callback) {
return self.mciReady(mciData, callback); return self.mciReady(mciData, callback);
}, },
@ -512,7 +498,7 @@ exports.MenuModule = class MenuModule extends PluginModule {
this.optionalMoveToPosition(position); this.optionalMoveToPosition(position);
return theme.displayThemedPause(this.client, cb); return theme.displayThemedPause(this.client, position, cb);
} }
promptForInput( { formName, formId, promptName, prevFormName, position } = {}, options, cb) { promptForInput( { formName, formId, promptName, prevFormName, position } = {}, options, cb) {

View File

@ -551,6 +551,7 @@ function displayThemedPrompt(name, client, options, cb) {
if(options.clearScreen) { if(options.clearScreen) {
client.term.rawWrite(ansi.resetScreen()); client.term.rawWrite(ansi.resetScreen());
options.position = {row: 1, column: 1};
} }
// //
@ -583,12 +584,11 @@ function displayThemedPrompt(name, client, options, cb) {
return callback(null, promptConfig, artInfo); return callback(null, promptConfig, artInfo);
} }
client.once('cursor position report', pos => { if(options.row != null) {
artInfo.startRow = pos[0] - artInfo.height; artInfo.startRow = options.row - artInfo.height;
return callback(null, promptConfig, artInfo); }
});
client.term.rawWrite(ansi.queryPos()); return callback(null, promptConfig, artInfo);
}, },
function createMCIViews(promptConfig, artInfo, callback) { function createMCIViews(promptConfig, artInfo, callback) {
const assocViewController = usingTempViewController ? new ViewController( { client : client } ) : options.viewController; const assocViewController = usingTempViewController ? new ViewController( { client : client } ) : options.viewController;
@ -614,7 +614,9 @@ function displayThemedPrompt(name, client, options, cb) {
}); });
}, },
function clearPauseArt(artInfo, assocViewController, callback) { function clearPauseArt(artInfo, assocViewController, callback) {
if(options.clearPrompt) { // Only clear with height if clearPrompt is true and if we were able
// to determine the row
if(options.clearPrompt && artInfo.startRow) {
if(artInfo.startRow && artInfo.height) { if(artInfo.startRow && artInfo.height) {
client.term.rawWrite(ansi.goto(artInfo.startRow, 1)); client.term.rawWrite(ansi.goto(artInfo.startRow, 1));