Skip to content

Commit

Permalink
Continue 5866
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Aug 4, 2021
1 parent 0ebe6df commit 99f912d
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 24 deletions.
5 changes: 5 additions & 0 deletions far/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
--------------------------------------------------------------------------------
drkns 04.08.2021 18:55:09 +0100 - build 5868

1. Continue 5866.

--------------------------------------------------------------------------------
drkns 03.08.2021 17:48:48 +0100 - build 5867

Expand Down
5 changes: 5 additions & 0 deletions far/disabled_warnings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#pragma warning(disable: 5052) // Keyword 'char8_t' was introduced in C++20 and requires use of the '/std:c++latest' command-line option
#endif

#ifdef _DEBUG
// Happens only after "Apply code changes"
#pragma warning(disable: 4599) // command line argument number number does not match precompiled header
#endif

#endif


Expand Down
7 changes: 5 additions & 2 deletions far/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3459,7 +3459,7 @@ bool Editor::Search(bool Next)
const auto strSearchStrLower = Case? strSearchStr : lower(strSearchStr);

const time_check TimeCheck;
single_progress const Progress(msg(lng::MEditSearchTitle), format(msg(lng::MEditSearchingFor), QuotedStr), 0);
std::optional<single_progress> Progress;
int StartLine = m_it_CurLine.Number();
SCOPED_ACTION(taskbar::indeterminate);
SCOPED_ACTION(wakeful);
Expand All @@ -3475,10 +3475,13 @@ bool Editor::Search(bool Next)
break;
}

if (!Progress)
Progress.emplace(msg(lng::MEditSearchTitle), format(msg(lng::MEditSearchingFor), QuotedStr), 0);

SetCursorType(false, -1);
const auto Total = FindAllReferences? Lines.size() : ReverseSearch? StartLine : Lines.size() - StartLine;
const auto Current = abs(CurPtr.Number() - StartLine);
Progress.update(Total > 0? Current * 100 / Total : 100);
Progress->update(Total > 0? Current * 100 / Total : 100);
taskbar::set_value(Current,Total);
}

Expand Down
15 changes: 10 additions & 5 deletions far/fileedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1639,7 +1639,7 @@ bool FileEditor::LoadFile(const string& Name,int &UserBreak, error_state_ex& Err
LOGWARNING(L"GetSize({}): {}"sv, EditFile.GetName(), last_error());
}

single_progress const Progress(msg(lng::MEditTitle), format(msg(lng::MEditReading), Name), 0);
std::optional<single_progress> Progress;

const time_check TimeCheck;

Expand Down Expand Up @@ -1669,6 +1669,9 @@ bool FileEditor::LoadFile(const string& Name,int &UserBreak, error_state_ex& Err
return false;
}

if (!Progress)
Progress.emplace(msg(lng::MEditTitle), format(msg(lng::MEditReading), Name), 0);

SetCursorType(false, 0);
const auto CurPos = EditFile.GetPointer();
auto Percent = FileSize? CurPos * 100 / FileSize : 0;
Expand All @@ -1685,7 +1688,7 @@ bool FileEditor::LoadFile(const string& Name,int &UserBreak, error_state_ex& Err
Percent = FileSize? std::min(CurPos * 100 / FileSize, 100ull) : 100;
}

Progress.update(Percent);
Progress->update(Percent);
}

if (m_editor->GlobalEOL == eol::none && Str.Eol != eol::none)
Expand Down Expand Up @@ -2036,8 +2039,7 @@ int FileEditor::SaveFile(const string& Name,int Ask, bool bSaveAs, error_state_e
if (!bSaveAs)
AddSignature = m_bAddSignature;

single_progress const Progress(msg(lng::MEditTitle), format(msg(lng::MEditSaving), Name), 0);

std::optional<single_progress> Progress;
const time_check TimeCheck;

// We've already validated the codepage above
Expand All @@ -2051,7 +2053,10 @@ int FileEditor::SaveFile(const string& Name,int Ask, bool bSaveAs, error_state_e

if (TimeCheck)
{
Progress.update(LineNumber * 100 / m_editor->Lines.size());
if (!Progress)
Progress.emplace(msg(lng::MEditTitle), format(msg(lng::MEditSaving), Name), 0);

Progress->update(LineNumber * 100 / m_editor->Lines.size());
}

const auto& SaveStr = Line.GetString();
Expand Down
14 changes: 8 additions & 6 deletions far/filelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5074,25 +5074,27 @@ void FileList::CountDirSize(bool IsRealNames)
//Рефреш текущему времени для фильтра перед началом операции
m_Filter->UpdateCurrentTime();

time_check TimeCheck;

struct
{
unsigned long long Items;
unsigned long long Size;
}
Total{};

dirinfo_progress const DirinfoProgress(msg(lng::MDirInfoViewTitle));
time_check TimeCheck;
std::optional<dirinfo_progress> DirinfoProgress;

const auto DirInfoCallback = [&](string_view const Name, unsigned long long const ItemsCount, unsigned long long const Size)
{
if (!TimeCheck)
return;

DirinfoProgress.set_name(Name);
DirinfoProgress.set_count(Total.Items + ItemsCount);
DirinfoProgress.set_size(Total.Size + Size);
if (!DirinfoProgress)
DirinfoProgress.emplace(msg(lng::MDirInfoViewTitle));

DirinfoProgress->set_name(Name);
DirinfoProgress->set_count(Total.Items + ItemsCount);
DirinfoProgress->set_size(Total.Size + Size);
};

for (auto& i: m_ListData)
Expand Down
11 changes: 7 additions & 4 deletions far/plugapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1661,16 +1661,19 @@ intptr_t WINAPI apiGetPluginDirList(const UUID* PluginId, HANDLE hPlugin, const
// BUGBUG This is API, shouldn't the callback be empty?

const time_check TimeCheck;
dirinfo_progress const DirinfoProgress(msg(lng::MPreparingList));
std::optional<dirinfo_progress> DirinfoProgress;

const auto DirInfoCallback = [&](string_view const Name, unsigned long long const ItemsCount, unsigned long long const Size)
{
if (!TimeCheck)
return;

DirinfoProgress.set_name(Name);
DirinfoProgress.set_count(ItemsCount);
DirinfoProgress.set_size(Size);
if (!DirinfoProgress)
DirinfoProgress.emplace(msg(lng::MPreparingList));

DirinfoProgress->set_name(Name);
DirinfoProgress->set_count(ItemsCount);
DirinfoProgress->set_size(Size);
};

const auto Result = GetPluginDirList(UuidToPlugin(PluginId), hPlugin, Dir, nullptr, *Items, DirInfoCallback);
Expand Down
11 changes: 7 additions & 4 deletions far/qview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,16 +401,19 @@ void QuickView::ShowFile(string_view const FileName, const UserDataItem* const U
if (hDirPlugin || os::fs::is_directory(strCurFileName))
{
const time_check TimeCheck;
dirinfo_progress const DirinfoProgress(msg(lng::MQuickViewTitle));
std::optional<dirinfo_progress> DirinfoProgress;

const auto DirInfoCallback = [&](string_view const Name, unsigned long long const ItemsCount, unsigned long long const Size)
{
if (!TimeCheck)
return;

DirinfoProgress.set_name(Name);
DirinfoProgress.set_count(ItemsCount);
DirinfoProgress.set_size(Size);
if (!DirinfoProgress)
DirinfoProgress.emplace(msg(lng::MQuickViewTitle));

DirinfoProgress->set_name(Name);
DirinfoProgress->set_count(ItemsCount);
DirinfoProgress->set_size(Size);
};

if (SameFile && !hDirPlugin)
Expand Down
1 change: 1 addition & 0 deletions far/scrobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ void ScreenObjectWithShadow::Shadow(bool Full)
{
ShadowSaveScr = std::make_unique<SaveScreen>(rectangle{ 0, 0, ScrX, ScrY });
MakeShadow({ 0, 0, ScrX, ScrY });
DropShadow(m_Where);
}
}
else
Expand Down
2 changes: 2 additions & 0 deletions far/stddlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,8 @@ void progress_impl::init(span<DialogItemEx> const Items, rectangle const Positio
m_Dialog->SetPosition(Position);
m_Dialog->SetCanLoseFocus(true);
m_Dialog->Process();

Global->WindowManager->PluginCommit();
}

struct single_progress_detail
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5867
5868
7 changes: 5 additions & 2 deletions far/viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3376,7 +3376,7 @@ void Viewer::Search(int Next,const Manager::Key* FirstChar)
SCOPED_ACTION(taskbar::indeterminate);
SetCursorType(false, 0);

single_progress const Progress(msg(lng::MViewSearchTitle), concat(msg(SearchHex? lng::MViewSearchingHex : lng::MViewSearchingFor), L' ', strMsgStr), 0);
std::optional<single_progress> Progress;
const time_check TimeCheck;

for (;;)
Expand Down Expand Up @@ -3452,7 +3452,10 @@ void Viewer::Search(int Next,const Manager::Key* FirstChar)
percent = static_cast<int>(done*100/total);
}

Progress.update(percent);
if (!Progress)
Progress.emplace(msg(lng::MViewSearchTitle), concat(msg(SearchHex? lng::MViewSearchingHex : lng::MViewSearchingFor), L' ', strMsgStr), 0);

Progress->update(percent);
}
}
}
Expand Down

0 comments on commit 99f912d

Please sign in to comment.