fix: bump max file name size for Files list view to 128 bytes
This commit is contained in:
1 parent
36291cd1cc
commit
559c3e2875
1 file changed
+6
-22
@@ -589,28 +589,12 @@ void filemanager_on_draw(Window* win, Framebuffer& fb) {
|
|||||||
// The entry being renamed shows its rename box (drawn later).
|
// The entry being renamed shows its rename box (drawn later).
|
||||||
if (!(fm->rename_active && fm->rename_idx == i)) {
|
if (!(fm->rename_active && fm->rename_idx == i)) {
|
||||||
if (ty >= list_y && ty + fm_sfh <= c.h) {
|
if (ty >= list_y && ty + fm_sfh <= c.h) {
|
||||||
// Truncate name to fit the name column width
|
// Truncate name to fit the name column width. The buffer
|
||||||
const char* name = fm->entry_names[i];
|
// matches entry_names so long names are only ever cut by
|
||||||
int name_max_w = cols.name_right - tx;
|
// pixel width, never silently by byte count.
|
||||||
char label[64];
|
char label[sizeof(fm->entry_names[0])];
|
||||||
montauk::utf8::copy(label, 64, name);
|
fit_label_with_ellipsis(label, sizeof(label), fm->entry_names[i],
|
||||||
|
cols.name_right - tx);
|
||||||
if (text_width(label) > name_max_w && montauk::slen(name) > 3) {
|
|
||||||
int ellipsis_w = text_width("...");
|
|
||||||
int final_len = montauk::slen(label);
|
|
||||||
while (final_len > 1) {
|
|
||||||
label[final_len] = '\0';
|
|
||||||
int w = text_width(label);
|
|
||||||
if (w + ellipsis_w <= name_max_w) break;
|
|
||||||
final_len = montauk::utf8::prev_boundary(label, final_len);
|
|
||||||
}
|
|
||||||
if (final_len > 60)
|
|
||||||
final_len = montauk::utf8::floor_boundary(label, final_len, 60);
|
|
||||||
label[final_len] = '.';
|
|
||||||
label[final_len + 1] = '.';
|
|
||||||
label[final_len + 2] = '.';
|
|
||||||
label[final_len + 3] = '\0';
|
|
||||||
}
|
|
||||||
c.text(tx, ty, label, colors::TEXT_COLOR);
|
c.text(tx, ty, label, colors::TEXT_COLOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user