Skip to content

Commit c160fe7

Browse files
committed
reword "move" to "column" and improve ColorizeMatchResultProc
* "move" is not common, just "column" with "in line offset" as explanation * the columns that a `\t` counts depends on editors. We take it as 1.
1 parent c6ec222 commit c160fe7

29 files changed

+126
-119
lines changed

src/LineData.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
struct LineDataLine
2424
{
2525
DWORD number;
26-
DWORD move;
26+
DWORD column;
2727
std::wstring text;
2828
};
2929

src/Resources/grepWin.rc

+3-3
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 and move:",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, %move% with an extra offset",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,7 +376,7 @@ BEGIN
376376
IDS_REGEXINVALID "invalid regex!"
377377
IDS_SIZE "Size"
378378
IDS_LINE "Line"
379-
IDS_MOVE "Move"
379+
IDS_COLUMN "Column"
380380
IDS_MATCHES "Matches"
381381
IDS_TEXT "Text"
382382
IDS_PATH "Path"

src/SearchDlg.cpp

+40-33
Original file line numberDiff line numberDiff line change
@@ -1988,7 +1988,7 @@ bool CSearchDlg::InitResultList()
19881988
std::wstring sName = TranslatedString(hResource, IDS_NAME);
19891989
std::wstring sSize = TranslatedString(hResource, IDS_SIZE);
19901990
std::wstring sLine = TranslatedString(hResource, IDS_LINE);
1991-
std::wstring sMove = TranslatedString(hResource, IDS_MOVE);
1991+
std::wstring sMove = TranslatedString(hResource, IDS_COLUMN);
19921992
std::wstring sMatches = TranslatedString(hResource, IDS_MATCHES);
19931993
std::wstring sText = TranslatedString(hResource, IDS_TEXT);
19941994
std::wstring sPath = TranslatedString(hResource, IDS_PATH);
@@ -2279,7 +2279,7 @@ void CSearchDlg::ShowContextMenu(HWND hWnd, int x, int y)
22792279
if (static_cast<int>(info.matchLinesNumbers.size()) > subIdx)
22802280
{
22812281
dataLine.number = info.matchLinesNumbers[subIdx];
2282-
dataLine.move = info.matchMovesNumbers[subIdx];
2282+
dataLine.column = info.matchColumnsNumbers[subIdx];
22832283
}
22842284
if (static_cast<int>(info.matchLines.size()) > subIdx)
22852285
dataLine.text = info.matchLines[subIdx];
@@ -2455,35 +2455,43 @@ LRESULT CSearchDlg::ColorizeMatchResultProc(LPNMLVCUSTOMDRAW lpLVCD)
24552455
return CDRF_NOTIFYPOSTPAINT | CDRF_NEWFONT;
24562456
case CDDS_ITEMPOSTPAINT | CDDS_SUBITEM: // use the theme color
24572457
{
2458-
if (IsDlgButtonChecked(*this, IDC_RESULTFILES) != BST_CHECKED && lpLVCD->iSubItem == 3)
2458+
if (lpLVCD->iSubItem == 3 && IsDlgButtonChecked(*this, IDC_RESULTFILES) != BST_CHECKED)
24592459
{
2460-
HDC hdc = lpLVCD->nmcd.hdc;
2461-
RECT rc = lpLVCD->nmcd.rc; // lpLVCD->rcText does not work
2460+
HDC hdc = lpLVCD->nmcd.hdc;
2461+
RECT rc = lpLVCD->nmcd.rc; // lpLVCD->rcText does not work
24622462
if (rc.top == 0)
24632463
{
24642464
// hover on items
24652465
break;
24662466
}
24672467

2468-
int iRow = (int)(lpLVCD->nmcd.dwItemSpec);
2469-
auto tup = m_listItems[iRow];
2470-
int index = std::get<0>(tup);
2471-
CSearchInfo* pInfo = &m_items[index];
2468+
int iRow = (int)(lpLVCD->nmcd.dwItemSpec);
2469+
auto tup = m_listItems[iRow];
2470+
int index = std::get<0>(tup);
2471+
CSearchInfo* pInfo = &m_items[index];
24722472
if (pInfo->encoding == CTextFile::Binary)
24732473
{
24742474
break;
24752475
}
24762476

2477-
int subIndex = std::get<1>(tup);
2478-
int lenText = static_cast<int>(pInfo->matchLines[subIndex].length());
2477+
int subIndex = std::get<1>(tup);
2478+
int lenText = static_cast<int>(pInfo->matchLines[subIndex].length());
24792479

2480-
HWND hListControl = GetDlgItem(*this, IDC_RESULTLIST);
2481-
WCHAR textBuf[MAX_PATH * 4] = {0}; // align to AutoSizeAllColumns()
2482-
LVITEM lv = {0};
2483-
lv.iItem = iRow;
2484-
lv.iSubItem = 3;
2485-
lv.mask = LVIF_TEXT;
2486-
lv.pszText = textBuf;
2480+
auto colMatch = pInfo->matchColumnsNumbers[subIndex];
2481+
WCHAR textBuf[MAX_PATH] = {0};
2482+
if (colMatch + pInfo->matchLengths[subIndex] >= MAX_PATH)
2483+
{
2484+
// LV_ITEM: Allows any length string to be stored as item text, only the first 259 TCHARs are displayed.
2485+
// 259, I counted it, not 260.
2486+
break;
2487+
}
2488+
2489+
HWND hListControl = GetDlgItem(*this, IDC_RESULTLIST);
2490+
LVITEM lv = {0};
2491+
lv.iItem = iRow;
2492+
lv.iSubItem = 3;
2493+
lv.mask = LVIF_TEXT;
2494+
lv.pszText = textBuf;
24872495
if (lenText + 1 > _countof(textBuf))
24882496
{
24892497
lv.cchTextMax = _countof(textBuf);
@@ -2494,11 +2502,10 @@ LRESULT CSearchDlg::ColorizeMatchResultProc(LPNMLVCUSTOMDRAW lpLVCD)
24942502
}
24952503
if (ListView_GetItem(hListControl, &lv))
24962504
{
2497-
auto colMatch = pInfo->matchMovesNumbers[subIndex];
24982505
LPWSTR pMatch = lv.pszText + colMatch - 1;
24992506
SIZE textSize = {0, 0};
25002507

2501-
rc.left += 6;
2508+
rc.left += CDPIAware::Instance().Scale(*this, 6);
25022509

25032510
// Not precise sometimes.
25042511
// We keep the text and draw a transparent rectangle only. So, will not break the text.
@@ -2725,10 +2732,10 @@ void CSearchDlg::DoListNotify(LPNMITEMACTIVATE lpNMItemActivate)
27252732
std::wstring matchText = inf.matchLines[subIndex];
27262733
CStringUtils::rtrim(matchText);
27272734
DWORD iShow = 0;
2728-
if (inf.matchMovesNumbers[subIndex] > 8)
2735+
if (inf.matchColumnsNumbers[subIndex] > 8)
27292736
{
27302737
// 6 + 1 prefix chars would give a context
2731-
iShow = inf.matchMovesNumbers[subIndex] - 8;
2738+
iShow = inf.matchColumnsNumbers[subIndex] - 8;
27322739
}
27332740
matchString += CStringUtils::Format(sFormat.c_str(), inf.matchLinesNumbers[subIndex], matchText.substr(iShow, 50).c_str());
27342741
}
@@ -2870,7 +2877,7 @@ void CSearchDlg::DoListNotify(LPNMITEMACTIVATE lpNMItemActivate)
28702877
swprintf_s(pItem->pszText, pItem->cchTextMax, L"%ld", pInfo->matchLinesNumbers[subIndex]);
28712878
break;
28722879
case 2: // move number
2873-
swprintf_s(pItem->pszText, pItem->cchTextMax, L"%ld", pInfo->matchMovesNumbers[subIndex]);
2880+
swprintf_s(pItem->pszText, pItem->cchTextMax, L"%ld", pInfo->matchColumnsNumbers[subIndex]);
28742881
break;
28752882
case 3: // line
28762883
{
@@ -2928,7 +2935,7 @@ void CSearchDlg::OpenFileAtListIndex(int listIndex)
29282935
}
29292936

29302937
swprintf_s(line, 32, L"%ld", inf.matchLinesNumbers[subIndex]);
2931-
swprintf_s(move, 32, L"%ld", inf.matchMovesNumbers[subIndex]);
2938+
swprintf_s(move, 32, L"%ld", inf.matchColumnsNumbers[subIndex]);
29322939

29332940
CRegStdString regEditorCmd(L"Software\\grepWin\\editorcmd");
29342941
std::wstring cmd = regEditorCmd;
@@ -2937,7 +2944,7 @@ void CSearchDlg::OpenFileAtListIndex(int listIndex)
29372944
if (!cmd.empty() && !inf.readError && inf.encoding != CTextFile::UnicodeType::Binary)
29382945
{
29392946
SearchReplace(cmd, L"%line%", line);
2940-
SearchReplace(cmd, L"%move%", move);
2947+
SearchReplace(cmd, L"%column%", move);
29412948
SearchReplace(cmd, L"%path%", inf.filePath);
29422949
OpenFileInProcess(const_cast<wchar_t*>(cmd.c_str()));
29432950
return;
@@ -3034,7 +3041,7 @@ void CSearchDlg::OpenFileAtListIndex(int listIndex)
30343041
L"\\^", L"\\$", L"\\.", L"\\?", L"\\*", L"\\+", L"\\[", L"\\]", L"\\(", L"\\)", L"\\{", L"\\}", L"\\|",
30353042
L"\\x22", L"\\x20", L"\\x09"
30363043
};
3037-
match = inf.matchLines[subIndex].substr(inf.matchMovesNumbers[subIndex] - 1, inf.matchLengths[subIndex]);
3044+
match = inf.matchLines[subIndex].substr(inf.matchColumnsNumbers[subIndex] - 1, inf.matchLengths[subIndex]);
30383045
for (int i = 0; i < _countof(specialChar); ++i)
30393046
{
30403047
SearchReplace(match, specialChar[i], specialEscaped[i]);
@@ -3939,7 +3946,7 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
39393946
lenLineMatch = lenMatch;
39403947
}
39413948
sInfo.matchLinesNumbers.push_back(l);
3942-
sInfo.matchMovesNumbers.push_back(colMatch);
3949+
sInfo.matchColumnsNumbers.push_back(colMatch);
39433950
if (m_bCaptureSearch)
39443951
{
39453952
auto out = whatC.format(m_replaceString, flags);
@@ -3996,7 +4003,7 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
39964003
auto out = whatC.format(m_replaceString, flags);
39974004
sInfo.matchLines.push_back(out);
39984005
sInfo.matchLinesNumbers.push_back(lineStart);
3999-
sInfo.matchMovesNumbers.push_back(colMatch);
4006+
sInfo.matchColumnsNumbers.push_back(colMatch);
40004007
sInfo.matchLengths.push_back(static_cast<long>(out.length()));
40014008
}
40024009
else
@@ -4011,7 +4018,7 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
40114018
}
40124019
sInfo.matchLines.push_back(sLine);
40134020
sInfo.matchLinesNumbers.push_back(l);
4014-
sInfo.matchMovesNumbers.push_back(colMatch);
4021+
sInfo.matchColumnsNumbers.push_back(colMatch);
40154022
sInfo.matchLengths.push_back(lenLineMatch);
40164023
if (lenMatch > lenLineMatch)
40174024
{
@@ -4182,7 +4189,7 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
41824189
{
41834190
boost::regex expression = boost::regex(searchFor, ft);
41844191
std::vector<DWORD> matchLinesNumbers;
4185-
std::vector<DWORD> matchMovesNumbers;
4192+
std::vector<DWORD> matchColumnsNumbers;
41864193
bool bFound = false;
41874194
{
41884195
boost::spirit::classic::file_iterator<> start(filePath.c_str());
@@ -4195,7 +4202,7 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
41954202
if (m_bNotSearch)
41964203
break;
41974204
matchLinesNumbers.push_back(static_cast<DWORD>(whatC[0].first - fBeg));
4198-
matchMovesNumbers.push_back(1);
4205+
matchColumnsNumbers.push_back(1);
41994206
++sInfo.matchCount;
42004207
// update search position:
42014208
start = whatC[0].second;
@@ -4220,7 +4227,7 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
42204227
if (m_bNotSearch)
42214228
break;
42224229
matchLinesNumbers.push_back(static_cast<DWORD>(whatC[0].first - fBeg));
4223-
matchMovesNumbers.push_back(1);
4230+
matchColumnsNumbers.push_back(1);
42244231
++sInfo.matchCount;
42254232
// update search position:
42264233
start = whatC[0].second;
@@ -4300,7 +4307,7 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
43004307
}
43014308
}
43024309
sInfo.matchLinesNumbers = matchLinesNumbers;
4303-
sInfo.matchMovesNumbers = matchMovesNumbers;
4310+
sInfo.matchColumnsNumbers = matchColumnsNumbers;
43044311

43054312
if (m_bReplace)
43064313
{

src/SearchInfo.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class CSearchInfo
4949
std::wstring filePath;
5050
__int64 fileSize;
5151
std::vector<DWORD> matchLinesNumbers;
52-
std::vector<DWORD> matchMovesNumbers;
52+
std::vector<DWORD> matchColumnsNumbers;
5353
std::vector<DWORD> matchLengths;
5454
std::vector<std::wstring> matchLines;
5555
__int64 matchCount;

src/ShellContextMenu.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -342,8 +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->move);
346-
SearchReplace(cmd, L"%move%", buf);
345+
swprintf_s(buf, L"%ld", it2->column);
346+
SearchReplace(cmd, L"%column%", buf);
347347

348348
STARTUPINFO startupInfo;
349349
PROCESS_INFORMATION processInfo;
@@ -367,13 +367,13 @@ UINT CShellContextMenu::ShowContextMenu(HWND hWnd, POINT pt)
367367
wchar_t buf[40] = {0};
368368
swprintf_s(buf, L"%ld", it->matchLinesNumbers[0]);
369369
SearchReplace(cmd, L"%line%", buf);
370-
swprintf_s(buf, L"%ld", it->matchMovesNumbers[0]);
371-
SearchReplace(cmd, L"%move%", buf);
370+
swprintf_s(buf, L"%ld", it->matchColumnsNumbers[0]);
371+
SearchReplace(cmd, L"%column%", buf);
372372
}
373373
else
374374
{
375375
SearchReplace(cmd, L"%line%", L"0");
376-
SearchReplace(cmd, L"%move%", L"0");
376+
SearchReplace(cmd, L"%column%", L"0");
377377
}
378378

379379
STARTUPINFO startupInfo;

src/resource.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
#define IDS_COPY_COLUMN 177
9292
#define IDS_COPY_COLUMN_SEL 178
9393
#define IDS_REGEXEXCEPTION 179
94-
#define IDS_MOVE 180
94+
#define IDS_COLUMN 180
9595
#define IDC_SEARCHTEXT 1000
9696
#define IDC_REGEXRADIO 1001
9797
#define IDC_TEXTRADIO 1002

translations/Afrikaans.lang

+3-3
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, %move% with an extra offset"
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)
@@ -125,11 +125,11 @@ msgid "Check for updates"
125125
msgstr "Kyk vir opdaterings"
126126

127127
#. Resource IDs: (180)
128-
msgid "Move"
128+
msgid "Column"
129129
msgstr ""
130130

131131
#. Resource IDs: (1068)
132-
msgid "Command line to start an editor at a specific line and move:"
132+
msgid "Command line to start an editor at a specific line and in line offset:"
133133
msgstr "Opdragreël om 'n redakteur op 'n spesifieke reël te begin:"
134134

135135
#. Resource IDs: (1060)

translations/Belarusian.lang

+3-3
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, %move% with an extra offset"
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)
@@ -125,11 +125,11 @@ msgid "Check for updates"
125125
msgstr ""
126126

127127
#. Resource IDs: (180)
128-
msgid "Move"
128+
msgid "Column"
129129
msgstr ""
130130

131131
#. Resource IDs: (1068)
132-
msgid "Command line to start an editor at a specific line and move:"
132+
msgid "Command line to start an editor at a specific line and in line offset:"
133133
msgstr "Каманда для адкрыцця рэдактара на выбраным радку:"
134134

135135
#. Resource IDs: (1060)

translations/Chinese Simplified.lang

+6-6
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, %move% with an extra offset"
48-
msgstr "%path% 将被替换为文件的路径, %line% 将被替换为要转至的行号, %move% 为额外偏移量."
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..."
@@ -125,12 +125,12 @@ msgid "Check for updates"
125125
msgstr "检查更新"
126126

127127
#. Resource IDs: (180)
128-
msgid "Move"
129-
msgstr "偏移"
128+
msgid "Column"
129+
msgstr "行内偏移"
130130

131131
#. Resource IDs: (1068)
132-
msgid "Command line to start an editor at a specific line and move:"
133-
msgstr "用于在指定的行和列来启动编辑器的命令行:"
132+
msgid "Command line to start an editor at a specific line and in line offset:"
133+
msgstr "用于在指定的行和行内偏移来启动编辑器的命令行:"
134134

135135
#. Resource IDs: (1060)
136136
msgid "Content"

translations/Chinese Traditional.lang

+6-6
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, %move% with an extra offset"
48-
msgstr "%path% 將被取代為檔案的路徑, %line% 將被取代為要轉至的行號, %move% 為額外偏移量."
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..."
@@ -125,12 +125,12 @@ msgid "Check for updates"
125125
msgstr "檢查更新"
126126

127127
#. Resource IDs: (180)
128-
msgid "Move"
129-
msgstr "偏移"
128+
msgid "Column"
129+
msgstr "行内偏移"
130130

131131
#. Resource IDs: (1068)
132-
msgid "Command line to start an editor at a specific line and move:"
133-
msgstr "用於在指定的行和列來啟動編輯器的命令:"
132+
msgid "Command line to start an editor at a specific line and in line offset:"
133+
msgstr "用於在指定的行和行内偏移來啟動編輯器的命令:"
134134

135135
#. Resource IDs: (1060)
136136
msgid "Content"

0 commit comments

Comments
 (0)