Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
shmuz committed Jan 11, 2025
1 parent 47f4f63 commit 3b86cb5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 37 deletions.
34 changes: 14 additions & 20 deletions far/src/fileedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,26 +442,23 @@ void FileEditor::Init(
private:
Editor *editor;
public:
SmartLock() {editor=nullptr;}
~SmartLock() {if (editor) editor->Unlock();}

void Set(Editor *e) {editor=e; editor->Lock();}
SmartLock(Editor *e) : editor(e) { editor->Lock(); }
~SmartLock() { editor->Unlock(); }
};
SmartLock __smartlock;
SysErrorCode=0;
int BlankFileName=!StrCmp(Name,Msg::NewFileName);
//AY: флаг оповещающий закрытие редактора.
m_bClosing = false;
bEE_READ_Sent = false;
m_AddSignature = FB_NO;
m_editor = new Editor;
__smartlock.Set(m_editor);

m_editor = new(std::nothrow) Editor;
if (!m_editor)
{
ExitCode=XC_OPEN_ERROR;
return;
}
SCOPED_ACTION(SmartLock)(m_editor);

m_codepage = codepage;
m_editor->SetOwner(this);
Expand Down Expand Up @@ -1807,20 +1804,17 @@ int FileEditor::SaveFile(const wchar_t *Name,int Ask, bool bSaveAs, int TextForm
if (!m_editor->Flags.Check(FEDITOR_MODIFIED))
return SAVEFILE_SUCCESS;

if (Ask)
switch (Message(MSG_WARNING,3,&EditAskSaveId,Msg::EditTitle,Msg::EditAskSave,Msg::HYes,Msg::HNo,Msg::HCancel))
{
switch (Message(MSG_WARNING,3,&EditAskSaveId,Msg::EditTitle,Msg::EditAskSave,Msg::HYes,Msg::HNo,Msg::HCancel))
{
case -1:
case -2:
case 2: // Continue Edit
return SAVEFILE_CANCEL;
case 0: // Save
break;
case 1: // Not Save
m_editor->TextChanged(0); // 10.08.2000 skv: TextChanged() support;
return SAVEFILE_SUCCESS;
}
case -1:
case -2:
case 2: // Continue Edit
return SAVEFILE_CANCEL;
case 0: // Save
break;
case 1: // Not Save
m_editor->TextChanged(0); // 10.08.2000 skv: TextChanged() support;
return SAVEFILE_SUCCESS;
}
}

Expand Down
10 changes: 5 additions & 5 deletions far/src/macro/macro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ std::string GuidToString(const GUID& Guid)
}

// для диалога назначения клавиши
struct DlgParam
struct MacroDlgParam
{
bool Changed;
FarKey MacroKey;
Expand Down Expand Up @@ -487,7 +487,7 @@ bool KeyMacro::ProcessKey(FarKey dwKey, const INPUT_RECORD *Rec)
if (ctrldot||ctrlshiftdot) // признак конца записи?
{
m_InternalInput = 1;
DlgParam Param {false, 0, 0};
MacroDlgParam Param {false, 0, 0};
bool AssignRet = AssignMacroKey(&Param);

if (AssignRet && !Param.Changed && !m_RecCode.IsEmpty())
Expand Down Expand Up @@ -779,12 +779,12 @@ LONG_PTR WINAPI KeyMacro::AssignMacroDlgProc(HANDLE hDlg, int Msg, int Param1, L
FARString strKeyText;
static int Recurse;
static FarKey LastKey;
static DlgParam *KMParam;
static MacroDlgParam *KMParam;
bool KeyIsValid = false;

if (Msg == DN_INITDIALOG)
{
KMParam = reinterpret_cast<DlgParam*>(Param2);
KMParam = reinterpret_cast<MacroDlgParam*>(Param2);
LastKey = 0;
Recurse = 0;
// <Клавиши, которые не введешь в диалоге назначения>
Expand Down Expand Up @@ -935,7 +935,7 @@ LONG_PTR WINAPI KeyMacro::AssignMacroDlgProc(HANDLE hDlg, int Msg, int Param1, L
return DefDlgProc(hDlg, Msg, Param1, Param2);
}

bool KeyMacro::AssignMacroKey(DlgParam *Param)
bool KeyMacro::AssignMacroKey(MacroDlgParam *Param)
{
/*
+------ Define macro ------+
Expand Down
4 changes: 2 additions & 2 deletions far/src/macro/macro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct MacroPanelSelect {
const wchar_t *Item;
};

struct DlgParam;
struct MacroDlgParam;

class KeyMacro
{
Expand Down Expand Up @@ -100,7 +100,7 @@ class KeyMacro
static FARMACROSTATE GetExecutingState();
static bool GetMacroSettings(FarKey Key, DWORD &Flags, const wchar_t* Src, const wchar_t* Descr);

bool AssignMacroKey(DlgParam *Param);
bool AssignMacroKey(MacroDlgParam *Param);
void RestoreMacroChar() const;

static FARString m_RecCode;
Expand Down
7 changes: 0 additions & 7 deletions far/src/modal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Modal::Modal():
WriteKey(KEY_INVALID),
ExitCode(-1),
EndLoop(0)
{
}
Expand Down Expand Up @@ -128,12 +127,6 @@ void Modal::ClearDone()
}


int Modal::GetExitCode()
{
return(ExitCode);
}


void Modal::SetExitCode(int Code)
{
ExitCode=Code;
Expand Down
2 changes: 0 additions & 2 deletions far/src/modal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class Modal: public Frame
protected:
INPUT_RECORD ReadRec;
FARString strHelpTopic;
int ExitCode;
int EndLoop;

public:
Expand All @@ -58,7 +57,6 @@ class Modal: public Frame
virtual void GetDialogObjectsData() {};
int Done();
void ClearDone();
int GetExitCode();
virtual void SetExitCode(int Code);

virtual void Process();
Expand Down
1 change: 0 additions & 1 deletion far/src/plug/PluginA.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ typedef void (WINAPI *PLUGINGETGLOBALINFO)(GlobalInfo *gi);
class PluginA: public Plugin
{
private:
FARString strRootKey;
std::string mbRootKey;

PluginInfo PI;
Expand Down

0 comments on commit 3b86cb5

Please sign in to comment.