Skip to content

Commit 1411712

Browse files
committed
improving QSFRM_LINE and QSFRM_LINE_CR, part 4
1 parent e719587 commit 1411712

File tree

8 files changed

+249
-81
lines changed

8 files changed

+249
-81
lines changed

Docs/QSearch-Eng.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,12 @@ Additional options (QSearch panel's popup menu or file
484484
* Log Output (output to Log::Output when "Find All" is pressed)
485485

486486
38) findall_result = 272
487-
Represents the "Find All Results Format" dialog.
487+
Represents the "Output options" dialog (for "Find all").
488488
The value will be the sum of the following numbers:
489489
0 - Include the line with the occurrence
490490
1 - Include only the match (occurrence) itself
491491
2 - Filter mode: pure text without header/footer/position
492+
4 - Filter mode: add the context (refer to FindResultsPolicy)
492493
16 - Include the position: (Ln:Pos)
493494
32 - Include the match length: (Len)
494495
256 - Include the header: "Searching for %s ..."
@@ -576,6 +577,9 @@ v.7.8 (February 2022)
576577
* improved: now "Find all in all files" does not depend on the "not found"
577578
state (as this state applies only to the current document)
578579
* improved: the behaviour of srch_stop_eof = 11
580+
+ added: "Search results" options in the "Output options" dialog
581+
+ added: "Add the context" option for the "Filter mode" check-box in the
582+
"Output options" dialog
579583

580584
v.7.7 (May 2021)
581585
* improved: find next by F3 (when 'catch_main_f3' is on) right after Ctrl+F3

Docs/QSearch-Rus.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,11 +504,12 @@ SelFindNext
504504
* ����� � Log::Output (��� ������� ������ "����� ���")
505505

506506
38) findall_result = 272
507-
������������� ������� "Find All Results Format".
507+
������������� ������� "��������� ������" (��� "����� ���").
508508
��� �������� ����� ������ ��������� �����:
509509
0 - ���������� ������ �� ����������
510510
1 - ���������� ������ ���� ���������� (���������)
511511
2 - ����� �������: ������ ����� ��� ���������/����������/�������
512+
4 - ����� �������: �������� �������� (��. FindResultsPolicy)
512513
16 - ���������� �������: (���:���)
513514
32 - ���������� ����� ����������: (�����)
514515
256 - ���������� ���������: "���� %s ..."
@@ -601,6 +602,9 @@ v.7.8 (
601602
* ��������: ������ ������ "����� ��� �� ���� ������" �� ������� �� ���������
602603
"�� �������" (��������� ��� ��������� �������� ������ �������� ���������)
603604
* ��������: ��������� ��� srch_stop_eof = 11
605+
+ ���������: ������ �������� "���������� ������" � ������� "��������� ������"
606+
+ ���������: ��������� "�������� ��������" ��� ������� "����� �������" �
607+
������� "��������� ������"
604608

605609
v.7.7 (��� 2021)
606610
* ��������: ����������� ������ �� F3 (��� 'catch_main_f3' ���.) ����� �����

Source/QSearch/QSearch.rc

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,19 @@ BEGIN
6464
CONTROL "Whole line",IDC_RB_FA_WHOLELINE,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|BS_AUTORADIOBUTTON,6,42,162,9
6565
CONTROL "Match only",IDC_RB_FA_MATCHONLY,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|BS_AUTORADIOBUTTON,6,52,162,11
6666
// CONTROL "Footer: %d found.",IDC_CH_FA_FOOTER,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,6,66,162,8
67-
CONTROL "Filter mode",IDC_CH_FA_FILTERMODE,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,6,66,162,8
67+
CONTROL "Filter mode",IDC_CH_FA_FILTERMODE,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,6,66,86,8
68+
CONTROL "Add the context",IDC_CH_FA_FILTERCONTEXT,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,98,66,86,8
6869
CONTROL "Apply the syntax theme",IDC_CH_FA_SYNTAXTHEME,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,6,82,162,9
6970
CONTROL "Example:",IDC_ST_FA_EXAMPLE,"Static",WS_CHILDWINDOW|WS_VISIBLE,6,99,84,9
7071
CONTROL "",IDC_ST_FA_EXAMPLE_DATA,"Static",WS_CHILDWINDOW|WS_VISIBLE,6,110,182,36,WS_EX_STATICEDGE
71-
CONTROL "Output Mode",IDC_GB_OUTPUT,"Button",WS_CHILDWINDOW|WS_VISIBLE|BS_FLAT|BS_GROUPBOX,6,154,182,52
72-
CONTROL "",IDC_CB_OUTPUT_DEST,"ComboBox",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,12,166,106,51
73-
CONTROL "Context:",IDC_ST_MODE,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_CENTERIMAGE|SS_RIGHT,12,186,36,10
74-
CONTROL "",IDC_CB_MODE,"ComboBox",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,50,184,68,51
75-
CONTROL "Before:",IDC_ST_BEFORE,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_CENTERIMAGE|SS_RIGHT,124,172,36,8
76-
CONTROL "",IDC_ED_BEFORE,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,162,171,20,13,WS_EX_CLIENTEDGE
77-
CONTROL "After:",IDC_ST_AFTER,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_CENTERIMAGE|SS_RIGHT,124,188,36,10
78-
CONTROL "",IDC_ED_AFTER,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,162,187,20,13,WS_EX_CLIENTEDGE
72+
CONTROL "Output Mode",IDC_GB_FA_OUTPUT,"Button",WS_CHILDWINDOW|WS_VISIBLE|BS_FLAT|BS_GROUPBOX,6,154,182,52
73+
CONTROL "",IDC_CB_FA_OUTPUT_DEST,"ComboBox",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,12,166,106,51
74+
CONTROL "Context:",IDC_ST_FA_MODE,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_CENTERIMAGE|SS_RIGHT,12,186,36,10
75+
CONTROL "",IDC_CB_FA_MODE,"ComboBox",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,50,184,68,51
76+
CONTROL "Before:",IDC_ST_FA_BEFORE,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_CENTERIMAGE|SS_RIGHT,124,172,36,8
77+
CONTROL "",IDC_ED_FA_BEFORE,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,162,171,20,13,WS_EX_CLIENTEDGE
78+
CONTROL "After:",IDC_ST_FA_AFTER,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_CENTERIMAGE|SS_RIGHT,124,188,36,10
79+
CONTROL "",IDC_ED_FA_AFTER,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,162,187,20,13,WS_EX_CLIENTEDGE
7980
END
8081

8182
IDR_MENU_OPTIONS MENU

Source/QSearch/QSearchDlg.c

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ typedef struct sFindAllContext {
351351
unsigned int nTotalFiles;
352352
unsigned int nFilesWithOccurrences;
353353
// output
354-
int nLastLine; // last line in the results
355-
int nLastOccurrenceLine; // last line with the occurrence
354+
int nLastLine; // last line in the results (in current file)
355+
int nLastOccurrenceLine; // last line with the occurrence (in current file)
356356
tDynamicBuffer ResultsBuf;
357357
tDynamicBuffer OccurrencesBuf;
358358
} tFindAllContext;
@@ -1112,6 +1112,7 @@ static void qsFindResultCallback(tFindAllContext* pFindContext, const AECHARRANG
11121112
AETEXTRANGEW tr;
11131113
HWND hWndEdit;
11141114
UINT_PTR nBytesToAllocate;
1115+
BOOL bAddLineCR;
11151116
int nLinesBeforeAfter[2];
11161117

11171118
if ( !pfrPolicy->pfnStoreResultCallback )
@@ -1124,6 +1125,13 @@ static void qsFindResultCallback(tFindAllContext* pFindContext, const AECHARRANG
11241125
nLinesBeforeAfter[0] = 0;
11251126
nLinesBeforeAfter[1] = 0;
11261127

1128+
bAddLineCR = FALSE;
1129+
if ( pfrPolicy->nMode == QSFRM_LINE_CR )
1130+
{
1131+
if ( !(pFindContext->dwFindAllResult & QS_FINDALL_RSLT_FILTERMODE) || (pFindContext->dwFindAllResult & QS_FINDALL_RSLT_FILTERCONTEXT) )
1132+
bAddLineCR = TRUE;
1133+
}
1134+
11271135
if ( (pFindContext->dwFindAllResult & QS_FINDALL_RSLT_MATCHONLY) == 0 )
11281136
{
11291137
// TODO: check pfrPolicy->nMaxLineLen
@@ -1147,6 +1155,19 @@ static void qsFindResultCallback(tFindAllContext* pFindContext, const AECHARRANG
11471155
io.nNewLine = AELB_R;
11481156
SendMessage( hWndEdit, AEM_INDEXOFFSET, 0, (LPARAM) &io );
11491157
}
1158+
if ( (pFindContext->dwFindAllResult & QS_FINDALL_RSLT_FILTERMODE) && !(pFindContext->dwFindAllResult & QS_FINDALL_RSLT_FILTERCONTEXT) )
1159+
{
1160+
if ( tr.cr.ciMin.nLine < pcrFound->ciMin.nLine )
1161+
{
1162+
x_mem_cpy( &tr.cr.ciMin, &pcrFound->ciMin, sizeof(AECHARINDEX) );
1163+
AEC_WrapLineBegin(&tr.cr.ciMin);
1164+
}
1165+
if ( tr.cr.ciMax.nLine > pcrFound->ciMax.nLine )
1166+
{
1167+
x_mem_cpy( &tr.cr.ciMax, &pcrFound->ciMax, sizeof(AECHARINDEX) );
1168+
AEC_WrapLineEnd(&tr.cr.ciMax);
1169+
}
1170+
}
11501171
}
11511172
else if ( pfrPolicy->nMode == QSFRM_CHARINLINE )
11521173
{
@@ -1176,7 +1197,8 @@ static void qsFindResultCallback(tFindAllContext* pFindContext, const AECHARRANG
11761197
}
11771198
else // QSFRM_LINE or QSFRM_LINE_CR
11781199
{
1179-
if ( pfrPolicy->nBefore == 0 && pfrPolicy->nAfter == 0 )
1200+
if ( (pfrPolicy->nBefore == 0 && pfrPolicy->nAfter == 0) ||
1201+
((pFindContext->dwFindAllResult & QS_FINDALL_RSLT_FILTERMODE) && !(pFindContext->dwFindAllResult & QS_FINDALL_RSLT_FILTERCONTEXT)) )
11801202
{
11811203
AEC_WrapLineBegin(&tr.cr.ciMin);
11821204
AEC_WrapLineEnd(&tr.cr.ciMax);
@@ -1206,7 +1228,7 @@ static void qsFindResultCallback(tFindAllContext* pFindContext, const AECHARRANG
12061228
nLines = pFindContext->nLastLine - tr.cr.ciMin.nLine;
12071229
if ( nLines > 0 || ((nLines == 0 || nLines == -1) && pFindContext->nLastLine != -1) )
12081230
{
1209-
if ( pfrPolicy->nMode == QSFRM_LINE_CR )
1231+
if ( bAddLineCR )
12101232
{
12111233
if ( pFindContext->OccurrencesBuf.nBytesStored != 0 )
12121234
pFindContext->OccurrencesBuf.nBytesStored -= 1*sizeof(wchar_t); // exclude the trailing '\r'
@@ -1265,7 +1287,7 @@ static void qsFindResultCallback(tFindAllContext* pFindContext, const AECHARRANG
12651287
return; // no text to retrieve
12661288

12671289
nBytesToAllocate = sizeof(wchar_t) * tr.dwBufferMax;
1268-
if ( pfrPolicy->nMode == QSFRM_LINE_CR )
1290+
if ( bAddLineCR )
12691291
nBytesToAllocate += 1*sizeof(wchar_t); // for the trailing '\r'
12701292

12711293
if ( !tDynamicBuffer_Allocate(pTempBuf, nBytesToAllocate) )
@@ -1275,7 +1297,7 @@ static void qsFindResultCallback(tFindAllContext* pFindContext, const AECHARRANG
12751297
tr.pBuffer = (wchar_t *) pTempBuf->ptr;
12761298
tr.pBuffer[0] = 0;
12771299
pTempBuf->nBytesStored += sizeof(wchar_t) * (UINT_PTR) SendMessage( hWndEdit, AEM_GETTEXTRANGEW, 0, (LPARAM) &tr );
1278-
if ( pfrPolicy->nMode == QSFRM_LINE_CR )
1300+
if ( bAddLineCR )
12791301
{
12801302
tr.pBuffer += pTempBuf->nBytesStored / sizeof(wchar_t);
12811303
*tr.pBuffer = L'\r'; // the trailing '\r'
@@ -5538,6 +5560,8 @@ void qsearchDoSearchText(HWND hEdit, DWORD dwParams, const DWORD dwOptFlags[], t
55385560
SendMessageW( hWndEdit, AEM_GETINDEX, AEGI_LASTCHAR, (LPARAM) &aeftW.crSearch.ciMax);
55395561

55405562
FindContext.nOccurrences = 0;
5563+
FindContext.nLastLine = -1;
5564+
FindContext.nLastOccurrenceLine = -1;
55415565

55425566
pFindAll->ShowFindResults.pfnInit(&FindContext, &pFindAll->tempBuf);
55435567

Source/QSearch/QSearchLng.c

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,15 @@ void qsearchSetFindAllSettDlgLang(HWND hDlg)
766766
L"\x0420\x0435\x0436\x0438\x043C\x0020\x0444\x0456\x043B\x044C\x0442\x0440\x0430"
767767
};
768768

769+
static const wchar_t* szFindAllOutputFilterContextW[INLNG_COUNT] = {
770+
/* eng */
771+
L"Add the context",
772+
/* rus */
773+
L"\x0414\x043E\x0431\x0430\x0432\x0438\x0442\x044C\x0020\x043A\x043E\x043D\x0442\x0435\x043A\x0441\x0442",
774+
/* ukr */
775+
L"\x0414\x043E\x0434\x0430\x0442\x0438\x0020\x043A\x043E\x043D\x0442\x0435\x043A\x0441\x0442"
776+
};
777+
769778
static const wchar_t* szFindAllOutputSyntaxThemeW[INLNG_COUNT] = {
770779
/* eng */
771780
L"Apply the syntax theme",
@@ -823,19 +832,20 @@ void qsearchSetFindAllSettDlgLang(HWND hDlg)
823832

824833
uInternalLng = getInternalLng();
825834
SetWindowTextW( hDlg, szFindAllSettTitleW[uInternalLng] );
826-
SetWindowTextW( GetDlgItem(hDlg, IDC_CH_FA_HEADER), szFindAllOutputHeaderW[uInternalLng] );
827-
SetWindowTextW( GetDlgItem(hDlg, IDC_CH_FA_POSITION), szFindAllOutputPositionW[uInternalLng] );
828-
SetWindowTextW( GetDlgItem(hDlg, IDC_CH_FA_LENGTH), szFindAllOutputLengthW[uInternalLng] );
829-
SetWindowTextW( GetDlgItem(hDlg, IDC_RB_FA_WHOLELINE), szFindAllOutputWholeLineW[uInternalLng] );
830-
SetWindowTextW( GetDlgItem(hDlg, IDC_RB_FA_MATCHONLY), szFindAllOutputMatchOnlyW[uInternalLng] );
831-
// SetWindowTextW( GetDlgItem(hDlg, IDC_CH_FA_FOOTER), szFindAllOutputFooterW[uInternalLng] );
832-
SetWindowTextW( GetDlgItem(hDlg, IDC_CH_FA_FILTERMODE), szFindAllOutputFilterModeW[uInternalLng] );
833-
SetWindowTextW( GetDlgItem(hDlg, IDC_CH_FA_SYNTAXTHEME), szFindAllOutputSyntaxThemeW[uInternalLng] );
834-
SetWindowTextW( GetDlgItem(hDlg, IDC_ST_FA_EXAMPLE), szFindAllOutputExampleW[uInternalLng] );
835-
SetWindowTextW( GetDlgItem(hDlg, IDC_GB_OUTPUT), szFindAllOutputModeW[uInternalLng] );
836-
SetWindowTextW( GetDlgItem(hDlg, IDC_ST_MODE), szFindAllOutputContextW[uInternalLng] );
837-
SetWindowTextW( GetDlgItem(hDlg, IDC_ST_BEFORE), szFindAllContextBeforeW[uInternalLng] );
838-
SetWindowTextW( GetDlgItem(hDlg, IDC_ST_AFTER), szFindAllContextAfterW[uInternalLng] );
835+
SetWindowTextW( GetDlgItem(hDlg, IDC_CH_FA_HEADER), szFindAllOutputHeaderW[uInternalLng] );
836+
SetWindowTextW( GetDlgItem(hDlg, IDC_CH_FA_POSITION), szFindAllOutputPositionW[uInternalLng] );
837+
SetWindowTextW( GetDlgItem(hDlg, IDC_CH_FA_LENGTH), szFindAllOutputLengthW[uInternalLng] );
838+
SetWindowTextW( GetDlgItem(hDlg, IDC_RB_FA_WHOLELINE), szFindAllOutputWholeLineW[uInternalLng] );
839+
SetWindowTextW( GetDlgItem(hDlg, IDC_RB_FA_MATCHONLY), szFindAllOutputMatchOnlyW[uInternalLng] );
840+
// SetWindowTextW( GetDlgItem(hDlg, IDC_CH_FA_FOOTER), szFindAllOutputFooterW[uInternalLng] );
841+
SetWindowTextW( GetDlgItem(hDlg, IDC_CH_FA_FILTERMODE), szFindAllOutputFilterModeW[uInternalLng] );
842+
SetWindowTextW( GetDlgItem(hDlg, IDC_CH_FA_FILTERCONTEXT), szFindAllOutputFilterContextW[uInternalLng] );
843+
SetWindowTextW( GetDlgItem(hDlg, IDC_CH_FA_SYNTAXTHEME), szFindAllOutputSyntaxThemeW[uInternalLng] );
844+
SetWindowTextW( GetDlgItem(hDlg, IDC_ST_FA_EXAMPLE), szFindAllOutputExampleW[uInternalLng] );
845+
SetWindowTextW( GetDlgItem(hDlg, IDC_GB_FA_OUTPUT), szFindAllOutputModeW[uInternalLng] );
846+
SetWindowTextW( GetDlgItem(hDlg, IDC_ST_FA_MODE), szFindAllOutputContextW[uInternalLng] );
847+
SetWindowTextW( GetDlgItem(hDlg, IDC_ST_FA_BEFORE), szFindAllContextBeforeW[uInternalLng] );
848+
SetWindowTextW( GetDlgItem(hDlg, IDC_ST_FA_AFTER), szFindAllContextAfterW[uInternalLng] );
839849
}
840850

841851
void qsearchSetPopupMenuLang(HMENU hPopupMenu)

0 commit comments

Comments
 (0)