Getting closer, fixed fse

This commit is contained in:
Nathan Byrd 2022-03-25 19:27:01 -05:00
parent 77e4425df6
commit b7da0dc82a
6 changed files with 81 additions and 48 deletions

View File

@ -21,10 +21,16 @@ function ANSIEscapeParser(options) {
events.EventEmitter.call(this); events.EventEmitter.call(this);
this.column = 1; this.column = 1;
this.row = 1;
this.scrollBack = 0; this.scrollBack = 0;
this.graphicRendition = {}; this.graphicRendition = {};
if(options.startRow != null) {
this.row = options.startRow;
}
else {
this.row = 1;
}
this.parseState = { this.parseState = {
re : /(?:\x1b\x5b)([?=;0-9]*?)([ABCDHJKfhlmnpsu])/g, // eslint-disable-line no-control-regex re : /(?:\x1b\x5b)([?=;0-9]*?)([ABCDHJKfhlmnpsu])/g, // eslint-disable-line no-control-regex
}; };

View File

@ -269,6 +269,7 @@ function display(client, art, options, cb) {
termHeight : client.term.termHeight, termHeight : client.term.termHeight,
termWidth : client.term.termWidth, termWidth : client.term.termWidth,
trailingLF : options.trailingLF, trailingLF : options.trailingLF,
startRow : options.startRow,
}); });
let parseComplete = false; let parseComplete = false;

View File

@ -603,7 +603,7 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
theme.displayThemedAsset( theme.displayThemedAsset(
footerArt, footerArt,
self.client, self.client,
{ font : self.menuConfig.font }, { font : self.menuConfig.font, startRow: self.header.height + self.body.height },
function displayed(err, artData) { function displayed(err, artData) {
callback(err, artData); callback(err, artData);
} }
@ -626,19 +626,34 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
async.series( async.series(
[ [
function displayHeaderAndBody(callback) { function displayHeaderAndBody(callback) {
async.eachSeries( comps, function dispArt(n, next) { async.waterfall(
theme.displayThemedAsset( [
art[n], function displayHeader(callback) {
self.client, theme.displayThemedAsset(
{ font : self.menuConfig.font }, art['header'],
function displayed(err) { self.client,
next(err); { font : self.menuConfig.font },
function displayed(err, artInfo) {
return callback(err, artInfo);
}
);
},
function displayBody(artInfo, callback) {
theme.displayThemedAsset(
art['header'],
self.client,
{ font : self.menuConfig.font, startRow: artInfo.height + 1 },
function displayed(err, artInfo) {
return callback(err, artInfo);
}
);
} }
); ],
}, function complete(err) { function complete(err) {
//self.body.height = self.client.term.termHeight - self.header.height - 1; //self.body.height = self.client.term.termHeight - self.header.height - 1;
callback(err); callback(err);
}); }
);
}, },
function displayFooter(callback) { function displayFooter(callback) {
// we have to treat the footer special // we have to treat the footer special
@ -700,31 +715,39 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
assert(_.isObject(art)); assert(_.isObject(art));
async.series( async.waterfall(
[ [
function beforeDisplayArt(callback) { function beforeDisplayArt(callback) {
self.beforeArt(callback); self.beforeArt(callback);
}, },
function displayHeaderAndBodyArt(callback) { function displayHeader(callback) {
async.eachSeries( [ 'header', 'body' ], function dispArt(n, next) { theme.displayThemedAsset(
theme.displayThemedAsset( art.header,
art[n], self.client,
self.client, { font : self.menuConfig.font },
{ font : self.menuConfig.font }, function displayed(err, artInfo) {
function displayed(err, artData) { if(artInfo) {
if(artData) { mciData['header'] = artInfo;
mciData[n] = artData; self.header = {height: artInfo.height};
self[n] = { height : artData.height };
}
next(err);
} }
); return callback(err, artInfo);
}, function complete(err) { }
callback(err); );
});
}, },
function displayFooter(callback) { function displayBody(artInfo, callback) {
theme.displayThemedAsset(
art.body,
self.client,
{ font : self.menuConfig.font, startRow: artInfo.height },
function displayed(err, artInfo) {
if(artInfo) {
mciData['body'] = artInfo;
self.body = {height: artInfo.height - self.header.height};
}
return callback(err, artInfo);
});
},
function displayFooter(artInfo, callback) {
self.setInitialFooterMode(); self.setInitialFooterMode();
var footerName = self.getFooterName(); var footerName = self.getFooterName();

View File

@ -124,6 +124,11 @@ exports.MenuModule = class MenuModule extends PluginModule {
return callback(null); return callback(null);
} }
if(self.client.term.termHeight > 0 && pausePosition.row > self.client.termHeight) {
// If this scrolled, the prompt will go to the bottom of the screen
pausePosition.row = self.client.termHeight;
}
return self.pausePrompt(pausePosition, callback); return self.pausePrompt(pausePosition, callback);
}, },
function finishAndNext(callback) { function finishAndNext(callback) {

View File

@ -171,22 +171,15 @@ exports.getModule = class ShowArtModule extends MenuModule {
return callback(err); return callback(err);
} }
const mciData = { menu : artData.mciMap }; const mciData = { menu : artData.mciMap };
return callback(null, mciData); if(self.client.term.termHeight > 0 && artData.height > self.client.term.termHeight) {
// We must have scrolled, adjust the positioning for pause
artData.height = self.client.term.termHeight;
}
const pausePosition = { row: artData.height + 1, col: 1};
return callback(null, mciData, pausePosition);
} }
); );
}, },
function recordCursorPosition(mciData, callback) {
if(!options.pause) {
return callback(null, mciData, null); // cursor position not needed
}
self.client.once('cursor position report', pos => {
const pausePosition = { row : pos[0], col : 1 };
return callback(null, mciData, pausePosition);
});
self.client.term.rawWrite(ANSI.queryPos());
},
function afterArtDisplayed(mciData, pausePosition, callback) { function afterArtDisplayed(mciData, pausePosition, callback) {
self.mciReady(mciData, err => { self.mciReady(mciData, err => {
return callback(err, pausePosition); return callback(err, pausePosition);

View File

@ -495,6 +495,7 @@ function displayPreparedArt(options, artInfo, cb) {
sauce : artInfo.sauce, sauce : artInfo.sauce,
font : options.font, font : options.font,
trailingLF : options.trailingLF, trailingLF : options.trailingLF,
startRow : options.startRow,
}; };
art.display(options.client, artInfo.data, displayOpts, (err, mciMap, extraInfo) => { art.display(options.client, artInfo.data, displayOpts, (err, mciMap, extraInfo) => {
return cb(err, { mciMap : mciMap, artInfo : artInfo, extraInfo : extraInfo } ); return cb(err, { mciMap : mciMap, artInfo : artInfo, extraInfo : extraInfo } );
@ -585,7 +586,11 @@ function displayThemedPrompt(name, client, options, cb) {
} }
if(options.row != null) { if(options.row != null) {
artInfo.startRow = options.row - artInfo.height; artInfo.startRow = options.row;
if(client.term.termHeight > 0 && artInfo.startRow + artInfo.height > client.term.termHeight) {
// in this case, we will have scrolled
artInfo.startRow = client.term.termHeight - artInfo.height;
}
} }
return callback(null, promptConfig, artInfo); return callback(null, promptConfig, artInfo);
@ -614,7 +619,7 @@ function displayThemedPrompt(name, client, options, cb) {
}); });
}, },
function clearPauseArt(artInfo, assocViewController, callback) { function clearPauseArt(artInfo, assocViewController, callback) {
// Only clear with height if clearPrompt is true and if we were able // Only clear with height if clearPrompt is true and if we were able
// to determine the row // to determine the row
if(options.clearPrompt && artInfo.startRow) { if(options.clearPrompt && artInfo.startRow) {
if(artInfo.startRow && artInfo.height) { if(artInfo.startRow && artInfo.height) {