diff --git a/core/file_area_list.js b/core/file_area_list.js index 35ce3ea6..a62271ca 100644 --- a/core/file_area_list.js +++ b/core/file_area_list.js @@ -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); diff --git a/core/file_base_area.js b/core/file_base_area.js index 95040791..44ecb406 100644 --- a/core/file_base_area.js +++ b/core/file_base_area.js @@ -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); + }); }); }); }, () => { diff --git a/core/file_entry.js b/core/file_entry.js index 4f5e47d1..0539f137 100644 --- a/core/file_entry.js +++ b/core/file_entry.js @@ -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 { diff --git a/core/multi_line_edit_text_view.js b/core/multi_line_edit_text_view.js index bd49a73f..9f099b16 100644 --- a/core/multi_line_edit_text_view.js +++ b/core/multi_line_edit_text_view.js @@ -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, diff --git a/core/oputil/oputil_file_base.js b/core/oputil/oputil_file_base.js index b12c4d69..f1956cce 100644 --- a/core/oputil/oputil_file_base.js +++ b/core/oputil/oputil_file_base.js @@ -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 => { diff --git a/core/sauce.js b/core/sauce.js index 6291c16e..7d5f52fd 100644 --- a/core/sauce.js +++ b/core/sauce.js @@ -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;