Skip to content

Commit

Permalink
Remove more fake dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Aug 1, 2021
1 parent 8459df5 commit 21c2022
Show file tree
Hide file tree
Showing 22 changed files with 204 additions and 252 deletions.
5 changes: 5 additions & 0 deletions far/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
--------------------------------------------------------------------------------
drkns 01.08.2021 15:34:13 +0100 - build 5864

1. Remove more fake dialogs.

--------------------------------------------------------------------------------
drkns 31.07.2021 14:22:45 +0100 - build 5863

Expand Down
11 changes: 4 additions & 7 deletions far/copy_progress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,10 @@ unsigned long long copy_progress::get_total_bytes() const

bool copy_progress::CheckEsc()
{
if (!m_IsCancelled)
{
if (CheckForEscSilent())
{
m_IsCancelled = ConfirmAbortOp() != 0;
}
}
if (m_IsCancelled)
return m_IsCancelled;

m_IsCancelled = CheckForEscAndConfirmAbort();
return m_IsCancelled;
}

Expand Down
2 changes: 1 addition & 1 deletion far/delete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static void ShellDeleteMsgImpl(string_view const Name, DEL_MODE Mode, ShellDelet

static void ShellDeleteMsg(string_view const Name, DEL_MODE Mode, ShellDelete::progress Files, int WipePercent)
{
if (CheckForEscSilent() && ConfirmAbortOp())
if (CheckForEscAndConfirmAbort())
cancel_operation();

ShellDeleteMsgImpl(Name, Mode, Files, WipePercent);
Expand Down
5 changes: 2 additions & 3 deletions far/dirinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,9 @@ static void ScanPluginDir(plugin_panel* hDirListPlugin, OPERATION_MODES OpMode,

span<PluginPanelItem> PanelData;

if (CheckForEscSilent())
if (CheckForEscAndConfirmAbort())
{
if (ConfirmAbortOp())
StopSearch = true;
StopSearch = true;
}

if (StopSearch || !Global->CtrlObject->Plugins->GetFindData(hDirListPlugin, PanelData, OPM_FIND | OpMode))
Expand Down
2 changes: 1 addition & 1 deletion far/dizlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void DizList::Read(string_view const Path, const string* DizName)
SetCursorType(false, 0);
PR_ReadingMsg();

if (CheckForEsc())
if (CheckForEscAndConfirmAbort())
break;
}

Expand Down
65 changes: 4 additions & 61 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;
editor_progress const Progress(msg(lng::MEditSearchTitle), format(msg(lng::MEditSearchingFor), QuotedStr), 0);
single_progress const Progress(msg(lng::MEditSearchTitle), format(msg(lng::MEditSearchingFor), QuotedStr), 0);
int StartLine = m_it_CurLine.Number();
SCOPED_ACTION(taskbar::indeterminate);
SCOPED_ACTION(wakeful);
Expand All @@ -3469,13 +3469,10 @@ bool Editor::Search(bool Next)
{
if (TimeCheck)
{
if (CheckForEscSilent())
if (CheckForEscAndConfirmAbort())
{
if (ConfirmAbortOp())
{
UserBreak = true;
break;
}
UserBreak = true;
break;
}

SetCursorType(false, -1);
Expand Down Expand Up @@ -6920,57 +6917,3 @@ void Editor::AutoDeleteColors()

m_AutoDeletedColors.clear();
}

namespace
{
enum
{
DlgW = 76,
DlgH = 6,
};

enum progress_items
{
pr_doublebox,
pr_label,
pr_progress,

pr_count
};
}

editor_progress::editor_progress(string_view const Title, string_view const Msg, size_t const Percent)
{
auto ProgressDlgItems = MakeDialogItems<progress_items::pr_count>(
{
{ DI_DOUBLEBOX, {{ 3, 1 }, { DlgW - 4, DlgH - 2 }}, DIF_NONE, Title, },
{ DI_TEXT, {{ 5, 2 }, { DlgW - 6, 2 }}, DIF_CENTERTEXT, Msg },
{ DI_TEXT, {{ 5, 3 }, { DlgW - 6, 3 }}, DIF_NONE, make_progressbar(DlgW - 10, Percent, true, true) },
});

m_Dialog = Dialog::create(ProgressDlgItems, [](Dialog* const Dlg, intptr_t const Msg, intptr_t const Param1, void* const Param2)
{
if (Msg == DN_RESIZECONSOLE)
{
COORD Position{ -1, -1 };
Dlg->SendMessage(DM_MOVEDIALOG, 1, &Position);
}

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

m_Dialog->SetPosition({ -1, -1, DlgW, DlgH });
m_Dialog->SetCanLoseFocus(true);
m_Dialog->Process();
}

editor_progress::~editor_progress()
{
if (m_Dialog)
m_Dialog->CloseDialog();
}

void editor_progress::update(size_t const Percent) const
{
m_Dialog->SendMessage(DM_SETTEXTPTR, progress_items::pr_progress, UNSAFE_CSTR(make_progressbar(DlgW - 10, Percent, true, true)));
}
12 changes: 0 additions & 12 deletions far/editor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,16 +405,4 @@ class EditorContainer
virtual Editor* GetEditor() = 0;
};

class editor_progress
{
public:
editor_progress(string_view Title, string_view Msg, size_t Percent);
~editor_progress();

void update(size_t Percent) const;

private:
dialog_ptr m_Dialog;
};

#endif // EDITOR_HPP_79DE09D5_8F9C_467E_A3BF_8E1BB34E4BD3
26 changes: 13 additions & 13 deletions far/farlang.templ.m4
Original file line number Diff line number Diff line change
Expand Up @@ -21396,19 +21396,19 @@ MPrintFilesTo
"Друк {0} файлаў на"
"Spausdinti {0} failus su"

MPreparingForPrinting
"Подготовка файлов к печати"
"Preparing files for printing"
"Připravuji soubory pro tisk"
"Vorbereiten der Druckaufträge"
"Fájlok előkészítése nyomtatáshoz"
"Przygotowuję plik(i) do drukowania"
"Preparando archivos para imprimir"
"Pripravujem súbory na tlač"
"Preparazione Dei Files Per La Stampa"
"Підготовка файлів до друку"
"Падрыхтоўка файлаў да друку"
"Ruošiu failus spausdinimui"
MPrintingFile
"Печать {0}"
"Printing {0}"
"Tisk {0}"
"Drucken {0}"
"Nyomtatás {0}"
"Druk {0}"
"Impresión {0}"
"Tlač {0}"
"Stampa {0}"
"Друк {0}"
"Друк {0}"
"Spausdinimas {0}"

MCannotEnumeratePrinters
"Не удалось получить список доступных принтеров"
Expand Down
18 changes: 7 additions & 11 deletions far/fileedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "scrbuf.hpp"
#include "savescr.hpp"
#include "filestr.hpp"
#include "TPreRedrawFunc.hpp"
#include "taskbar.hpp"
#include "interf.hpp"
#include "message.hpp"
Expand Down Expand Up @@ -1640,7 +1639,7 @@ bool FileEditor::LoadFile(const string& Name,int &UserBreak, error_state_ex& Err
LOGWARNING(L"GetSize({}): {}"sv, EditFile.GetName(), last_error());
}

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

const time_check TimeCheck;

Expand All @@ -1663,14 +1662,11 @@ bool FileEditor::LoadFile(const string& Name,int &UserBreak, error_state_ex& Err

if (TimeCheck)
{
if (CheckForEscSilent())
if (CheckForEscAndConfirmAbort())
{
if (ConfirmAbortOp())
{
UserBreak = 1;
EditFile.Close();
return false;
}
UserBreak = 1;
EditFile.Close();
return false;
}

SetCursorType(false, 0);
Expand Down Expand Up @@ -2040,7 +2036,7 @@ int FileEditor::SaveFile(const string& Name,int Ask, bool bSaveAs, error_state_e
if (!bSaveAs)
AddSignature = m_bAddSignature;

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

const time_check TimeCheck;

Expand Down Expand Up @@ -2423,7 +2419,7 @@ bool FileEditor::UpdateFileList() const

if (strPanelPath == strFilePath)
{
ActivePanel->Update(UPDATE_KEEP_SELECTION|UPDATE_DRAW_MESSAGE);
ActivePanel->Update(UPDATE_KEEP_SELECTION);
return true;
}

Expand Down
Loading

0 comments on commit 21c2022

Please sign in to comment.