Getting closer, fixed fse
This commit is contained in:
parent
77e4425df6
commit
b7da0dc82a
|
@ -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
|
||||||
};
|
};
|
||||||
|
|
|
@ -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;
|
||||||
|
|
63
core/fse.js
63
core/fse.js
|
@ -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(
|
||||||
|
[
|
||||||
|
function displayHeader(callback) {
|
||||||
theme.displayThemedAsset(
|
theme.displayThemedAsset(
|
||||||
art[n],
|
art['header'],
|
||||||
self.client,
|
self.client,
|
||||||
{ font : self.menuConfig.font },
|
{ font : self.menuConfig.font },
|
||||||
function displayed(err) {
|
function displayed(err, artInfo) {
|
||||||
next(err);
|
return callback(err, artInfo);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}, function complete(err) {
|
},
|
||||||
|
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) {
|
||||||
//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[n],
|
art.header,
|
||||||
self.client,
|
self.client,
|
||||||
{ font : self.menuConfig.font },
|
{ font : self.menuConfig.font },
|
||||||
function displayed(err, artData) {
|
function displayed(err, artInfo) {
|
||||||
if(artData) {
|
if(artInfo) {
|
||||||
mciData[n] = artData;
|
mciData['header'] = artInfo;
|
||||||
self[n] = { height : artData.height };
|
self.header = {height: artInfo.height};
|
||||||
}
|
}
|
||||||
|
return callback(err, artInfo);
|
||||||
next(err);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}, function complete(err) {
|
},
|
||||||
callback(err);
|
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(callback) {
|
function displayFooter(artInfo, callback) {
|
||||||
self.setInitialFooterMode();
|
self.setInitialFooterMode();
|
||||||
|
|
||||||
var footerName = self.getFooterName();
|
var footerName = self.getFooterName();
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue