From 73ffb66b3d53ac49d06d7a04ba39918b7097b715 Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Thu, 5 May 2022 00:20:33 +0200 Subject: [PATCH] allow quick select for directories starting with non-letter chars (fixes #891) --- src/emucore/EventHandler.hxx | 2 +- src/gui/FileListWidget.cxx | 13 ++++++++++++- src/gui/FileListWidget.hxx | 4 ++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/emucore/EventHandler.hxx b/src/emucore/EventHandler.hxx index ba47b18c7..2182e08e2 100644 --- a/src/emucore/EventHandler.hxx +++ b/src/emucore/EventHandler.hxx @@ -349,7 +349,7 @@ class EventHandler /** Check for QWERTZ keyboard layout */ - bool isQwertz() { return myQwertz; } + bool isQwertz() const { return myQwertz; } /** Clipboard methods. diff --git a/src/gui/FileListWidget.cxx b/src/gui/FileListWidget.cxx index 8ad16a624..dda5d2c7a 100644 --- a/src/gui/FileListWidget.cxx +++ b/src/gui/FileListWidget.cxx @@ -304,7 +304,9 @@ bool FileListWidget::handleKeyDown(StellaKey key, StellaMod mod) if(StellaModTest::isAlt(mod)) { handled = true; +#ifdef DEBUG_BUILD cerr << " " << mod << ", " << key << endl; +#endif switch(key) { case KBDK_HOME: @@ -332,6 +334,11 @@ bool FileListWidget::handleKeyDown(StellaKey key, StellaMod mod) break; } } + // Handle shift input for quick directory selection + _lastKey = key; _lastMod = mod; + if(_quickSelectTime < TimerManager::getTicks() / 1000) + _firstMod = mod; + return handled; } @@ -342,6 +349,10 @@ bool FileListWidget::handleText(char text) // (or a substring accumulated from the last couple key presses). // Only works in a useful fashion if the list entries are sorted. const uInt64 time = TimerManager::getTicks() / 1000; + const bool firstShift = StellaModTest::isShift(_firstMod); + + if(StellaModTest::isShift(_lastMod)) + text = *StellaKeyName::forKey(_lastKey); if(_quickSelectTime < time) _quickSelectStr = text; @@ -354,7 +365,7 @@ bool FileListWidget::handleText(char text) { if(BSPF::startsWithIgnoreCase(i, _quickSelectStr)) // Select directories when the first character is uppercase - if((std::isupper(_quickSelectStr[0]) != 0) == + if(firstShift == (_iconTypeList[selectedItem] == IconType::directory || _iconTypeList[selectedItem] == IconType::userdir || _iconTypeList[selectedItem] == IconType::recentdir diff --git a/src/gui/FileListWidget.hxx b/src/gui/FileListWidget.hxx index c1f4fe512..bf410d18d 100644 --- a/src/gui/FileListWidget.hxx +++ b/src/gui/FileListWidget.hxx @@ -182,6 +182,10 @@ class FileListWidget : public StringListWidget uInt32 _selected{0}; + // Allow quick select for "uppercase", non-letter input + StellaKey _lastKey{StellaKey::KBDK_UNKNOWN}; + StellaMod _lastMod{StellaMod::KBDM_NONE}; + StellaMod _firstMod{StellaMod::KBDM_NONE}; string _quickSelectStr; uInt64 _quickSelectTime{0}; static uInt64 _QUICK_SELECT_DELAY;