Fix FILE_ID.DIZ (and other) display issues when ANSI is stored with specific term width in SAUCE
+ Preserve SAUCE records of desc/long_desc during import (in meta) * Use SAUCE term width for ANSI Prep when displaying desc
This commit is contained in:
parent
046550842b
commit
6b02ddbdae
|
@ -413,16 +413,23 @@ exports.getModule = class FileAreaList extends MenuModule {
|
|||
//
|
||||
const desc = controlCodesToAnsi(self.currentFileEntry.desc);
|
||||
if(desc.length != self.currentFileEntry.desc.length || isAnsi(desc)) {
|
||||
descView.setAnsi(
|
||||
desc,
|
||||
{
|
||||
prepped : false,
|
||||
forceLineTerm : true
|
||||
},
|
||||
() => {
|
||||
return callback(null);
|
||||
}
|
||||
);
|
||||
const opts = {
|
||||
prepped : false,
|
||||
forceLineTerm : true
|
||||
};
|
||||
|
||||
//
|
||||
// if SAUCE states a term width, honor it else we may see
|
||||
// display corruption
|
||||
//
|
||||
const sauceTermWidth = _.get(self.currentFileEntry.meta, 'desc_sauce.Character.characterWidth');
|
||||
if(_.isNumber(sauceTermWidth)) {
|
||||
opts.termWidth = sauceTermWidth;
|
||||
}
|
||||
|
||||
descView.setAnsi(desc, opts, () => {
|
||||
return callback(null);
|
||||
});
|
||||
} else {
|
||||
descView.setText(self.currentFileEntry.desc);
|
||||
return callback(null);
|
||||
|
|
|
@ -16,6 +16,7 @@ const wordWrapText = require('./word_wrap.js').wordWrapText;
|
|||
const StatLog = require('./stat_log.js');
|
||||
const UserProps = require('./user_property.js');
|
||||
const SysProps = require('./system_property.js');
|
||||
const SAUCE = require('./sauce.js');
|
||||
|
||||
// deps
|
||||
const _ = require('lodash');
|
||||
|
@ -386,13 +387,24 @@ function extractAndProcessDescFiles(fileEntry, filePath, archiveEntries, cb) {
|
|||
return next(null);
|
||||
}
|
||||
|
||||
//
|
||||
// Assume FILE_ID.DIZ, NFO files, etc. are CP437.
|
||||
//
|
||||
// :TODO: This isn't really always the case - how to handle this? We could do a quick detection...
|
||||
fileEntry[descType] = iconv.decode(sliceAtSauceMarker(data, 0x1a), 'cp437');
|
||||
fileEntry[`${descType}Src`] = 'descFile';
|
||||
return next(null);
|
||||
SAUCE.readSAUCE(data, (err, sauce) => {
|
||||
if(sauce) {
|
||||
// if we have SAUCE, this information will be kept as well,
|
||||
// but separate/pre-parsed.
|
||||
const metaKey = `desc${'descLong' === descType ? '_long' : ''}_sauce`;
|
||||
fileEntry.meta[metaKey] = JSON.stringify(sauce);
|
||||
}
|
||||
|
||||
//
|
||||
// Assume FILE_ID.DIZ, NFO files, etc. are CP437; we need
|
||||
// to decode to a native format for storage
|
||||
//
|
||||
// :TODO: This isn't really always the case - how to handle this? We could do a quick detection...
|
||||
const decodedData = iconv.decode(data, 'cp437');
|
||||
fileEntry[descType] = sliceAtSauceMarker(decodedData, 0x1a);
|
||||
fileEntry[`${descType}Src`] = 'descFile';
|
||||
return next(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
}, () => {
|
||||
|
|
|
@ -39,6 +39,8 @@ const FILE_WELL_KNOWN_META = {
|
|||
tic_desc : null, // TIC "Desc"
|
||||
tic_ldesc : null, // TIC "Ldesc" joined by '\n'
|
||||
session_temp_dl : (v) => parseInt(v) ? true : false,
|
||||
desc_sauce : (s) => JSON.parse(s) || {},
|
||||
desc_long_sauce : (s) => JSON.parse(s) || {},
|
||||
};
|
||||
|
||||
module.exports = class FileEntry {
|
||||
|
|
|
@ -567,8 +567,8 @@ function MultiLineEditTextView(options) {
|
|||
ansiPrep(
|
||||
ansi,
|
||||
{
|
||||
termWidth : this.client.term.termWidth,
|
||||
termHeight : this.client.term.termHeight,
|
||||
termWidth : options.termWidth || this.client.term.termWidth,
|
||||
termHeight : options.termHeight || this.client.term.termHeight,
|
||||
cols : this.dimens.width,
|
||||
rows : 'auto',
|
||||
startCol : this.position.col,
|
||||
|
|
|
@ -259,8 +259,10 @@ function scanFileAreaForChanges(areaInfo, options, cb) {
|
|||
|
||||
if( tagsEq &&
|
||||
fileEntry.desc === existingEntry.desc &&
|
||||
fileEntry.descLong == existingEntry.descLong &&
|
||||
fileEntry.meta.est_release_year == existingEntry.meta.est_release_year)
|
||||
fileEntry.descLong === existingEntry.descLong &&
|
||||
fileEntry.meta.est_release_year === existingEntry.meta.est_release_year &&
|
||||
fileEntry.meta.desc_sauce === existingEntry.meta.desc_sauce
|
||||
)
|
||||
{
|
||||
console.info('Dupe');
|
||||
return nextFile(null);
|
||||
|
@ -276,6 +278,10 @@ function scanFileAreaForChanges(areaInfo, options, cb) {
|
|||
existingEntry.meta.est_release_year = fileEntry.meta.est_release_year;
|
||||
}
|
||||
|
||||
if(fileEntry.meta.desc_sauce) {
|
||||
existingEntry.meta.desc_sauce = fileEntry.meta.desc_sauce;
|
||||
}
|
||||
|
||||
updateTags(existingEntry);
|
||||
|
||||
finalizeEntryAndPersist(true, existingEntry, descHandler, err => {
|
||||
|
|
|
@ -163,7 +163,7 @@ function parseCharacterSAUCE(sauce) {
|
|||
result.fileType = SAUCE_CHARACTER_FILE_TYPES[sauce.fileType] || 'Unknown';
|
||||
|
||||
if(sauce.fileType === 0 || sauce.fileType === 1 || sauce.fileType === 2) {
|
||||
// convience: create ansiFlags
|
||||
// convenience: create ansiFlags
|
||||
sauce.ansiFlags = sauce.flags;
|
||||
|
||||
let i = 0;
|
||||
|
@ -175,6 +175,16 @@ function parseCharacterSAUCE(sauce) {
|
|||
if(fontName.length > 0) {
|
||||
result.fontName = fontName;
|
||||
}
|
||||
|
||||
const setDimen = (v, field) => {
|
||||
const i = parseInt(v, 10);
|
||||
if(!isNaN(i)) {
|
||||
result[field] = i;
|
||||
}
|
||||
};
|
||||
|
||||
setDimen(sauce.tinfo1, 'characterWidth');
|
||||
setDimen(sauce.tinfo2, 'characterHeight');
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
Loading…
Reference in New Issue