[Debugger] Alphabetize script lists (#2174)
This commit is contained in:
parent
93740c612f
commit
9e99ef1855
|
@ -423,8 +423,8 @@ LRESULT CDebugScripts::OnConsoleClear(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /
|
||||||
LRESULT CDebugScripts::OnRefreshList(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
|
LRESULT CDebugScripts::OnRefreshList(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
|
||||||
{
|
{
|
||||||
int nIndex = m_ScriptList.GetSelectedIndex();
|
int nIndex = m_ScriptList.GetSelectedIndex();
|
||||||
|
|
||||||
CPath searchPath(m_ScriptsDir.c_str(), "*");
|
CPath searchPath(m_ScriptsDir.c_str(), "*");
|
||||||
|
strlist fileNames;
|
||||||
|
|
||||||
if (!searchPath.FindFirst(CPath::FIND_ATTRIBUTE_FILES))
|
if (!searchPath.FindFirst(CPath::FIND_ATTRIBUTE_FILES))
|
||||||
{
|
{
|
||||||
|
@ -432,22 +432,27 @@ LRESULT CDebugScripts::OnRefreshList(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (searchPath.GetExtension() == "js")
|
||||||
|
{
|
||||||
|
fileNames.push_back(searchPath.GetNameExtension());
|
||||||
|
}
|
||||||
|
} while (searchPath.FindNext());
|
||||||
|
|
||||||
|
fileNames.sort([](stdstr a, stdstr b) {
|
||||||
|
return a.ToLower() < b.ToLower();
|
||||||
|
});
|
||||||
|
|
||||||
m_ScriptList.SetRedraw(false);
|
m_ScriptList.SetRedraw(false);
|
||||||
m_ScriptList.DeleteAllItems();
|
m_ScriptList.DeleteAllItems();
|
||||||
|
|
||||||
size_t nItem = 0;
|
int nItem = 0;
|
||||||
|
for (const stdstr& fileName : fileNames)
|
||||||
do
|
|
||||||
{
|
{
|
||||||
if (searchPath.GetExtension() != "js")
|
JSInstanceStatus status = m_Debugger->ScriptSystem()->GetStatus(fileName.c_str());
|
||||||
{
|
const wchar_t* statusIcon = L"";
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
stdstr scriptFileName = searchPath.GetNameExtension();
|
|
||||||
JSInstanceStatus status = m_Debugger->ScriptSystem()->GetStatus(scriptFileName.c_str());
|
|
||||||
const wchar_t *statusIcon = L"";
|
|
||||||
|
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
case JS_STATUS_STARTING:
|
case JS_STATUS_STARTING:
|
||||||
|
@ -460,11 +465,11 @@ LRESULT CDebugScripts::OnRefreshList(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*
|
||||||
statusIcon = L"-";
|
statusIcon = L"-";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ScriptList.AddItem(nItem, 0, statusIcon);
|
m_ScriptList.AddItem(nItem, 0, statusIcon);
|
||||||
m_ScriptList.SetItemText(nItem, 1, scriptFileName.ToUTF16().c_str());
|
m_ScriptList.SetItemText(nItem, 1, fileName.ToUTF16().c_str());
|
||||||
nItem++;
|
nItem++;
|
||||||
} while (searchPath.FindNext());
|
}
|
||||||
|
|
||||||
m_ScriptList.SetRedraw(true);
|
m_ScriptList.SetRedraw(true);
|
||||||
m_ScriptList.Invalidate();
|
m_ScriptList.Invalidate();
|
||||||
|
|
|
@ -132,29 +132,38 @@ LRESULT CScriptsAutorunDlg::OnRefreshScriptList(UINT /*uMsg*/, WPARAM /*wParam*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ScriptListView.SetRedraw(false);
|
strlist fileNames;
|
||||||
m_ScriptListView.DeleteAllItems();
|
|
||||||
|
|
||||||
size_t nItem = 0;
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
stdstr scriptFileName = searchPath.GetNameExtension();
|
stdstr fileName = searchPath.GetNameExtension();
|
||||||
if (searchPath.GetExtension() == "js" &&
|
if (searchPath.GetExtension() == "js" &&
|
||||||
m_ScriptSystem->AutorunList().count(scriptFileName) == 0)
|
m_ScriptSystem->AutorunList().count(fileName) == 0)
|
||||||
{
|
{
|
||||||
m_ScriptListView.AddItem(nItem, 0, scriptFileName.ToUTF16().c_str());
|
fileNames.push_back(searchPath.GetNameExtension());
|
||||||
if (scriptFileName == m_InitSelectedScriptName)
|
|
||||||
{
|
|
||||||
nSelectedItem = nItem;
|
|
||||||
m_bScriptListNeedsRefocus = true;
|
|
||||||
m_InitSelectedScriptName = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
nItem++;
|
|
||||||
}
|
}
|
||||||
} while (searchPath.FindNext());
|
} while (searchPath.FindNext());
|
||||||
|
|
||||||
|
fileNames.sort([](stdstr a, stdstr b) {
|
||||||
|
return a.ToLower() < b.ToLower();
|
||||||
|
});
|
||||||
|
|
||||||
|
m_ScriptListView.SetRedraw(false);
|
||||||
|
m_ScriptListView.DeleteAllItems();
|
||||||
|
|
||||||
|
int nItem = 0;
|
||||||
|
for (const stdstr& fileName : fileNames)
|
||||||
|
{
|
||||||
|
m_ScriptListView.AddItem(nItem, 0, fileName.ToUTF16().c_str());
|
||||||
|
if (fileName == m_InitSelectedScriptName)
|
||||||
|
{
|
||||||
|
nSelectedItem = nItem;
|
||||||
|
m_bScriptListNeedsRefocus = true;
|
||||||
|
m_InitSelectedScriptName = "";
|
||||||
|
}
|
||||||
|
nItem++;
|
||||||
|
}
|
||||||
|
|
||||||
m_ScriptListView.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
|
m_ScriptListView.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
|
||||||
|
|
||||||
int itemCount = m_ScriptListView.GetItemCount();
|
int itemCount = m_ScriptListView.GetItemCount();
|
||||||
|
@ -178,16 +187,19 @@ LRESULT CScriptsAutorunDlg::OnRefreshAutorunList(UINT /*uMsg*/, WPARAM /*wParam*
|
||||||
{
|
{
|
||||||
int nSelectedItem = m_AutorunListView.GetSelectedIndex();
|
int nSelectedItem = m_AutorunListView.GetSelectedIndex();
|
||||||
|
|
||||||
|
strlist fileNames(m_ScriptSystem->AutorunList().begin(), m_ScriptSystem->AutorunList().end());
|
||||||
|
fileNames.sort([](stdstr a, stdstr b) {
|
||||||
|
return a.ToLower() < b.ToLower();
|
||||||
|
});
|
||||||
|
|
||||||
m_AutorunListView.SetRedraw(FALSE);
|
m_AutorunListView.SetRedraw(FALSE);
|
||||||
m_AutorunListView.DeleteAllItems();
|
m_AutorunListView.DeleteAllItems();
|
||||||
|
|
||||||
int nItem = 0;
|
int nItem = 0;
|
||||||
std::set<std::string>& scripts = m_ScriptSystem->AutorunList();
|
for (const stdstr& fileName : fileNames)
|
||||||
std::set<std::string>::iterator it;
|
|
||||||
for (it = scripts.begin(); it != scripts.end(); it++)
|
|
||||||
{
|
{
|
||||||
m_AutorunListView.AddItem(nItem, 0, stdstr(*it).ToUTF16().c_str());
|
m_AutorunListView.AddItem(nItem, 0, fileName.ToUTF16().c_str());
|
||||||
if (*it == m_InitSelectedScriptName)
|
if (fileName == m_InitSelectedScriptName)
|
||||||
{
|
{
|
||||||
nSelectedItem = nItem;
|
nSelectedItem = nItem;
|
||||||
m_bAutorunListNeedsRefocus = true;
|
m_bAutorunListNeedsRefocus = true;
|
||||||
|
|
Loading…
Reference in New Issue