From e7e3be93b86a75b8e91f6708430d7241deaf479a Mon Sep 17 00:00:00 2001 From: donho Date: Sun, 16 Mar 2008 03:23:04 +0000 Subject: [PATCH] [NEW_FEATURE] Add scroll to end line after update feature. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@148 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Notepad_plus.cpp | 48 +++++++++++++++--- PowerEditor/src/Notepad_plus.h | 1 + PowerEditor/src/Parameters.cpp | 49 ++++++++++++++++--- PowerEditor/src/Parameters.h | 3 +- PowerEditor/src/ScitillaComponent/Buffer.h | 3 +- .../WinControls/ColourPicker/ColourPicker.cpp | 2 +- .../WinControls/ColourPicker/ColourPopup.cpp | 2 + .../WinControls/ColourPicker/ColourPopup.h | 2 + .../WinControls/Preference/preferenceDlg.cpp | 38 ++++++++++++-- PowerEditor/src/menuCmdID.h | 3 -- 10 files changed, 124 insertions(+), 27 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index fb8b9c233..1f4df81be 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -3732,6 +3732,7 @@ void Notepad_plus::command(int id) shortcutMapper.destroy(); break; } +/* case IDM_SETTING_FILE_AUTODETECTION_ENABLE : { NppGUI & nppgui = (NppGUI &)(pNppParam->getNppGUI()); @@ -3751,7 +3752,7 @@ void Notepad_plus::command(int id) nppgui._fileAutoDetection = cdAutoUpdate; break; } -/* + case IDM_SETTING_TRAYICON : { NppGUI & nppgui = (NppGUI &)(pNppParam->getNppGUI()); @@ -4454,7 +4455,7 @@ void Notepad_plus::checkModifiedDocument() NppParameters *pNppParam = NppParameters::getInstance(); const NppGUI & nppGUI = pNppParam->getNppGUI(); - bool autoUpdate = (nppGUI._fileAutoDetection == cdAutoUpdate); + bool autoUpdate = (nppGUI._fileAutoDetection == cdAutoUpdate) || (nppGUI._fileAutoDetection == cdAutoUpdateGo2end); for (int j = 0 ; j < NB_VIEW ; j++) { @@ -4462,7 +4463,7 @@ void Notepad_plus::checkModifiedDocument() { Buffer & docBuf = pScintillaArray[j]->getBufferAt(i); docFileStaus fStatus = docBuf.checkFileState(); - pDocTabArray[j]->updateTabItem(i); + //pDocTabArray[j]->updateTabItem(i); bool update = !docBuf.isDirty() && autoUpdate; if (fStatus == MODIFIED_FROM_OUTSIDE) @@ -4471,26 +4472,31 @@ void Notepad_plus::checkModifiedDocument() if (::IsIconic(_hSelf)) ::ShowWindow(_hSelf, SW_SHOWNORMAL); - if (update || doReloadOrNot(docBuf.getFileName()) == IDYES) + if (update) + docBuf._reloadOnSwitchBack = true; + else if (doReloadOrNot(docBuf.getFileName()) == IDYES) { + docBuf._reloadOnSwitchBack = true; setTitleWith(pDocTabArray[j]->activate(i)); // if it's a non current view, make it as the current view if (j == 1) switchEditViewTo(getNonCurrentView()); +/* if (pScintillaArray[j]->isCurrentBufReadOnly()) pScintillaArray[j]->execute(SCI_SETREADONLY, FALSE); reload(docBuf.getFileName()); -/* + //if (goToEOL) { int line = _pEditView->getNbLine(); _pEditView->gotoLine(line); } -*/ + if (pScintillaArray[j]->isCurrentBufReadOnly()) pScintillaArray[j]->execute(SCI_SETREADONLY, TRUE); +*/ } if (_activeAppInf._isActivated) @@ -4546,6 +4552,32 @@ void Notepad_plus::checkModifiedDocument() } } +void Notepad_plus::reloadOnSwitchBack() +{ + Buffer & buf = _pEditView->getCurrentBuffer(); + + if (buf._reloadOnSwitchBack) + { + if (_pEditView->isCurrentBufReadOnly()) + _pEditView->execute(SCI_SETREADONLY, FALSE); + + reload(buf.getFileName()); + + NppParameters *pNppParam = NppParameters::getInstance(); + const NppGUI & nppGUI = pNppParam->getNppGUI(); + if (nppGUI._fileAutoDetection == cdAutoUpdateGo2end || nppGUI._fileAutoDetection == cdGo2end) + { + int line = _pEditView->getNbLine(); + _pEditView->gotoLine(line); + } + + if (_pEditView->isCurrentBufReadOnly()) + _pEditView->execute(SCI_SETREADONLY, TRUE); + + buf._reloadOnSwitchBack = false; + } +} + void Notepad_plus::hideCurrentView() { if (_mainWindowStatus & DOCK_MASK) @@ -7455,11 +7487,11 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa checkDocState(); dynamicCheckMenuAndTB(); setLangStatus(_pEditView->getCurrentDocType()); - //checkUnicodeMenuItems(_pEditView->getCurrentBuffer().getUnicodeMode()); updateStatusBar(); + reloadOnSwitchBack(); return TRUE; } - + case NPPM_INTERNAL_ISTABBARREDUCED : { return _toReduceTabBar?TRUE:FALSE; diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index cdf8ab2dd..5113fb0cb 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -708,6 +708,7 @@ private: }; void setFileOpenSaveDlgFilters(FileDialog & fDlg); + void reloadOnSwitchBack(); }; #endif //NOTEPAD_PLUS_H diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 6d3fa4169..3a8848c43 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -2174,16 +2174,20 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) val = n->Value(); if (val) { - - if (!strcmp(val, "no")) - _nppGUI._fileAutoDetection = cdDisabled; + if (!strcmp(val, "yes")) + _nppGUI._fileAutoDetection = cdEnabled; else if (!strcmp(val, "auto")) _nppGUI._fileAutoDetection = cdAutoUpdate; - else - _nppGUI._fileAutoDetection = cdEnabled; + else if (!strcmp(val, "Update2End")) + _nppGUI._fileAutoDetection = cdGo2end; + else if (!strcmp(val, "autoUpdate2End")) + _nppGUI._fileAutoDetection = cdAutoUpdateGo2end; + else //(!strcmp(val, "no")) + _nppGUI._fileAutoDetection = cdDisabled; } } } + else if (!strcmp(nm, "TrayIcon")) { TiXmlNode *n = childNode->FirstChild(); @@ -3055,7 +3059,22 @@ bool NppParameters::writeGUIParams() else if (!strcmp(nm, "Auto-detection")) { autoDetectionExist = true; - const char *pStr = (cdEnabled == _nppGUI._fileAutoDetection)?"yes":((cdAutoUpdate == _nppGUI._fileAutoDetection)?"auto":"no"); + const char *pStr = "no"; + switch (_nppGUI._fileAutoDetection) + { + case cdEnabled: + pStr = "yes"; + break; + case cdAutoUpdate: + pStr = "auto"; + break; + case cdGo2end: + pStr = "Update2End"; + break; + case cdAutoUpdateGo2end: + pStr = "autoUpdate2End"; + break; + } TiXmlNode *n = childNode->FirstChild(); if (n) n->SetValue(pStr); @@ -3248,8 +3267,22 @@ bool NppParameters::writeGUIParams() if (!autoDetectionExist) { - //insertGUIConfigBoolNode(GUIRoot, "Auto-detection", _nppGUI._fileAutoDetection); - const char *pStr = _nppGUI._fileAutoDetection==0?"no":(_nppGUI._fileAutoDetection==1?"yes":"auto"); + const char *pStr = "no"; + switch (_nppGUI._fileAutoDetection) + { + case cdEnabled: + pStr = "yes"; + break; + case cdAutoUpdate: + pStr = "auto"; + break; + case cdGo2end: + pStr = "Update2End"; + break; + case cdAutoUpdateGo2end: + pStr = "autoUpdate2End"; + break; + } TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement("GUIConfig")))->ToElement(); GUIConfigElement->SetAttribute("name", "Auto-detection"); GUIConfigElement->InsertEndChild(TiXmlText(pStr)); diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 772cb4ab1..a42dfb385 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -57,7 +57,8 @@ enum formatType {WIN_FORMAT, MAC_FORMAT, UNIX_FORMAT}; enum UniMode {uni8Bit=0, uniUTF8=1, uni16BE=2, uni16LE=3, uniCookie=4, uniEnd}; -enum ChangeDetect {cdDisabled=0, cdEnabled=1, cdAutoUpdate=2}; +enum ChangeDetect {cdDisabled=0, cdEnabled=1, cdAutoUpdate=2, cdGo2end=3, cdAutoUpdateGo2end=4}; + enum BackupFeature {bak_none = 0, bak_simple = 1, bak_verbose = 2}; diff --git a/PowerEditor/src/ScitillaComponent/Buffer.h b/PowerEditor/src/ScitillaComponent/Buffer.h index c9df2a55a..af52440d2 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.h +++ b/PowerEditor/src/ScitillaComponent/Buffer.h @@ -107,7 +107,7 @@ public : Buffer(const Buffer & buf) : _isDirty(buf._isDirty), _doc(buf._doc), _lang(buf._lang), _timeStamp(buf._timeStamp), _isReadOnly(buf._isReadOnly), _isSetReadOnly(buf._isSetReadOnly), _pos(buf._pos), _format(buf._format),_unicodeMode(buf._unicodeMode), _foldState(buf._foldState), _recentTag(buf._recentTag), - _dontBotherMeAnymore(false) + _dontBotherMeAnymore(false), _reloadOnSwitchBack(false) { strcpy(_fullPathName, buf._fullPathName); strcpy(_userLangExt, buf._userLangExt); @@ -339,6 +339,7 @@ private : static long _recentTagCtr; //bool _isBinary; bool _dontBotherMeAnymore; + bool _reloadOnSwitchBack; Lang * getCurrentLang() const { int i = 0 ; diff --git a/PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp b/PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp index 57b7a20e1..4d7a0e791 100644 --- a/PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp @@ -79,7 +79,7 @@ LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam) p.y = rc.top + rc.bottom; ::ClientToScreen(_hSelf, &p); - _pColourPopup = new ColourPopup; + _pColourPopup = new ColourPopup(_currentColour); _pColourPopup->init(_hInst, _hSelf); _pColourPopup->doDialog(p); } diff --git a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp index 3da5e9d07..54f67dade 100644 --- a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp @@ -191,6 +191,7 @@ BOOL CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPara cc.hwndOwner = _hParent; cc.lpCustColors = (LPDWORD) acrCustClr; + cc.rgbResult = _colour; cc.Flags = CC_FULLOPEN | CC_RGBINIT; display(false); @@ -236,3 +237,4 @@ BOOL CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPara } + diff --git a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.h b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.h index c40b75803..76686b76d 100644 --- a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.h +++ b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.h @@ -31,6 +31,7 @@ class ColourPopup : public Window { public : ColourPopup() : Window(), isColourChooserLaunched(false) {}; + ColourPopup(COLORREF defaultColor) : Window(), isColourChooserLaunched(false), _colour(defaultColor) {}; ~ColourPopup(){}; bool isCreated() const { @@ -64,3 +65,4 @@ private : #endif //COLOUR_POPUP_H + diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 9d1355b05..7b9f9c6d0 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -441,7 +441,7 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara ::SendDlgItemMessage(_hSelf, IDC_CHECK_REPLACEBYSPACE, BM_SETCHECK, nppGUI._tabReplacedBySpace, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_DONTCHECKHISTORY, BM_SETCHECK, !nppGUI._checkHistoryFiles, 0); - // + if (nppGUI._fileAutoDetection == cdEnabled) { ::SendDlgItemMessage(_hSelf, IDC_CHECK_FILEAUTODETECTION, BM_SETCHECK, BST_CHECKED, 0); @@ -451,9 +451,21 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara ::SendDlgItemMessage(_hSelf, IDC_CHECK_FILEAUTODETECTION, BM_SETCHECK, BST_CHECKED, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_UPDATESILENTLY, BM_SETCHECK, BST_CHECKED, 0); } + else if (nppGUI._fileAutoDetection == cdGo2end) + { + ::SendDlgItemMessage(_hSelf, IDC_CHECK_FILEAUTODETECTION, BM_SETCHECK, BST_CHECKED, 0); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_UPDATEGOTOEOF, BM_SETCHECK, BST_CHECKED, 0); + } + else if (nppGUI._fileAutoDetection == cdAutoUpdateGo2end) + { + ::SendDlgItemMessage(_hSelf, IDC_CHECK_FILEAUTODETECTION, BM_SETCHECK, BST_CHECKED, 0); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_UPDATESILENTLY, BM_SETCHECK, BST_CHECKED, 0); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_UPDATEGOTOEOF, BM_SETCHECK, BST_CHECKED, 0); + } else //cdDisabled { ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_UPDATESILENTLY), FALSE); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_UPDATEGOTOEOF), FALSE); } ::SendDlgItemMessage(_hSelf, IDC_CHECK_MIN2SYSTRAY, BM_SETCHECK, nppGUI._isMinimizedToTray, 0); @@ -532,20 +544,36 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara { bool isChecked = isCheckedOrNot(IDC_CHECK_FILEAUTODETECTION); if (!isChecked) + { ::SendDlgItemMessage(_hSelf, IDC_CHECK_UPDATESILENTLY, BM_SETCHECK, BST_UNCHECKED, 0); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_UPDATEGOTOEOF, BM_SETCHECK, BST_UNCHECKED, 0); + } ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_UPDATESILENTLY), isChecked); - ::SendMessage(_hParent, WM_COMMAND, isChecked?IDM_SETTING_FILE_AUTODETECTION_ENABLE:IDM_SETTING_FILE_AUTODETECTION_DISABLE, 0); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_UPDATEGOTOEOF), isChecked); + + nppGUI._fileAutoDetection = isChecked?cdAutoUpdate:cdDisabled; + //::SendMessage(_hParent, WM_COMMAND, isChecked?IDM_SETTING_FILE_AUTODETECTION_ENABLE:IDM_SETTING_FILE_AUTODETECTION_DISABLE, 0); } return TRUE; case IDC_CHECK_UPDATESILENTLY: + case IDC_CHECK_UPDATEGOTOEOF: { - bool isChecked = isCheckedOrNot(IDC_CHECK_UPDATESILENTLY); - ::SendMessage(_hParent, WM_COMMAND, isChecked?IDM_SETTING_FILE_AUTODETECTION_ENABLESILENTLY:IDM_SETTING_FILE_AUTODETECTION_ENABLE, 0); + bool isSilent = isCheckedOrNot(IDC_CHECK_UPDATESILENTLY); + bool isGo2End = isCheckedOrNot(IDC_CHECK_UPDATEGOTOEOF); + + ChangeDetect cd; + if (!isSilent && isGo2End) + cd = cdGo2end; + else if (isSilent && !isGo2End) + cd = cdAutoUpdate; + else + cd = cdAutoUpdateGo2end; + + nppGUI._fileAutoDetection = cd; } return TRUE; - case IDC_CHECK_CLICKABLELINK_ENABLE: { bool isChecked = isCheckedOrNot(IDC_CHECK_CLICKABLELINK_ENABLE); diff --git a/PowerEditor/src/menuCmdID.h b/PowerEditor/src/menuCmdID.h index 4a66fa36e..afb672621 100644 --- a/PowerEditor/src/menuCmdID.h +++ b/PowerEditor/src/menuCmdID.h @@ -270,9 +270,6 @@ #define IDM_SETTING_REMEMBER_LAST_SESSION (IDM_SETTING + 10) #define IDM_SETTING_PREFERECE (IDM_SETTING + 11) - #define IDM_SETTING_FILE_AUTODETECTION_ENABLE (IDM_SETTING + 12) - #define IDM_SETTING_FILE_AUTODETECTION_DISABLE (IDM_SETTING + 13) - #define IDM_SETTING_FILE_AUTODETECTION_ENABLESILENTLY (IDM_SETTING + 14) #define IDM_SETTING_AUTOCNBCHAR (IDM_SETTING + 15) // Menu macro