* Fix ANSI description display during upload

* Major improvements to upload: Allow user to properly edit descriptions even if provided by .diz/system/etc.
This commit is contained in:
Bryan Ashby 2017-09-11 21:01:35 -06:00
parent 861055d935
commit 50bac95857
3 changed files with 57 additions and 23 deletions

View File

@ -1068,9 +1068,9 @@ MultiLineEditTextView.prototype.setFocus = function(focused) {
MultiLineEditTextView.super_.prototype.setFocus.call(this, focused); MultiLineEditTextView.super_.prototype.setFocus.call(this, focused);
}; };
MultiLineEditTextView.prototype.setText = function(text) { MultiLineEditTextView.prototype.setText = function(text, options = { scrollMode : 'default' } ) {
this.textLines = [ ]; this.textLines = [ ];
this.addText(text); this.addText(text, options);
/*this.insertRawText(text); /*this.insertRawText(text);
if(this.isEditMode()) { if(this.isEditMode()) {
@ -1085,13 +1085,27 @@ MultiLineEditTextView.prototype.setAnsi = function(ansi, options = { prepped : f
return this.setAnsiWithOptions(ansi, options, cb); return this.setAnsiWithOptions(ansi, options, cb);
}; };
MultiLineEditTextView.prototype.addText = function(text) { MultiLineEditTextView.prototype.addText = function(text, options = { scrollMode : 'default' }) {
this.insertRawText(text); this.insertRawText(text);
if(this.isEditMode() || this.autoScroll) { switch(options.scrollMode) {
this.cursorEndOfDocument(); case 'default' :
} else { if(this.isEditMode() || this.autoScroll) {
this.cursorStartOfDocument(); this.cursorEndOfDocument();
} else {
this.cursorStartOfDocument();
}
break;
case 'top' :
case 'start' :
this.cursorStartOfDocument();
break;
case 'end' :
case 'bottom' :
this.cursorEndOfDocument();
break;
} }
}; };

View File

@ -623,6 +623,10 @@ function isFormattedLine(line) {
} }
function isAnsi(input) { function isAnsi(input) {
if(!input || 0 === input.length) {
return false;
}
// //
// * ANSI found - limited, just colors // * ANSI found - limited, just colors
// * Full ANSI art // * Full ANSI art

View File

@ -15,6 +15,7 @@ const pathWithTerminatingSeparator = require('../core/file_util.js').pathWithTe
const Log = require('../core/logger.js').log; const Log = require('../core/logger.js').log;
const Errors = require('../core/enig_error.js').Errors; const Errors = require('../core/enig_error.js').Errors;
const FileEntry = require('../core/file_entry.js'); const FileEntry = require('../core/file_entry.js');
const isAnsi = require('../core/string_util.js').isAnsi;
// deps // deps
const async = require('async'); const async = require('async');
@ -421,9 +422,8 @@ exports.getModule = class UploadModule extends MenuModule {
return nextEntry(err); return nextEntry(err);
} }
// if the file entry did *not* have a desc, take the user desc if(!newEntry.descIsAnsi) {
if(!this.fileEntryHasDetectedDesc(newEntry)) { newEntry.desc = _.trimEnd(newValues.shortDesc);
newEntry.desc = newValues.shortDesc.trim();
} }
if(newValues.estYear.length > 0) { if(newValues.estYear.length > 0) {
@ -659,14 +659,16 @@ exports.getModule = class UploadModule extends MenuModule {
displayFileDetailsPageForUploadEntry(fileEntry, cb) { displayFileDetailsPageForUploadEntry(fileEntry, cb) {
const self = this; const self = this;
async.series( async.waterfall(
[ [
function prepArtAndViewController(callback) { function prepArtAndViewController(callback) {
return self.prepViewControllerWithArt( return self.prepViewControllerWithArt(
'fileDetails', 'fileDetails',
FormIds.fileDetails, FormIds.fileDetails,
{ clearScreen : true, trailingLF : false }, { clearScreen : true, trailingLF : false },
callback err => {
return callback(err);
}
); );
}, },
function populateViews(callback) { function populateViews(callback) {
@ -679,18 +681,32 @@ exports.getModule = class UploadModule extends MenuModule {
tagsView.setText( Array.from(fileEntry.hashTags).join(',') ); // :TODO: optional 'hashTagsSep' like file list/browse tagsView.setText( Array.from(fileEntry.hashTags).join(',') ); // :TODO: optional 'hashTagsSep' like file list/browse
yearView.setText(fileEntry.meta.est_release_year || ''); yearView.setText(fileEntry.meta.est_release_year || '');
if(self.fileEntryHasDetectedDesc(fileEntry)) { if(isAnsi(fileEntry.desc)) {
descView.setPropertyValue('mode', 'preview'); fileEntry.descIsAnsi = true;
descView.setText(fileEntry.desc);
descView.acceptsFocus = false;
self.viewControllers.fileDetails.switchFocus(MciViewIds.fileDetails.tags);
} else {
descView.setPropertyValue('mode', 'edit');
descView.setText(getDescFromFileName(fileEntry.fileName)); // try to come up with something good as a default
descView.acceptsFocus = true;
self.viewControllers.fileDetails.switchFocus(MciViewIds.fileDetails.desc);
}
return descView.setAnsi(
fileEntry.desc,
{
prepped : false,
forceLineTerm : true,
},
() => {
return callback(null, descView, 'preview', MciViewIds.fileDetails.tags);
}
);
} else {
const hasDesc = self.fileEntryHasDetectedDesc(fileEntry);
descView.setText(
hasDesc ? fileEntry.desc : getDescFromFileName(fileEntry.fileName),
{ scrollMode : 'top' } // override scroll mode; we want to be @ top
);
return callback(null, descView, 'edit', hasDesc ? MciViewIds.fileDetails.tags : MciViewIds.fileDetails.desc);
}
},
function finalizeViews(descView, descViewMode, focusId, callback) {
descView.setPropertyValue('mode', descViewMode);
descView.acceptsFocus = 'preview' === descViewMode ? false : true;
self.viewControllers.fileDetails.switchFocus(focusId);
return callback(null); return callback(null);
} }
], ],