@@ -1988,7 +1988,7 @@ bool CSearchDlg::InitResultList()
1988
1988
std::wstring sName = TranslatedString (hResource, IDS_NAME);
1989
1989
std::wstring sSize = TranslatedString (hResource, IDS_SIZE);
1990
1990
std::wstring sLine = TranslatedString (hResource, IDS_LINE);
1991
- std::wstring sMove = TranslatedString (hResource, IDS_MOVE );
1991
+ std::wstring sMove = TranslatedString (hResource, IDS_COLUMN );
1992
1992
std::wstring sMatches = TranslatedString (hResource, IDS_MATCHES);
1993
1993
std::wstring sText = TranslatedString (hResource, IDS_TEXT);
1994
1994
std::wstring sPath = TranslatedString (hResource, IDS_PATH);
@@ -2279,7 +2279,7 @@ void CSearchDlg::ShowContextMenu(HWND hWnd, int x, int y)
2279
2279
if (static_cast <int >(info.matchLinesNumbers .size ()) > subIdx)
2280
2280
{
2281
2281
dataLine.number = info.matchLinesNumbers [subIdx];
2282
- dataLine.move = info.matchMovesNumbers [subIdx];
2282
+ dataLine.column = info.matchColumnsNumbers [subIdx];
2283
2283
}
2284
2284
if (static_cast <int >(info.matchLines .size ()) > subIdx)
2285
2285
dataLine.text = info.matchLines [subIdx];
@@ -2455,35 +2455,43 @@ LRESULT CSearchDlg::ColorizeMatchResultProc(LPNMLVCUSTOMDRAW lpLVCD)
2455
2455
return CDRF_NOTIFYPOSTPAINT | CDRF_NEWFONT;
2456
2456
case CDDS_ITEMPOSTPAINT | CDDS_SUBITEM: // use the theme color
2457
2457
{
2458
- if (IsDlgButtonChecked (*this , IDC_RESULTFILES) != BST_CHECKED && lpLVCD-> iSubItem == 3 )
2458
+ if (lpLVCD-> iSubItem == 3 && IsDlgButtonChecked (*this , IDC_RESULTFILES) != BST_CHECKED)
2459
2459
{
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
2462
2462
if (rc.top == 0 )
2463
2463
{
2464
2464
// hover on items
2465
2465
break ;
2466
2466
}
2467
2467
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 ];
2472
2472
if (pInfo->encoding == CTextFile::Binary)
2473
2473
{
2474
2474
break ;
2475
2475
}
2476
2476
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 ());
2479
2479
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;
2487
2495
if (lenText + 1 > _countof (textBuf))
2488
2496
{
2489
2497
lv.cchTextMax = _countof (textBuf);
@@ -2494,11 +2502,10 @@ LRESULT CSearchDlg::ColorizeMatchResultProc(LPNMLVCUSTOMDRAW lpLVCD)
2494
2502
}
2495
2503
if (ListView_GetItem (hListControl, &lv))
2496
2504
{
2497
- auto colMatch = pInfo->matchMovesNumbers [subIndex];
2498
2505
LPWSTR pMatch = lv.pszText + colMatch - 1 ;
2499
2506
SIZE textSize = {0 , 0 };
2500
2507
2501
- rc.left += 6 ;
2508
+ rc.left += CDPIAware::Instance (). Scale (* this , 6 ) ;
2502
2509
2503
2510
// Not precise sometimes.
2504
2511
// 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)
2725
2732
std::wstring matchText = inf.matchLines [subIndex];
2726
2733
CStringUtils::rtrim (matchText);
2727
2734
DWORD iShow = 0 ;
2728
- if (inf.matchMovesNumbers [subIndex] > 8 )
2735
+ if (inf.matchColumnsNumbers [subIndex] > 8 )
2729
2736
{
2730
2737
// 6 + 1 prefix chars would give a context
2731
- iShow = inf.matchMovesNumbers [subIndex] - 8 ;
2738
+ iShow = inf.matchColumnsNumbers [subIndex] - 8 ;
2732
2739
}
2733
2740
matchString += CStringUtils::Format (sFormat .c_str (), inf.matchLinesNumbers [subIndex], matchText.substr (iShow, 50 ).c_str ());
2734
2741
}
@@ -2870,7 +2877,7 @@ void CSearchDlg::DoListNotify(LPNMITEMACTIVATE lpNMItemActivate)
2870
2877
swprintf_s (pItem->pszText , pItem->cchTextMax , L" %ld" , pInfo->matchLinesNumbers [subIndex]);
2871
2878
break ;
2872
2879
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]);
2874
2881
break ;
2875
2882
case 3 : // line
2876
2883
{
@@ -2928,7 +2935,7 @@ void CSearchDlg::OpenFileAtListIndex(int listIndex)
2928
2935
}
2929
2936
2930
2937
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]);
2932
2939
2933
2940
CRegStdString regEditorCmd (L" Software\\ grepWin\\ editorcmd" );
2934
2941
std::wstring cmd = regEditorCmd;
@@ -2937,7 +2944,7 @@ void CSearchDlg::OpenFileAtListIndex(int listIndex)
2937
2944
if (!cmd.empty () && !inf.readError && inf.encoding != CTextFile::UnicodeType::Binary)
2938
2945
{
2939
2946
SearchReplace (cmd, L" %line%" , line);
2940
- SearchReplace (cmd, L" %move %" , move);
2947
+ SearchReplace (cmd, L" %column %" , move);
2941
2948
SearchReplace (cmd, L" %path%" , inf.filePath );
2942
2949
OpenFileInProcess (const_cast <wchar_t *>(cmd.c_str ()));
2943
2950
return ;
@@ -3034,7 +3041,7 @@ void CSearchDlg::OpenFileAtListIndex(int listIndex)
3034
3041
L" \\ ^" , L" \\ $" , L" \\ ." , L" \\ ?" , L" \\ *" , L" \\ +" , L" \\ [" , L" \\ ]" , L" \\ (" , L" \\ )" , L" \\ {" , L" \\ }" , L" \\ |" ,
3035
3042
L" \\ x22" , L" \\ x20" , L" \\ x09"
3036
3043
};
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]);
3038
3045
for (int i = 0 ; i < _countof (specialChar); ++i)
3039
3046
{
3040
3047
SearchReplace (match, specialChar[i], specialEscaped[i]);
@@ -3939,7 +3946,7 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
3939
3946
lenLineMatch = lenMatch;
3940
3947
}
3941
3948
sInfo .matchLinesNumbers .push_back (l);
3942
- sInfo .matchMovesNumbers .push_back (colMatch);
3949
+ sInfo .matchColumnsNumbers .push_back (colMatch);
3943
3950
if (m_bCaptureSearch)
3944
3951
{
3945
3952
auto out = whatC.format (m_replaceString, flags);
@@ -3996,7 +4003,7 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
3996
4003
auto out = whatC.format (m_replaceString, flags);
3997
4004
sInfo .matchLines .push_back (out);
3998
4005
sInfo .matchLinesNumbers .push_back (lineStart);
3999
- sInfo .matchMovesNumbers .push_back (colMatch);
4006
+ sInfo .matchColumnsNumbers .push_back (colMatch);
4000
4007
sInfo .matchLengths .push_back (static_cast <long >(out.length ()));
4001
4008
}
4002
4009
else
@@ -4011,7 +4018,7 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
4011
4018
}
4012
4019
sInfo .matchLines .push_back (sLine );
4013
4020
sInfo .matchLinesNumbers .push_back (l);
4014
- sInfo .matchMovesNumbers .push_back (colMatch);
4021
+ sInfo .matchColumnsNumbers .push_back (colMatch);
4015
4022
sInfo .matchLengths .push_back (lenLineMatch);
4016
4023
if (lenMatch > lenLineMatch)
4017
4024
{
@@ -4182,7 +4189,7 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
4182
4189
{
4183
4190
boost::regex expression = boost::regex (searchFor, ft);
4184
4191
std::vector<DWORD> matchLinesNumbers;
4185
- std::vector<DWORD> matchMovesNumbers ;
4192
+ std::vector<DWORD> matchColumnsNumbers ;
4186
4193
bool bFound = false ;
4187
4194
{
4188
4195
boost::spirit::classic::file_iterator<> start (filePath.c_str ());
@@ -4195,7 +4202,7 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
4195
4202
if (m_bNotSearch)
4196
4203
break ;
4197
4204
matchLinesNumbers.push_back (static_cast <DWORD>(whatC[0 ].first - fBeg ));
4198
- matchMovesNumbers .push_back (1 );
4205
+ matchColumnsNumbers .push_back (1 );
4199
4206
++sInfo .matchCount ;
4200
4207
// update search position:
4201
4208
start = whatC[0 ].second ;
@@ -4220,7 +4227,7 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
4220
4227
if (m_bNotSearch)
4221
4228
break ;
4222
4229
matchLinesNumbers.push_back (static_cast <DWORD>(whatC[0 ].first - fBeg ));
4223
- matchMovesNumbers .push_back (1 );
4230
+ matchColumnsNumbers .push_back (1 );
4224
4231
++sInfo .matchCount ;
4225
4232
// update search position:
4226
4233
start = whatC[0 ].second ;
@@ -4300,7 +4307,7 @@ void CSearchDlg::SearchFile(CSearchInfo sInfo, const std::wstring& searchRoot, b
4300
4307
}
4301
4308
}
4302
4309
sInfo .matchLinesNumbers = matchLinesNumbers;
4303
- sInfo .matchMovesNumbers = matchMovesNumbers ;
4310
+ sInfo .matchColumnsNumbers = matchColumnsNumbers ;
4304
4311
4305
4312
if (m_bReplace)
4306
4313
{
0 commit comments