@@ -79,14 +79,18 @@ ConsoleDialog::~ConsoleDialog()
7979
8080}
8181
82+ WNDPROC ConsoleDialog::s_originalScintillaWndProc;
83+
8284
8385void ConsoleDialog::initDialog (HINSTANCE hInst, NppData& nppData, ConsoleInterface* console)
8486{
8587 DockingDlgInterface::init (hInst, nppData._nppHandle );
8688
8789 // Window::init(hInst, nppData._nppHandle);
8890 createOutputWindow (nppData._nppHandle );
89- m_console = console;
91+
92+
93+ m_console = console;
9094 m_hContext = CreatePopupMenu ();
9195 MENUITEMINFO mi;
9296 mi.cbSize = sizeof (mi);
@@ -106,6 +110,10 @@ void ConsoleDialog::initDialog(HINSTANCE hInst, NppData& nppData, ConsoleInterfa
106110 mi.dwTypeData = _T (" Clear" );
107111 InsertMenuItem (m_hContext, 3 , TRUE , &mi);
108112
113+ mi.wID = 4 ;
114+ mi.dwTypeData = _T (" To Input" );
115+ InsertMenuItem (m_hContext, 4 , TRUE , &mi);
116+
109117}
110118
111119BOOL CALLBACK ConsoleDialog::run_dlgProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
@@ -127,8 +135,10 @@ BOOL CALLBACK ConsoleDialog::run_dlgProc(HWND hWnd, UINT message, WPARAM wParam,
127135 // Subclass the Input box
128136 ::SetWindowLongPtr (::GetDlgItem(_hSelf, IDC_INPUT), GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this ));
129137 m_originalInputWndProc = reinterpret_cast <WNDPROC>(::SetWindowLongPtr (::GetDlgItem (_hSelf, IDC_INPUT), GWLP_WNDPROC, reinterpret_cast <LONG_PTR>(ConsoleDialog::inputWndProc)));
130-
131- return TRUE ;
138+ // Subclass Scintilla
139+ s_originalScintillaWndProc = reinterpret_cast <WNDPROC>(SetWindowLongPtr (m_scintilla, GWLP_WNDPROC, reinterpret_cast <LONG_PTR>(&ConsoleDialog::scintillaWndProc)));
140+ ::SetFocus (m_hInput);
141+ return FALSE ;
132142 }
133143 case WM_SIZE:
134144 MoveWindow (m_scintilla, 0 , 0 , LOWORD (lParam), HIWORD (lParam)-30 , TRUE );
@@ -176,6 +186,10 @@ BOOL CALLBACK ConsoleDialog::run_dlgProc(HWND hWnd, UINT message, WPARAM wParam,
176186 clearText ();
177187 break ;
178188
189+ case 4 : // To input (TODO: TEST only!)
190+ giveInputFocus ();
191+ break ;
192+
179193 default :
180194 break ;
181195 }
@@ -201,6 +215,24 @@ BOOL CALLBACK ConsoleDialog::run_dlgProc(HWND hWnd, UINT message, WPARAM wParam,
201215 }
202216 break ;
203217
218+ case WM_SETFOCUS:
219+ // giveInputFocus();
220+ OutputDebugString (_T (" ConsoleDialog SetFocus\r\n " ));
221+ return FALSE ;
222+
223+ case WM_ACTIVATE:
224+ if (wParam == WA_ACTIVE)
225+ {
226+ OutputDebugString (_T (" ConsoleDialog WM_ACTIVATE WA_ACTIVE\r\n " ));
227+ giveInputFocus ();
228+ }
229+ break ;
230+
231+ case WM_CHILDACTIVATE:
232+ OutputDebugString (_T (" ConsoleDialog WM_CHILDACTIVATE\r\n " ));
233+ giveInputFocus ();
234+ break ;
235+
204236 case WM_NOTIFY:
205237 {
206238 LPNMHDR nmhdr = reinterpret_cast <LPNMHDR>(lParam);
@@ -215,7 +247,7 @@ BOOL CALLBACK ConsoleDialog::run_dlgProc(HWND hWnd, UINT message, WPARAM wParam,
215247 case SCN_HOTSPOTCLICK:
216248 onHotspotClick (reinterpret_cast <SCNotification*>(lParam));
217249 return FALSE ;
218-
250+
219251 default :
220252 break ;
221253 }
@@ -382,8 +414,11 @@ LRESULT ConsoleDialog::run_inputWndProc(HWND hWnd, UINT message, WPARAM wParam,
382414 default :
383415 return CallWindowProc (m_originalInputWndProc, hWnd, message, wParam, lParam);
384416 }
385-
386- default :
417+
418+ case WM_SETFOCUS:
419+ OutputDebugString (_T (" Input SetFocus\r\n " ));
420+
421+ default :
387422 return CallWindowProc (m_originalInputWndProc, hWnd, message, wParam, lParam);
388423 }
389424}
@@ -431,7 +466,12 @@ void ConsoleDialog::setPrompt(const char *prompt)
431466void ConsoleDialog::createOutputWindow (HWND hParentWindow)
432467{
433468 m_scintilla = (HWND)::SendMessage (_hParent, NPPM_CREATESCINTILLAHANDLE, 0 , reinterpret_cast <LPARAM>(hParentWindow));
434- callScintilla (SCI_SETREADONLY, 1 , 0 );
469+
470+ LONG currentStyle = GetWindowLong (m_scintilla, GWL_STYLE);
471+ SetWindowLong (m_scintilla, GWL_STYLE, currentStyle | WS_TABSTOP);
472+
473+
474+ callScintilla (SCI_SETREADONLY, 1 , 0 );
435475
436476 /* Style bits
437477 * LSB 0 - stderr = 1
@@ -485,6 +525,26 @@ void ConsoleDialog::createOutputWindow(HWND hParentWindow)
485525
486526 callScintilla (SCI_USEPOPUP, 0 );
487527 callScintilla (SCI_SETLEXER, SCLEX_CONTAINER);
528+
529+
530+ }
531+
532+ LRESULT ConsoleDialog::scintillaWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
533+ {
534+ switch (message)
535+ {
536+ case WM_GETDLGCODE:
537+ return DLGC_WANTARROWS | DLGC_WANTCHARS;
538+
539+ case WM_SETFOCUS:
540+ OutputDebugString (_T (" Scintilla SetFocus\r\n " ));
541+ break ;
542+
543+ default :
544+ break ;
545+ }
546+
547+ return CallWindowProc (s_originalScintillaWndProc, hWnd, message, wParam, lParam);
488548}
489549
490550void ConsoleDialog::writeText (size_t length, const char *text)
0 commit comments