[NEW_FEATURE] Add 2 context menus on status bar

Add language context menu and EOL conversion context menu on status bar.
This commit is contained in:
Don Ho 2015-06-08 03:19:34 +02:00
parent 7edd53a535
commit 251e987a71
9 changed files with 135 additions and 94 deletions

6
.gitignore vendored
View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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;
}
@ -341,6 +356,31 @@ BOOL Notepad_plus::notify(SCNotification *notification)
else if (notification->nmhdr.hwndFrom == _subDocTab.getHSelf())
{
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())
{
@ -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;

View File

@ -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)

View File

@ -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

View File

@ -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)
{

View File

@ -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