Skip to content

Commit

Permalink
Partial revert of 6423 (4610fb5)
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Feb 1, 2025
1 parent 5f98e7d commit 4bbecc2
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 13 deletions.
5 changes: 5 additions & 0 deletions far/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
--------------------------------------------------------------------------------
drkns 2025-02-01 02:49:37+00:00 - build 6426

1. Partial revert of 6423 (4610fb5).

--------------------------------------------------------------------------------
drkns 2025-02-01 02:10:34+00:00 - build 6425

Expand Down
2 changes: 1 addition & 1 deletion far/filefilterparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ bool FileFilterConfig(FileFilterParams& Filter, bool ColorConfig)
{lng::MHighlightFileName4, {}},
};

const auto ColumnSize = msg(std::ranges::max_element(NameLabels, {}, [](auto const& i) { return msg(i.first).size(); })->first).size() + 1;
const auto ColumnSize = std::ranges::fold_left(NameLabels, 0uz, [](size_t const Value, auto const& i){ return std::max(Value, msg(i.first).size()); }) + 1;

for (auto& [LngId, Label]: NameLabels)
{
Expand Down
2 changes: 1 addition & 1 deletion far/filetype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ static auto FillFileTypesMenu(VMenu2* TypesMenu, int MenuPos)
Data.emplace_back(std::move(Item));
}

const auto MaxElementSize = std::ranges::max_element(Data, {}, [](data_item const& i) { return i.Description.size(); })->Description.size();
const auto MaxElementSize = std::ranges::fold_left(Data, 0uz, [](size_t const Value, data_item const & i){ return std::max(Value, i.Description.size()); });

TypesMenu->clear();

Expand Down
3 changes: 2 additions & 1 deletion far/language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "platform.fs.hpp"

// Common:
#include "common/function_traits.hpp"
#include "common/scope_exit.hpp"
#include "common/string_utils.hpp"

Expand Down Expand Up @@ -178,7 +179,7 @@ static string SelectLanguage(bool HelpLanguage, string_view const Current)
Languages.try_emplace(LangFile.Name, LangFile.Description);
}

const auto MaxNameLength = std::ranges::max_element(Languages, {}, [](const auto& i){ return i.first.size(); })->first.size();
const auto MaxNameLength = std::ranges::fold_left(Languages, 0uz, [](size_t const Value, const auto& i){ return std::max(Value, i.first.size()); });

for (const auto& [Name, Description]: Languages)
{
Expand Down
2 changes: 1 addition & 1 deletion far/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ window_ptr Manager::WindowMenu()
}
}

const auto TypesWidth = std::get<0>(*std::ranges::max_element(Data, {}, [](auto const& i){ return std::get<0>(i).size(); })).size();
const auto TypesWidth = std::ranges::fold_left(Data, 0uz, [](size_t const Value, auto const& i){ return std::max(Value, std::get<0>(i).size()); });

const auto ModalMenu = VMenu2::create(msg(lng::MScreensTitle), {}, ScrY - 4);
ModalMenu->SetHelp(L"ScrSwitch"sv);
Expand Down
2 changes: 1 addition & 1 deletion far/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ static message_result MessageImpl(
}
}

auto MaxLength = !Strings.empty()? std::ranges::max_element(Strings, {}, [](string const& i) { return i.size(); })->size() : 0;
auto MaxLength = !Strings.empty()? std::ranges::fold_left(Strings, 0uz, [](size_t const Value, string const& i){ return std::max(Value, i.size()); }) : 0;

string strClipText;

Expand Down
2 changes: 1 addition & 1 deletion far/panelmix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ string FormatStr_Size(
lng::MListFolder,
};

const auto LabelSize = msg(*std::ranges::max_element(FolderLabels, {}, [](lng const Id){ return msg(Id).size(); })).size();
const auto LabelSize = std::ranges::fold_left(FolderLabels, 0uz, [](size_t const Value, lng const Id) { return std::max(Value, msg(Id).size()); });

string TypeName;

Expand Down
2 changes: 1 addition & 1 deletion far/plist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void ShowProcessList()
return false;
}

const auto MaxPid = std::ranges::max_element(Info.Windows, {}, &ProcInfo::proc_item::Pid)->Pid;
const auto MaxPid = std::ranges::fold_left(Info.Windows, DWORD{}, [](DWORD const Value, auto const& Item) { return std::max(Value, Item.Pid); });
const auto PidWidth = static_cast<size_t>(std::log10(MaxPid)) + 1;

for (const auto& i: Info.Windows)
Expand Down
4 changes: 2 additions & 2 deletions far/qview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void QuickView::DisplayObject()

if (m_DirectoryScanStatus == scan_status::real_ok || m_DirectoryScanStatus == scan_status::plugin_ok)
{
static constexpr lng TableLabels[]
static const lng TableLabels[] =
{
lng::MQuickViewFolders,
lng::MQuickViewFiles,
Expand All @@ -227,7 +227,7 @@ void QuickView::DisplayObject()
lng::MQuickViewSlack,
};

const auto ColumnSize = msg(*std::ranges::max_element(TableLabels, {}, [](lng const Id) { return msg(Id).size(); })).size() + 1;
const auto ColumnSize = std::ranges::fold_left(TableLabels, 0uz, [](size_t const Value, lng const Id) { return std::max(Value, msg(Id).size()); }) + 1;

const auto iColor = uncomplete_dirscan? COL_PANELHIGHLIGHTTEXT : COL_PANELINFOTEXT;
const auto prefix = uncomplete_dirscan? L"~"sv : L""sv;
Expand Down
2 changes: 1 addition & 1 deletion far/strmix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1776,7 +1776,7 @@ TEST_CASE("xwcsncpy")
{ L"12345"sv, },
};

const auto MaxBufferSize = std::ranges::max_element(Tests, {}, [](auto const& Item) { return Item.Src.size(); })->Src.size() + 1;
const auto MaxBufferSize = std::ranges::fold_left(Tests, 0uz, [](size_t const Value, auto const& Item){ return std::max(Value, Item.Src.size()); }) + 1;

for (const auto BufferSize: std::views::iota(0uz, MaxBufferSize + 1))
{
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6425
6426
5 changes: 4 additions & 1 deletion far/viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2010,7 +2010,10 @@ bool Viewer::process_key(const Manager::Key& Key)
// Перейти на конец строк
if (ViewFile)
{
const size_t MaxLen = std::ranges::max_element(Strings, {}, [](const ViewerString& i){ return i.Data.size(); })->Data.size();
const size_t MaxLen = std::ranges::fold_left(Strings, 0uz, [](size_t Value, const ViewerString& i)
{
return std::max(Value, i.Data.size());
});
LeftPos = (MaxLen > static_cast<size_t>(ScrollbarAdjustedWidth))? MaxLen - ScrollbarAdjustedWidth : 0;
Show();
}
Expand Down
5 changes: 4 additions & 1 deletion far/vmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3389,7 +3389,10 @@ std::vector<string> VMenu::AddHotkeys(std::span<menu_item> const MenuItems)
{
std::vector<string> Result(MenuItems.size());

const size_t MaxLength = std::ranges::max_element(MenuItems, {}, [](menu_item const& i){ return i.Name.size(); })->Name.size();
const size_t MaxLength = std::ranges::fold_left(MenuItems, 0uz, [](size_t Value, const auto& i)
{
return std::max(Value, i.Name.size());
});

for (const auto& [Item, Str]: zip(MenuItems, Result))
{
Expand Down

0 comments on commit 4bbecc2

Please sign in to comment.