@@ -3526,10 +3526,7 @@ namespace
35263526
35273527 void add_item (FindCoord FoundCoords, string_view ItemText)
35283528 {
3529- menu_item_ex Item{ far::format (L" {:{}}{:{}}{}" sv,
3530- FoundCoords.Line + 1 , m_LineNumColumnMaxWidth,
3531- FoundCoords.Pos + 1 , m_FoundPosColumnMaxWidth,
3532- ItemText) };
3529+ menu_item_ex Item{ string{ ItemText } };
35333530 Item.Annotations .emplace_back (FoundCoords.Pos , segment::length_tag{ FoundCoords.SearchLen });
35343531 Item.ComplexUserData = FoundCoords;
35353532 m_Menu->AddItem (Item);
@@ -3554,25 +3551,39 @@ namespace
35543551 m_Menu->SetHelp (L" FindAllMenu" sv);
35553552 m_Menu->SetId (EditorFindAllListId);
35563553
3557- const short LineNumColumnWidth{ radix10_formatted_width (m_MaxLineNum + 1 ) };
3558- const short FoundPosColumnWidth{ radix10_formatted_width (m_MaxFoundPos + 1 ) };
3559- const short LineNumColumnStart{ static_cast <short >(m_LineNumColumnMaxWidth - LineNumColumnWidth) };
3560- const short FoundPosColumnStart{ static_cast <short >(m_LineNumColumnMaxWidth + m_FoundPosColumnMaxWidth - FoundPosColumnWidth) };
3561- const short ItemTextStart{ static_cast <short >(m_LineNumColumnMaxWidth + m_FoundPosColumnMaxWidth) };
3562- m_Menu->SetFixedColumns (
3554+ const auto LineNumColumnWidth{ radix10_formatted_width (m_MaxLineNum + 1 ) };
3555+ const auto FoundPosColumnWidth{ radix10_formatted_width (m_MaxFoundPos + 1 ) };
3556+ m_Menu->ListBox ().RegisterFixedColumnsProvider (
35633557 {
35643558 {
3565- .TextSegment { LineNumColumnStart, segment::length_tag{ LineNumColumnWidth } } ,
3559+ .MaxWidth = LineNumColumnWidth,
35663560 .CurrentWidth = LineNumColumnWidth,
3567- .Separator = BoxSymbols[BS_V1]
3561+ .Separator = BoxSymbols[BS_V1],
3562+ .ColumnId = 0 ,
35683563 },
35693564 {
3570- .TextSegment { FoundPosColumnStart, segment::length_tag{ FoundPosColumnWidth } } ,
3565+ .MaxWidth = FoundPosColumnWidth,
35713566 .CurrentWidth = FoundPosColumnWidth,
3572- .Separator = BoxSymbols[BS_V1]
3567+ .Separator = BoxSymbols[BS_V1],
3568+ .ColumnId = 1 ,
35733569 },
35743570 },
3575- segment::ray (ItemTextStart)
3571+ [](const menu_item_ex& Item, const VMenu::fixed_column_t & Column)
3572+ {
3573+ if (const auto * Coord{ std::any_cast<FindCoord>(&Item.ComplexUserData ) })
3574+ {
3575+ switch (Column.ColumnId )
3576+ {
3577+ case 0 : // Line Number
3578+ return far::format (L" {:{}}" sv, Coord->Line + 1 , Column.MaxWidth );
3579+
3580+ case 1 : // Found Position
3581+ return far::format (L" {:{}}" sv, Coord->Pos + 1 , Column.MaxWidth );
3582+ }
3583+ }
3584+
3585+ return string{};
3586+ }
35763587 );
35773588 m_Menu->ListBox ().RegisterExtendedDataProvider (
35783589 [](const menu_item_ex& Item, VMenu::extended_item_data& ExtendedData)
@@ -4022,8 +4033,11 @@ void Editor::DoSearchReplace(const SearchReplaceDisposition Disposition)
40224033 if (SelectedPos == -1 )
40234034 break ;
40244035
4025- SelectFoundPattern (*FindAllList->m_Menu ->GetComplexUserDataPtr <FindCoord>(SelectedPos));
4026- Refresh ();
4036+ if (const auto * Coord{ FindAllList->m_Menu ->GetComplexUserDataPtr <FindCoord>(SelectedPos) })
4037+ {
4038+ SelectFoundPattern (*Coord);
4039+ Refresh ();
4040+ }
40274041 }
40284042 break ;
40294043
@@ -4087,8 +4101,11 @@ void Editor::DoSearchReplace(const SearchReplaceDisposition Disposition)
40874101
40884102 if (ExitCode >= 0 )
40894103 {
4090- SelectFoundPattern (*FindAllList->m_Menu ->GetComplexUserDataPtr <FindCoord>(ExitCode));
4091- Show ();
4104+ if (const auto * Coord{ FindAllList->m_Menu ->GetComplexUserDataPtr <FindCoord>(ExitCode) })
4105+ {
4106+ SelectFoundPattern (*Coord);
4107+ Show ();
4108+ }
40924109 }
40934110 }
40944111
@@ -4138,26 +4155,29 @@ void Editor::SaveFoundItemsToNewEditor(const VMenu& ListBox, const bool Matching
41384155 {
41394156 if (Item.Flags & FilterFlags) continue ;
41404157
4141- const auto ThisEditorCoord{ std::any_cast<FindCoord>(Item.ComplexUserData ) };
4158+ const auto * ThisEditorCoord{ std::any_cast<FindCoord>(&Item.ComplexUserData ) };
4159+ if (!ThisEditorCoord) continue ;
41424160
4143- if (ThisEditorCoord. Line != ThisEditorLastLine)
4161+ if (ThisEditorCoord-> Line != ThisEditorLastLine)
41444162 {
4145- ThisEditorLastLine = ThisEditorCoord. Line ;
4163+ ThisEditorLastLine = ThisEditorCoord-> Line ;
41464164
4147- const auto CurString{ GetStringByNumber (ThisEditorCoord. Line ) };
4165+ const auto CurString{ GetStringByNumber (ThisEditorCoord-> Line ) };
41484166 const auto NewEditorLine{ NewEditor.InsertString (CurString->GetString (), NewEditor.LastLine ()) };
41494167 NewEditorLine->SetEOL (CurString->GetEOL ());
41504168 }
41514169
41524170 if (static_cast <intptr_t >(Index) == ExitCode)
41534171 {
4154- const auto CurrentFoundCoord{ *ListBox.GetComplexUserDataPtr <const FindCoord>(ExitCode) };
4155- NewEditorFoundCoord =
4172+ if (const auto * CurrentFoundCoord{ ListBox.GetComplexUserDataPtr <const FindCoord>(ExitCode) })
41564173 {
4157- .Line = std::prev (NewEditor.LastLine ()).Number (),
4158- .Pos = CurrentFoundCoord.Pos ,
4159- .SearchLen = CurrentFoundCoord.SearchLen
4160- };
4174+ NewEditorFoundCoord =
4175+ {
4176+ .Line = std::prev (NewEditor.LastLine ()).Number (),
4177+ .Pos = CurrentFoundCoord->Pos ,
4178+ .SearchLen = CurrentFoundCoord->SearchLen
4179+ };
4180+ }
41614181 }
41624182 }
41634183
0 commit comments