fill the output buffer with blanks on DGUS2 clone displays
The intention behind the original logic was to fill the entire line with blanks, so that the output buffer of the display gets "flushed". Restore this behavior.
This commit is contained in:
@@ -1193,10 +1193,10 @@
|
|||||||
// The longname may not be filed, so we use the built-in fallback here.
|
// The longname may not be filed, so we use the built-in fallback here.
|
||||||
char* fileName = card.longest_filename();
|
char* fileName = card.longest_filename();
|
||||||
int fileNameLen = strlen(fileName);
|
int fileNameLen = strlen(fileName);
|
||||||
bool fileNameWasCut = false;
|
|
||||||
|
|
||||||
// Cut off too long filenames. They don't fit on the screen anyway.
|
// Cut off too long filenames. They don't fit on the screen anyway.
|
||||||
#if ENABLED(KNUTWURST_DGUS2_TFT)
|
#if ENABLED(KNUTWURST_DGUS2_TFT)
|
||||||
|
bool fileNameWasCut = false;
|
||||||
if (fileNameLen > MAX_PRINTABLE_FILENAME_LEN) {
|
if (fileNameLen > MAX_PRINTABLE_FILENAME_LEN) {
|
||||||
fileNameWasCut = true;
|
fileNameWasCut = true;
|
||||||
fileNameLen = MAX_PRINTABLE_FILENAME_LEN;
|
fileNameLen = MAX_PRINTABLE_FILENAME_LEN;
|
||||||
@@ -1213,19 +1213,27 @@
|
|||||||
outputString[i] = '_';
|
outputString[i] = '_';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Terminate the string.
|
#if ENABLED(KNUTWURST_DGUS2_TFT)
|
||||||
outputString[fileNameLen] = '\0';
|
// Append extension, if filename was truncated. I know, it's ugly, but it's faster than a string lib.
|
||||||
|
if (fileNameWasCut) {
|
||||||
// Append extension, if filename was truncated. I know, it's ugly, but it's faster than a string lib.
|
outputString[fileNameLen - 7] = '~';
|
||||||
if (fileNameWasCut) {
|
outputString[fileNameLen - 6] = '.';
|
||||||
outputString[fileNameLen - 7] = '~';
|
outputString[fileNameLen - 5] = 'g';
|
||||||
outputString[fileNameLen - 6] = '.';
|
outputString[fileNameLen - 4] = 'c';
|
||||||
outputString[fileNameLen - 5] = 'g';
|
outputString[fileNameLen - 3] = 'o';
|
||||||
outputString[fileNameLen - 4] = 'c';
|
outputString[fileNameLen - 2] = 'd';
|
||||||
outputString[fileNameLen - 3] = 'o';
|
outputString[fileNameLen - 1] = 'e';
|
||||||
outputString[fileNameLen - 2] = 'd';
|
} else {
|
||||||
outputString[fileNameLen - 1] = 'e';
|
// Make sure to fill the output buffer with blanks.
|
||||||
}
|
for (unsigned char i = fileNameLen; i < MAX_PRINTABLE_FILENAME_LEN; i++) {
|
||||||
|
outputString[i] = ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outputString[MAX_PRINTABLE_FILENAME_LEN] = '\0';
|
||||||
|
#else
|
||||||
|
// Just terminate the string.
|
||||||
|
outputString[fileNameLen] = '\0';
|
||||||
|
#endif
|
||||||
|
|
||||||
if (card.flag.filenameIsDir) {
|
if (card.flag.filenameIsDir) {
|
||||||
#if ENABLED(KNUTWURST_DGUS2_TFT)
|
#if ENABLED(KNUTWURST_DGUS2_TFT)
|
||||||
|
Reference in New Issue
Block a user