Skip to content

Commit

Permalink
AcceleratorTo now remembers which plugin called it
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Jun 16, 2011
1 parent 24d7440 commit 9657606
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc.h
Expand Up @@ -1310,6 +1310,7 @@ class CMUSHclientDoc : public CDocument
map<long, WORD> m_AcceleratorToCommandMap; // command to send for accelerator
map<WORD, string> m_CommandToMacroMap; // what that command does
map<WORD, short> m_CommandToSendToMap; // where it goes (eg. 0 = world, 1 = command etc.)
map<WORD, string> m_CommandToPluginMap; // what plugin it belongs to
HACCEL m_accelerator;

// for mapping colours to colours
Expand Down
6 changes: 6 additions & 0 deletions scripting/methods/methods_accelerators.cpp
Expand Up @@ -133,6 +133,12 @@ WORD key;
// and where to send it
m_CommandToSendToMap [command] = SendTo;

// remember which plugin did it
m_CommandToPluginMap [command].empty ();

if (m_CurrentPlugin)
m_CommandToPluginMap [command] = m_CurrentPlugin->m_strID;

} // end of having something to do (ie. not deleting accelerator)

// create new handle
Expand Down
7 changes: 7 additions & 0 deletions sendvw.cpp
Expand Up @@ -2535,6 +2535,11 @@ void CSendView::OnAcceleratorCommand (UINT nID)
CString strExtraOutput;
pDoc->m_iCurrentActionSource = eUserAccelerator;

CPlugin * pSavedPlugin = pDoc->m_CurrentPlugin;

// which plugin wanted it
pDoc->m_CurrentPlugin = pDoc->GetPlugin (pDoc->m_CommandToPluginMap [nID].c_str ());

// ok let's do it now
pDoc->SendTo (pDoc->m_CommandToSendToMap [nID],
sCommand.c_str (),
Expand All @@ -2545,6 +2550,8 @@ void CSendView::OnAcceleratorCommand (UINT nID)
strExtraOutput // if we sent to output, it goes here
);

pDoc->m_CurrentPlugin = pSavedPlugin;

// display any stuff sent to output window

if (!strExtraOutput.IsEmpty ())
Expand Down

0 comments on commit 9657606

Please sign in to comment.