Skip to content

Commit

Permalink
1. рефакторинг: обработка нажатий клавиш.
Browse files Browse the repository at this point in the history
  • Loading branch information
zg0 committed Mar 19, 2015
1 parent 3c571d5 commit fd74dcf
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 15 deletions.
6 changes: 5 additions & 1 deletion far/changelog
@@ -1,4 +1,8 @@
w17 19.03.2015 13:08:26 +0300 - build 4317
zg 19.03.2015 19:12:19 +0200 - build 4318

1. рефакторинг: обработка нажатий клавиш.

w17 19.03.2015 13:08:26 +0300 - build 4317

1. M#2971: Падение при использовании регулярного выражения с большим количеством групп

Expand Down
14 changes: 7 additions & 7 deletions far/dialog.cpp
Expand Up @@ -2513,11 +2513,10 @@ int Dialog::ProcessKey(const Manager::Key& Key)

if (LocalKey == KEY_KILLFOCUS || LocalKey == KEY_GOTFOCUS)
{
INPUT_RECORD rec;
if (KeyToInputRecord(LocalKey,&rec))
{
DlgProc(DN_INPUT,0,&rec);
}
assert(Key.IsEvent());
INPUT_RECORD rec=Key.Event();
assert(rec.EventType == FOCUS_EVENT);
DlgProc(DN_INPUT,0,&rec);

return FALSE;
}
Expand Down Expand Up @@ -2554,8 +2553,9 @@ int Dialog::ProcessKey(const Manager::Key& Key)
LocalKey = KEY_END;
}
}
INPUT_RECORD rec;
if (KeyToInputRecord(LocalKey,&rec) && DlgProc(DN_CONTROLINPUT,m_FocusPos,&rec))
assert(Key.IsEvent());
INPUT_RECORD rec=Key.Event();
if (DlgProc(DN_CONTROLINPUT,m_FocusPos,&rec))
return TRUE;
}

Expand Down
3 changes: 2 additions & 1 deletion far/fileedit.cpp
Expand Up @@ -955,7 +955,8 @@ int FileEditor::ReProcessKey(const Manager::Key& Key,int CalledFromControl)
_SVS(if (Global->CtrlObject->Macro.IsRecording() == MACROSTATE_RECORDING_COMMON || Global->CtrlObject->Macro.IsExecuting() == MACROSTATE_EXECUTING_COMMON))
_SVS(SysLog(L"%d !!!! Global->CtrlObject->Macro.GetState() != MACROSTATE_NOMACRO !!!!",__LINE__));

if (Key.IsEvent()&&LocalKey!=KEY_IDLE&&Key.Event().EventType!=0)
assert(Key.IsEvent());
if (LocalKey!=KEY_IDLE&&Key.Event().EventType!=0)
{
ProcessedNext=!ProcessEditorInput(Key.Event());
}
Expand Down
4 changes: 2 additions & 2 deletions far/keyboard.cpp
Expand Up @@ -490,10 +490,10 @@ int InputRecordToKey(const INPUT_RECORD *r)
}


int KeyToInputRecord(int Key, INPUT_RECORD *Rec)
bool KeyToInputRecord(int Key, INPUT_RECORD *Rec)
{
int VirtKey, ControlState;
return TranslateKeyToVK(Key, VirtKey, ControlState, Rec);
return TranslateKeyToVK(Key, VirtKey, ControlState, Rec) != 0;
}

//BUGBUG - âðåìåííàÿ çàòû÷êà
Expand Down
2 changes: 1 addition & 1 deletion far/keyboard.hpp
Expand Up @@ -87,7 +87,7 @@ bool InputRecordToText(const INPUT_RECORD *Rec, string &strKeyText);
bool KeyToText(int Key, string &strKeyText);
bool KeyToLocalizedText(int Key, string &strKeyText);
int InputRecordToKey(const INPUT_RECORD *Rec);
int KeyToInputRecord(int Key, INPUT_RECORD *Rec);
bool KeyToInputRecord(int Key, INPUT_RECORD *Rec);
void ProcessKeyToInputRecord(int Key, unsigned int dwControlState, INPUT_RECORD *Rec);
void FarKeyToInputRecord(const FarKey& Key,INPUT_RECORD* Rec);
DWORD GetInputRecord(INPUT_RECORD *rec,bool ExcludeMacro=false,bool ProcessMouse=false,bool AllowSynchro=true);
Expand Down
6 changes: 6 additions & 0 deletions far/manager.cpp
Expand Up @@ -112,6 +112,12 @@ class MessageStop: public Manager::MessageAbstract
virtual bool Process(void) override { return false; }
};

Manager::Key::Key(int Key): m_Event(), m_FarKey(Key), m_EventFilled(false)
{
m_EventFilled = KeyToInputRecord(m_FarKey, &m_Event);
assert(m_EventFilled);
}

Manager::Manager():
m_currentWindow(nullptr),
EndLoop(false),
Expand Down
2 changes: 1 addition & 1 deletion far/manager.hpp
Expand Up @@ -48,7 +48,7 @@ class Manager: noncopyable
bool m_EventFilled;
public:
Key(): m_Event(), m_FarKey(0), m_EventFilled(false) {}
explicit Key(int Key): m_Event(), m_FarKey(Key), m_EventFilled(false) {}
explicit Key(int Key);
Key(int Key, const INPUT_RECORD& Event): m_Event(Event), m_FarKey(Key), m_EventFilled(true) {}
const INPUT_RECORD& Event(void)const {return m_Event;}
bool IsEvent(void)const {return m_EventFilled;}
Expand Down
2 changes: 1 addition & 1 deletion far/plugapi.cpp
Expand Up @@ -3060,7 +3060,7 @@ BOOL WINAPI apiKeyNameToInputRecord(const wchar_t *Name, INPUT_RECORD* RecKey) n
try
{
int Key = KeyNameToKey(Name);
return Key > 0 ? KeyToInputRecord(Key, RecKey) != 0 : FALSE;
return Key > 0 ? KeyToInputRecord(Key, RecKey) : FALSE;
}
catch (...)
{
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
@@ -1 +1 @@
m4_define(BUILD,4317)m4_dnl
m4_define(BUILD,4318)m4_dnl

0 comments on commit fd74dcf

Please sign in to comment.