diff --git a/PowerEditor/src/MISC/Common/Common.h b/PowerEditor/src/MISC/Common/Common.h index 6bbb79d5d..3b25eb90b 100644 --- a/PowerEditor/src/MISC/Common/Common.h +++ b/PowerEditor/src/MISC/Common/Common.h @@ -41,6 +41,7 @@ #define generic_strncat wcsncat #define generic_strchr wcschr #define generic_atoi _wtoi + #define generic_itoa _itow #define generic_atof _wtof #define generic_strtok wcstok #define generic_strftime wcsftime @@ -61,6 +62,7 @@ #define generic_strncat strncat #define generic_strchr strchr #define generic_atoi atoi + #define generic_itoa itoa #define generic_atof atof #define generic_strtok strtok #define generic_strftime strftime diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index 9a429b23b..f70bdb18b 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -156,7 +156,17 @@ bool PluginsManager::loadPlugins(const TCHAR *dir) if (!PathFileExists(xmlPath)) { - throw generic_string(generic_string(xmlPath) + TEXT(" is missing.")); + lstrcpyn( xmlPath, TEXT("\0"), MAX_PATH ); + lstrcpy( xmlPath, nppParams->getAppDataNppDir() ); + PathAppend(xmlPath, TEXT("plugins\\Config")); + PathAppend( xmlPath, pi->_moduleName ); + PathRemoveExtension( xmlPath ); + PathAddExtension( xmlPath, TEXT(".xml") ); + + if (! PathFileExists( xmlPath ) ) + { + throw generic_string(generic_string(xmlPath) + TEXT(" is missing.")); + } } TiXmlDocument *_pXmlDoc = new TiXmlDocument(xmlPath); diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 2c4f28959..a51063ef0 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -196,7 +196,7 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLine, CmdL Window::init(hInst, parent); WNDCLASS nppClass; - nppClass.style = CS_BYTEALIGNWINDOW | CS_DBLCLKS;//CS_HREDRAW | CS_VREDRAW; + nppClass.style = CS_BYTEALIGNWINDOW | CS_DBLCLKS; nppClass.lpfnWndProc = Notepad_plus_Proc; nppClass.cbClsExtra = 0; nppClass.cbWndExtra = 0; @@ -263,7 +263,10 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLine, CmdL if (newUpperLeft.y + nppGUI._appPos.bottom < ::GetSystemMetrics(SM_YVIRTUALSCREEN)+margin) newUpperLeft.y = workAreaRect.top; } - ::MoveWindow(_hSelf, newUpperLeft.x, newUpperLeft.y, nppGUI._appPos.right, nppGUI._appPos.bottom, TRUE); + if (cmdLineParams->isPointValid()) + ::MoveWindow(_hSelf, cmdLineParams->_point.x, cmdLineParams->_point.y, nppGUI._appPos.right, nppGUI._appPos.bottom, TRUE); + else + ::MoveWindow(_hSelf, newUpperLeft.x, newUpperLeft.y, nppGUI._appPos.right, nppGUI._appPos.bottom, TRUE); ::GetModuleFileName(NULL, _nppPath, MAX_PATH); @@ -283,22 +286,26 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLine, CmdL loadLastSession(); } - ::ShowWindow(_hSelf, nppGUI._isMaximized?SW_MAXIMIZE:SW_SHOW); + if (cmdLineParams->isPointValid()) + ::ShowWindow(_hSelf, SW_SHOW); + else + ::ShowWindow(_hSelf, nppGUI._isMaximized?SW_MAXIMIZE:SW_SHOW); if (cmdLine) { loadCommandlineParams(cmdLine, cmdLineParams); } -#ifdef UNICODE - LocalizationSwicher & localizationSwitcher = pNppParams->getLocalizationSwitcher(); - vector fileNames; - vector patterns; + vector fileNames; + vector patterns; patterns.push_back(TEXT("*.xml")); - wchar_t tmp[MAX_PATH]; - lstrcpyW(tmp, _nppPath); + TCHAR tmp[MAX_PATH]; + lstrcpy(tmp, _nppPath); ::PathRemoveFileSpec(tmp); + +#ifdef UNICODE + LocalizationSwitcher & localizationSwitcher = pNppParams->getLocalizationSwitcher(); wstring localizationDir = tmp; localizationDir += TEXT("\\localization\\"); @@ -309,6 +316,34 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLine, CmdL } #endif + fileNames.clear(); + ThemeSwitcher & themeSwitcher = pNppParams->getThemeSwitcher(); + + // Get themes from both npp install themes dir and app data themes dir with the per user + // overriding default themes of the same name. + generic_string themeDir(pNppParams->getAppDataNppDir()); + themeDir.append(TEXT("\\themes\\")); + + getMatchedFileNames(themeDir.c_str(), patterns, fileNames, false, false); + for (size_t i = 0 ; i < fileNames.size() ; i++) + { + themeSwitcher.addThemeFromXml(fileNames[i].c_str()); + } + + fileNames.clear(); + themeDir.clear(); + themeDir.assign(tmp); + themeDir.append(TEXT("\\themes\\")); + getMatchedFileNames(themeDir.c_str(), patterns, fileNames, false, false); + for (size_t i = 0 ; i < fileNames.size() ; i++) + { + generic_string themeName( themeSwitcher.getThemeFromXmlFileName(fileNames[i].c_str()) ); + if (! themeSwitcher.themeNameExists(themeName.c_str()) ) + { + themeSwitcher.addThemeFromXml(fileNames[i].c_str()); + } + } + // Notify plugins that Notepad++ is ready SCNotification scnN; scnN.nmhdr.code = NPPN_READY; @@ -2081,7 +2116,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) { prevWasEdit = false; } - +/* if (!_isFileOpening && (isFromPrimary || isFromSecondary) && _pEditView->hasMarginShowed(ScintillaEditView::_SC_MARGE_MODIFMARKER)) { bool isProcessed = false; @@ -2216,6 +2251,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) } } } + */ } break; @@ -2257,7 +2293,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) case TCN_TABDROPPED: { TabBarPlus *sender = reinterpret_cast(notification->nmhdr.idFrom); - + bool isInCtrlStat = (::GetKeyState(VK_LCONTROL) & 0x80000000) != 0; if (notification->nmhdr.code == TCN_TABDROPPEDOUTSIDE) { POINT p = sender->getDraggingPoint(); @@ -2269,8 +2305,8 @@ BOOL Notepad_plus::notify(SCNotification *notification) { if (!_tabPopupDropMenu.isCreated()) { - TCHAR goToView[32] = TEXT("Go to another View"); - TCHAR cloneToView[32] = TEXT("Clone to another View"); + TCHAR goToView[32] = TEXT("Move to other view"); + TCHAR cloneToView[32] = TEXT("Clone to other View"); vector itemUnitArray; itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_GOTO_ANOTHER_VIEW, goToView)); itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_CLONE_TO_ANOTHER_VIEW, cloneToView)); @@ -2282,13 +2318,19 @@ BOOL Notepad_plus::notify(SCNotification *notification) else if ((hWin == _pNonDocTab->getHSelf()) || (hWin == _pNonEditView->getHSelf())) // In the another view group { - if (::GetKeyState(VK_LCONTROL) & 0x80000000) - docGotoAnotherEditView(TransferClone); - else - docGotoAnotherEditView(TransferMove); + docGotoAnotherEditView(isInCtrlStat?TransferClone:TransferMove); } + else { + RECT nppZone; + ::GetWindowRect(_hSelf, &nppZone); + bool isInNppZone = (((p.x >= nppZone.left) && (p.x <= nppZone.right)) && (p.y >= nppZone.top) && (p.y <= nppZone.bottom)); + if (isInNppZone) + { + // Do nothing + return TRUE; + } generic_string quotFileName = TEXT("\""); quotFileName += _pEditView->getCurrentBuffer()->getFullPathName(); quotFileName += TEXT("\""); @@ -2300,7 +2342,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) HWND hWinParent = ::GetParent(hWin); TCHAR className[MAX_PATH]; ::GetClassName(hWinParent,className, sizeof(className)); - if (lstrcmp(className, _className) == 0 && hWinParent != _hSelf) + if (lstrcmp(className, _className) == 0 && hWinParent != _hSelf) // another Notepad++ { int index = _pDocTab->getCurrentTabIndex(); BufferID bufferToClose = notifyDocTab->getBufferByIndex(index); @@ -2308,18 +2350,28 @@ BOOL Notepad_plus::notify(SCNotification *notification) int iView = isFromPrimary?MAIN_VIEW:SUB_VIEW; if (buf->isDirty()) { - ::MessageBox(_hSelf, TEXT("Document is modified, save it then try again."), TEXT("Go to another Notepad++ instance"), MB_OK); + ::MessageBox(_hSelf, TEXT("Document is modified, save it then try again."), TEXT("Move to new Notepad++ Instance"), MB_OK); } else { ::SendMessage(hWinParent, NPPM_INTERNAL_SWITCHVIEWFROMHWND, 0, (LPARAM)hWin); ::SendMessage(hWinParent, WM_COPYDATA, (WPARAM)_hInst, (LPARAM)&fileNamesData); - fileClose(bufferToClose, iView); + if (!isInCtrlStat) + { + fileClose(bufferToClose, iView); + if (noOpenedDoc()) + ::SendMessage(_hSelf, WM_CLOSE, 0, 0); + } } } + else // Not Notepad++, we open it here + { + docOpenInNewInstance(isInCtrlStat?TransferClone:TransferMove, p.x, p.y); + } } } - break; + //break; + return TRUE; } case TCN_TABDELETE: @@ -2442,9 +2494,9 @@ BOOL Notepad_plus::notify(SCNotification *notification) itemUnitArray.push_back(MenuItemUnit(IDM_EDIT_FILENAMETOCLIP, TEXT("File name to Clipboard"))); itemUnitArray.push_back(MenuItemUnit(IDM_EDIT_CURRENTDIRTOCLIP, TEXT("Current dir path to Clipboard"))); itemUnitArray.push_back(MenuItemUnit(0, NULL)); - itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_GOTO_ANOTHER_VIEW, TEXT("Go to another View"))); - itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_CLONE_TO_ANOTHER_VIEW, TEXT("Clone to another View"))); - itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_GOTO_NEW_INSTANCE, TEXT("Go to new instance"))); + itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_GOTO_ANOTHER_VIEW, TEXT("Move to other view"))); + itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_CLONE_TO_ANOTHER_VIEW, TEXT("Clone to other view"))); + itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_GOTO_NEW_INSTANCE, TEXT("Move to new instance"))); itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_LOAD_IN_NEW_INSTANCE, TEXT("Open in new instance"))); _tabPopupMenu.create(_hSelf, itemUnitArray); @@ -2934,7 +2986,7 @@ void Notepad_plus::specialCmd(int id, int param) { case IDM_VIEW_LINENUMBER: case IDM_VIEW_SYMBOLMARGIN: - case IDM_VIEW_DOCCHANGEMARGIN: + //case IDM_VIEW_DOCCHANGEMARGIN: case IDM_VIEW_FOLDERMAGIN: { int margin; @@ -2942,10 +2994,12 @@ void Notepad_plus::specialCmd(int id, int param) margin = ScintillaEditView::_SC_MARGE_LINENUMBER; else if (id == IDM_VIEW_SYMBOLMARGIN) margin = ScintillaEditView::_SC_MARGE_SYBOLE; + /* else if (id == IDM_VIEW_DOCCHANGEMARGIN) { margin = ScintillaEditView::_SC_MARGE_MODIFMARKER; } + */ else margin = ScintillaEditView::_SC_MARGE_FOLDER; @@ -4914,6 +4968,12 @@ void Notepad_plus::hideView(int whichOne) _mainWindowStatus &= ~viewToDisable; } +bool Notepad_plus::loadStyles() +{ + NppParameters *pNppParam = NppParameters::getInstance(); + return pNppParam->reloadStylers(); +} + bool Notepad_plus::reloadLang() { NppParameters *pNppParam = NppParameters::getInstance(); @@ -5211,7 +5271,7 @@ void Notepad_plus::undockUserDlg() (ScintillaEditView::getUserDefineDlg())->display(); } -void Notepad_plus::docOpenInNewInstance(FileTransferMode mode) +void Notepad_plus::docOpenInNewInstance(FileTransferMode mode, int x, int y) { BufferID bufferID = _pEditView->getCurrentBufferID(); Buffer * buf = MainFileManager->getBufferByID(bufferID); @@ -5224,12 +5284,23 @@ void Notepad_plus::docOpenInNewInstance(FileTransferMode mode) command += nppName; command += TEXT("\""); - command += TEXT(" \"$(FULL_CURRENT_PATH)\" -multiInst -nosession"); + command += TEXT(" \"$(FULL_CURRENT_PATH)\" -multiInst -nosession -x"); + TCHAR pX[10], pY[10]; + generic_itoa(x, pX, 10); + generic_itoa(y, pY, 10); + + command += pX; + command += TEXT(" -y"); + command += pY; Command cmd(command); cmd.run(_hSelf); if (mode == TransferMove) + { doClose(bufferID, currentView()); + if (noOpenedDoc()) + ::SendMessage(_hSelf, WM_CLOSE, 0, 0); + } } void Notepad_plus::docGotoAnotherEditView(FileTransferMode mode) @@ -5264,6 +5335,8 @@ void Notepad_plus::docGotoAnotherEditView(FileTransferMode mode) { //just close the activate document, since thats the one we moved (no search) doClose(_pEditView->getCurrentBufferID(), currentView()); + if (noOpenedDoc()) + ::SendMessage(_hSelf, WM_CLOSE, 0, 0); } // else it was cone, so leave it //Activate the other view since thats where the document went @@ -6709,7 +6782,7 @@ bool Notepad_plus::saveScintillaParams(bool whichOne) svp._lineNumberMarginShow = pView->hasMarginShowed(ScintillaEditView::_SC_MARGE_LINENUMBER); svp._bookMarkMarginShow = pView->hasMarginShowed(ScintillaEditView::_SC_MARGE_SYBOLE); - svp._docChangeStateMarginShow = pView->hasMarginShowed(ScintillaEditView::_SC_MARGE_MODIFMARKER); + //svp._docChangeStateMarginShow = pView->hasMarginShowed(ScintillaEditView::_SC_MARGE_MODIFMARKER); svp._indentGuideLineShow = pView->isShownIndentGuide(); svp._folderStyle = pView->getFolderStyle(); svp._currentLineHilitingShow = pView->isCurrentLineHiLiting(); @@ -6930,8 +7003,8 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa _subEditView.showMargin(ScintillaEditView::_SC_MARGE_LINENUMBER, svp2._lineNumberMarginShow); _mainEditView.showMargin(ScintillaEditView::_SC_MARGE_SYBOLE, svp1._bookMarkMarginShow); _subEditView.showMargin(ScintillaEditView::_SC_MARGE_SYBOLE, svp2._bookMarkMarginShow); - _mainEditView.showMargin(ScintillaEditView::_SC_MARGE_MODIFMARKER, svp1._docChangeStateMarginShow); - _subEditView.showMargin(ScintillaEditView::_SC_MARGE_MODIFMARKER, svp2._docChangeStateMarginShow); + //_mainEditView.showMargin(ScintillaEditView::_SC_MARGE_MODIFMARKER, svp1._docChangeStateMarginShow); + //_subEditView.showMargin(ScintillaEditView::_SC_MARGE_MODIFMARKER, svp2._docChangeStateMarginShow); _mainEditView.showIndentGuideLine(svp1._indentGuideLineShow); _subEditView.showIndentGuideLine(svp2._indentGuideLineShow); @@ -7682,6 +7755,12 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } return TRUE; + case NPPM_INTERNAL_RELOADSTYLERS: + { + loadStyles(); + } + return TRUE; + case NPPM_INTERNAL_PLUGINSHORTCUTMOTIFIED: { SCNotification scnN; @@ -9707,6 +9786,8 @@ void Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, CmdLineParam LangType lt = pCmdParams->_langType;//LangType(pCopyData->dwData & LASTBYTEMASK); int ln = pCmdParams->_line2go; + int cn = pCmdParams->_column2go; + bool readOnly = pCmdParams->_isReadOnly; BufferID lastOpened = BUFFER_INVALID; @@ -9730,11 +9811,18 @@ void Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, CmdLineParam int iView = currentView(); //store view since fileswitch can cause it to change switchToFile(bufID); //switch to the file. No deferred loading, but this way we can easily move the cursor to the right position + if (cn == -1) _pEditView->execute(SCI_GOTOLINE, ln-1); + else + { + int pos = _pEditView->execute(SCI_FINDCOLUMN, ln-1, cn-1); + _pEditView->execute(SCI_GOTOPOS, pos); + } switchEditViewTo(iView); //restore view } } - if (lastOpened != BUFFER_INVALID) { + if (lastOpened != BUFFER_INVALID) + { switchToFile(lastOpened); } } diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index ad401e3b6..0a80e2168 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -403,6 +403,8 @@ private: void hideCurrentView(); bool bothActive() { return (_mainWindowStatus & WindowBothActive) == WindowBothActive; }; bool reloadLang(); + bool loadStyles(); + int currentView(){ return _activeView; }; @@ -417,7 +419,7 @@ private: int switchEditViewTo(int gid); //activate other view (set focus etc) void docGotoAnotherEditView(FileTransferMode mode); //TransferMode - void docOpenInNewInstance(FileTransferMode mode); + void docOpenInNewInstance(FileTransferMode mode, int x = 0, int y = 0); void loadBufferIntoView(BufferID id, int whichOne, bool dontClose = false); //Doesnt _activate_ the buffer void removeBufferFromView(BufferID id, int whichOne); //Activates alternative of possible, or creates clean document if not clean already @@ -816,6 +818,19 @@ private: void drawTabbarColoursFromStylerArray(); void loadCommandlineParams(const TCHAR * commandLine, CmdLineParams * pCmdParams); + + bool noOpenedDoc() const { + if (_mainDocTab.isVisible() && _subDocTab.isVisible()) + return false; + if (_pDocTab->nbItem() == 1) + { + BufferID buffer = _pDocTab->getBufferByIndex(0); + Buffer * buf = MainFileManager->getBufferByID(buffer); + if (!buf->isDirty() && buf->isUntitled()) + return true; + } + return false; + }; }; #endif //NOTEPAD_PLUS_H diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index 31be6c22b..ed78c2b8f 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -1,4 +1,4 @@ -/* + /* this file is part of notepad++ Copyright (C)2003 Don HO ( donho@altern.org ) @@ -113,6 +113,7 @@ IDI_FIND_RESULT_ICON ICON "icons\\findResult.ico" IDC_DRAG_TAB CURSOR "cursors\\drag.cur" IDC_DRAG_INTERDIT_TAB CURSOR "cursors\\drag_interdit.cur" IDC_DRAG_PLUS_TAB CURSOR "cursors\\drag_plus.cur" +IDC_DRAG_OUT_TAB CURSOR "cursors\\drag_out.cur" IDR_FILENEW BITMAP "icons\\newFile.bmp" IDR_FILEOPEN BITMAP "icons\\openFile.bmp" @@ -206,36 +207,49 @@ BEGIN MENUITEM "Cu&t", IDM_EDIT_CUT MENUITEM "&Copy", IDM_EDIT_COPY MENUITEM "&Paste", IDM_EDIT_PASTE - MENUITEM "&Delete", IDM_EDIT_DELETE MENUITEM "Select A&ll", IDM_EDIT_SELECTALL MENUITEM SEPARATOR - MENUITEM "Copy Current full file path to Clipboard", IDM_EDIT_FULLPATHTOCLIP - MENUITEM "Copy Current file name to Clipboard", IDM_EDIT_FILENAMETOCLIP - MENUITEM "Copy Current dir path to Clipboard", IDM_EDIT_CURRENTDIRTOCLIP - MENUITEM SEPARATOR - MENUITEM "Insert TAB (Indent)", IDM_EDIT_INS_TAB - MENUITEM "Remove TAB (Outdent)", IDM_EDIT_RMV_TAB - MENUITEM "Duplicate current line", IDM_EDIT_DUP_LINE - MENUITEM "Split lines", IDM_EDIT_SPLIT_LINES - MENUITEM "Join lines", IDM_EDIT_JOIN_LINES - MENUITEM "Move Up current line", IDM_EDIT_LINE_UP - MENUITEM "Move Down current line", IDM_EDIT_LINE_DOWN + POPUP "Copy to clipboard" + BEGIN + MENUITEM "Current full file path to Clipboard", IDM_EDIT_FULLPATHTOCLIP + MENUITEM "Current file name to Clipboard", IDM_EDIT_FILENAMETOCLIP + MENUITEM "Current dir path to Clipboard", IDM_EDIT_CURRENTDIRTOCLIP + END + POPUP "Indent" + BEGIN + MENUITEM "Increase Line Indent", IDM_EDIT_INS_TAB + MENUITEM "Decrease Line Indent", IDM_EDIT_RMV_TAB + END + POPUP "Convert case" + BEGIN + MENUITEM "to &UPPERCASE", IDM_EDIT_UPPERCASE + MENUITEM "to &lowercase", IDM_EDIT_LOWERCASE + END + POPUP "Line operations" + BEGIN + MENUITEM "Duplicate current line", IDM_EDIT_DUP_LINE + MENUITEM "Split lines", IDM_EDIT_SPLIT_LINES + MENUITEM "Join lines", IDM_EDIT_JOIN_LINES + MENUITEM "Move Up current line", IDM_EDIT_LINE_UP + MENUITEM "Move Down current line", IDM_EDIT_LINE_DOWN + END + POPUP "Comment/Uncomment" + BEGIN + MENUITEM "Toggle block comment", IDM_EDIT_BLOCK_COMMENT + MENUITEM "Block comment", IDM_EDIT_BLOCK_COMMENT_SET + MENUITEM "Block uncomment", IDM_EDIT_BLOCK_UNCOMMENT + MENUITEM "Stream comment", IDM_EDIT_STREAM_COMMENT + END + POPUP "Auto-completion" + BEGIN + MENUITEM "Function completion", IDM_EDIT_AUTOCOMPLETE + MENUITEM "Word completion", IDM_EDIT_AUTOCOMPLETE_CURRENTFILE + MENUITEM "Function parameters hint", IDM_EDIT_FUNCCALLTIP + END MENUITEM "Trim Trailing Space", IDM_EDIT_TRIMTRAILING MENUITEM SEPARATOR MENUITEM "Column Editor...", IDM_EDIT_COLUMNMODE MENUITEM SEPARATOR - MENUITEM "to &Upper case", IDM_EDIT_UPPERCASE - MENUITEM "to &Lower case", IDM_EDIT_LOWERCASE - MENUITEM SEPARATOR - MENUITEM "Block toggle comment", IDM_EDIT_BLOCK_COMMENT - MENUITEM "Block comment", IDM_EDIT_BLOCK_COMMENT_SET - MENUITEM "Block uncomment", IDM_EDIT_BLOCK_UNCOMMENT - MENUITEM "Stream comment", IDM_EDIT_STREAM_COMMENT - MENUITEM SEPARATOR - MENUITEM "Function completion", IDM_EDIT_AUTOCOMPLETE - MENUITEM "Word completion", IDM_EDIT_AUTOCOMPLETE_CURRENTFILE - MENUITEM "Function parameters hint", IDM_EDIT_FUNCCALLTIP - MENUITEM SEPARATOR MENUITEM "Set Read Only", IDM_EDIT_SETREADONLY MENUITEM "Clear Read Only Flag", IDM_EDIT_CLEARREADONLY //MENUITEM SEPARATOR @@ -255,22 +269,22 @@ BEGIN MENUITEM "Go to matching brace", IDM_SEARCH_GOTOMATCHINGBRACE MENUITEM SEPARATOR - POPUP "Mark all with..." + POPUP "Mark all" BEGIN - MENUITEM "Mark all with the 1st style", IDM_SEARCH_MARKALLEXT1 - MENUITEM "Mark all with the 2nd style", IDM_SEARCH_MARKALLEXT2 - MENUITEM "Mark all with the 3rd style", IDM_SEARCH_MARKALLEXT3 - MENUITEM "Mark all with the 4th style", IDM_SEARCH_MARKALLEXT4 - MENUITEM "Mark all with the 5th style", IDM_SEARCH_MARKALLEXT5 + MENUITEM "Using 1st style", IDM_SEARCH_MARKALLEXT1 + MENUITEM "Using 2nd style", IDM_SEARCH_MARKALLEXT2 + MENUITEM "Using 3rd style", IDM_SEARCH_MARKALLEXT3 + MENUITEM "Using 4th style", IDM_SEARCH_MARKALLEXT4 + MENUITEM "Using 5th style", IDM_SEARCH_MARKALLEXT5 END - POPUP "Unark all with..." + POPUP "Unmark all" BEGIN - MENUITEM "Unmark all the 1st style", IDM_SEARCH_UNMARKALLEXT1 - MENUITEM "Unmark all the 2nd style", IDM_SEARCH_UNMARKALLEXT2 - MENUITEM "Unmark all the 3rd style", IDM_SEARCH_UNMARKALLEXT3 - MENUITEM "Unmark all the 4th style", IDM_SEARCH_UNMARKALLEXT4 - MENUITEM "Unmark all the 5th style", IDM_SEARCH_UNMARKALLEXT5 - MENUITEM "Clear all marks", IDM_SEARCH_CLEARALLMARKS + MENUITEM "Clear 1st style", IDM_SEARCH_UNMARKALLEXT1 + MENUITEM "Clear 2nd style", IDM_SEARCH_UNMARKALLEXT2 + MENUITEM "Clear 3rd style", IDM_SEARCH_UNMARKALLEXT3 + MENUITEM "Clear 4th style", IDM_SEARCH_UNMARKALLEXT4 + MENUITEM "Clear 5th style", IDM_SEARCH_UNMARKALLEXT5 + MENUITEM "Clear all styles", IDM_SEARCH_CLEARALLMARKS END @@ -287,28 +301,43 @@ BEGIN POPUP "&View" BEGIN - MENUITEM "Toggle Full Screen Mode", IDM_VIEW_FULLSCREENTOGGLE MENUITEM "Always on top", IDM_VIEW_ALWAYSONTOP + MENUITEM "Toggle Full Screen Mode", IDM_VIEW_FULLSCREENTOGGLE MENUITEM "Post-it", IDM_VIEW_POSTIT MENUITEM SEPARATOR - MENUITEM "Show White Space and TAB", IDM_VIEW_TAB_SPACE - MENUITEM "Show End Of Line", IDM_VIEW_EOL - MENUITEM "Show all characters", IDM_VIEW_ALL_CHARACTERS - MENUITEM SEPARATOR - MENUITEM "Show Indent guide", IDM_VIEW_INDENT_GUIDE - MENUITEM "Wrap", IDM_VIEW_WRAP - MENUITEM "Show wrap symbol", IDM_VIEW_WRAP_SYMBOL + POPUP "Show Symbol" + BEGIN + MENUITEM "Show White Space and TAB", IDM_VIEW_TAB_SPACE + MENUITEM "Show End Of Line", IDM_VIEW_EOL + MENUITEM "Show all characters", IDM_VIEW_ALL_CHARACTERS + MENUITEM SEPARATOR + MENUITEM "Show Indent guide", IDM_VIEW_INDENT_GUIDE + MENUITEM "Show wrap symbol", IDM_VIEW_WRAP_SYMBOL + END + POPUP "Zoom" + BEGIN + MENUITEM "Zoom &in", IDM_VIEW_ZOOMIN + MENUITEM "Zoom &out", IDM_VIEW_ZOOMOUT + MENUITEM "Restore default zoom", IDM_VIEW_ZOOMRESTORE + END + POPUP "Move/Clone current document" + BEGIN + MENUITEM "Move to other view", IDM_VIEW_GOTO_ANOTHER_VIEW + MENUITEM "Clone to other view", IDM_VIEW_CLONE_TO_ANOTHER_VIEW + MENUITEM "Move to new instance", IDM_VIEW_GOTO_NEW_INSTANCE + MENUITEM "Open in new instance", IDM_VIEW_LOAD_IN_NEW_INSTANCE + END + MENUITEM "Word wrap", IDM_VIEW_WRAP + MENUITEM "Focus on other view", IDM_VIEW_SWITCHTO_OTHER_VIEW + MENUITEM "Hide lines", IDM_VIEW_HIDELINES MENUITEM "User Define Dialog...", IDM_VIEW_USER_DLG MENUITEM SEPARATOR - MENUITEM "Zoom &in", IDM_VIEW_ZOOMIN - MENUITEM "Zoom &out", IDM_VIEW_ZOOMOUT - MENUITEM "Restore default zoom setting", IDM_VIEW_ZOOMRESTORE - MENUITEM SEPARATOR MENUITEM "Fold all", IDM_VIEW_TOGGLE_FOLDALL - MENUITEM "Collapse the current level", IDM_VIEW_FOLD_CURRENT - MENUITEM "Uncollapse the current level", IDM_VIEW_UNFOLD_CURRENT - POPUP "Collapse the level" + MENUITEM "Unfold all", IDM_VIEW_TOGGLE_UNFOLDALL + MENUITEM "Collapse current level", IDM_VIEW_FOLD_CURRENT + MENUITEM "Uncollapse current level", IDM_VIEW_UNFOLD_CURRENT + POPUP "Collapse level" BEGIN MENUITEM "1" , IDM_VIEW_FOLD_1 MENUITEM "2", IDM_VIEW_FOLD_2 @@ -319,7 +348,7 @@ BEGIN MENUITEM "7", IDM_VIEW_FOLD_7 MENUITEM "8", IDM_VIEW_FOLD_8 END - POPUP "Uncollapse the level" + POPUP "Uncollapse level" BEGIN MENUITEM "1" , IDM_VIEW_UNFOLD_1 MENUITEM "2", IDM_VIEW_UNFOLD_2 @@ -330,15 +359,7 @@ BEGIN MENUITEM "7", IDM_VIEW_UNFOLD_7 MENUITEM "8", IDM_VIEW_UNFOLD_8 END - MENUITEM "Unfold all", IDM_VIEW_TOGGLE_UNFOLDALL - MENUITEM SEPARATOR - MENUITEM "Hide lines", IDM_VIEW_HIDELINES - MENUITEM SEPARATOR - MENUITEM "Go to another view", IDM_VIEW_GOTO_ANOTHER_VIEW - MENUITEM "Clone to another view", IDM_VIEW_CLONE_TO_ANOTHER_VIEW - MENUITEM "Focus on other view", IDM_VIEW_SWITCHTO_OTHER_VIEW - MENUITEM "Go to new instance", IDM_VIEW_GOTO_NEW_INSTANCE - MENUITEM "Open in new instance", IDM_VIEW_LOAD_IN_NEW_INSTANCE + MENUITEM SEPARATOR MENUITEM "Synchronize Vertical Scrolling", IDM_VIEW_SYNSCROLLV MENUITEM "Synchronize Horizontal Scrolling", IDM_VIEW_SYNSCROLLH @@ -433,7 +454,7 @@ BEGIN MENUITEM "Start Re&cording", IDM_MACRO_STARTRECORDINGMACRO MENUITEM "S&top Recording", IDM_MACRO_STOPRECORDINGMACRO MENUITEM "&Playback", IDM_MACRO_PLAYBACKRECORDEDMACRO - MENUITEM "&Save current recorded macro", IDM_MACRO_SAVECURRENTMACRO + MENUITEM "&Save current recorded macro...", IDM_MACRO_SAVECURRENTMACRO MENUITEM "&Run a macro multiple times...", IDM_MACRO_RUNMULTIMACRODLG END diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 05ee1704d..191a65d86 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -331,43 +331,9 @@ ScintillaKeyDefinition scintKeyDefs[] = { //array of accelerator keys for all po #ifdef UNICODE #include "localizationString.h" -LocalizationSwicher::LocalizationSwicher() +wstring LocalizationSwitcher::getLangFromXmlFileName(wchar_t *fn) const { - TCHAR userPath[MAX_PATH]; - - // Make localConf.xml path - TCHAR localConfPath[MAX_PATH]; - TCHAR nppPath[MAX_PATH]; - ::GetModuleFileName(NULL, nppPath, MAX_PATH); - PathRemoveFileSpec(nppPath); - lstrcpy(localConfPath, nppPath); - PathAppend(localConfPath, localConfFile); - - // Test if localConf.xml exist - bool isLocal = (PathFileExists(localConfPath) == TRUE); - - if (isLocal) - { - lstrcpy(userPath, nppPath); - } - else - { - ITEMIDLIST *pidl; - SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl); - SHGetPathFromIDList(pidl, userPath); - PathAppend(userPath, TEXT("Notepad++")); - } - - TCHAR nativeLangPath[MAX_PATH]; - lstrcpy(nativeLangPath, userPath); - PathAppend(nativeLangPath, TEXT("nativeLang.xml")); - - _nativeLangPath = nativeLangPath; -} - -wstring LocalizationSwicher::getLangFromXmlFileName(wchar_t *fn) const -{ - size_t nbItem = sizeof(localizationDefs)/sizeof(LocalizationSwicher::LocalizationDefinition); + size_t nbItem = sizeof(localizationDefs)/sizeof(LocalizationSwitcher::LocalizationDefinition); for (size_t i = 0 ; i < nbItem ; i++) { if (wcsicmp(fn, localizationDefs[i]._xmlFileName) == 0) @@ -376,7 +342,7 @@ wstring LocalizationSwicher::getLangFromXmlFileName(wchar_t *fn) const return TEXT(""); } -wstring LocalizationSwicher::getXmlFilePathFromLangName(wchar_t *langName) const +wstring LocalizationSwitcher::getXmlFilePathFromLangName(wchar_t *langName) const { for (size_t i = 0 ; i < _localizationList.size() ; i++) { @@ -386,19 +352,19 @@ wstring LocalizationSwicher::getXmlFilePathFromLangName(wchar_t *langName) const return TEXT(""); } -bool LocalizationSwicher::addLanguageFromXml(wstring xmlFullPath) +bool LocalizationSwitcher::addLanguageFromXml(wstring xmlFullPath) { wchar_t * fn = ::PathFindFileNameW(xmlFullPath.c_str()); wstring foundLang = getLangFromXmlFileName(fn); if (foundLang != TEXT("")) { - _localizationList.push_back(pair(foundLang ,xmlFullPath)); + _localizationList.push_back(pair(foundLang, xmlFullPath)); return true; } return false; } -bool LocalizationSwicher::switchToLang(wchar_t *lang2switch) const +bool LocalizationSwitcher::switchToLang(wchar_t *lang2switch) const { wstring langPath = getXmlFilePathFromLangName(lang2switch); if (langPath == TEXT("")) @@ -409,6 +375,17 @@ bool LocalizationSwicher::switchToLang(wchar_t *lang2switch) const #endif + +generic_string ThemeSwitcher::getThemeFromXmlFileName(const TCHAR *xmlFullPath) const +{ + if (xmlFullPath == TEXT("")) return xmlFullPath; + TCHAR fn[MAX_PATH]; + lstrcpy(fn, ::PathFindFileName(xmlFullPath)); + PathRemoveExtension(fn); + generic_string themeName = fn; + return themeName; +} + typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO); winVer getWindowsVersion() @@ -585,32 +562,30 @@ void cutString(const TCHAR *str2cut, vector & patternVect) } } +bool NppParameters::reloadStylers(TCHAR *stylePath) +{ + if (_pXmlUserStylerDoc) + delete _pXmlUserStylerDoc; + + _pXmlUserStylerDoc = new TiXmlDocument(stylePath?stylePath:_stylerPath); + bool loadOkay = _pXmlUserStylerDoc->LoadFile(); + if (!loadOkay) + { + ::MessageBox(NULL, TEXT("Load stylers.xml failed!"), TEXT("Configurator"),MB_OK); + delete _pXmlUserStylerDoc; + _pXmlUserStylerDoc = NULL; + return false; + } + _lexerStylerArray.eraseAll(); + _widgetStyleArray.setNbStyler( 0 ); + + return getUserStylersFromXmlTree(); +} + bool NppParameters::reloadLang() { - TCHAR userPath[MAX_PATH]; - - // Make localConf.xml path - TCHAR localConfPath[MAX_PATH]; - lstrcpy(localConfPath, _nppPath); - PathAppend(localConfPath, localConfFile); - - // Test if localConf.xml exist - bool isLocal = (PathFileExists(localConfPath) == TRUE); - - if (isLocal) - { - lstrcpy(userPath, _nppPath); - } - else - { - ITEMIDLIST *pidl; - SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl); - SHGetPathFromIDList(pidl, userPath); - PathAppend(userPath, TEXT("Notepad++")); - } - TCHAR nativeLangPath[MAX_PATH]; - lstrcpy(nativeLangPath, userPath); + lstrcpy(nativeLangPath, _userPath); PathAppend(nativeLangPath, TEXT("nativeLang.xml")); if (!PathFileExists(nativeLangPath)) @@ -639,8 +614,6 @@ bool NppParameters::load() bool isAllLaoded = true; for (int i = 0 ; i < NB_LANG ; _langList[i] = NULL, i++); - TCHAR userPath[MAX_PATH]; - // Make localConf.xml path TCHAR localConfPath[MAX_PATH]; lstrcpy(localConfPath, _nppPath); @@ -651,21 +624,21 @@ bool NppParameters::load() if (isLocal) { - lstrcpy(userPath, _nppPath); + lstrcpy(_userPath, _nppPath); } else { ITEMIDLIST *pidl; SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl); - SHGetPathFromIDList(pidl, userPath); + SHGetPathFromIDList(pidl, _userPath); - PathAppend(userPath, TEXT("Notepad++")); + PathAppend(_userPath, TEXT("Notepad++")); - lstrcpy(_appdataNppDir, userPath); + lstrcpy(_appdataNppDir, _userPath); - if (!PathFileExists(userPath)) + if (!PathFileExists(_userPath)) { - ::CreateDirectory(userPath, NULL); + ::CreateDirectory(_userPath, NULL); } } @@ -715,7 +688,7 @@ bool NppParameters::load() // config.xml : for per user // //---------------------------// TCHAR configPath[MAX_PATH]; - lstrcpy(configPath, userPath); + lstrcpy(configPath, _userPath); PathAppend(configPath, TEXT("config.xml")); TCHAR srcConfigPath[MAX_PATH]; @@ -758,20 +731,26 @@ bool NppParameters::load() //----------------------------// // stylers.xml : for per user // //----------------------------// - TCHAR stylerPath[MAX_PATH]; - lstrcpy(stylerPath, userPath); - PathAppend(stylerPath, TEXT("stylers.xml")); + + lstrcpy(_stylerPath, _userPath); + PathAppend(_stylerPath, TEXT("stylers.xml")); - if (!PathFileExists(stylerPath)) + if (!PathFileExists(_stylerPath)) { TCHAR srcStylersPath[MAX_PATH]; lstrcpy(srcStylersPath, _nppPath); PathAppend(srcStylersPath, TEXT("stylers.model.xml")); - ::CopyFile(srcStylersPath, stylerPath, TRUE); + ::CopyFile(srcStylersPath, _stylerPath, TRUE); } - _pXmlUserStylerDoc = new TiXmlDocument(stylerPath); + if ( _nppGUI._themeName.empty() || (!PathFileExists(_nppGUI._themeName.c_str())) ) + { + _nppGUI._themeName.assign(_stylerPath); + } + + _pXmlUserStylerDoc = new TiXmlDocument(_nppGUI._themeName.c_str()); + loadOkay = _pXmlUserStylerDoc->LoadFile(); if (!loadOkay) { @@ -783,10 +762,14 @@ bool NppParameters::load() else getUserStylersFromXmlTree(); + _themeSwitcher._stylesXmlPath = _stylerPath; + // Firstly, add the default theme + _themeSwitcher.addDefaultThemeFromXml(_stylerPath); + //-----------------------------------// // userDefineLang.xml : for per user // //-----------------------------------// - lstrcpy(_userDefineLangPath, userPath); + lstrcpy(_userDefineLangPath, _userPath); PathAppend(_userDefineLangPath, TEXT("userDefineLang.xml")); _pXmlUserLangDoc = new TiXmlDocument(_userDefineLangPath); @@ -806,7 +789,7 @@ bool NppParameters::load() // We'll look in the Notepad++ Dir. // //----------------------------------------------// TCHAR nativeLangPath[MAX_PATH]; - lstrcpy(nativeLangPath, userPath); + lstrcpy(nativeLangPath, _userPath); PathAppend(nativeLangPath, TEXT("nativeLang.xml")); if (!PathFileExists(nativeLangPath)) @@ -824,36 +807,14 @@ bool NppParameters::load() _pXmlNativeLangDocA = NULL; isAllLaoded = false; } - -/* - //----------------------------------------------// - // english.xml : for every user // - // Always in the Notepad++ Dir. // - //----------------------------------------------// - TCHAR englishPath[MAX_PATH]; - lstrcpy(englishPath, _nppPath); - PathAppend(englishPath, TEXT("localization\\english.xml")); - - if (PathFileExists(englishPath)) - { - _pXmlEnglishDocA = new TiXmlDocumentA(); - - loadOkay = _pXmlEnglishDocA->LoadUnicodeFilePath(englishPath); - if (!loadOkay) - { - delete _pXmlEnglishDocA; - _pXmlEnglishDocA = NULL; - isAllLaoded = false; - } - } -*/ - - +#ifdef UNICODE + _localizationSwitcher._nativeLangPath = nativeLangPath; +#endif //---------------------------------// // toolbarIcons.xml : for per user // //---------------------------------// TCHAR toolbarIconsPath[MAX_PATH]; - lstrcpy(toolbarIconsPath, userPath); + lstrcpy(toolbarIconsPath, _userPath); PathAppend(toolbarIconsPath, TEXT("toolbarIcons.xml")); _pXmlToolIconsDoc = new TiXmlDocument(toolbarIconsPath); @@ -868,7 +829,7 @@ bool NppParameters::load() //------------------------------// // shortcuts.xml : for per user // //------------------------------// - lstrcpy(_shortcutsPath, userPath); + lstrcpy(_shortcutsPath, _userPath); PathAppend(_shortcutsPath, TEXT("shortcuts.xml")); if (!PathFileExists(_shortcutsPath)) @@ -902,7 +863,7 @@ bool NppParameters::load() //---------------------------------// // contextMenu.xml : for per user // //---------------------------------// - lstrcpy(_contextMenuPath, userPath); + lstrcpy(_contextMenuPath, _userPath); PathAppend(_contextMenuPath, TEXT("contextMenu.xml")); if (!PathFileExists(_contextMenuPath)) @@ -928,7 +889,7 @@ bool NppParameters::load() //----------------------------// // session.xml : for per user // //----------------------------// - lstrcpy(_sessionPath, userPath); + lstrcpy(_sessionPath, _userPath); PathAppend(_sessionPath, TEXT("session.xml")); // Don't load session.xml if not required in order to speed up!! @@ -2280,6 +2241,17 @@ void LexerStylerArray::addLexerStyler(const TCHAR *lexerName, const TCHAR *lexer } } +void LexerStylerArray::eraseAll() +{ + + for (int i = 0 ; i < _nbLexerStyler ; i++) + { + _lexerStylerArray[i].setNbStyler( 0 ); + } + + _nbLexerStyler = 0; +} + void StyleArray::addStyler(int styleID, TiXmlNode *styleNode) { _styleArray[_nbStyler]._styleID = styleID; @@ -3228,6 +3200,12 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) _nppGUI._shortTitlebar = false; } } + else if (!lstrcmp(nm, TEXT("stylerTheme"))) + { + const TCHAR *themePath = element->Attribute(TEXT("path")); + if (themePath != NULL && themePath != TEXT("")) + _nppGUI._themeName.assign(themePath); + } } } @@ -3255,7 +3233,7 @@ void NppParameters::feedScintillaParam(bool whichOne, TiXmlNode *node) else if (!lstrcmp(nm, TEXT("hide"))) _svp[whichOne]._bookMarkMarginShow = false; } - +/* // doc change state Margin nm = element->Attribute(TEXT("docChangeStateMargin")); if (nm) @@ -3266,7 +3244,7 @@ void NppParameters::feedScintillaParam(bool whichOne, TiXmlNode *node) else if (!lstrcmp(nm, TEXT("hide"))) _svp[whichOne]._docChangeStateMarginShow = false; } - +*/ // Indent GuideLine nm = element->Attribute(TEXT("indentGuideLine")); if (nm) @@ -3468,7 +3446,7 @@ bool NppParameters::writeScintillaParams(const ScintillaViewParams & svp, bool w (scintNode->ToElement())->SetAttribute(TEXT("lineNumberMargin"), svp._lineNumberMarginShow?TEXT("show"):TEXT("hide")); (scintNode->ToElement())->SetAttribute(TEXT("bookMarkMargin"), svp._bookMarkMarginShow?TEXT("show"):TEXT("hide")); - (scintNode->ToElement())->SetAttribute(TEXT("docChangeStateMargin"), svp._docChangeStateMarginShow?TEXT("show"):TEXT("hide")); + //(scintNode->ToElement())->SetAttribute(TEXT("docChangeStateMargin"), svp._docChangeStateMarginShow?TEXT("show"):TEXT("hide")); (scintNode->ToElement())->SetAttribute(TEXT("indentGuideLine"), svp._indentGuideLineShow?TEXT("show"):TEXT("hide")); const TCHAR *pFolderStyleStr = (svp._folderStyle == FOLDER_STYLE_SIMPLE)?TEXT("simple"): (svp._folderStyle == FOLDER_STYLE_ARROW)?TEXT("arrow"): @@ -3526,6 +3504,7 @@ bool NppParameters::writeGUIParams() bool caretExist = false; bool openSaveDirExist = false; bool titleBarExist = false; + bool stylerThemeExist = false; TiXmlNode *dockingParamNode = NULL; @@ -3865,6 +3844,11 @@ bool NppParameters::writeGUIParams() //pStr = (_nppGUI._showDirty)?TEXT("yes"):TEXT("no"); //element->SetAttribute(TEXT("showDirty"), pStr); } + else if (!lstrcmp(nm, TEXT("stylerTheme"))) + { + stylerThemeExist = true; + element->SetAttribute(TEXT("path"), _nppGUI._themeName.c_str()); + } } if (!noUpdateExist) @@ -4045,6 +4029,12 @@ bool NppParameters::writeGUIParams() const TCHAR *pStr = (_nppGUI._shortTitlebar)?TEXT("yes"):TEXT("no"); GUIConfigElement->SetAttribute(TEXT("short"), pStr); } + if (!stylerThemeExist) + { + TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); + GUIConfigElement->SetAttribute(TEXT("name"), TEXT("stylerTheme")); + GUIConfigElement->SetAttribute(TEXT("path"), _nppGUI._themeName.c_str()); + } insertDockingParamNode(GUIRoot); return true; diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index fd44cfe65..6d5e4126f 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -137,8 +137,22 @@ struct CmdLineParams { bool _isNoTab; int _line2go; + int _column2go; + + POINT _point; + bool _isPointXValid; + bool _isPointYValid; + bool isPointValid() { + return _isPointXValid && _isPointXValid; + }; + LangType _langType; - CmdLineParams() : _isNoPlugin(false), _isReadOnly(false), _isNoSession(false), _isNoTab(false), _line2go(-1), _langType(L_EXTERNAL){} + CmdLineParams() : _isNoPlugin(false), _isReadOnly(false), _isNoSession(false), _isNoTab(false),\ + _line2go(-1), _column2go(-1), _langType(L_EXTERNAL), _isPointXValid(false), _isPointYValid(false) + { + _point.x = 0; + _point.y = 0; + } }; struct FloatingWindowInfo { @@ -466,7 +480,7 @@ public : }; bool hasEnoughSpace() {return (_nbLexerStyler < MAX_LEXER_STYLE);}; void addLexerStyler(const TCHAR *lexerName, const TCHAR *lexerDesc, const TCHAR *lexerUserExt, TiXmlNode *lexerNode); - + void eraseAll(); private : LexerStyler _lexerStylerArray[MAX_LEXER_STYLE]; int _nbLexerStyler; @@ -538,7 +552,7 @@ struct NppGUI _isMaximized(false), _isMinimizedToTray(false), _rememberLastSession(true), _backup(bak_none), _useDir(false),\ _doTaskList(true), _maitainIndent(true), _openSaveDir(dir_followCurrent), _styleMRU(true), _styleURL(0),\ _autocStatus(autoc_none), _autocFromLen(1), _funcParams(false), _definedSessionExt(TEXT("")), _neverUpdate(false),\ - _doesExistUpdater(false), _caretBlinkRate(250), _caretWidth(1), _shortTitlebar(false) { + _doesExistUpdater(false), _caretBlinkRate(250), _caretWidth(1), _shortTitlebar(false), _themeName(TEXT("")) { _appPos.left = 0; _appPos.top = 0; _appPos.right = 700; @@ -617,17 +631,18 @@ struct NppGUI OpenSaveDirSetting _openSaveDir; TCHAR _defaultDir[MAX_PATH]; TCHAR _defaultDirExp[MAX_PATH]; //expanded environment variables + generic_string _themeName; }; struct ScintillaViewParams { - ScintillaViewParams() : _lineNumberMarginShow(true), _bookMarkMarginShow(true), _docChangeStateMarginShow(true),\ + ScintillaViewParams() : _lineNumberMarginShow(true), _bookMarkMarginShow(true),\ _folderStyle(FOLDER_STYLE_BOX), _indentGuideLineShow(true),\ _currentLineHilitingShow(true), _wrapSymbolShow(false), _doWrap(false),\ _zoom(0), _whiteSpaceShow(false), _eolShow(false){}; bool _lineNumberMarginShow; bool _bookMarkMarginShow; - bool _docChangeStateMarginShow; + //bool _docChangeStateMarginShow; folderStyle _folderStyle; //"simple", TEXT("arrow"), TEXT("circle") and "box" bool _indentGuideLineShow; bool _currentLineHilitingShow; @@ -833,9 +848,10 @@ struct FindHistory { #ifdef UNICODE -class LocalizationSwicher { +class LocalizationSwitcher { +friend class NppParameters; public : - LocalizationSwicher(); + LocalizationSwitcher() {}; struct LocalizationDefinition { wchar_t *_langName; @@ -864,6 +880,58 @@ private : }; #endif +class ThemeSwitcher { +friend class NppParameters; + +public : + ThemeSwitcher(){}; + + struct ThemeDefinition { + TCHAR *_themeName; + TCHAR *_xmlFileName; + }; + + void addThemeFromXml(generic_string xmlFullPath) { + _themeList.push_back(pair(getThemeFromXmlFileName(xmlFullPath.c_str()), xmlFullPath)); + }; + + void addDefaultThemeFromXml(generic_string xmlFullPath) { + _themeList.push_back(pair(TEXT("Default"), xmlFullPath)); + }; + + generic_string getThemeFromXmlFileName(const TCHAR *fn) const; + + generic_string getXmlFilePathFromThemeName(const TCHAR *themeName) const { + if (!themeName || themeName[0]) + return TEXT(""); + generic_string themePath = _stylesXmlPath; + return themePath; + }; + + bool themeNameExists(const TCHAR *themeName) { + for (size_t i = 0; i < _themeList.size(); i++ ) + { + if (! (getElementFromIndex(i)).first.compare(themeName) ) return true; + } + return false; + } + + size_t size() const { + return _themeList.size(); + }; + + + pair & getElementFromIndex(size_t index) { + //if (index >= _themeList.size()) + //return pair(TEXT(""), TEXT("")); + return _themeList[index]; + }; + +private : + vector< pair< generic_string, generic_string > > _themeList; + generic_string _stylesXmlPath; +}; + const int NB_LANG = 80; const bool DUP = true; @@ -876,6 +944,7 @@ public: static LangType getLangIDFromStr(const TCHAR *langName); bool load(); bool reloadLang(); + bool reloadStylers(TCHAR *stylePath = NULL); void destroyInstance(); bool _isTaskListRBUTTONUP_Active; @@ -1184,11 +1253,13 @@ public: bool _isFindReplacing; // an on the fly variable for find/replace functions #ifdef UNICODE - LocalizationSwicher & getLocalizationSwitcher() { + LocalizationSwitcher & getLocalizationSwitcher() { return _localizationSwitcher; }; - #endif + ThemeSwitcher & getThemeSwitcher() { + return _themeSwitcher; + }; private: NppParameters(); @@ -1248,9 +1319,10 @@ private: vector _scintillaKeyCommands; //scintilla keycommands. Static size vector _scintillaModifiedKeyIndices; //modified scintilla keys. Indices static, determined by searching for commandId. Needed when saving alterations #ifdef UNICODE - LocalizationSwicher _localizationSwitcher; - + LocalizationSwitcher _localizationSwitcher; #endif + ThemeSwitcher _themeSwitcher; + //vector _noMenuCmdNames; vector _contextMenuItems; Session _session; @@ -1259,6 +1331,8 @@ private: TCHAR _contextMenuPath[MAX_PATH]; TCHAR _sessionPath[MAX_PATH]; TCHAR _nppPath[MAX_PATH]; + TCHAR _userPath[MAX_PATH]; + TCHAR _stylerPath[MAX_PATH]; TCHAR _appdataNppDir[MAX_PATH]; // sentinel of the absence of "doLocalConf.xml" : (_appdataNppDir == TEXT(""))?"doLocalConf.xml present":"doLocalConf.xml absent" TCHAR _currentDirectory[MAX_PATH]; diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index 3877314ae..a83b4855d 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -327,7 +327,7 @@ void Buffer::setDeferredReload() { //triggers a reload on the next Document acce doNotify(BufferChangeDirty); } - +/* pair Buffer::getLineUndoState(size_t currentLine) const { for (size_t i = 0 ; i < _linesUndoState.size() ; i++) @@ -354,6 +354,7 @@ void Buffer::setLineUndoState(size_t currentLine, size_t undoLevel, bool isSaved _linesUndoState.push_back(pair >(currentLine, pair(undoLevel, false))); } } +*/ //filemanager @@ -581,7 +582,7 @@ bool FileManager::saveBuffer(BufferID id, const TCHAR * filename, bool isCopy) { buffer->setStatus(DOC_REGULAR); buffer->checkFileState(); _pscratchTilla->execute(SCI_SETSAVEPOINT); - _pscratchTilla->markSavedLines(); + //_pscratchTilla->markSavedLines(); _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault); return true; @@ -589,7 +590,8 @@ bool FileManager::saveBuffer(BufferID id, const TCHAR * filename, bool isCopy) { return false; } -BufferID FileManager::newEmptyDocument() { +BufferID FileManager::newEmptyDocument() +{ TCHAR newTitle[10]; lstrcpy(newTitle, UNTITLED_STR); wsprintf(newTitle+4, TEXT("%d"), _nextNewNumber); diff --git a/PowerEditor/src/ScitillaComponent/Buffer.h b/PowerEditor/src/ScitillaComponent/Buffer.h index 14c5eea76..8a19a355e 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.h +++ b/PowerEditor/src/ScitillaComponent/Buffer.h @@ -323,8 +323,11 @@ public : void setNeedReload(bool reload) { _needReloading = reload; } + + /* pair getLineUndoState(size_t currentLine) const; void setLineUndoState(size_t currentLine, size_t undoLevel, bool isSaved = false); + */ int docLength() const { return _pManager->docLength(_id); @@ -350,7 +353,8 @@ private : vector< ScintillaEditView * > _referees; vector< Position > _positions; vector< vector > _foldStates; - vector< pair > > _linesUndoState; + + //vector< pair > > _linesUndoState; //Environment properties DocFileStatus _currentStatus; diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index 8dc82f8b7..1df138ed4 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -30,7 +30,7 @@ UserDefineDialog ScintillaEditView::_userDefineDlg; const int ScintillaEditView::_SC_MARGE_LINENUMBER = 0; const int ScintillaEditView::_SC_MARGE_SYBOLE = 1; const int ScintillaEditView::_SC_MARGE_FOLDER = 2; -const int ScintillaEditView::_SC_MARGE_MODIFMARKER = 3; +//const int ScintillaEditView::_SC_MARGE_MODIFMARKER = 3; WNDPROC ScintillaEditView::_scintillaDefaultProc = NULL; /* @@ -153,14 +153,14 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere) showMargin(_SC_MARGE_FOLDER, true); execute(SCI_SETMARGINMASKN, _SC_MARGE_SYBOLE, (1<getNppGUI())._tabSize); @@ -1901,7 +1901,7 @@ void ScintillaEditView::performGlobalStyles() } for (int j = 0 ; j < NB_FOLDER_STATE ; j++) defineMarker(_markersArray[FOLDER_TYPE][j], _markersArray[_folderStyle][j], foldfgColor, foldbgColor); - +/* COLORREF unsavedChangebgColor = liteRed; i = stylers.getStylerIndexByName(TEXT("Unsaved change marker")); if (i != -1) @@ -1919,7 +1919,7 @@ void ScintillaEditView::performGlobalStyles() savedChangebgColor = style._bgColor; } execute(SCI_MARKERSETBACK, MARK_LINEMODIFIEDSAVED, savedChangebgColor); - +*/ COLORREF wsSymbolFgColor = black; i = stylers.getStylerIndexByName(TEXT("White space symbol")); if (i != -1) diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h index cda6c9a82..a1ba13881 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h @@ -102,8 +102,8 @@ const UCHAR BASE_02 = 0x03; // Bin const int MARK_BOOKMARK = 24; const int MARK_HIDELINESBEGIN = 23; const int MARK_HIDELINESEND = 22; -const int MARK_LINEMODIFIEDUNSAVED = 21; -const int MARK_LINEMODIFIEDSAVED = 20; +//const int MARK_LINEMODIFIEDUNSAVED = 21; +//const int MARK_LINEMODIFIEDSAVED = 20; // 24 - 16 reserved for Notepad++ internal used // 15 - 0 are free to use for plugins @@ -245,7 +245,7 @@ public: static const int _SC_MARGE_LINENUMBER; static const int _SC_MARGE_SYBOLE; static const int _SC_MARGE_FOLDER; - static const int _SC_MARGE_MODIFMARKER; + //static const int _SC_MARGE_MODIFMARKER; void showMargin(int whichMarge, bool willBeShowed = true) { if (whichMarge == _SC_MARGE_LINENUMBER) @@ -526,7 +526,7 @@ public: return false; }; void setHiLiteResultWords(const TCHAR *keywords); - +/* pair getLineUndoState(size_t currentLine) { Buffer * buf = getCurrentBuffer(); return buf->getLineUndoState(currentLine); @@ -548,7 +548,7 @@ public: } } }; - +*/ protected: static HINSTANCE _hLib; static int _refCount; diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp index cfef1d25a..02943f92f 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp @@ -71,21 +71,14 @@ BOOL CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar { case WM_INITDIALOG : { - _lsArray = (NppParameters::getInstance())->getLStylerArray(); - _globalStyles = (NppParameters::getInstance())->getGlobalStylers(); - - ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_ADDSTRING, 0, (LPARAM)TEXT("Global Styles")); - // All the lexers - for (int i = 0 ; i < _lsArray.getNbLexer() ; i++) - { - ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_ADDSTRING, 0, (LPARAM)_lsArray.getLexerDescFromIndex(i)); - } + NppParameters *nppParamInst = NppParameters::getInstance(); _hCheckBold = ::GetDlgItem(_hSelf, IDC_BOLD_CHECK); _hCheckItalic = ::GetDlgItem(_hSelf, IDC_ITALIC_CHECK); _hCheckUnderline = ::GetDlgItem(_hSelf, IDC_UNDERLINE_CHECK); _hFontNameCombo = ::GetDlgItem(_hSelf, IDC_FONT_COMBO); _hFontSizeCombo = ::GetDlgItem(_hSelf, IDC_FONTSIZE_COMBO); + _hSwitch2ThemeCombo = ::GetDlgItem(_hSelf, IDC_SWITCH2THEME_COMBO); _hFgColourStaticText = ::GetDlgItem(_hSelf, IDC_FG_STATIC); _hBgColourStaticText = ::GetDlgItem(_hSelf, IDC_BG_STATIC); @@ -96,6 +89,29 @@ BOOL CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar colourHooker.setColour(RGB(0xFF, 0x00, 0x00)); colourHooker.hookOn(_hStyleInfoStaticText); + _currentThemeIndex = -1; + int defaultThemeIndex = 0; + ThemeSwitcher & themeSwitcher = nppParamInst->getThemeSwitcher(); + for(size_t i = 0 ; i < themeSwitcher.size() ; i++) + { + pair & themeInfo = themeSwitcher.getElementFromIndex(i); + int j = ::SendMessage(_hSwitch2ThemeCombo, CB_ADDSTRING, 0, (LPARAM)themeInfo.first.c_str()); + ::SendMessage(_hSwitch2ThemeCombo, CB_SETITEMDATA, j, (LPARAM)themeInfo.second.c_str()); + if (! themeInfo.second.compare( nppParamInst->getNppGUI()._themeName ) ) + { + _currentThemeIndex = j; + } + if (! themeInfo.first.compare(TEXT("Default")) ) + { + defaultThemeIndex = j; + } + } + if (_currentThemeIndex == -1) + { + _currentThemeIndex = defaultThemeIndex; + } + ::SendMessage(_hSwitch2ThemeCombo, CB_SETCURSEL, _currentThemeIndex, 0); + for(int i = 0 ; i < sizeof(fontSizeStrs)/(3*sizeof(TCHAR)) ; i++) ::SendMessage(_hFontSizeCombo, CB_ADDSTRING, 0, (LPARAM)fontSizeStrs[i]); @@ -124,14 +140,11 @@ BOOL CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar _pFgColour->display(); _pBgColour->display(); - const int index2Begin = 0; - ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_SETCURSEL, 0, index2Begin); - setStyleListFromLexer(index2Begin); - ::EnableWindow(::GetDlgItem(_hSelf, IDOK), _isDirty); - ::EnableWindow(::GetDlgItem(_hSelf, IDC_SAVECLOSE_BUTTON), !_isSync); - NppParameters *pNppParam = NppParameters::getInstance(); - ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture(); + ::EnableWindow(::GetDlgItem(_hSelf, IDOK), _isDirty); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_SAVECLOSE_BUTTON), FALSE/*!_isSync*/); + + ETDTProc enableDlgTheme = (ETDTProc)nppParamInst->getEnableThemeDlgTexture(); if (enableDlgTheme) { enableDlgTheme(_hSelf, ETDT_ENABLETAB); @@ -141,6 +154,9 @@ BOOL CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar updateGlobalOverrideCtrls(); setVisualFromStyleList(); goToCenter(); + + loadLangListFromNppParam(); + return TRUE; } @@ -206,19 +222,40 @@ BOOL CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar //::MessageBox(NULL, TEXT("cancel"), TEXT(""), MB_OK); if (_isDirty) { - //::MessageBox(NULL, TEXT("dirty"), TEXT(""), MB_OK); - LexerStylerArray & lsArray = (NppParameters::getInstance())->getLStylerArray(); - StyleArray & globalStyles = (NppParameters::getInstance())->getGlobalStylers(); + NppParameters *nppParamInst = NppParameters::getInstance(); + if (_restoreInvalid) + { + generic_string str( nppParamInst->getNppGUI()._themeName ); + nppParamInst->reloadStylers( &str[0] ); + } + + LexerStylerArray & lsArray = nppParamInst->getLStylerArray(); + StyleArray & globalStyles = nppParamInst->getGlobalStylers(); - globalStyles = _globalStyles = _gstyles2restored; - lsArray = _lsArray = _styles2restored; + if (_restoreInvalid) + { + _lsArray = _styles2restored = lsArray; + _globalStyles = _gstyles2restored = globalStyles; + } + else + { + globalStyles = _globalStyles = _gstyles2restored; + lsArray = _lsArray = _styles2restored; + } + restoreGlobalOverrideValues(); + _restoreInvalid = false; _isDirty = false; + _isThemeDirty = false; setVisualFromStyleList(); + + + //(nppParamInst->getNppGUI())._themeName + ::SendMessage(_hSwitch2ThemeCombo, CB_SETCURSEL, _currentThemeIndex, 0); ::SendMessage(_hParent, WM_UPDATESCINTILLAS, 0, 0); } - ::EnableWindow(::GetDlgItem(_hSelf, IDC_SAVECLOSE_BUTTON), !_isSync); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_SAVECLOSE_BUTTON), FALSE/*!_isSync*/); display(false); return TRUE; @@ -229,15 +266,19 @@ BOOL CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar LexerStylerArray & lsa = (NppParameters::getInstance())->getLStylerArray(); StyleArray & globalStyles = (NppParameters::getInstance())->getGlobalStylers(); - lsa = _lsArray; - globalStyles = _globalStyles; + _lsArray = lsa; + _globalStyles = globalStyles; + updateThemeName(_themeName); + _restoreInvalid = false; + _currentThemeIndex = ::SendMessage(_hSwitch2ThemeCombo, CB_GETCURSEL, 0, 0); ::EnableWindow(::GetDlgItem(_hSelf, IDOK), FALSE); _isDirty = false; } + _isThemeDirty = false; (NppParameters::getInstance())->writeStyles(_lsArray, _globalStyles); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SAVECLOSE_BUTTON), FALSE); - _isSync = true; + //_isSync = true; display(false); ::SendMessage(_hParent, WM_UPDATESCINTILLAS, 0, 0); return TRUE; @@ -339,12 +380,24 @@ BOOL CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar { int i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETCURSEL, 0, 0); if (i != LB_ERR) + { + bool prevThemeState = _isThemeDirty; setStyleListFromLexer(i); + _isThemeDirty = prevThemeState; + } break; } case IDC_STYLES_LIST : setVisualFromStyleList(); break; + + case IDC_SWITCH2THEME_COMBO : + switchToTheme(); + setVisualFromStyleList(); + notifyDataModified(); + _isThemeDirty = false; + apply(); + break; } return TRUE; } @@ -400,6 +453,34 @@ BOOL CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar return FALSE; } +void WordStyleDlg::loadLangListFromNppParam() +{ + NppParameters *nppParamInst = NppParameters::getInstance(); + _lsArray = nppParamInst->getLStylerArray(); + _globalStyles = nppParamInst->getGlobalStylers(); + + // Clean up Language List + ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_RESETCONTENT, 0, 0); + + ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_ADDSTRING, 0, (LPARAM)TEXT("Global Styles")); + // All the lexers + for (int i = 0 ; i < _lsArray.getNbLexer() ; i++) + { + ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_ADDSTRING, 0, (LPARAM)_lsArray.getLexerDescFromIndex(i)); + } + + const int index2Begin = 0; + ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_SETCURSEL, 0, index2Begin); + setStyleListFromLexer(index2Begin); +} + +void WordStyleDlg::updateThemeName(generic_string themeName) +{ + NppParameters *pNppParam = NppParameters::getInstance(); + NppGUI & nppGUI = (NppGUI & )pNppParam->getNppGUI(); + nppGUI._themeName.assign( themeName ); +} + void WordStyleDlg::updateColour(bool which) { Style & style = getCurrentStyler(); @@ -504,6 +585,39 @@ void WordStyleDlg::updateFontStyleStatus(fontStyleType whitchStyle) } } +void WordStyleDlg::switchToTheme() +{ + int iSel = ::SendMessage(_hSwitch2ThemeCombo, CB_GETCURSEL, 0, 0); + + generic_string prevThemeName(_themeName); + _themeName.clear(); + _themeName.assign( (TCHAR *)::SendMessage(_hSwitch2ThemeCombo, CB_GETITEMDATA, iSel, 0) ); + + //if (!_themeName.compare(prevThemeName) ) return; + + if ( _isThemeDirty ) { + TCHAR themeFileName[MAX_PATH]; + lstrcpy(themeFileName, prevThemeName.c_str()); + PathStripPath( themeFileName ); + PathRemoveExtension( themeFileName ); + int mb_response = + ::MessageBox( _hSelf, + TEXT(" Unsaved changes are about to be discarded!\n") + TEXT(" Do you want to save your changes before switching themes?"), + themeFileName, + MB_ICONWARNING | MB_YESNO | MB_APPLMODAL | MB_SETFOREGROUND ); + if ( mb_response == IDYES ) (NppParameters::getInstance())->writeStyles(_lsArray, _globalStyles); + } + + + NppParameters *nppParamInst = NppParameters::getInstance(); + nppParamInst->reloadStylers(&_themeName[0]); + + loadLangListFromNppParam(); + _restoreInvalid = true; + +} + void WordStyleDlg::setStyleListFromLexer(int index) { _currentLexerIndex = index; @@ -705,6 +819,6 @@ void WordStyleDlg::apply() ::EnableWindow(::GetDlgItem(_hSelf, IDOK), FALSE); //_isDirty = false; - _isSync = false; + //_isSync = false; ::SendMessage(_hParent, WM_UPDATESCINTILLAS, 0, 0); } diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h index 862372656..fd82ef45d 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h @@ -63,7 +63,7 @@ private : class WordStyleDlg : public StaticDialog { public : - WordStyleDlg():_isDirty(false), _isSync(true), _isShownGOCtrls(false){/*_originalWarning[0] = '\0';*/}; + WordStyleDlg():_isDirty(false), _isThemeDirty(false), _restoreInvalid(false), /*_isSync(true),*/ _isShownGOCtrls(false){}; void init(HINSTANCE hInst, HWND parent) { Window::init(hInst, parent); @@ -114,12 +114,14 @@ private : ColourPicker *_pBgColour; int _currentLexerIndex; + int _currentThemeIndex; HWND _hCheckBold; HWND _hCheckItalic; HWND _hCheckUnderline; HWND _hFontNameCombo; HWND _hFontSizeCombo; + HWND _hSwitch2ThemeCombo; HWND _hFgColourStaticText; HWND _hBgColourStaticText; @@ -130,15 +132,18 @@ private : LexerStylerArray _lsArray; StyleArray _globalStyles; + generic_string _themeName; LexerStylerArray _styles2restored; StyleArray _gstyles2restored; GlobalOverride _gOverride2restored; + bool _restoreInvalid; ColourStaticTextHooker colourHooker; bool _isDirty; - bool _isSync; + bool _isThemeDirty; + //bool _isSync; bool _isShownGOCtrls; BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); @@ -183,6 +188,10 @@ private : void updateFontName(); void updateFontSize(); void updateUserKeywords(); + void switchToTheme(); + void updateThemeName(generic_string themeName); + + void loadLangListFromNppParam(); void enableFg(bool isEnable) { ::EnableWindow(_pFgColour->getHSelf(), isEnable); @@ -211,7 +220,7 @@ private : }; long notifyDataModified() { _isDirty = true; - //::EnableWindow(::GetDlgItem(_hSelf, IDOK), TRUE); + _isThemeDirty = true; ::EnableWindow(::GetDlgItem(_hSelf, IDC_SAVECLOSE_BUTTON), TRUE); return TRUE; } diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.rc b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.rc index 06356326a..206f04c95 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.rc +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.rc @@ -24,53 +24,59 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #define IDC_STATIC -1 #endif -IDD_STYLER_DLG DIALOGEX 36, 44, 500, 227 -STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | - WS_SYSMENU +IDD_STYLER_DLG DIALOGEX 36, 44, 500, 246 +STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_TOOLWINDOW CAPTION "Style Configurator" -FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0 +FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - LTEXT "Foreground color",IDC_FG_STATIC,203,48,59,8,0, WS_EX_RIGHT - LTEXT "Background color",IDC_BG_STATIC,203,75,59,8,0, WS_EX_RIGHT - COMBOBOX IDC_FONT_COMBO,371,44,104,78,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_FONTSIZE_COMBO,442,71,33,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "Bold",IDC_BOLD_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,64,63,10 - CONTROL "Italic",IDC_ITALIC_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,76,62,10 - GROUPBOX "Font style",IDC_FONTGROUP_STATIC,311,28,169,77 - GROUPBOX "Colour style",IDC_COLOURGROUP_STATIC,191,28,111,77 - LTEXT "Font Name :",IDC_FONTNAME_STATIC,315,47,52,8,0, WS_EX_RIGHT - LTEXT "Font size :",IDC_FONTSIZE_STATIC,388,73,51,8,0, WS_EX_RIGHT - LTEXT "Style :",IDC_STYLEDESC_STATIC,87,10,68,8 - //LTEXT "Attention : The definition of this style will be the default definition for all non defined styles", IDC_STYLEDEFAULT_WARNING_STATIC,190,6,295,22 - LTEXT " ", IDC_STYLEDESCRIPTION_STATIC,190,6,295,22 - EDITTEXT IDC_DEF_EXT_EDIT,17,191,61,14,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Default ext : ",IDC_DEF_EXT_STATIC,20,179,61,8 - EDITTEXT IDC_USER_EXT_EDIT,93,191,71,14, ES_AUTOHSCROLL - LTEXT "User ext :",IDC_USER_EXT_STATIC,95,180,71,8 - CONTROL "Underline",IDC_UNDERLINE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,88,80,10 - EDITTEXT IDC_DEF_KEYWORDS_EDIT,191,127,136,43,ES_MULTILINE | ES_READONLY | WS_VSCROLL - EDITTEXT IDC_USER_KEYWORDS_EDIT,347,126,134,43,ES_MULTILINE | WS_VSCROLL - LTEXT "Default keywords",IDC_DEF_KEYWORDS_STATIC,193,117,122,8 - LTEXT "User Define keywords",IDC_USER_KEYWORDS_STATIC,349,116,126,8 - LTEXT "+",IDC_PLUSSYMBOL_STATIC,335,142,8,8 - PUSHBUTTON "Cancel",IDCANCEL,332,198,57,14 - //PUSHBUTTON "Apply",IDOK,264,198,60,14 - PUSHBUTTON "Save && Close",IDC_SAVECLOSE_BUTTON,255,198,69,14 - CONTROL "",IDC_SC_PERCENTAGE_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | NOT WS_VISIBLE | WS_TABSTOP,441,208,53,10 - CONTROL "Transparency",IDC_SC_TRANSPARENT_CHECK,"Button", BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,431,197,63, 10 - LISTBOX IDC_LANGUAGES_LIST,17,22,59,146,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - LISTBOX IDC_STYLES_LIST,87,22,76,146,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP - GROUPBOX "",IDC_STATIC,7,0,166,212 - LTEXT "Language :",IDC_LANGDESC_STATIC,19,10,61,8 - GROUPBOX "",IDC_STATIC,181,0,310,184 - LTEXT "+",IDC_PLUSSYMBOL2_STATIC,83,193,8,8 - CONTROL "Enable global foreground color",IDC_GLOBAL_FG_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,191,114,132,10 - CONTROL "Enable global background color",IDC_GLOBAL_BG_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,191,129,131,10 - CONTROL "Enable global font",IDC_GLOBAL_FONT_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,110,153,10 - CONTROL "Enable global font size",IDC_GLOBAL_FONTSIZE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,125,135,10 - CONTROL "Enable global bold font style",IDC_GLOBAL_BOLD_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,328,140,135,10 - CONTROL "Enable global Italic font style",IDC_GLOBAL_ITALIC_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,328,155,135,10 - CONTROL "Enable global underline font style",IDC_GLOBAL_UNDERLINE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,328,170,135,10 + LTEXT "Switch to theme : ",IDC_SWITCH2THEME_STATIC,6,9,83,8,0,WS_EX_RIGHT + COMBOBOX IDC_SWITCH2THEME_COMBO,95,7,104,78,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP + LTEXT "Foreground color",IDC_FG_STATIC,203,72,59,8,0,WS_EX_RIGHT + LTEXT "Background color",IDC_BG_STATIC,203,99,59,8,0,WS_EX_RIGHT + COMBOBOX IDC_FONT_COMBO,371,68,104,78,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_FONTSIZE_COMBO,442,95,33,82,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "Bold",IDC_BOLD_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,88,63,10 + CONTROL "Italic",IDC_ITALIC_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,100,62,10 + GROUPBOX "Font style",IDC_FONTGROUP_STATIC,311,52,169,77 + GROUPBOX "Colour style",IDC_COLOURGROUP_STATIC,191,52,111,77 + LTEXT "Font Name :",IDC_FONTNAME_STATIC,315,71,52,8,0,WS_EX_RIGHT + LTEXT "Font size :",IDC_FONTSIZE_STATIC,388,97,51,8,0,WS_EX_RIGHT + LTEXT "Style :",IDC_STYLEDESC_STATIC,87,34,68,8 + LTEXT " ",IDC_STYLEDESCRIPTION_STATIC,190,30,295,22 + EDITTEXT IDC_DEF_EXT_EDIT,17,215,61,14,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Default ext : ",IDC_DEF_EXT_STATIC,20,203,61,8 + EDITTEXT IDC_USER_EXT_EDIT,93,215,71,14,ES_AUTOHSCROLL + LTEXT "User ext :",IDC_USER_EXT_STATIC,95,204,71,8 + CONTROL "Underline",IDC_UNDERLINE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,112,80,10 + EDITTEXT IDC_DEF_KEYWORDS_EDIT,191,151,136,43,ES_MULTILINE | ES_READONLY | WS_VSCROLL + EDITTEXT IDC_USER_KEYWORDS_EDIT,347,150,134,43,ES_MULTILINE | WS_VSCROLL + LTEXT "Default keywords",IDC_DEF_KEYWORDS_STATIC,193,141,122,8 + LTEXT "User Define keywords",IDC_USER_KEYWORDS_STATIC,349,140,126,8 + LTEXT "+",IDC_PLUSSYMBOL_STATIC,335,166,8,8 + PUSHBUTTON "Cancel",IDCANCEL,332,222,57,14 + PUSHBUTTON "Save && Close",IDC_SAVECLOSE_BUTTON,255,222,69,14 + CONTROL "",IDC_SC_PERCENTAGE_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | NOT WS_VISIBLE | WS_TABSTOP,441,235,53,10 + CONTROL "Transparency",IDC_SC_TRANSPARENT_CHECK,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,431,221,63,10 + LISTBOX IDC_LANGUAGES_LIST,17,46,59,146,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + LISTBOX IDC_STYLES_LIST,87,46,76,146,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP + GROUPBOX "",IDC_STATIC,7,24,166,212 + LTEXT "Language :",IDC_LANGDESC_STATIC,19,34,61,8 + GROUPBOX "",IDC_STATIC,181,24,310,184 + LTEXT "+",IDC_PLUSSYMBOL2_STATIC,83,217,8,8 + CONTROL "Enable global foreground color",IDC_GLOBAL_FG_CHECK, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,191,138,132,10 + CONTROL "Enable global background color",IDC_GLOBAL_BG_CHECK, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,191,153,131,10 + CONTROL "Enable global font",IDC_GLOBAL_FONT_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,134,153,10 + CONTROL "Enable global font size",IDC_GLOBAL_FONTSIZE_CHECK, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,149,135,10 + CONTROL "Enable global bold font style",IDC_GLOBAL_BOLD_CHECK, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,328,164,135,10 + CONTROL "Enable global Italic font style",IDC_GLOBAL_ITALIC_CHECK, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,328,179,135,10 + CONTROL "Enable global underline font style",IDC_GLOBAL_UNDERLINE_CHECK, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,328,194,135,10 + END diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlgRes.h b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlgRes.h index 59bf6973f..bb624a079 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlgRes.h +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlgRes.h @@ -61,3 +61,5 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #define IDC_SC_TRANSPARENT_CHECK (IDD_GLOBAL_STYLER_DLG + 3) #define IDC_LANGUAGES_LIST (IDD_GLOBAL_STYLER_DLG + 4) #define IDC_STYLES_LIST (IDD_GLOBAL_STYLER_DLG + 5) + #define IDC_SWITCH2THEME_STATIC (IDD_GLOBAL_STYLER_DLG + 6) + #define IDC_SWITCH2THEME_COMBO (IDD_GLOBAL_STYLER_DLG + 7) diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index f5c0312c8..ccba93e19 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -23,17 +23,17 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #ifndef IDC_STATIC #define IDC_STATIC -1 #endif -IDD_PREFERENCE_BOX DIALOGEX 0, 0, 395, 231 +IDD_PREFERENCE_BOX DIALOGEX 0, 0, 400, 235 STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE CAPTION "Preferences" FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN - PUSHBUTTON "Close",IDC_BUTTON_CLOSE,174,206,45,14 + PUSHBUTTON "Close",IDC_BUTTON_CLOSE,174,212,45,14 END -IDD_PREFERENCE_BAR_BOX DIALOGEX 0, 0, 370, 180 +IDD_PREFERENCE_BAR_BOX DIALOGEX 0, 0, 390, 185 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN @@ -62,7 +62,7 @@ BEGIN COMBOBOX IDC_COMBO_LOCALIZATION,28,20,119,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP END -IDD_PREFERENCE_MARGEIN_BOX DIALOGEX 0, 0, 392, 185 +IDD_PREFERENCE_MARGEIN_BOX DIALOGEX 0, 0, 390, 185 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN @@ -74,10 +74,8 @@ BEGIN CONTROL "Display line number margin",IDC_CHECK_LINENUMBERMARGE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,33,117,141,10 CONTROL "Display bookmark margin",IDC_CHECK_BOOKMARKMARGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,33,129,150,10 - CONTROL "Display line change state margin",IDC_CHECK_DOCCHANGESTATEMARGE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,33,141,162,10 - CONTROL "Enable current line highlight",IDC_CHECK_CURRENTLINEHILITE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,33,153,129,10 + //CONTROL "Display line change state margin",IDC_CHECK_DOCCHANGESTATEMARGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,33,141,162,10 + CONTROL "Enable current line highlight",IDC_CHECK_CURRENTLINEHILITE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,33,141,129,10 CONTROL "Show vertical edge",IDC_CHECK_SHOWVERTICALEDGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,212,81,122,10 RTEXT "Number of columns :",IDC_NBCOLONE_STATIC,207,129,83,8 LTEXT "0",IDC_COLONENUMBER_STATIC,297,128,18,8 @@ -100,7 +98,7 @@ BEGIN END -IDD_PREFERENCE_SETTING_BOX DIALOGEX 0, 0, 370, 180 +IDD_PREFERENCE_SETTING_BOX DIALOGEX 0, 0, 390, 185 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN @@ -132,7 +130,7 @@ BEGIN EDITTEXT IDC_EDIT_SESSIONFILEEXT,315,157,34,14,ES_AUTOHSCROLL END -IDD_PREFERENCE_NEWDOCSETTING_BOX DIALOGEX 0, 0, 370, 180 +IDD_PREFERENCE_NEWDOCSETTING_BOX DIALOGEX 0, 0, 390, 185 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN @@ -160,7 +158,7 @@ BEGIN CONTROL "Apply while open ANSI file",IDC_CHECK_OPENANSIASUTF8,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,74,46,124,10 END -IDD_PREFERENCE_LANG_BOX DIALOGEX 0, 0, 370, 180 +IDD_PREFERENCE_LANG_BOX DIALOGEX 0, 0, 390, 185 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN @@ -172,7 +170,7 @@ BEGIN CTEXT "Disabled items",IDC_DISABLEDITEMS_STATIC,229,8,72,8 END -IDD_PREFERENCE_PRINT_BOX DIALOGEX 0, 0, 370, 180 +IDD_PREFERENCE_PRINT_BOX DIALOGEX 0, 0, 390, 185 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN @@ -193,7 +191,7 @@ BEGIN GROUPBOX "Margin Setting (Unit:mm)",IDC_MARGESETTINGS_STATIC,187,45,144,96,BS_CENTER END -IDD_PREFERENCE_PRINT2_BOX DIALOGEX 0, 0, 370, 180 +IDD_PREFERENCE_PRINT2_BOX DIALOGEX 0, 0, 390, 185 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN @@ -226,7 +224,7 @@ BEGIN LTEXT "",IDC_VIEWPANEL_STATIC,121,149,213,8 END -IDD_PREFERENCE_BACKUP_BOX DIALOGEX 0, 0, 370, 180 +IDD_PREFERENCE_BACKUP_BOX DIALOGEX 0, 0, 390, 185 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index c5d16c652..ec2038172 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -174,7 +174,7 @@ BOOL CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) ::EnableWindow(::GetDlgItem(_hSelf, IDC_LOCALIZATION_GB_STATIC), FALSE); ::EnableWindow(::GetDlgItem(_hSelf, IDC_COMBO_LOCALIZATION), FALSE); #else - LocalizationSwicher & localizationSwitcher = pNppParam->getLocalizationSwitcher(); + LocalizationSwitcher & localizationSwitcher = pNppParam->getLocalizationSwitcher(); for (size_t i = 0 ; i < localizationSwitcher.size() ; i++) { @@ -276,7 +276,7 @@ BOOL CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) case IDC_RADIO_STANDARD : ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_TOOLBAR_STANDARD, 0); return TRUE; -#ifdef UNICODE + default : switch (HIWORD(wParam)) { @@ -286,11 +286,38 @@ BOOL CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) { case IDC_COMBO_LOCALIZATION : { - LocalizationSwicher & localizationSwitcher = pNppParam->getLocalizationSwitcher(); +#ifdef UNICODE + LocalizationSwitcher & localizationSwitcher = pNppParam->getLocalizationSwitcher(); int index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_GETCURSEL, 0, 0); wchar_t langName[MAX_PATH]; ::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_GETLBTEXT, index, (LPARAM)langName); if (langName[0]) + { + + // Make English as basic language + if (localizationSwitcher.switchToLang(TEXT("English"))) + { + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_RELOADNATIVELANG, 0, 0); + } + // Change the language + if (localizationSwitcher.switchToLang(langName)) + { + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_RELOADNATIVELANG, 0, 0); + ::InvalidateRect(_hParent, NULL, TRUE); + } + //::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_RELOADSTYLERS, 0, 0); + } +#endif + } + return TRUE; +/* + case IDC_COMBO_THEME : + { + LocalizationSwitcher & localizationSwitcher = pNppParam->getLocalizationSwitcher(); + int index = ::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_GETCURSEL, 0, 0); + TCHAR themeName[MAX_PATH]; + ::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_GETLBTEXT, index, (LPARAM)themeName); + if (langName[0]) { // Make English as basic language if (localizationSwitcher.switchToLang(TEXT("English"))) @@ -306,12 +333,12 @@ BOOL CALLBACK BarsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) } } return TRUE; + */ default: break; } } } -#endif } } } @@ -347,7 +374,7 @@ void MarginsDlg::changePanelTo(int index) ::SendDlgItemMessage(_hSelf, IDC_CHECK_LINENUMBERMARGE, BM_SETCHECK, svp._lineNumberMarginShow, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_BOOKMARKMARGE, BM_SETCHECK, svp._bookMarkMarginShow, 0); - ::SendDlgItemMessage(_hSelf, IDC_CHECK_DOCCHANGESTATEMARGE, BM_SETCHECK, svp._docChangeStateMarginShow, 0); + //::SendDlgItemMessage(_hSelf, IDC_CHECK_DOCCHANGESTATEMARGE, BM_SETCHECK, svp._docChangeStateMarginShow, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_CURRENTLINEHILITE, BM_SETCHECK, svp._currentLineHilitingShow, 0); bool isEnable = !(svp._edgeMode == EDGE_NONE); @@ -456,12 +483,12 @@ BOOL CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam svp._bookMarkMarginShow = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_CHECK_BOOKMARKMARGE, BM_GETCHECK, 0, 0)); ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_SYMBOLMARGIN, iView); return TRUE; - +/* case IDC_CHECK_DOCCHANGESTATEMARGE: svp._docChangeStateMarginShow = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_CHECK_DOCCHANGESTATEMARGE, BM_GETCHECK, 0, 0)); ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_DOCCHANGEMARGIN, iView); return TRUE; - +*/ case IDC_CHECK_CURRENTLINEHILITE: svp._currentLineHilitingShow = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_CHECK_CURRENTLINEHILITE, BM_GETCHECK, 0, 0)); ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_CURLINE_HILITING, iView); diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.cpp b/PowerEditor/src/WinControls/TabBar/TabBar.cpp index 3c1c189b9..fe0a51591 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.cpp +++ b/PowerEditor/src/WinControls/TabBar/TabBar.cpp @@ -26,6 +26,7 @@ const COLORREF grey = RGB(128, 128, 128); #define IDC_DRAG_TAB 1404 #define IDC_DRAG_INTERDIT_TAB 1405 #define IDC_DRAG_PLUS_TAB 1406 +#define IDC_DRAG_OUT_TAB 1407 bool TabBarPlus::_doDragNDrop = false; @@ -738,8 +739,10 @@ void TabBarPlus::draggingCursor(POINT screenPoint) else ::SetCursor(::LoadCursor(_hInst, MAKEINTRESOURCE(IDC_DRAG_TAB))); } - else + else if (isPointInParentZone(screenPoint)) ::SetCursor(::LoadCursor(_hInst, MAKEINTRESOURCE(IDC_DRAG_INTERDIT_TAB))); + else // drag out of application + ::SetCursor(::LoadCursor(_hInst, MAKEINTRESOURCE(IDC_DRAG_OUT_TAB))); } } diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.h b/PowerEditor/src/WinControls/TabBar/TabBar.h index 2294d623a..eb5399b67 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.h +++ b/PowerEditor/src/WinControls/TabBar/TabBar.h @@ -370,6 +370,13 @@ protected: return ::SendMessage(_hSelf, TCM_HITTEST, 0, (LPARAM)&hitInfo); }; + + bool isPointInParentZone(POINT screenPoint) const { + RECT parentZone; + ::GetWindowRect(_hParent, &parentZone); + return (((screenPoint.x >= parentZone.left) && (screenPoint.x <= parentZone.right)) && + (screenPoint.y >= parentZone.top) && (screenPoint.y <= parentZone.bottom)); + }; }; #endif // TAB_BAR_H diff --git a/PowerEditor/src/WinControls/TaskList/TaskListDlg.h b/PowerEditor/src/WinControls/TaskList/TaskListDlg.h index d1d93bd0e..6d29f3414 100644 --- a/PowerEditor/src/WinControls/TaskList/TaskListDlg.h +++ b/PowerEditor/src/WinControls/TaskList/TaskListDlg.h @@ -249,9 +249,7 @@ private : ::DrawText(hDC, label, lstrlen(label), &rect, DT_SINGLELINE | DT_VCENTER | DT_LEFT); }; - }; - #endif // TASKLISTDLG_H diff --git a/PowerEditor/src/contextMenu.xml b/PowerEditor/src/contextMenu.xml index 067f535c8..19b66b21c 100644 --- a/PowerEditor/src/contextMenu.xml +++ b/PowerEditor/src/contextMenu.xml @@ -22,7 +22,7 @@ - + diff --git a/PowerEditor/src/langs.model.xml b/PowerEditor/src/langs.model.xml index 24af76cb2..76ed65b1f 100644 --- a/PowerEditor/src/langs.model.xml +++ b/PowerEditor/src/langs.model.xml @@ -75,7 +75,7 @@ as case class data default deriving do else hiding if import in infix infixl infixr instance let module newtype of proc qualified rec then type where _ - !doctype a abbr accept-charset accept accesskey acronym action address align alink alt applet archive area axis b background base basefont bdo bgcolor big blockquote body border br button caption cellpadding cellspacing center char charoff charset checkbox checked cite class classid clear code codebase codetype col colgroup color cols colspan compact content coords data datafld dataformatas datapagesize datasrc datetime dd declare defer del dfn dir disabled div dl dt em embed enctype event face fieldset file font for form frame frameborder frameset h1 h2 h3 h4 h5 h6 head headers height hidden hr href hreflang hspace html http-equiv i id iframe image img input ins isindex ismap kbd label lang language leftmargin legend li link longdesc map marginwidth marginheight maxlength media menu meta method multiple name noframes nohref noresize noscript noshade nowrap object ol onblur onchange onclick ondblclick onfocus onkeydown onkeypress onkeyup onload onmousedown onmousemove onmouseover onmouseout onmouseup optgroup option onreset onselect onsubmit onunload p param password profile pre prompt public q radio readonly rel reset rev rows rowspan rules s samp scheme scope script scrolling select selected shape size small span src standby start strike strong style sub submit summary sup tabindex table target tbody td text textarea tfoot th thead title topmargin tr tt type u ul usemap valign value valuetype var version vlink vspace width xml xmlns + !doctype a abbr accept-charset accept accesskey acronym action address align alink alt applet archive area axis b background base basefont bdo bgcolor big blockquote body border br button caption cellpadding cellspacing center char charoff charset checkbox checked cite class classid clear code codebase codetype col colgroup color cols colspan comment compact content coords data datafld dataformatas datapagesize datasrc datetime dd declare defer del dfn dir disabled div dl dt em embed enctype event face fieldset file font for form frame frameborder frameset h1 h2 h3 h4 h5 h6 head headers height hidden hr href hreflang hspace html http-equiv i id iframe image img input ins isindex ismap kbd label lang language leftmargin legend li link longdesc map marginwidth marginheight maxlength media menu meta method multiple name noframes nohref noresize noscript noshade nowrap object ol onblur onchange onclick ondblclick onfocus onkeydown onkeypress onkeyup onload onmousedown onmousemove onmouseover onmouseout onmouseup optgroup option onreset onselect onsubmit onunload p param password profile pre prompt public q radio readonly rel reset rev rows rowspan rules s samp scheme scope script scrolling select selected shape size small span src standby start strike strong style sub submit summary sup tabindex table target tbody td text textarea tfoot th thead title topmargin tr tt type u ul usemap valign value valuetype var version vlink vspace width xml xmlns diff --git a/PowerEditor/src/localizationString.h b/PowerEditor/src/localizationString.h index d9c7ea1f5..45c21bec9 100644 Binary files a/PowerEditor/src/localizationString.h and b/PowerEditor/src/localizationString.h differ diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 4f11ff6cf..dac1c87d4 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -127,7 +127,9 @@ #define IDC_DRAG_TAB 1404 #define IDC_DRAG_INTERDIT_TAB 1405 #define IDC_DRAG_PLUS_TAB 1406 -#define IDC_MACRO_RECORDING 1407 +#define IDC_DRAG_OUT_TAB 1407 + +#define IDC_MACRO_RECORDING 1408 #define IDR_SAVEALL 1500 #define IDR_CLOSEFILE 1501 @@ -306,6 +308,7 @@ #define NPPM_INTERNAL_SEARCH_GOTONEXTFOUND (NOTEPADPLUS_USER_INTERNAL + 28) #define NPPM_INTERNAL_SEARCH_GOTOPREVFOUND (NOTEPADPLUS_USER_INTERNAL + 29) #define NPPM_INTERNAL_FOCUS_ON_FOUND_RESULTS (NOTEPADPLUS_USER_INTERNAL + 30) + #define NPPM_INTERNAL_RELOADSTYLERS (NOTEPADPLUS_USER_INTERNAL + 31) // See Notepad_plus_msgs.h //#define NOTEPADPLUS_USER (WM_USER + 1000) diff --git a/PowerEditor/src/stylers.model.xml b/PowerEditor/src/stylers.model.xml index dbab04239..e7dedf08f 100644 --- a/PowerEditor/src/stylers.model.xml +++ b/PowerEditor/src/stylers.model.xml @@ -726,7 +726,5 @@ - - diff --git a/PowerEditor/src/tools/xmlUpdater/xmlUpdater.vcproj b/PowerEditor/src/tools/xmlUpdater/xmlUpdater.vcproj index f332fc7ef..ad38fa487 100644 --- a/PowerEditor/src/tools/xmlUpdater/xmlUpdater.vcproj +++ b/PowerEditor/src/tools/xmlUpdater/xmlUpdater.vcproj @@ -1,114 +1,178 @@ + Keyword="Win32Proj" + > + Name="Win32" + /> + + + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + + + + + + CompileAs="2" + /> + Name="VCManagedResourceCompilerTool" + /> + + + TargetMachine="1" + /> + Name="VCALinkTool" + /> + Name="VCManifestTool" + /> + Name="VCXDCMakeTool" + /> + Name="VCBscMakeTool" + /> + Name="VCFxCopTool" + /> + Name="VCAppVerifierTool" + /> + Name="VCWebDeploymentTool" + /> - - + Name="VCPostBuildEventTool" + /> + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + + + + + + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + Name="VCManagedResourceCompilerTool" + /> + + + TargetMachine="1" + /> + Name="VCALinkTool" + /> + Name="VCManifestTool" + /> + Name="VCXDCMakeTool" + /> + Name="VCBscMakeTool" + /> + Name="VCFxCopTool" + /> + Name="VCAppVerifierTool" + /> + Name="VCWebDeploymentTool" + /> - - + Name="VCPostBuildEventTool" + /> @@ -117,32 +181,41 @@ + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + RelativePath="..\..\TinyXml\tinystr.cpp" + > + RelativePath="..\..\TinyXml\tinyxml.cpp" + > + RelativePath="..\..\TinyXml\tinyxmlerror.cpp" + > + RelativePath="..\..\TinyXml\tinyxmlparser.cpp" + > + RelativePath=".\xmlUpdater.cpp" + > + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + RelativePath="..\..\TinyXml\tinystr.h" + > + RelativePath="..\..\TinyXml\tinyxml.h" + > diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index ea404c791..829a56f3b 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -127,6 +127,17 @@ LangType getLangTypeFromParam(ParamVector & params) { return NppParameters::getLangIDFromStr(langStr.c_str()); }; +int getNumberFromParam(char paramName, ParamVector & params, bool & isParamePresent) { + generic_string numStr; + if (!getParamVal(paramName, params, numStr)) + { + isParamePresent = false; + return -1; + } + isParamePresent = true; + return generic_atoi(numStr.c_str()); +}; +/* int getLn2GoFromParam(ParamVector & params) { generic_string lineNumStr; if (!getParamVal('n', params, lineNumStr)) @@ -134,6 +145,14 @@ int getLn2GoFromParam(ParamVector & params) { return generic_atoi(lineNumStr.c_str()); }; +int getPointXFromParam(ParamVector & params) { + generic_string pointXStr; + if (!getParamVal('x', params, pointXStr)) + return -1; + return generic_atoi(pointXStr.c_str()); +}; +*/ + const TCHAR FLAG_MULTI_INSTANCE[] = TEXT("-multiInst"); const TCHAR FLAG_NO_PLUGIN[] = TEXT("-noPlugin"); const TCHAR FLAG_READONLY[] = TEXT("-ro"); @@ -142,7 +161,6 @@ const TCHAR FLAG_NOTABBAR[] = TEXT("-notabbar"); void doException(Notepad_plus & notepad_plus_plus); -//int WINAPI NppMainEntry(HINSTANCE hInstance, HINSTANCE, TCHAR * cmdLine, int nCmdShow) int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR cmdLineAnsi, int nCmdShow) { LPTSTR cmdLine = ::GetCommandLine(); @@ -157,6 +175,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR cmdLineAnsi, int nCmdSh if (::GetLastError() == ERROR_ALREADY_EXISTS) TheFirstOne = false; + bool isParamePresent; CmdLineParams cmdLineParams; bool isMultiInst = isInList(FLAG_MULTI_INSTANCE, params); cmdLineParams._isNoTab = isInList(FLAG_NOTABBAR, params); @@ -164,7 +183,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR cmdLineAnsi, int nCmdSh cmdLineParams._isReadOnly = isInList(FLAG_READONLY, params); cmdLineParams._isNoSession = isInList(FLAG_NOSESSION, params); cmdLineParams._langType = getLangTypeFromParam(params); - cmdLineParams._line2go = getLn2GoFromParam(params); + cmdLineParams._line2go = getNumberFromParam('n', params, isParamePresent); + cmdLineParams._column2go = getNumberFromParam('c', params, isParamePresent); + cmdLineParams._point.x = getNumberFromParam('x', params, cmdLineParams._isPointXValid); + cmdLineParams._point.y = getNumberFromParam('y', params, cmdLineParams._isPointYValid); NppParameters *pNppParameters = NppParameters::getInstance(); // override the settings if notepad style is present diff --git a/PowerEditor/visual.net/notepadPlus.vcproj b/PowerEditor/visual.net/notepadPlus.vcproj index 44515d626..425489dd1 100644 --- a/PowerEditor/visual.net/notepadPlus.vcproj +++ b/PowerEditor/visual.net/notepadPlus.vcproj @@ -631,6 +631,14 @@ RelativePath="..\src\resource.h" > + + + +