Skip to content

Commit

Permalink
new function ExMessager::AddMultiline() & tuning after #2576
Browse files Browse the repository at this point in the history
  • Loading branch information
akruphi committed Jan 4, 2025
1 parent 9fb2133 commit f5f8d2e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
14 changes: 5 additions & 9 deletions far2l/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,22 +312,18 @@ static int MainProcess(FARString strEditViewArg, FARString strDestName1, FARStri
if (tweaks & TWEAK_STATUS_SUPPORT_OSC52CLIP_SET) {
SetMessageHelp(L"Far2lGettingStarted");

std::wstring source_str = Msg::OSC52Confirm.CPtr();
std::vector<std::wstring> lines;
ExMessager em;
StrExplode(lines, source_str, L"\n", false);
for (const auto &current_line : lines) {
em.AddDup(current_line.c_str());
}
em.AddMultiline(Msg::OSC52Confirm);
em.AddDup(L"Yes");
em.AddDup(L"No");

if (em.Show(0, 2)) {
Opt.OSC52ClipSet = 0;
if (Opt.OSC52ClipSet != 0)
{ Opt.OSC52ClipSet = 0; cfgNeedSave = true; }
} else {
Opt.OSC52ClipSet = 1;
if (Opt.OSC52ClipSet != 1)
{ Opt.OSC52ClipSet = 1; cfgNeedSave = true; }
}
cfgNeedSave = true;
}
}

Expand Down
10 changes: 10 additions & 0 deletions far2l/src/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,16 @@ Messager &FN_NOINLINE ExMessager::AddDup(const wchar_t *v)
return *this;
}

Messager &FN_NOINLINE ExMessager::AddMultiline(const wchar_t *v, const wchar_t *divs)
{
std::wstring source_str = v;
std::vector<std::wstring> lines;
StrExplode(lines, source_str, divs, false);
for (const auto &current_line : lines)
AddDup(current_line.c_str());
return *this;
}

///////////////////////////////////

void GetMessagePosition(int &X1, int &Y1, int &X2, int &Y2)
Expand Down
3 changes: 3 additions & 0 deletions far2l/src/message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ struct ExMessager : Messager
Messager &AddFormat(FarLangMsg fmt, ...);
Messager &AddFormat(const wchar_t *fmt, ...);
Messager &AddDup(const wchar_t *v);
Messager &AddMultiline(const wchar_t *v, const wchar_t *divs = L"\n");
Messager &AddMultiline(FarLangMsg v, const wchar_t *divs = L"\n")
{ return AddMultiline(v.CPtr(), divs); };

private:
std::vector<FARString> _owneds;
Expand Down

0 comments on commit f5f8d2e

Please sign in to comment.