Arrow keys should account for visibility

This commit is contained in:
Learath 2018-10-08 19:07:25 +03:00
parent ad566aa158
commit 4fedd91020
2 changed files with 25 additions and 2 deletions

View file

@ -4153,9 +4153,11 @@ void CEditor::RenderFileDialog()
int ScrollNum = 0; int ScrollNum = 0;
for(int i = 0; i < m_FileList.size(); i++) for(int i = 0; i < m_FileList.size(); i++)
{ {
m_FileList[i].m_IsVisible = false;
if(!m_aFileDialogSearchText[0] || str_find_nocase(m_FileList[i].m_aName, m_aFileDialogSearchText)) if(!m_aFileDialogSearchText[0] || str_find_nocase(m_FileList[i].m_aName, m_aFileDialogSearchText))
{ {
AddFileDialogEntry(i, &View); AddFileDialogEntry(i, &View);
m_FileList[i].m_IsVisible = true;
ScrollNum++; ScrollNum++;
} }
} }
@ -4171,6 +4173,10 @@ void CEditor::RenderFileDialog()
else else
ScrollNum = 0; ScrollNum = 0;
if(!m_FileList[m_FilesSelectedIndex].m_IsVisible)
{
m_FilesSelectedIndex = 0;
}
if(m_FilesSelectedIndex > -1) if(m_FilesSelectedIndex > -1)
{ {
@ -4179,8 +4185,24 @@ void CEditor::RenderFileDialog()
int NewIndex = -1; int NewIndex = -1;
if(Input()->GetEvent(i).m_Flags&IInput::FLAG_PRESS) if(Input()->GetEvent(i).m_Flags&IInput::FLAG_PRESS)
{ {
if(Input()->GetEvent(i).m_Key == KEY_DOWN) NewIndex = m_FilesSelectedIndex + 1; if(Input()->GetEvent(i).m_Key == KEY_DOWN)
if(Input()->GetEvent(i).m_Key == KEY_UP) NewIndex = m_FilesSelectedIndex - 1; {
for(NewIndex = m_FilesSelectedIndex + 1; NewIndex < m_FileList.size(); NewIndex++)
{
if(m_FileList[NewIndex].m_IsVisible)
break;
}
dbg_msg("DEBUG", "NewIndex='%d'", NewIndex);
}
if(Input()->GetEvent(i).m_Key == KEY_UP)
{
for(NewIndex = m_FilesSelectedIndex - 1; NewIndex >= 0; NewIndex--)
{
if(m_FileList[NewIndex].m_IsVisible)
break;
}
dbg_msg("DEBUG", "NewIndex='%d'", NewIndex);
}
} }
if(NewIndex > -1 && NewIndex < m_FileList.size()) if(NewIndex > -1 && NewIndex < m_FileList.size())
{ {

View file

@ -859,6 +859,7 @@ public:
bool m_IsDir; bool m_IsDir;
bool m_IsLink; bool m_IsLink;
int m_StorageType; int m_StorageType;
bool m_IsVisible;
bool operator<(const CFilelistItem &Other) { return !str_comp(m_aFilename, "..") ? true : !str_comp(Other.m_aFilename, "..") ? false : bool operator<(const CFilelistItem &Other) { return !str_comp(m_aFilename, "..") ? true : !str_comp(Other.m_aFilename, "..") ? false :
m_IsDir && !Other.m_IsDir ? true : !m_IsDir && Other.m_IsDir ? false : m_IsDir && !Other.m_IsDir ? true : !m_IsDir && Other.m_IsDir ? false :