From 251e987a715cdb7ff829e23319677e849705a6b8 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Mon, 8 Jun 2015 03:19:34 +0200 Subject: [PATCH] [NEW_FEATURE] Add 2 context menus on status bar Add language context menu and EOL conversion context menu on status bar. --- .gitignore | 6 + PowerEditor/src/MISC/RegExt/regExtDlg.h | 3 - PowerEditor/src/Notepad_plus.rc | 1 - PowerEditor/src/NppNotification.cpp | 54 ++++++- PowerEditor/src/ScitillaComponent/Buffer.cpp | 8 - PowerEditor/src/ScitillaComponent/Buffer.h | 2 - .../src/WinControls/StatusBar/StatusBar.cpp | 2 +- PowerEditor/src/localization.cpp | 141 +++++++++--------- PowerEditor/src/localization.h | 12 ++ 9 files changed, 135 insertions(+), 94 deletions(-) diff --git a/.gitignore b/.gitignore index 03bfc2cb..b23d1733 100644 --- a/.gitignore +++ b/.gitignore @@ -104,3 +104,9 @@ $RECYCLE.BIN/ *.DS_Store *.swp *.out +scintilla/.hgeol +scintilla/.hgtags +scintilla/cppcheck.suppress +scintilla/.hg_archival.txt +scintilla/.hgignore +scintilla/bin/__init__.py diff --git a/PowerEditor/src/MISC/RegExt/regExtDlg.h b/PowerEditor/src/MISC/RegExt/regExtDlg.h index db5878d5..6bdc8232 100644 --- a/PowerEditor/src/MISC/RegExt/regExtDlg.h +++ b/PowerEditor/src/MISC/RegExt/regExtDlg.h @@ -29,10 +29,7 @@ #ifndef REG_EXT_DLG_H #define REG_EXT_DLG_H -#ifndef REGEXTDLGRC_H #include "regExtDlgRc.h" -#endif //REGEXTDLGRC_H - #include "StaticDialog.h" const int extNameLen = 32; diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index 4fdaf591..a484f190 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -291,7 +291,6 @@ BEGIN MENUITEM "Sort Lines As Decimals (Comma) Descending", IDM_EDIT_SORTLINES_DECIMALCOMMA_DESCENDING MENUITEM "Sort Lines As Decimals (Dot) Descending", IDM_EDIT_SORTLINES_DECIMALDOT_DESCENDING END - MENUITEM SEPARATOR POPUP "Comment/Uncomment" BEGIN MENUITEM "Toggle Single Line Comment", IDM_EDIT_BLOCK_COMMENT diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index 44599880..2366eb32 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -167,12 +167,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) (hWin == _pNonEditView->getHSelf())) // In the another view group { docGotoAnotherEditView(isInCtrlStat?TransferClone:TransferMove); - }/* - else if ((hWin == _pProjectPanel_1->getTreeHandle())) - { - - //printStr(TEXT("IN!!!")); - }*/ + } else { RECT nppZone; @@ -325,6 +320,26 @@ BOOL Notepad_plus::notify(SCNotification *notification) { command(IDM_VIEW_SUMMARY); } + else if (lpnm->dwItemSpec == DWORD(STATUSBAR_DOC_TYPE)) + { + POINT p; + ::GetCursorPos(&p); + HMENU hLangMenu = ::GetSubMenu(_mainMenuHandle, MENUINDEX_LANGUAGE); + TrackPopupMenu(hLangMenu, 0, p.x, p.y, 0, _pPublicInterface->getHSelf(), NULL); + } + else if (lpnm->dwItemSpec == DWORD(STATUSBAR_EOF_FORMAT)) + { + POINT p; + ::GetCursorPos(&p); + MenuPosition & menuPos = getMenuPosition("edit-eolConversion"); + HMENU hEditMenu = ::GetSubMenu(_mainMenuHandle, menuPos._x); + if (!hEditMenu) + return TRUE; + HMENU hEolFormatMenu = ::GetSubMenu(hEditMenu, menuPos._y); + if (!hEolFormatMenu) + return TRUE; + TrackPopupMenu(hEolFormatMenu, 0, p.x, p.y, 0, _pPublicInterface->getHSelf(), NULL); + } } break; } @@ -342,6 +357,31 @@ BOOL Notepad_plus::notify(SCNotification *notification) { switchEditViewTo(SUB_VIEW); } + else if (notification->nmhdr.hwndFrom == _statusBar.getHSelf()) // From Status Bar + { + LPNMMOUSE lpnm = (LPNMMOUSE)notification; + if (lpnm->dwItemSpec == DWORD(STATUSBAR_DOC_TYPE)) + { + POINT p; + ::GetCursorPos(&p); + HMENU hLangMenu = ::GetSubMenu(_mainMenuHandle, MENUINDEX_LANGUAGE); + TrackPopupMenu(hLangMenu, 0, p.x, p.y, 0, _pPublicInterface->getHSelf(), NULL); + } + else if (lpnm->dwItemSpec == DWORD(STATUSBAR_EOF_FORMAT)) + { + POINT p; + ::GetCursorPos(&p); + MenuPosition & menuPos = getMenuPosition("edit-eolConversion"); + HMENU hEditMenu = ::GetSubMenu(_mainMenuHandle, menuPos._x); + if (!hEditMenu) + return TRUE; + HMENU hEolFormatMenu = ::GetSubMenu(hEditMenu, menuPos._y); + if (!hEolFormatMenu) + return TRUE; + TrackPopupMenu(hEolFormatMenu, 0, p.x, p.y, 0, _pPublicInterface->getHSelf(), NULL); + } + return TRUE; + } else if (_pFileSwitcherPanel && notification->nmhdr.hwndFrom == _pFileSwitcherPanel->getHSelf()) { // Already switched, so do nothing here. @@ -361,7 +401,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) return TRUE; } } - else // From tool bar or Status Bar + else // From tool bar return TRUE; //break; diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index 4930ed0b..f7e51f9a 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -40,18 +40,10 @@ FileManager * FileManager::_pSelf = new FileManager(); static const int blockSize = 128 * 1024 + 4; - -// Ordre important!! Ne le changes pas! -//SC_EOL_CRLF (0), SC_EOL_CR (1), or SC_EOL_LF (2). - static const int CR = 0x0D; static const int LF = 0x0A; - - - - Buffer::Buffer(FileManager * pManager, BufferID id, Document doc, DocFileStatus type, const TCHAR *fileName) //type must be either DOC_REGULAR or DOC_UNNAMED : _pManager(pManager), _id(id), _isDirty(false), _doc(doc), _isFileReadOnly(false), _isUserReadOnly(false), _recentTag(-1), _references(0), _canNotify(false), _timeStamp(0), _needReloading(false), _encoding(-1), _backupFileName(TEXT("")), _isModified(false), _isLoadedDirty(false), _lang(L_TEXT) diff --git a/PowerEditor/src/ScitillaComponent/Buffer.h b/PowerEditor/src/ScitillaComponent/Buffer.h index ce0cc40e..dc9c0140 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.h +++ b/PowerEditor/src/ScitillaComponent/Buffer.h @@ -29,9 +29,7 @@ #ifndef BUFFER_H #define BUFFER_H -#ifndef UTF8_16_H #include "Utf8_16.h" -#endif// UTF8_16_H class Buffer; typedef Buffer * BufferID; //each buffer has unique ID by which it can be retrieved diff --git a/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp b/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp index 49245b59..97054d29 100644 --- a/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp +++ b/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp @@ -99,4 +99,4 @@ bool StatusBar::setOwnerDrawText(const TCHAR *str) { _lastSetText = str; return (::SendMessage(_hSelf, SB_SETTEXT, SBT_OWNERDRAW, (LPARAM)_lastSetText.c_str()) == TRUE); -} \ No newline at end of file +} diff --git a/PowerEditor/src/localization.cpp b/PowerEditor/src/localization.cpp index 920eba3e..bba4ca21 100644 --- a/PowerEditor/src/localization.cpp +++ b/PowerEditor/src/localization.cpp @@ -33,6 +33,72 @@ using namespace std; + + +MenuPosition menuPos[] = { + //============================================== + // {L0, L1, L2, id}, + //============================================== + { 0, -1, -1, "file" }, + { 1, -1, -1, "edit" }, + { 2, -1, -1, "search" }, + { 3, -1, -1, "view" }, + { 4, -1, -1, "encoding" }, + { 5, -1, -1, "language" }, + { 6, -1, -1, "settings" }, + { 7, -1, -1, "macro" }, + { 8, -1, -1, "run" }, + + { 0, 2, -1, "file-openFolder" }, + { 0, 11, -1, "file-closeMore" }, + { 0, 20, -1, "file-recentFiles" }, + + { 1, 10, -1, "edit-copyToClipboard" }, + { 1, 11, -1, "edit-indent" }, + { 1, 12, -1, "edit-convertCaseTo" }, + { 1, 13, -1, "edit-lineOperations" }, + { 1, 14, -1, "edit-comment" }, + { 1, 15, -1, "edit-autoCompletion" }, + { 1, 16, -1, "edit-eolConversion" }, + { 1, 17, -1, "edit-blankOperations" }, + { 1, 18, -1, "edit-pasteSpecial" }, + + { 2, 18, -1, "search-markAll" }, + { 2, 19, -1, "search-unmarkAll" }, + { 2, 20, -1, "search-jumpUp" }, + { 2, 21, -1, "search-jumpDown" }, + { 2, 23, -1, "search-bookmark" }, + + { 3, 4, -1, "view-showSymbol" }, + { 3, 5, -1, "view-zoom" }, + { 3, 6, -1, "view-moveCloneDocument" }, + { 3, 7, -1, "view-tab" }, + { 3, 16, -1, "view-collapseLevel" }, + { 3, 17, -1, "view-uncollapseLevel" }, + { 3, 21, -1, "view-project" }, + + { 4, 5, -1, "encoding-characterSets" }, + { 4, 5, 0, "encoding-arabic" }, + { 4, 5, 1, "encoding-baltic" }, + { 4, 5, 2, "encoding-celtic" }, + { 4, 5, 3, "encoding-cyrillic" }, + { 4, 5, 4, "encoding-centralEuropean" }, + { 4, 5, 5, "encoding-chinese" }, + { 4, 5, 6, "encoding-easternEuropean" }, + { 4, 5, 7, "encoding-greek" }, + { 4, 5, 8, "encoding-hebrew" }, + { 4, 5, 9, "encoding-japanese" }, + { 4, 5, 10, "encoding-korean" }, + { 4, 5, 11, "encoding-northEuropean" }, + { 4, 5, 12, "encoding-thai" }, + { 4, 5, 13, "encoding-turkish" }, + { 4, 5, 14, "encoding-westernEuropean" }, + { 4, 5, 15, "encoding-vietnamese" }, + + { 6, 4, -1, "settings-import" }, + { -1, -1, -1, "" } // End of array +}; + void NativeLangSpeaker::init(TiXmlDocumentA *nativeLangDocRootA, bool loadIfEnglish) { if (nativeLangDocRootA) @@ -137,78 +203,9 @@ generic_string NativeLangSpeaker::getNativeLangMenuString(int itemID) return TEXT(""); } -struct MenuPosition { - int _x; - int _y; - int _z; - char _id[64]; -}; -MenuPosition menuPos[] = { -//============================================== -// {L0, L1, L2, id}, -//============================================== - { 0, -1, -1, "file"}, - { 1, -1, -1, "edit"}, - { 2, -1, -1, "search"}, - { 3, -1, -1, "view"}, - { 4, -1, -1, "encoding"}, - { 5, -1, -1, "language"}, - { 6, -1, -1, "settings"}, - { 7, -1, -1, "macro"}, - { 8, -1, -1, "run"}, - - { 0, 2, -1, "file-openFolder"}, - { 0, 11, -1, "file-closeMore"}, - { 0, 20, -1, "file-recentFiles"}, - - { 1, 10, -1, "edit-copyToClipboard"}, - { 1, 11, -1, "edit-indent"}, - { 1, 12, -1, "edit-convertCaseTo"}, - { 1, 13, -1, "edit-lineOperations"}, - { 1, 14, -1, "edit-comment"}, - { 1, 15, -1, "edit-autoCompletion"}, - { 1, 16, -1, "edit-eolConversion"}, - { 1, 17, -1, "edit-blankOperations"}, - { 1, 18, -1, "edit-pasteSpecial"}, - - { 2, 18, -1, "search-markAll"}, - { 2, 19, -1, "search-unmarkAll"}, - { 2, 20, -1, "search-jumpUp"}, - { 2, 21, -1, "search-jumpDown"}, - { 2, 23, -1, "search-bookmark"}, - - { 3, 4, -1, "view-showSymbol"}, - { 3, 5, -1, "view-zoom"}, - { 3, 6, -1, "view-moveCloneDocument"}, - { 3, 7, -1, "view-tab"}, - { 3, 16, -1, "view-collapseLevel"}, - { 3, 17, -1, "view-uncollapseLevel"}, - { 3, 21, -1, "view-project"}, - - { 4, 5, -1, "encoding-characterSets"}, - { 4, 5, 0, "encoding-arabic"}, - { 4, 5, 1, "encoding-baltic"}, - { 4, 5, 2, "encoding-celtic"}, - { 4, 5, 3, "encoding-cyrillic"}, - { 4, 5, 4, "encoding-centralEuropean"}, - { 4, 5, 5, "encoding-chinese"}, - { 4, 5, 6, "encoding-easternEuropean"}, - { 4, 5, 7, "encoding-greek"}, - { 4, 5, 8, "encoding-hebrew"}, - { 4, 5, 9, "encoding-japanese"}, - { 4, 5, 10, "encoding-korean"}, - { 4, 5, 11, "encoding-northEuropean"}, - { 4, 5, 12, "encoding-thai"}, - { 4, 5, 13, "encoding-turkish"}, - { 4, 5, 14, "encoding-westernEuropean"}, - { 4, 5, 15, "encoding-vietnamese"}, - - { 6, 4, -1, "settings-import"}, - {-1, -1, -1, ""} // End of array -}; - -MenuPosition & getMenuPosition(const char *id) { +MenuPosition & getMenuPosition(const char *id) +{ int nbSubMenuPos = sizeof(menuPos)/sizeof(MenuPosition); @@ -218,7 +215,7 @@ MenuPosition & getMenuPosition(const char *id) { return menuPos[i]; } return menuPos[nbSubMenuPos-1]; -}; +} void NativeLangSpeaker::changeMenuLang(HMENU menuHandle, generic_string & pluginsTrans, generic_string & windowTrans) { diff --git a/PowerEditor/src/localization.h b/PowerEditor/src/localization.h index 4d77d6db..d158d408 100644 --- a/PowerEditor/src/localization.h +++ b/PowerEditor/src/localization.h @@ -38,6 +38,15 @@ class PreferenceDlg; class ShortcutMapper; class UserDefineDialog; +class MenuPosition { +public: + int _x; + int _y; + int _z; + char _id[64]; +}; + + class NativeLangSpeaker { public: NativeLangSpeaker():_nativeLangA(NULL), _nativeLangEncoding(CP_ACP), _isRTL(false), _fileName(NULL){}; @@ -84,4 +93,7 @@ private: const char *_fileName; }; + +MenuPosition & getMenuPosition(const char *id); + #endif // LOCALIZATION_H