Skip to content

Commit

Permalink
Display full filename in file info (for long filenames)
Browse files Browse the repository at this point in the history
  • Loading branch information
d0k3 committed Mar 14, 2021
1 parent 4e00b8b commit 2948900
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
20 changes: 20 additions & 0 deletions arm9/source/common/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,26 @@ u32 GetFontHeight(void) {
return font_height;
}

void MultiLineString(char* dest, const char* orig, int llen, int maxl) {
char* ptr_o = (char*) orig;
char* ptr_d = (char*) dest;
for (int l = 0; l < maxl; l++) {
int len = strnlen(ptr_o, llen+1);
snprintf(ptr_d, llen+1, "%.*s", llen, ptr_o);
ptr_o += min(len, llen);
ptr_d += min(len, llen);
if (len <= llen) break;
*(ptr_d++) = '\n';
}

// string too long?
if (!maxl) *dest = '\0';
else if (*ptr_o) {
if (llen >= 3) snprintf(ptr_d - 4, 4, "...");
else *(ptr_d-1) = '\0';
}
}

void WordWrapString(char* str, int llen) {
char* last_brk = str - 1;
char* last_spc = str - 1;
Expand Down
1 change: 1 addition & 0 deletions arm9/source/common/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ u32 GetDrawStringWidth(const char* str);
u32 GetFontWidth(void);
u32 GetFontHeight(void);

void MultiLineString(char* dest, const char* orig, int llen, int maxl);
void WordWrapString(char* str, int llen);
void ResizeString(char* dest, const char* orig, int nsize, int tpos, bool align_right);
void TruncateString(char* dest, const char* orig, int nsize, int tpos);
Expand Down
6 changes: 3 additions & 3 deletions arm9/source/godmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -952,12 +952,12 @@ u32 StandardCopy(u32* cursor, u32* scroll) {
u32 DirFileAttrMenu(const char* path, const char *name) {
bool drv = (path[2] == '\0');
bool vrt = (!drv); // will be checked below
char namestr[32], datestr[32], attrstr[128], sizestr[192];
char namestr[128], datestr[32], attrstr[128], sizestr[192];
FILINFO fno;
u8 new_attrib;

// create truncated name string
TruncateString(namestr, name, 31, 8);
// create mutiline name string
MultiLineString(namestr, name, 31, 4);

// preparations: create file info, date string
if (!drv) {
Expand Down

0 comments on commit 2948900

Please sign in to comment.