Skip to content

Commit

Permalink
adjust UI interaction logic
Browse files Browse the repository at this point in the history
* only the 1st search path is validated
* existing dir: all options for dir are enabled; otherwise, disabled
* nonexistent path, invalid regex of search, excluding dir or including
  file names: path: mark to red, and disable search and replace
* empty search: valid, counts files
* empty replace: invalid if search is emtpy
* softer red boarder for both light and dark themes
  • Loading branch information
lifenjoiner committed Feb 7, 2024
1 parent 373655e commit 3aa558b
Show file tree
Hide file tree
Showing 26 changed files with 291 additions and 283 deletions.
8 changes: 4 additions & 4 deletions src/Resources/grepWin.rc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ BEGIN
PUSHBUTTON "/",IDC_EDITMULTILINE2,553,81,13,12
CONTROL "Search case-sensitive",IDC_CASE_SENSITIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,98,89,10
CONTROL "Dot matches newline",IDC_DOTMATCHNEWLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,108,98,125,10
CONTROL "Create backup files",IDC_CREATEBACKUP,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,238,98,91,10
CONTROL "Create backup files",IDC_CREATEBACKUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,238,98,91,10
CONTROL "Treat files as UTF8",IDC_UTF8,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,335,98,93,10
PUSHBUTTON "Test regex",IDC_TESTREGEX,14,109,77,14
PUSHBUTTON "Add to Presets",IDC_ADDTOBOOKMARKS,108,109,76,14
Expand All @@ -91,7 +91,7 @@ BEGIN
CONTROL "Include system items",IDC_INCLUDESYSTEM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,166,90,10
CONTROL "Include hidden items",IDC_INCLUDEHIDDEN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,108,166,85,10
CONTROL "Include subfolders",IDC_INCLUDESUBFOLDERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,178,89,10
CONTROL "Include binary files",IDC_INCLUDEBINARY,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,108,178,86,10
CONTROL "Include binary files",IDC_INCLUDEBINARY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,108,178,86,10
CONTROL "Include symbolic links",IDC_INCLUDESYMLINK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,190,115,10
CONTROL "All dates",IDC_RADIO_DATE_ALL,"Button",BS_AUTORADIOBUTTON,198,139,106,10
CONTROL "Newer than",IDC_RADIO_DATE_NEWER,"Button",BS_AUTORADIOBUTTON,198,152,58,10
Expand Down Expand Up @@ -349,8 +349,8 @@ END

STRINGTABLE
BEGIN
IDS_PATTERN_TT "only files that match this pattern are searched.\r\nUse ""|"" as the delimiter.\r\nExample: *.cpp|*.h"
IDS_EXCLUDEDIR_TT "you can exclude directories, e.g. CVS and images.\r\nExample: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
IDS_PATTERN_TT "only files that match this pattern are searched.\r\nText match extended. Use ""|"" as the delimiter.\r\nExample: *.cpp|*.h"
IDS_EXCLUDEDIR_TT "you can exclude directories, e.g. CVS and images.\r\nText match extended. Example: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
IDS_SEARCHPATH_TT "the path(s) which is searched recursively.\r\nSeparate paths with the | symbol.\r\nExample: c:\\temp|d:\\logs"
IDS_DOTMATCHNEWLINE_TT "Newline is matched by '.'"
IDS_SEARCHTEXT_TT "a regular expression used for searching. Press F1 for more info."
Expand Down
457 changes: 230 additions & 227 deletions src/SearchDlg.cpp

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions src/SearchDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class CSearchDlg : public CDialog
m_showContent = true;
m_showContentSet = true;
}
bool isSearchPathValid() const;
bool isRegexValid() const;
bool isExcludeDirsRegexValid() const;
bool isFileNameMatchRegexValid() const;
Expand All @@ -114,7 +115,7 @@ class CSearchDlg : public CDialog
bool SaveSettings();
void SaveWndPosition();
void formatDate(wchar_t dateNative[], const FILETIME& fileTime, bool forceShortFmt) const;
int CheckRegex();
bool CheckRegex(const std::wstring& patternString);
bool MatchPath(LPCTSTR pathBuf) const;
void AutoSizeAllColumns();
int GetSelectedListIndex(int index);
Expand Down Expand Up @@ -199,7 +200,11 @@ class CSearchDlg : public CDialog
std::wstring m_resultString;
std::wstring m_toolTipReplaceString;
std::unique_ptr<CInfoRtfDialog> m_rtfDialog;
bool m_isRegexValid;

bool m_hasSearchDir;
bool m_isSearchPathValid;
int m_SearchValidLength;
int m_ReplaceValidLength;
bool m_isExcludeDirsRegexValid;
bool m_isFileNameMatchingRegexValid;

Expand Down
4 changes: 2 additions & 2 deletions translations/Afrikaans.lang
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ msgid "number of NULL bytes per MB allowed for a file to still be considered tex
msgstr "Aantal NULL-bytes per MB wat toegelaat word dat 'n lêer steeds as teks in plaas van binêre beskou kan word"

#. Resource IDs: (112)
msgid "only files that match this pattern are searched.\r\nUse \"|\" as the delimiter.\r\nExample: *.cpp|*.h"
msgid "only files that match this pattern are searched.\r\nText match extended. Use\"|\" as the delimiter.\r\nExample: *.cpp|*.h"
msgstr "slegs lêers wat by hierdie patroon ooreenstem, word deursoek\nGebruik '|' as die afbakening.\nVoorbeeld: *.cpp|*.h"

#. Resource IDs: (176)
Expand Down Expand Up @@ -641,7 +641,7 @@ msgid "the path(s) which is searched recursively.\r\nSeparate paths with the | s
msgstr "die pad(e) wat rekursief gesoek word.\nAfsonder paaie met die '|' simbool.\nVoorbeeld: c:\\temp|d:\\logs"

#. Resource IDs: (113)
msgid "you can exclude directories, e.g. CVS and images.\r\nExample: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
msgid "you can exclude directories, e.g. CVS and images.\r\nText match extended. Example: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
msgstr "jy kan directories uitsluit, bv. CVS en beelde.\nVoorbeeld: ^(CVS|images)$\nOpmerking: '.svn' gidse is 'versteek' op Windows, dus word dit meestal nie geskandeer nie"

#. Resource IDs: (1064, 1066, 1067)
Expand Down
4 changes: 2 additions & 2 deletions translations/Belarusian.lang
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ msgid "number of NULL bytes per MB allowed for a file to still be considered tex
msgstr ""

#. Resource IDs: (112)
msgid "only files that match this pattern are searched.\r\nUse \"|\" as the delimiter.\r\nExample: *.cpp|*.h"
msgid "only files that match this pattern are searched.\r\nText match extended. Use\"|\" as the delimiter.\r\nExample: *.cpp|*.h"
msgstr ""

#. Resource IDs: (176)
Expand Down Expand Up @@ -641,7 +641,7 @@ msgid "the path(s) which is searched recursively.\r\nSeparate paths with the | s
msgstr ""

#. Resource IDs: (113)
msgid "you can exclude directories, e.g. CVS and images.\r\nExample: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
msgid "you can exclude directories, e.g. CVS and images.\r\nText match extended. Example: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
msgstr ""

#. Resource IDs: (1064, 1066, 1067)
Expand Down
8 changes: 4 additions & 4 deletions translations/Chinese Simplified.lang
Original file line number Diff line number Diff line change
Expand Up @@ -604,8 +604,8 @@ msgid "number of NULL bytes per MB allowed for a file to still be considered tex
msgstr "允许将文件仍视为文本而不是二进制文件的每 MB 空字节数"

#. Resource IDs: (112)
msgid "only files that match this pattern are searched.\r\nUse \"|\" as the delimiter.\r\nExample: *.cpp|*.h"
msgstr "仅匹配此样式的文件被搜索.\r\n 使用 \"|\" 作为分隔符.\r\n 例如: *.cpp|*.h"
msgid "only files that match this pattern are searched.\r\nText match extended. Use \"|\" as the delimiter.\r\nExample: *.cpp|*.h"
msgstr "仅匹配此样式的文件被搜索.\r\n文本匹配已扩展. 使用 \"|\" 作为分隔符.\r\n例如: *.cpp|*.h"

#. Resource IDs: (176)
msgid "open list with recent entries"
Expand Down Expand Up @@ -641,8 +641,8 @@ msgid "the path(s) which is searched recursively.\r\nSeparate paths with the | s
msgstr "将被递归搜索的路径.\r\n 使用 \"|\" 符号来分隔路径.\r\n 比如: c:\\temp|d:\\logs"

#. Resource IDs: (113)
msgid "you can exclude directories, e.g. CVS and images.\r\nExample: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
msgstr "你可以排除目录, 比如: CVS 和 images.\r\n 例如: ^(CVS|images)$\r\n 注意, \".svn\" 目录在 Windows 中是隐藏的, 所以通常不扫描它们."
msgid "you can exclude directories, e.g. CVS and images.\r\nText match extended. Example: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
msgstr "你可以排除目录, 比如: CVS 和 images.\r\n文本匹配已扩展. 例如: ^(CVS|images)$\r\n注意, \".svn\" 目录在 Windows 中是隐藏的, 所以通常不扫描它们."

#. Resource IDs: (1064, 1066, 1067)
msgid "|"
Expand Down
8 changes: 4 additions & 4 deletions translations/Chinese Traditional.lang
Original file line number Diff line number Diff line change
Expand Up @@ -604,8 +604,8 @@ msgid "number of NULL bytes per MB allowed for a file to still be considered tex
msgstr "每 MB 允許的 NULL 位元數,以便將檔案仍視為文字而不是二進位檔案"

#. Resource IDs: (112)
msgid "only files that match this pattern are searched.\r\nUse \"|\" as the delimiter.\r\nExample: *.cpp|*.h"
msgstr "僅搜尋與此模式匹配的檔案。\r\n使用 \"|\" 作為分隔符。\r\n例如: *.cpp|*.h"
msgid "only files that match this pattern are searched.\r\nText match extended. Use\"|\" as the delimiter.\r\nExample: *.cpp|*.h"
msgstr "僅搜尋與此模式匹配的檔案。\r\n文字匹配已擴充。使用 \"|\" 作為分隔符。\r\n例如: *.cpp|*.h"

#. Resource IDs: (176)
msgid "open list with recent entries"
Expand Down Expand Up @@ -641,8 +641,8 @@ msgid "the path(s) which is searched recursively.\r\nSeparate paths with the | s
msgstr "遞迴搜尋的路徑。\r\n使用 \"|\" 符號分隔路徑。\r\n例如: c:\\temp|d:\\logs"

#. Resource IDs: (113)
msgid "you can exclude directories, e.g. CVS and images.\r\nExample: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
msgstr "您可以排除目錄,例如 CVS 和 images。\r\n例如: ^(CVS|images)$\r\n注意,'.svn' 資料夾在 Windows 上是 '隱藏' 的,因此通常不會被掃描。"
msgid "you can exclude directories, e.g. CVS and images.\r\nText match extended. Example: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
msgstr "您可以排除目錄,例如 CVS 和 images。\r\n文字匹配已擴充。例如: ^(CVS|images)$\r\n注意,'.svn' 資料夾在 Windows 上是 '隱藏' 的,因此通常不會被掃描。"

#. Resource IDs: (1064, 1066, 1067)
msgid "|"
Expand Down
4 changes: 2 additions & 2 deletions translations/Dutch.lang
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ msgid "number of NULL bytes per MB allowed for a file to still be considered tex
msgstr "Aantal NULL-bytes per MB waarmee een bestand nog steeds wordt beschouwd als tekst in plaats van binair"

#. Resource IDs: (112)
msgid "only files that match this pattern are searched.\r\nUse \"|\" as the delimiter.\r\nExample: *.cpp|*.h"
msgid "only files that match this pattern are searched.\r\nText match extended. Use\"|\" as the delimiter.\r\nExample: *.cpp|*.h"
msgstr "alleen bestanden die overeenkomen met dit patroon, worden doorzocht.\r\nGebruik \"|\" als scheidingsteken.\r\nVoorbeeld: *.cpp|*.h"

#. Resource IDs: (176)
Expand Down Expand Up @@ -641,7 +641,7 @@ msgid "the path(s) which is searched recursively.\r\nSeparate paths with the | s
msgstr "het pad wordt recursief doorzocht.\r\nScheidt de paden met het | symbool.\r\nVoorbeeld: c:\\temp|d:\\logs"

#. Resource IDs: (113)
msgid "you can exclude directories, e.g. CVS and images.\r\nExample: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
msgid "you can exclude directories, e.g. CVS and images.\r\nText match extended. Example: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
msgstr "Je kunt mappen uitsluiten, bijv. CVS en afbeeldingen.\r\nVoorbeeld: ^(CVS|images)$\r\nOpmerking: '.svn' mappen zijn in Windows normaal verborgen en worden daarom normaal niet doorzocht."

#. Resource IDs: (1064, 1066, 1067)
Expand Down
4 changes: 2 additions & 2 deletions translations/English.lang
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ msgid "number of NULL bytes per MB allowed for a file to still be considered tex
msgstr ""

#. Resource IDs: (112)
msgid "only files that match this pattern are searched.\r\nUse \"|\" as the delimiter.\r\nExample: *.cpp|*.h"
msgid "only files that match this pattern are searched.\r\nText match extended. Use\"|\" as the delimiter.\r\nExample: *.cpp|*.h"
msgstr ""

#. Resource IDs: (176)
Expand Down Expand Up @@ -641,7 +641,7 @@ msgid "the path(s) which is searched recursively.\r\nSeparate paths with the | s
msgstr ""

#. Resource IDs: (113)
msgid "you can exclude directories, e.g. CVS and images.\r\nExample: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
msgid "you can exclude directories, e.g. CVS and images.\r\nText match extended. Example: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
msgstr ""

#. Resource IDs: (1064, 1066, 1067)
Expand Down
4 changes: 2 additions & 2 deletions translations/French.lang
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ msgid "number of NULL bytes per MB allowed for a file to still be considered tex
msgstr ""

#. Resource IDs: (112)
msgid "only files that match this pattern are searched.\r\nUse \"|\" as the delimiter.\r\nExample: *.cpp|*.h"
msgid "only files that match this pattern are searched.\r\nText match extended. Use\"|\" as the delimiter.\r\nExample: *.cpp|*.h"
msgstr "La recherche ne sera manée que dans les fichiers qui correspondent à ce motif.\nUtiliser '|' comme séparateur\nExemple : *.cpp|*.h"

#. Resource IDs: (176)
Expand Down Expand Up @@ -641,7 +641,7 @@ msgid "the path(s) which is searched recursively.\r\nSeparate paths with the | s
msgstr "Chemin(s) de recherche récursive.\n'|' pour ajouter un chemin.\nExemple : c:\\temp|d:\\logs"

#. Resource IDs: (113)
msgid "you can exclude directories, e.g. CVS and images.\r\nExample: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
msgid "you can exclude directories, e.g. CVS and images.\r\nText match extended. Example: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
msgstr "Il est possible d'exclure des dossiers. Exemple : ^(CVS|images)$ pour exclure CVS\\ et images\\.\nLes dossiers .svn sont 'cachés' sous Windows et ne sont normalment pas parcourus."

#. Resource IDs: (1064, 1066, 1067)
Expand Down
4 changes: 2 additions & 2 deletions translations/German.lang
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ msgid "number of NULL bytes per MB allowed for a file to still be considered tex
msgstr "Anzahl erlaubte NULL Bytes pro MB damit eine Datei als Text statt binär erkannt wird"

#. Resource IDs: (112)
msgid "only files that match this pattern are searched.\r\nUse \"|\" as the delimiter.\r\nExample: *.cpp|*.h"
msgid "only files that match this pattern are searched.\r\nText match extended. Use\"|\" as the delimiter.\r\nExample: *.cpp|*.h"
msgstr "Nur Dateien, die diesem Muster entsprechen, werden gesucht.\r\nVerwenden Sie \"|\" als Trennzeichen.\r\nBeispiel: *.cpp|*.h"

#. Resource IDs: (176)
Expand Down Expand Up @@ -641,7 +641,7 @@ msgid "the path(s) which is searched recursively.\r\nSeparate paths with the | s
msgstr "Der Pfad bzw. die Pfade, der bzw. die rekursiv gesucht wird bzw. werden.\r\nSeparieren Sie Pfade mit dem | Symbol.\r\nBeispiel: c:\\temp|d:\\logs"

#. Resource IDs: (113)
msgid "you can exclude directories, e.g. CVS and images.\r\nExample: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
msgid "you can exclude directories, e.g. CVS and images.\r\nText match extended. Example: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
msgstr "Sie können Verzeichnisse ausschließen, z.B. CVS und Images.\r\nBeispiel: ^(CVS|images)$\r\nHinweis´, '.svn'-Ordner sind in Windows 'versteckt', so werden diese üblicherweise nicht gescannt."

#. Resource IDs: (1064, 1066, 1067)
Expand Down
4 changes: 2 additions & 2 deletions translations/Greek.lang
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ msgid "number of NULL bytes per MB allowed for a file to still be considered tex
msgstr ""

#. Resource IDs: (112)
msgid "only files that match this pattern are searched.\r\nUse \"|\" as the delimiter.\r\nExample: *.cpp|*.h"
msgid "only files that match this pattern are searched.\r\nText match extended. Use\"|\" as the delimiter.\r\nExample: *.cpp|*.h"
msgstr "αναζητούνται μόνο αρχεία που ταιριάζουν με αυτό το μοτίβο.\nΧρήση του \"|\" ως διαχωριστικό.\r\nΠαράδειγμα: *.cpp|*.h"

#. Resource IDs: (176)
Expand Down Expand Up @@ -641,7 +641,7 @@ msgid "the path(s) which is searched recursively.\r\nSeparate paths with the | s
msgstr "διαδρομές που αναζητούνται διαδοχικά. \r\nΧρήση του \"|\" ως διαχωριστικό.\r\nΠαράδειγμα: c:\\temp|d:\\logs"

#. Resource IDs: (113)
msgid "you can exclude directories, e.g. CVS and images.\r\nExample: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
msgid "you can exclude directories, e.g. CVS and images.\r\nText match extended. Example: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
msgstr "μπορείτε να εξαιρέσετε καταλόγους, π.χ. CVS και εικόνες.\r\nΠαράδειγμα: ^(CVS|images)$\r\nΣημείωση, οι φάκελοι '.svn' είναι 'κρυφοί' στα Windows, επομένως συνήθως δεν σαρώνονται."

#. Resource IDs: (1064, 1066, 1067)
Expand Down
4 changes: 2 additions & 2 deletions translations/Hindi.lang
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ msgid "number of NULL bytes per MB allowed for a file to still be considered tex
msgstr "फ़ाइल को binary के बजाए टेक्स्ट मानने के लिए NULL bytes per MB की यह संख्या मान्य है"

#. Resource IDs: (112)
msgid "only files that match this pattern are searched.\r\nUse \"|\" as the delimiter.\r\nExample: *.cpp|*.h"
msgid "only files that match this pattern are searched.\r\nText match extended. Use\"|\" as the delimiter.\r\nExample: *.cpp|*.h"
msgstr "मात्र वही फ़ाइल खोजी जाएंगी जो इस स्वरूप से मिलान खाती हैं.\ndelimiter के रूप में '|' प्रयोग करें.\nउदाहरण: *.cpp|*.h"

#. Resource IDs: (176)
Expand Down Expand Up @@ -641,7 +641,7 @@ msgid "the path(s) which is searched recursively.\r\nSeparate paths with the | s
msgstr "जो पथ recursively खोजे जा रहे हैं.\n'|' चिन्ह से पथ अलग करें.\nउदाहरण: c:\\temp|d:\\logs"

#. Resource IDs: (113)
msgid "you can exclude directories, e.g. CVS and images.\r\nExample: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
msgid "you can exclude directories, e.g. CVS and images.\r\nText match extended. Example: ^(CVS|images)$\r\nNote, '.svn' folders are 'hidden' on Windows, so they usually are not scanned."
msgstr "आप निदेशिका बाहर रख सकते हैं, उदाहरण CVS and चित्र .\nउदाहरण: ^(CVS|चित्र)$\nकृपया ध्यान दें, 'Windows में .svn' फ़ोल्डर 'छिपे' हुए हैं, अतः वो प्रायः स्कैन नहीं किए जाते"

#. Resource IDs: (1064, 1066, 1067)
Expand Down
Loading

0 comments on commit 3aa558b

Please sign in to comment.