Skip to content

Commit 66d1bdc

Browse files
committed
[ADD] : add some sorting of '.' on UNIX (found in the fork of @jackm97 : jackm97@bf40515)
[RFR] : due to warnings on clang
1 parent 971d201 commit 66d1bdc

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

ImGuiFileDialog.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ namespace IGFD
638638
window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_ToggledSelection;
639639

640640
// Render
641-
if (held && (flags & ImGuiSelectableFlags_DrawHoveredWhenHeld) || vFlashing)
641+
if ((held && (flags & ImGuiSelectableFlags_DrawHoveredWhenHeld)) || vFlashing)
642642
hovered = true;
643643
if (hovered || selected)
644644
{
@@ -1415,7 +1415,7 @@ namespace IGFD
14151415
}
14161416
else
14171417
{
1418-
ImGui::Text("");
1418+
ImGui::Text("%s ", "");
14191419
}
14201420
}
14211421
if (ImGui::TableNextColumn()) // file date + time
@@ -2004,6 +2004,15 @@ namespace IGFD
20042004
std::sort(m_FileList.begin(), m_FileList.end(),
20052005
[](const FileInfoStruct& a, const FileInfoStruct& b) -> bool
20062006
{
2007+
if (a.fileName[0] == '.' && b.fileName[0] != '.') return true;
2008+
if (a.fileName[0] != '.' && b.fileName[0] == '.') return false;
2009+
if (a.fileName[0] == '.' && b.fileName[0] == '.')
2010+
{
2011+
if (a.fileName.length() == 1) return false;
2012+
if (b.fileName.length() == 1) return true;
2013+
return (stricmp(a.fileName.c_str() + 1, b.fileName.c_str() + 1) < 0);
2014+
}
2015+
20072016
if (a.type != b.type) return (a.type == 'd'); // directory in first
20082017
return (stricmp(a.fileName.c_str(), b.fileName.c_str()) < 0); // sort in insensitive case
20092018
});
@@ -2016,6 +2025,15 @@ namespace IGFD
20162025
std::sort(m_FileList.begin(), m_FileList.end(),
20172026
[](const FileInfoStruct& a, const FileInfoStruct& b) -> bool
20182027
{
2028+
if (a.fileName[0] == '.' && b.fileName[0] != '.') return false;
2029+
if (a.fileName[0] != '.' && b.fileName[0] == '.') return true;
2030+
if (a.fileName[0] == '.' && b.fileName[0] == '.')
2031+
{
2032+
if (a.fileName.length() == 1) return true;
2033+
if (b.fileName.length() == 1) return false;
2034+
return (stricmp(a.fileName.c_str() + 1, b.fileName.c_str() + 1) > 0);
2035+
}
2036+
20192037
if (a.type != b.type) return (a.type != 'd'); // directory in last
20202038
return (stricmp(a.fileName.c_str(), b.fileName.c_str()) > 0); // sort in insensitive case
20212039
});

ImGuiFileDialogConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
//#define FILTER_COMBO_WIDTH 120.0f
2323
// button widget use for compose path
2424
//#define IMGUI_PATH_BUTTON ImGui::Button
25-
// standar button
25+
// standard button
2626
//#define IMGUI_BUTTON ImGui::Button
2727

2828
// locales string

0 commit comments

Comments
 (0)