@@ -23,7 +23,8 @@ ShortcutDlg::ShortcutDlg(HINSTANCE hInst, NppData& nppData, const TCHAR *scriptD
2323 m_menuItemCount(0 ),
2424 m_toolbarColumnWidth(100 ),
2525 m_menuItemColumnWidth(100 ),
26- m_currentScript(NULL )
26+ m_currentScript(NULL ),
27+ m_hButtonConsoleErrorColor(NULL )
2728{
2829 Window::init (hInst, nppData._nppHandle );
2930 TCHAR temp[MAX_PATH]{};
@@ -78,7 +79,10 @@ INT_PTR CALLBACK ShortcutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
7879 switch (LOWORD (wParam))
7980 {
8081 case IDC_COLORCHOOSER:
81- ctrlOnClick ();
82+ ctrlOnClick (IDC_COLORCHOOSER);
83+ break ;
84+ case IDC_COLORCHOOSER2:
85+ ctrlOnClick (IDC_COLORCHOOSER2);
8286 break ;
8387 case IDC_CHECKCOLORIZEOUTPUT:
8488 if (HIWORD (wParam) == BN_CLICKED)
@@ -87,6 +91,13 @@ INT_PTR CALLBACK ShortcutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
8791 EnableWindow (m_hButtonColor, (result == BST_CHECKED) ? true : false );
8892 }
8993 break ;
94+ case IDC_CONSOLEERRORCOLOR:
95+ if (HIWORD (wParam) == BN_CLICKED)
96+ {
97+ size_t result = SendMessage (reinterpret_cast <HWND>(lParam), BM_GETCHECK, 0 , 0 );
98+ EnableWindow (m_hButtonConsoleErrorColor, (result == BST_CHECKED) ? true : false );
99+ }
100+ break ;
90101 }
91102 switch (wParam)
92103 {
@@ -224,6 +235,7 @@ void ShortcutDlg::onInitDialog()
224235 m_hListToolbarItems = ::GetDlgItem (_hSelf, IDC_TOOLBARITEMLIST2);
225236 m_hComboInitialisation = ::GetDlgItem (_hSelf, IDC_COMBOINITIALISATION);
226237 m_hButtonColor = ::GetDlgItem (_hSelf, IDC_COLORCHOOSER);
238+ m_hButtonConsoleErrorColor = ::GetDlgItem (_hSelf, IDC_COLORCHOOSER2);
227239 InitCommonControls ();
228240 HICON hIcon; // handle to icon
229241
@@ -533,6 +545,10 @@ void ShortcutDlg::populateCurrentItems()
533545 bool disablePopupWarning = (configFile->getSetting (_T (" DISABLEPOPUPWARNING" )) == _T (" 1" ));
534546 CheckDlgButton (_hSelf, IDC_DISABLEPOPUPWARNING, disablePopupWarning ? BST_CHECKED : BST_UNCHECKED);
535547
548+ bool colorConsoleError = (configFile->getSetting (_T (" CUSTOMCONSOLEERRORCOLOR" )) >= _T (" 0" ));
549+ CheckDlgButton (_hSelf, IDC_CONSOLEERRORCOLOR, colorConsoleError ? BST_CHECKED : BST_UNCHECKED);
550+ EnableWindow (m_hButtonConsoleErrorColor, colorConsoleError);
551+
536552}
537553
538554
@@ -573,6 +589,9 @@ void ShortcutDlg::saveConfig()
573589 bool disablePopupWarning = (BST_CHECKED == IsDlgButtonChecked (_hSelf, IDC_DISABLEPOPUPWARNING));
574590 configFile->setSetting (_T (" DISABLEPOPUPWARNING" ), disablePopupWarning ? _T (" 1" ) : _T (" 0" ));
575591
592+ bool customizeConsoleErrorColor = (BST_CHECKED == IsDlgButtonChecked (_hSelf, IDC_CONSOLEERRORCOLOR));
593+ configFile->setSetting (_T (" CUSTOMCONSOLEERRORCOLOR" ), customizeConsoleErrorColor ? ConfigFile::getInstance ()->getSetting (_T (" CUSTOMCONSOLEERRORCOLOR" )) : _T (" -1" ));
594+
576595 configFile->save ();
577596}
578597
@@ -625,16 +644,18 @@ void ShortcutDlg::toolbarSetIcon()
625644 }
626645}
627646
628- void ShortcutDlg::ctrlOnClick () const
647+ void ShortcutDlg::ctrlOnClick (WORD whichColorButton ) const
629648{
630649 CHOOSECOLOR cc;
631650 static COLORREF acrCustClr[16 ];
632651 for (int i = 0 ; i < 16 ; i++)
633652 {
634653 acrCustClr[i] = RGB (255 ,255 ,255 );
635654 }
636- const tstring strRGBCurrent = ConfigFile::getInstance ()->getSetting (_T (" COLORIZEOUTPUT" ));
637- static DWORD rgbCurrent = (strRGBCurrent == _T (" -1" )) ? RGB (135 ,214 ,18 ) : stoi (strRGBCurrent);
655+ const TCHAR *colorSetting = whichColorButton == IDC_COLORCHOOSER ? _T (" COLORIZEOUTPUT" ) : _T (" CUSTOMCONSOLEERRORCOLOR" );
656+ COLORREF defaultColor = whichColorButton == IDC_COLORCHOOSER ? RGB (135 , 214 , 18 ) : RGB (255 , 0 , 0 );
657+ const tstring strRGBCurrent = ConfigFile::getInstance ()->getSetting (colorSetting);
658+ static DWORD rgbCurrent = (strRGBCurrent == _T (" -1" )) ? defaultColor : stoi (strRGBCurrent);
638659
639660 ZeroMemory (&cc, sizeof (cc));
640661 cc.lStructSize = sizeof (cc);
@@ -646,7 +667,7 @@ void ShortcutDlg::ctrlOnClick() const
646667 if (ChooseColor (&cc) == TRUE )
647668 {
648669 rgbCurrent = cc.rgbResult ;
649- ConfigFile::getInstance ()->setSetting (_T ( " COLORIZEOUTPUT " ) , std::to_wstring (rgbCurrent));
670+ ConfigFile::getInstance ()->setSetting (colorSetting , std::to_wstring (rgbCurrent));
650671 }
651672
652673}
0 commit comments