Skip to content

Commit d5a8fd5

Browse files
committed
far:regex: selecting matches in the list selects the corresponding part of the test string
1 parent 473b2be commit d5a8fd5

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

far/changelog

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
--------------------------------------------------------------------------------
2+
drkns 2025-04-22 02:04:56+01:00 - build 6466
3+
4+
1. far:regex: selecting matches in the list selects the corresponding part of the test string.
5+
16
--------------------------------------------------------------------------------
27
drkns 2025-04-21 12:47:09+01:00 - build 6465
38

far/stddlg.cpp

+27-1
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ void regex_playground()
11861186
{ DI_EDIT, {{5, 8}, {45, 8}}, DIF_HISTORY, },
11871187
{ DI_TEXT, {{5, 9}, {0, 9}}, DIF_NONE, L"Result:" },
11881188
{ DI_EDIT, {{5, 10}, {45,10}}, DIF_READONLY, },
1189-
{ DI_LISTBOX, {{47, 2}, {70,11}}, DIF_NONE, L"Matches" },
1189+
{ DI_LISTBOX, {{47, 2}, {70,11}}, DIF_LISTNOCLOSE, L"Matches" },
11901190
{ DI_TEXT, {{5, 11}, {0, 11}}, DIF_NONE, L"Status:" },
11911191
{ DI_EDIT, {{5, 12}, {70,12}}, DIF_READONLY, },
11921192
{ DI_TEXT, {{-1,13}, {0, 13}}, DIF_SEPARATOR, },
@@ -1350,6 +1350,26 @@ void regex_playground()
13501350
return update_test();
13511351
};
13521352

1353+
const auto update_selection = [&](size_t const Index)
1354+
{
1355+
if (Dlg->SendMessage(DM_GETFOCUS, 0, {}) != rp_list_matches)
1356+
return;
1357+
1358+
const auto& m = Match.Matches[Index];
1359+
1360+
EditorSelect Select
1361+
{
1362+
sizeof(Select),
1363+
BTYPE_STREAM,
1364+
0,
1365+
m.start,
1366+
m.end - m.start,
1367+
1
1368+
};
1369+
1370+
Dlg->SendMessage(DM_SETSELECTION, rp_edit_test, &Select);
1371+
};
1372+
13531373
switch (Msg)
13541374
{
13551375
case DN_CTLCOLORDLGITEM:
@@ -1380,6 +1400,12 @@ void regex_playground()
13801400
}
13811401
}
13821402
break;
1403+
1404+
case DN_LISTCHANGE:
1405+
if (Param1 == rp_list_matches)
1406+
update_selection(std::bit_cast<size_t>(Param2));
1407+
1408+
break;
13831409
}
13841410

13851411
return Dlg->DefProc(Msg, Param1, Param2);

far/vbuild.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6465
1+
6466

0 commit comments

Comments
 (0)