88#include " PluginInterface.h"
99#include " Docking.h"
1010
11- using namespace std ;
12-
1311ConsoleDialog::ConsoleDialog ()
1412 : DockingDlgInterface(IDD_CONSOLE),
1513 m_data(new tTbData),
@@ -41,7 +39,7 @@ ConsoleDialog::~ConsoleDialog()
4139}
4240
4341
44- void ConsoleDialog::init (HINSTANCE hInst, NppData& nppData, ConsoleInterface* console)
42+ void ConsoleDialog::initDialog (HINSTANCE hInst, NppData& nppData, ConsoleInterface* console)
4543{
4644 DockingDlgInterface::init (hInst, nppData._nppHandle );
4745
@@ -69,7 +67,7 @@ void ConsoleDialog::init(HINSTANCE hInst, NppData& nppData, ConsoleInterface* co
6967
7068}
7169
72- BOOL ConsoleDialog::run_dlgProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
70+ BOOL CALLBACK ConsoleDialog::run_dlgProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
7371{
7472 switch (message)
7573 {
@@ -134,7 +132,6 @@ BOOL ConsoleDialog::run_dlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
134132 default :
135133 break ;
136134 }
137- break ;
138135 }
139136 break ;
140137 case WM_COMMAND:
@@ -146,7 +143,11 @@ BOOL ConsoleDialog::run_dlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM l
146143 }
147144 else
148145 {
149- m_console->stopStatement ();
146+ assert (m_console != NULL );
147+ if (m_console)
148+ {
149+ m_console->stopStatement ();
150+ }
150151 }
151152 // MessageBox(NULL, _T("Command") , _T("Python Command"), 0);
152153 return FALSE ;
@@ -196,11 +197,11 @@ void ConsoleDialog::historyPrevious()
196197 {
197198 if (m_changes.find (m_currentHistory) == m_changes.end ())
198199 {
199- m_changes.insert (pair<int , string>(m_currentHistory, string (buffer)));
200+ m_changes.insert (std:: pair<int , std:: string>(m_currentHistory, std:: string (buffer)));
200201 }
201202 else
202203 {
203- m_changes[m_currentHistory] = string (buffer);
204+ m_changes[m_currentHistory] = std:: string (buffer);
204205 }
205206 }
206207
@@ -236,11 +237,11 @@ void ConsoleDialog::historyNext()
236237 {
237238 if (m_changes.find (m_currentHistory) == m_changes.end ())
238239 {
239- m_changes.insert (pair<int , string>(m_currentHistory, string (buffer)));
240+ m_changes.insert (std:: pair<int , std:: string>(m_currentHistory, std:: string (buffer)));
240241 }
241242 else
242243 {
243- m_changes[m_currentHistory] = string (buffer);
244+ m_changes[m_currentHistory] = std:: string (buffer);
244245 }
245246 }
246247
@@ -276,7 +277,7 @@ void ConsoleDialog::historyAdd(const char *line)
276277{
277278 if (line && line[0 ])
278279 {
279- m_history.push_back (string (line));
280+ m_history.push_back (std:: string (line));
280281 m_currentHistory = m_history.size ();
281282 }
282283
@@ -314,11 +315,9 @@ LRESULT ConsoleDialog::run_inputWndProc(HWND hWnd, UINT message, WPARAM wParam,
314315 historyNext ();
315316 return FALSE ;
316317
317-
318318 default :
319319 return CallWindowProc (m_originalInputWndProc, hWnd, message, wParam, lParam);
320320 }
321- break ;
322321
323322 case WM_KEYUP:
324323 switch (wParam)
@@ -334,31 +333,36 @@ LRESULT ConsoleDialog::run_inputWndProc(HWND hWnd, UINT message, WPARAM wParam,
334333 default :
335334 return CallWindowProc (m_originalInputWndProc, hWnd, message, wParam, lParam);
336335 }
337- break ;
338336
339337 default :
340338 return CallWindowProc (m_originalInputWndProc, hWnd, message, wParam, lParam);
341339 }
342-
343340}
344341
345342void ConsoleDialog::runStatement ()
346343{
347- char buffer[1000 ];
348- GetWindowTextA (::GetDlgItem (_hSelf, IDC_INPUT), buffer, 1000 );
349- historyAdd (buffer);
350- writeText (m_prompt.size (), m_prompt.c_str ());
351- writeText (strlen (buffer), buffer);
352- writeText (1 , " \n " );
353- SetWindowTextA (::GetDlgItem (_hSelf, IDC_INPUT), " " );
354- m_console->runStatement (buffer);
355-
344+ assert (m_console != NULL );
345+ if (m_console)
346+ {
347+ char buffer[1000 ];
348+ GetWindowTextA (::GetDlgItem (_hSelf, IDC_INPUT), buffer, 1000 );
349+ historyAdd (buffer);
350+ writeText (m_prompt.size (), m_prompt.c_str ());
351+ writeText (strlen (buffer), buffer);
352+ writeText (1 , " \n " );
353+ SetWindowTextA (::GetDlgItem (_hSelf, IDC_INPUT), " " );
354+ m_console->runStatement (buffer);
355+ }
356356}
357357
358358
359359void ConsoleDialog::stopStatement ()
360360{
361- m_console->stopStatement ();
361+ assert (m_console != NULL );
362+ if (m_console)
363+ {
364+ m_console->stopStatement ();
365+ }
362366}
363367
364368
@@ -489,7 +493,7 @@ void ConsoleDialog::writeError(int length, const char *text)
489493
490494void ConsoleDialog::doDialog ()
491495{
492- if (!isCreated ())
496+ if (!isCreated ())
493497 {
494498 create (m_data);
495499
@@ -519,7 +523,7 @@ void ConsoleDialog::doDialog()
519523 callScintilla (SCI_COLOURISE, 0 , -1 );
520524 }
521525
522- display (true );
526+ display (true );
523527}
524528
525529void ConsoleDialog::hide ()
0 commit comments