Skip to content

Commit

Permalink
Merge pull request #277 from adamfowleruk/feature-268
Browse files Browse the repository at this point in the history
Added shortcut support to Quick Find File
  • Loading branch information
adamfowleruk authored Dec 15, 2019
2 parents ed166f1 + 90692c7 commit ceef360
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Paladin/QuickFindWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/
#include "QuickFindWindow.h"

#include <locale>
#include <string>

#include <Application.h>
#include <Button.h>
Expand Down Expand Up @@ -541,8 +543,44 @@ QuickFindWindow::DoSearchFile(const char* text, BMessage* reply,BEntry& entry)
// Check to see if the file name matches the search string
if (B_OK == entry.GetName(entryName))
{
bool matches = false;
s = strstr(entryName,text);
if (NULL != s)
{
matches = true;
} else if (strlen(text) < 10) {
// Grab filename capitals, lowercase them, and see if it matches
std::locale loc;
char caps[20];
int idx = 0;
for (int sIdx = 0;sIdx < strlen(entryName) && idx < 20;sIdx++)
{
if (std::isupper(entryName[sIdx],loc))
{
caps[idx++] = entryName[sIdx];
}
}
caps[idx] = '\0';
char textCaps[strlen(text)];
for (int tci = 0;tci < strlen(text);tci++)
{
textCaps[tci] = std::toupper(text[tci],loc);
}
textCaps[strlen(text)] = '\0';
STRACE(1,("Caps follows\n"));
STRACE(1,(caps));
STRACE(1,("Search text caps follows\n"));
STRACE(1,(textCaps));
if (idx > 0)
{
s = strstr(caps,textCaps); //std::toupper(text,loc)); B_BAD_CAST!?!
if (NULL != s)
{
matches = true;
}
}
}
if (matches)
{
// matches
if (B_OK == entry.GetPath(&entryPath))
Expand Down

0 comments on commit ceef360

Please sign in to comment.