Skip to content

Commit 939fb0b

Browse files
authored
Merge pull request #451 from lifenjoiner/matches
improve presentation of matching results and related
2 parents 632b65b + f2c00ea commit 939fb0b

31 files changed

+582
-295
lines changed

src/LineData.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
struct LineDataLine
2424
{
2525
DWORD number;
26+
DWORD column;
2627
std::wstring text;
2728
};
2829

src/Resources/grepWin.rc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ CAPTION "grepWin Settings"
191191
FONT 9, "Segoe UI", 400, 0, 0x1
192192
BEGIN
193193
GROUPBOX "Editor",IDC_EDITORGROUP,7,7,303,61
194-
LTEXT "Command line to start an editor at a specific line:",IDC_STATIC1,13,19,288,8
194+
LTEXT "Command line to start an editor at a specific line and in line offset:",IDC_STATIC1,13,19,288,8
195195
EDITTEXT IDC_EDITORCMD,13,31,269,14,ES_AUTOHSCROLL
196196
PUSHBUTTON "...",IDC_SEARCHPATHBROWSE,286,31,15,14
197-
LTEXT "%path% is replaced with the path of the file, %line% with the line to jump to",IDC_STATIC2,13,47,288,17
197+
LTEXT "%path% is replaced with the path of the file, %line% with the line to jump to, %column% with in line offset",IDC_STATIC2,13,47,288,17
198198
LTEXT "Language:",IDC_STATIC4,7,72,135,8
199199
COMBOBOX IDC_LANGUAGE,170,71,140,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
200200
LTEXT "number of NULL bytes per MB allowed for a file to still be considered text instead of binary",IDC_STATIC3,7,85,241,17
@@ -376,6 +376,7 @@ BEGIN
376376
IDS_REGEXINVALID "invalid regex!"
377377
IDS_SIZE "Size"
378378
IDS_LINE "Line"
379+
IDS_COLUMN "Column"
379380
IDS_MATCHES "Matches"
380381
IDS_TEXT "Text"
381382
IDS_PATH "Path"
@@ -395,7 +396,7 @@ BEGIN
395396
IDS_COPYRESULT "Copy text result to clipboard"
396397
IDS_COPYRESULTS "Copy text results to clipboard"
397398
IDS_XMOREMATCHES "%ld more matches"
398-
IDS_CONTEXTLINE "Line %5ld : %30s\n"
399+
IDS_CONTEXTLINE "Line %5ld : %s\n"
399400
IDS_INFOLABELFILE "scanning file '%s'"
400401
IDS_ERR_RELATIVEPATH "Relative paths are not allowed. Please enter an absolute path!"
401402
IDS_ERR_INVALID_PATH "Invalid path!"

src/SearchDlg.cpp

Lines changed: 375 additions & 193 deletions
Large diffs are not rendered by default.

src/SearchDlg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class CSearchDlg : public CDialog
109109
void FillResultList();
110110
bool AddFoundEntry(CSearchInfo* pInfo, bool bOnlyListControl = false);
111111
void ShowContextMenu(HWND hWnd, int x, int y);
112+
LRESULT ColorizeMatchResultProc(LPNMLVCUSTOMDRAW lpLVCD);
112113
void DoListNotify(LPNMITEMACTIVATE lpNMItemActivate);
113114
void OpenFileAtListIndex(int listIndex);
114115
void UpdateInfoLabel();

src/SearchInfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class CSearchInfo
4949
std::wstring filePath;
5050
__int64 fileSize;
5151
std::vector<DWORD> matchLinesNumbers;
52+
std::vector<DWORD> matchColumnsNumbers;
53+
std::vector<DWORD> matchLengths;
5254
std::vector<std::wstring> matchLines;
5355
__int64 matchCount;
5456
CTextFile::UnicodeType encoding;

src/ShellContextMenu.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ UINT CShellContextMenu::ShowContextMenu(HWND hWnd, POINT pt)
342342
wchar_t buf[40] = {0};
343343
swprintf_s(buf, L"%ld", it2->number);
344344
SearchReplace(cmd, L"%line%", buf);
345+
swprintf_s(buf, L"%ld", it2->column);
346+
SearchReplace(cmd, L"%column%", buf);
345347

346348
STARTUPINFO startupInfo;
347349
PROCESS_INFORMATION processInfo;
@@ -365,9 +367,14 @@ UINT CShellContextMenu::ShowContextMenu(HWND hWnd, POINT pt)
365367
wchar_t buf[40] = {0};
366368
swprintf_s(buf, L"%ld", it->matchLinesNumbers[0]);
367369
SearchReplace(cmd, L"%line%", buf);
370+
swprintf_s(buf, L"%ld", it->matchColumnsNumbers[0]);
371+
SearchReplace(cmd, L"%column%", buf);
368372
}
369373
else
374+
{
370375
SearchReplace(cmd, L"%line%", L"0");
376+
SearchReplace(cmd, L"%column%", L"0");
377+
}
371378

372379
STARTUPINFO startupInfo;
373380
PROCESS_INFORMATION processInfo;

src/grepWin.vcxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
<GenerateDebugInformation>true</GenerateDebugInformation>
114114
<SubSystem>Windows</SubSystem>
115115
<TargetMachine>MachineX86</TargetMachine>
116-
<AdditionalDependencies>shlwapi.lib;Urlmon.lib;UxTheme.lib;%(AdditionalDependencies)</AdditionalDependencies>
116+
<AdditionalDependencies>shlwapi.lib;Urlmon.lib;UxTheme.lib;Msimg32.lib;%(AdditionalDependencies)</AdditionalDependencies>
117117
</Link>
118118
<Manifest>
119119
<EnableDpiAwareness>true</EnableDpiAwareness>
@@ -140,7 +140,7 @@
140140
<Link>
141141
<GenerateDebugInformation>true</GenerateDebugInformation>
142142
<SubSystem>Windows</SubSystem>
143-
<AdditionalDependencies>shlwapi.lib;Urlmon.lib;UxTheme.lib;%(AdditionalDependencies)</AdditionalDependencies>
143+
<AdditionalDependencies>shlwapi.lib;Urlmon.lib;UxTheme.lib;Msimg32.lib;%(AdditionalDependencies)</AdditionalDependencies>
144144
</Link>
145145
<Manifest>
146146
<EnableDpiAwareness>true</EnableDpiAwareness>
@@ -172,7 +172,7 @@
172172
<SetChecksum>true</SetChecksum>
173173
<SubSystem>Windows</SubSystem>
174174
<TargetMachine>MachineX86</TargetMachine>
175-
<AdditionalDependencies>shlwapi.lib;Urlmon.lib;UxTheme.lib;%(AdditionalDependencies)</AdditionalDependencies>
175+
<AdditionalDependencies>shlwapi.lib;Urlmon.lib;UxTheme.lib;Msimg32.lib;%(AdditionalDependencies)</AdditionalDependencies>
176176
</Link>
177177
<Manifest>
178178
<EnableDpiAwareness>true</EnableDpiAwareness>
@@ -202,7 +202,7 @@
202202
<OptimizeReferences>true</OptimizeReferences>
203203
<SetChecksum>true</SetChecksum>
204204
<SubSystem>Windows</SubSystem>
205-
<AdditionalDependencies>shlwapi.lib;Urlmon.lib;UxTheme.lib;%(AdditionalDependencies)</AdditionalDependencies>
205+
<AdditionalDependencies>shlwapi.lib;Urlmon.lib;UxTheme.lib;Msimg32.lib;%(AdditionalDependencies)</AdditionalDependencies>
206206
</Link>
207207
<Manifest>
208208
<EnableDpiAwareness>true</EnableDpiAwareness>

src/resource.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
#define IDS_COPY_COLUMN 177
9292
#define IDS_COPY_COLUMN_SEL 178
9393
#define IDS_REGEXEXCEPTION 179
94+
#define IDS_COLUMN 180
9495
#define IDC_SEARCHTEXT 1000
9596
#define IDC_REGEXRADIO 1001
9697
#define IDC_TEXTRADIO 1002

translations/Afrikaans.lang

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ msgid "%ld more matches"
4444
msgstr "%ld meer gevind"
4545

4646
#. Resource IDs: (1069)
47-
msgid "%path% is replaced with the path of the file, %line% with the line to jump to"
47+
msgid "%path% is replaced with the path of the file, %line% with the line to jump to, %column% with in line offset"
4848
msgstr "%path% word vervang met die pad van die lêer, %line% met die lyn om na te spring, %pattern% met die soekreeks."
4949

5050
#. Resource IDs: (119)
@@ -124,8 +124,12 @@ msgstr "Vang Soektog"
124124
msgid "Check for updates"
125125
msgstr "Kyk vir opdaterings"
126126

127+
#. Resource IDs: (180)
128+
msgid "Column"
129+
msgstr ""
130+
127131
#. Resource IDs: (1068)
128-
msgid "Command line to start an editor at a specific line:"
132+
msgid "Command line to start an editor at a specific line and in line offset:"
129133
msgstr "Opdragreël om 'n redakteur op 'n spesifieke reël te begin:"
130134

131135
#. Resource IDs: (1060)
@@ -307,8 +311,8 @@ msgstr "Lyn"
307311

308312
#. Resource IDs: (150)
309313
#, c-format
310-
msgid "Line %5ld : %30s\n"
311-
msgstr "Lyn %5ld : %30s\n"
314+
msgid "Line %5ld : %s\n"
315+
msgstr "Lyn %5ld : %s\n"
312316

313317
#. Resource IDs: (135)
314318
msgid "Matches"

translations/Belarusian.lang

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ msgid "%ld more matches"
4444
msgstr "больш %ld супадзенняў"
4545

4646
#. Resource IDs: (1069)
47-
msgid "%path% is replaced with the path of the file, %line% with the line to jump to"
47+
msgid "%path% is replaced with the path of the file, %line% with the line to jump to, %column% with in line offset"
4848
msgstr ""
4949

5050
#. Resource IDs: (119)
@@ -124,8 +124,12 @@ msgstr ""
124124
msgid "Check for updates"
125125
msgstr ""
126126

127+
#. Resource IDs: (180)
128+
msgid "Column"
129+
msgstr ""
130+
127131
#. Resource IDs: (1068)
128-
msgid "Command line to start an editor at a specific line:"
132+
msgid "Command line to start an editor at a specific line and in line offset:"
129133
msgstr "Каманда для адкрыцця рэдактара на выбраным радку:"
130134

131135
#. Resource IDs: (1060)
@@ -307,8 +311,8 @@ msgstr "Радок"
307311

308312
#. Resource IDs: (150)
309313
#, c-format
310-
msgid "Line %5ld : %30s\n"
311-
msgstr "Радок %5ld : %30s\n"
314+
msgid "Line %5ld : %s\n"
315+
msgstr "Радок %5ld : %s\n"
312316

313317
#. Resource IDs: (135)
314318
msgid "Matches"

translations/Chinese Simplified.lang

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ msgid "%ld more matches"
4444
msgstr "还有 %ld 个匹配"
4545

4646
#. Resource IDs: (1069)
47-
msgid "%path% is replaced with the path of the file, %line% with the line to jump to"
48-
msgstr "%path% 将被替换为文件的路径, %line% 将被替换为要转至的行号."
47+
msgid "%path% is replaced with the path of the file, %line% with the line to jump to, %column% with in line offset"
48+
msgstr "%path% 将被替换为文件的路径, %line% 将被替换为要转至的行号, %column% 为行内偏移量."
4949

5050
#. Resource IDs: (119)
5151
msgid "&About grepWin..."
@@ -124,9 +124,13 @@ msgstr "输入替换搜索"
124124
msgid "Check for updates"
125125
msgstr "检查更新"
126126

127+
#. Resource IDs: (180)
128+
msgid "Column"
129+
msgstr "行内偏移"
130+
127131
#. Resource IDs: (1068)
128-
msgid "Command line to start an editor at a specific line:"
129-
msgstr "用于在指定的行来启动编辑器的命令行:"
132+
msgid "Command line to start an editor at a specific line and in line offset:"
133+
msgstr "用于在指定的行和行内偏移来启动编辑器的命令行:"
130134

131135
#. Resource IDs: (1060)
132136
msgid "Content"
@@ -307,8 +311,8 @@ msgstr "行号"
307311

308312
#. Resource IDs: (150)
309313
#, c-format
310-
msgid "Line %5ld : %30s\n"
311-
msgstr "行 %5ld : %30s\n"
314+
msgid "Line %5ld : %s\n"
315+
msgstr "行 %5ld : %s\n"
312316

313317
#. Resource IDs: (135)
314318
msgid "Matches"

translations/Chinese Traditional.lang

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ msgid "%ld more matches"
4444
msgstr "還有 %ld 個匹配"
4545

4646
#. Resource IDs: (1069)
47-
msgid "%path% is replaced with the path of the file, %line% with the line to jump to"
48-
msgstr "%path% 將被取代為檔案的路徑, %line% 將被取代為要轉至的行號."
47+
msgid "%path% is replaced with the path of the file, %line% with the line to jump to, %column% with in line offset"
48+
msgstr "%path% 將被取代為檔案的路徑, %line% 將被取代為要轉至的行號, %column% 為行内偏移量."
4949

5050
#. Resource IDs: (119)
5151
msgid "&About grepWin..."
@@ -124,9 +124,13 @@ msgstr "捕捉搜尋"
124124
msgid "Check for updates"
125125
msgstr "檢查更新"
126126

127+
#. Resource IDs: (180)
128+
msgid "Column"
129+
msgstr "行内偏移"
130+
127131
#. Resource IDs: (1068)
128-
msgid "Command line to start an editor at a specific line:"
129-
msgstr "用於在指定的行來啟動編輯器的命令:"
132+
msgid "Command line to start an editor at a specific line and in line offset:"
133+
msgstr "用於在指定的行和行内偏移來啟動編輯器的命令:"
130134

131135
#. Resource IDs: (1060)
132136
msgid "Content"
@@ -307,8 +311,8 @@ msgstr "行號"
307311

308312
#. Resource IDs: (150)
309313
#, c-format
310-
msgid "Line %5ld : %30s\n"
311-
msgstr "行 %5ld : %30s\n"
314+
msgid "Line %5ld : %s\n"
315+
msgstr "行 %5ld : %s\n"
312316

313317
#. Resource IDs: (135)
314318
msgid "Matches"

translations/Dutch.lang

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ msgid "%ld more matches"
4444
msgstr "%ld meer overeenkomsten"
4545

4646
#. Resource IDs: (1069)
47-
msgid "%path% is replaced with the path of the file, %line% with the line to jump to"
47+
msgid "%path% is replaced with the path of the file, %line% with the line to jump to, %column% with in line offset"
4848
msgstr "%path% wordt vervangen door het pad van het bestand, %line% door de juiste regel"
4949

5050
#. Resource IDs: (119)
@@ -124,8 +124,12 @@ msgstr "Zoekopdracht vastleggen"
124124
msgid "Check for updates"
125125
msgstr "Controleren op updates"
126126

127+
#. Resource IDs: (180)
128+
msgid "Column"
129+
msgstr ""
130+
127131
#. Resource IDs: (1068)
128-
msgid "Command line to start an editor at a specific line:"
132+
msgid "Command line to start an editor at a specific line and in line offset:"
129133
msgstr "Opdrachtregel om een Editor op een specifieke regel te openen"
130134

131135
#. Resource IDs: (1060)
@@ -307,8 +311,8 @@ msgstr "Regel"
307311

308312
#. Resource IDs: (150)
309313
#, c-format
310-
msgid "Line %5ld : %30s\n"
311-
msgstr "Regel %5ld : %30s\n"
314+
msgid "Line %5ld : %s\n"
315+
msgstr "Regel %5ld : %s\n"
312316

313317
#. Resource IDs: (135)
314318
msgid "Matches"

translations/English.lang

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ msgid "%ld more matches"
4444
msgstr ""
4545

4646
#. Resource IDs: (1069)
47-
msgid "%path% is replaced with the path of the file, %line% with the line to jump to"
47+
msgid "%path% is replaced with the path of the file, %line% with the line to jump to, %column% with in line offset"
4848
msgstr ""
4949

5050
#. Resource IDs: (119)
@@ -124,8 +124,12 @@ msgstr ""
124124
msgid "Check for updates"
125125
msgstr ""
126126

127+
#. Resource IDs: (180)
128+
msgid "Column"
129+
msgstr ""
130+
127131
#. Resource IDs: (1068)
128-
msgid "Command line to start an editor at a specific line:"
132+
msgid "Command line to start an editor at a specific line and in line offset:"
129133
msgstr ""
130134

131135
#. Resource IDs: (1060)
@@ -307,7 +311,7 @@ msgstr ""
307311

308312
#. Resource IDs: (150)
309313
#, c-format
310-
msgid "Line %5ld : %30s\n"
314+
msgid "Line %5ld : %s\n"
311315
msgstr ""
312316

313317
#. Resource IDs: (135)

translations/French.lang

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ msgid "%ld more matches"
4444
msgstr "%ld autres correspondances"
4545

4646
#. Resource IDs: (1069)
47-
msgid "%path% is replaced with the path of the file, %line% with the line to jump to"
47+
msgid "%path% is replaced with the path of the file, %line% with the line to jump to, %column% with in line offset"
4848
msgstr "%path% est remplacé par le chemin du fichier, %line% par la ligne à atteindre"
4949

5050
#. Resource IDs: (119)
@@ -124,8 +124,12 @@ msgstr ""
124124
msgid "Check for updates"
125125
msgstr ""
126126

127+
#. Resource IDs: (180)
128+
msgid "Column"
129+
msgstr ""
130+
127131
#. Resource IDs: (1068)
128-
msgid "Command line to start an editor at a specific line:"
132+
msgid "Command line to start an editor at a specific line and in line offset:"
129133
msgstr "Commande de lancement d'un éditeur à une ligne spécifique :"
130134

131135
#. Resource IDs: (1060)
@@ -307,8 +311,8 @@ msgstr "Ligne"
307311

308312
#. Resource IDs: (150)
309313
#, c-format
310-
msgid "Line %5ld : %30s\n"
311-
msgstr "Ligne %5ld : %30s\n"
314+
msgid "Line %5ld : %s\n"
315+
msgstr "Ligne %5ld : %s\n"
312316

313317
#. Resource IDs: (135)
314318
msgid "Matches"

0 commit comments

Comments
 (0)