[NEW_FEATURE] All the menu commands can be added in context menu, including plugins' commands, macros and user defined commands.

The bookmarks' look & feel are improved.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@213 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2008-06-01 14:47:28 +00:00
parent 9c0023c575
commit a3b344bbc2
10 changed files with 399 additions and 116 deletions

View File

@ -17,7 +17,6 @@
#include "SysMsg.h"
#include <memory>
#include <string>
#include <algorithm>
void systemMessage(const char *title)
@ -54,4 +53,30 @@ void writeLog(const char *logFileName, const char *log2write)
fputc('\n', f);
fflush(f);
fclose(f);
}
}
std::string purgeMenuItemString(const char * menuItemStr)
{
char cleanedName[64] = "";
size_t j = 0;
size_t menuNameLen = strlen(menuItemStr);
for(size_t k = 0 ; k < menuNameLen ; k++)
{
if (menuItemStr[k] == '\t')
{
cleanedName[k] = 0;
break;
}
else if (menuItemStr[k] == '&')
{
//skip
}
else
{
cleanedName[j] = menuItemStr[k];
j++;
}
}
cleanedName[j] = 0;
return cleanedName;
};

View File

@ -19,11 +19,13 @@
#define M30_IDE_COMMUN_H
#include <windows.h>
#include <string>
void systemMessage(const char *title);
//DWORD ShortToLongPathName(LPCTSTR lpszShortPath, LPTSTR lpszLongPath, DWORD cchBuffer);
void printInt(int int2print);
void printStr(const char *str2print);
void writeLog(const char *logFileName, const char *log2write);
std::string purgeMenuItemString(const char * menuItemStr);
#endif //M30_IDE_COMMUN_H

View File

@ -34,6 +34,7 @@
#include "ShortcutMapper.h"
#include "preferenceDlg.h"
#include "TaskListDlg.h"
#include "xpm_icons.h"
#include <time.h>
#include <algorithm>
@ -5769,48 +5770,6 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
}
case WM_CREATE:
{
char * acTop_xpm[] = {
"14 14 4 1", //0
" c #FFFFFF", //1
". c #000000", //2
"+ c #A400B7", //3
"@ c #DE25F4", //4
"++++++++++++++",
" +@@@@@@@@@@. ",
" +@@@@@@@@. ",
" +@@@@@@. ",
" +@@@@. ",
" +@@. ",
" +. ",
" ",
" ",
" @@ ",
" @@ ",
" ",
" @@ ",
" @@ "};
char * acBottom_xpm[] = {
"14 14 4 1", //0
" c #FFFFFF", //1
". c #000000", //2
"+ c #A400B7", //3
"@ c #DE25F4", //4
" @@ ",
" @@ ",
" ",
" @@ ",
" @@ ",
" ",
" ",
" +. ",
" +@@. ",
" +@@@@. ",
" +@@@@@@. ",
" +@@@@@@@@. ",
" +@@@@@@@@@@. ",
".............."};
pNppParam->setFontList(hwnd);
NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI();
@ -5828,8 +5787,12 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
_mainEditView.display();
_mainEditView.execute(SCI_MARKERDEFINEPIXMAP, MARK_HIDELINESBEGIN, (LPARAM)acTop_xpm);
_mainEditView.execute(SCI_MARKERDEFINEPIXMAP, MARK_HIDELINESEND, (LPARAM)acBottom_xpm);
_mainEditView.execute(SCI_MARKERSETALPHA, MARK_BOOKMARK, 70);
_mainEditView.execute(SCI_MARKERDEFINEPIXMAP, MARK_BOOKMARK, (LPARAM)bookmark_xpm);
_mainEditView.execute(SCI_MARKERDEFINEPIXMAP, MARK_HIDELINESBEGIN, (LPARAM)acTop_xpm);
_mainEditView.execute(SCI_MARKERDEFINEPIXMAP, MARK_HIDELINESEND, (LPARAM)acBottom_xpm);
_subEditView.execute(SCI_MARKERSETALPHA, MARK_BOOKMARK, 70);
_subEditView.execute(SCI_MARKERDEFINEPIXMAP, MARK_BOOKMARK, (LPARAM)bookmark_xpm);
_subEditView.execute(SCI_MARKERDEFINEPIXMAP, MARK_HIDELINESBEGIN, (LPARAM)acTop_xpm);
_subEditView.execute(SCI_MARKERDEFINEPIXMAP, MARK_HIDELINESEND, (LPARAM)acBottom_xpm);
@ -5880,12 +5843,6 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
_mainEditView.performGlobalStyles();
_subEditView.performGlobalStyles();
if (pNppParam->hasCustomContextMenu())
{
_mainEditView.execute(SCI_USEPOPUP, FALSE);
_subEditView.execute(SCI_USEPOPUP, FALSE);
}
_zoomOriginalValue = _pEditView->execute(SCI_GETZOOM);
_mainEditView.execute(SCI_SETZOOM, svp1._zoom);
_subEditView.execute(SCI_SETZOOM, svp2._zoom);
@ -5967,9 +5924,9 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
if (appDataNpp[0])
_pluginsManager.loadPlugins(appDataNpp);
// Menu
string pluginsTrans, windowTrans;
changeMenuLang(pluginsTrans, windowTrans);
// ------------ //
// Menu Section //
// ------------ //
// Macro Menu
std::vector<MacroShortcut> & macros = pNppParam->getMacroList();
@ -6045,12 +6002,6 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
::InsertMenu(hLangMenu, udlpos + i, MF_BYPOSITION, IDM_LANG_USER + i + 1, userLangContainer.getName());
}
//Plugin menu
_pluginsManager.setMenu(_mainMenuHandle, pluginsTrans.c_str());
//Windows menu
_windowsMenu.init(_hInst, _mainMenuHandle, windowTrans.c_str());
//Add recent files
HMENU hFileMenu = ::GetSubMenu(_mainMenuHandle, MENUINDEX_FILE);
int nbLRFile = pNppParam->getNbLRFile();
@ -6073,33 +6024,38 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
}
}
//The menu is loaded, add in all the accelerators
//Plugin menu
_pluginsManager.setMenu(_mainMenuHandle, NULL);
//Main menu is loaded, now load context menu items
pNppParam->getContextMenuFromXmlTree(_mainMenuHandle);
if (pNppParam->hasCustomContextMenu())
{
_mainEditView.execute(SCI_USEPOPUP, FALSE);
_subEditView.execute(SCI_USEPOPUP, FALSE);
}
string pluginsTrans, windowTrans;
changeMenuLang(pluginsTrans, windowTrans);
if (pluginsTrans != "")
{
::ModifyMenu(_mainMenuHandle, MENUINDEX_PLUGINS, MF_BYPOSITION, 0, pluginsTrans.c_str());
}
//Windows menu
_windowsMenu.init(_hInst, _mainMenuHandle, windowTrans.c_str());
// Update context menu strings
vector<MenuItemUnit> & tmp = pNppParam->getContextMenuItems();
size_t len = tmp.size();
char menuName[nameLenMax];
*menuName = 0;
size_t j, stlen;
char menuName[64];
for (size_t i = 0 ; i < len ; i++)
{
if (tmp[i]._itemName == "") {
if (tmp[i]._itemName == "")
{
::GetMenuString(_mainMenuHandle, tmp[i]._cmdID, menuName, 64, MF_BYCOMMAND);
stlen = strlen(menuName);
j = 0;
for(size_t k = 0; k < stlen; k++) {
if (menuName[k] == '\t') {
menuName[k] = 0;
break;
} else if (menuName[k] == '&') {
//skip
} else {
menuName[j] = menuName[k];
j++;
}
}
menuName[j] = 0;
tmp[i]._itemName = menuName;
tmp[i]._itemName = purgeMenuItemString(menuName);
}
}
@ -6108,24 +6064,15 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
//This will automatically do all translations, since menu translation has been done already
vector<CommandShortcut> & shortcuts = pNppParam->getUserShortcuts();
len = shortcuts.size();
int readI;
for(size_t i = 0; i < len; i++) {
for(size_t i = 0; i < len; i++)
{
CommandShortcut & csc = shortcuts[i];
if (!csc.getName()[0]) { //no predefined name, get name from menu and use that
if (::GetMenuString(_mainMenuHandle, csc.getID(), menuName, 64, MF_BYCOMMAND)) {
readI = 0;
while(menuName[readI] != 0)
{
if (menuName[readI] == '\t')
{
menuName[readI] = 0;
break;
}
readI++;
}
}
csc.setName(menuName);
}
if (!csc.getName()[0])
{ //no predefined name, get name from menu and use that
::GetMenuString(_mainMenuHandle, csc.getID(), menuName, 64, MF_BYCOMMAND);
csc.setName(purgeMenuItemString(menuName).c_str());
}
}
//Translate non-menu shortcuts

View File

@ -487,7 +487,7 @@ void cutString(const char *str2cut, vector<string> & patternVect)
}
bool NppParameters::load(/*bool noUserPath*/)
bool NppParameters::load()
{
L_END = L_EXTERNAL;
bool isAllLaoded = true;
@ -751,8 +751,8 @@ bool NppParameters::load(/*bool noUserPath*/)
_pXmlContextMenuDoc = NULL;
isAllLaoded = false;
}
else
getContextMenuFromXmlTree();
//else
//getContextMenuFromXmlTree();
//----------------------------//
// session.xml : for per user //
@ -1009,10 +1009,9 @@ void NppParameters::initScintillaKeys() {
}
prevID = skd.functionId;
}
}
bool NppParameters::getContextMenuFromXmlTree()
bool NppParameters::getContextMenuFromXmlTree(HMENU mainMenuHadle)
{
if (!_pXmlContextMenuDoc)
return false;
@ -1034,6 +1033,72 @@ bool NppParameters::getContextMenuFromXmlTree()
{
_contextMenuItems.push_back(MenuItemUnit(id, ""));
}
else
{
const char *menuEntryName = (childNode->ToElement())->Attribute("MenuEntryName");
const char *menuItemName = (childNode->ToElement())->Attribute("MenuItemName");
if (menuEntryName && menuItemName)
{
int nbMenuEntry = ::GetMenuItemCount(mainMenuHadle);
for (int i = 0 ; i < nbMenuEntry ; i++)
{
char menuEntryString[64];
::GetMenuString(mainMenuHadle, i, menuEntryString, 64, MF_BYPOSITION);
if (stricmp(menuEntryName, purgeMenuItemString(menuEntryString).c_str()) == 0)
{
HMENU subMenu = ::GetSubMenu(mainMenuHadle, i);
int nbSubMenuCmd = ::GetMenuItemCount(subMenu);
for (int j = 0 ; j < nbSubMenuCmd ; j++)
{
char cmdStr[256];
::GetMenuString(subMenu, j, cmdStr, 256, MF_BYPOSITION);
if (stricmp(menuItemName, purgeMenuItemString(cmdStr).c_str()) == 0)
{
int cmdId = ::GetMenuItemID(subMenu, j);
_contextMenuItems.push_back(MenuItemUnit(cmdId, ""));
break;
}
}
break;
}
}
}
else
{
const char *pluginName = (childNode->ToElement())->Attribute("PluginEntryName");
const char *pluginCmdName = (childNode->ToElement())->Attribute("pluginCommandItemName");
if (pluginName && pluginName)
{
HMENU pluginsMenu = ::GetSubMenu(mainMenuHadle, MENUINDEX_PLUGINS);
int nbPlugins = ::GetMenuItemCount(pluginsMenu);
for (int i = 0 ; i < nbPlugins ; i++)
{
char menuItemString[256];
::GetMenuString(pluginsMenu, i, menuItemString, 256, MF_BYPOSITION);
if (stricmp(pluginName, purgeMenuItemString(menuItemString).c_str()) == 0)
{
HMENU pluginMenu = ::GetSubMenu(pluginsMenu, i);
int nbPluginCmd = ::GetMenuItemCount(pluginMenu);
for (int j = 0 ; j < nbPluginCmd ; j++)
{
char pluginCmdStr[256];
::GetMenuString(pluginMenu, j, pluginCmdStr, 256, MF_BYPOSITION);
if (stricmp(pluginCmdName, purgeMenuItemString(pluginCmdStr).c_str()) == 0)
{
int pluginCmdId = ::GetMenuItemID(pluginMenu, j);
_contextMenuItems.push_back(MenuItemUnit(pluginCmdId, ""));
break;
}
}
break;
}
}
}
}
/*
*/
}
}
}

View File

@ -1078,6 +1078,8 @@ public:
return getPluginCmdsFromXmlTree();
}
bool getContextMenuFromXmlTree(HMENU mainMenuHadle);
winVer getWinVersion() { return _winVersion; };
private:
NppParameters();
@ -1177,7 +1179,6 @@ private:
bool getUserCmdsFromXmlTree();
bool getPluginCmdsFromXmlTree();
bool getScintKeysFromXmlTree();
bool getContextMenuFromXmlTree();
bool getSessionFromXmlTree(TiXmlDocument *pSessionDoc = NULL, Session *session = NULL);
void feedGUIParameters(TiXmlNode *node);

View File

@ -1369,7 +1369,7 @@ void ScintillaEditView::performGlobalStyles()
Style & style = stylers.getStyler(i);
execute(SCI_SETCARETLINEBACK, style._bgColor);
}
/*
i = stylers.getStylerIndexByName("Mark colour");
if (i != -1)
{
@ -1377,7 +1377,7 @@ void ScintillaEditView::performGlobalStyles()
execute(SCI_MARKERSETFORE, 1, style._fgColor);
execute(SCI_MARKERSETBACK, 1, style._bgColor);
}
*/
COLORREF selectColorBack = grey;
i = stylers.getStylerIndexByName("Selected text colour");

View File

@ -1,10 +1,10 @@
<NotepadPlus>
<ScintillaContextMenu>
<Item id="42001"/>
<Item id="42002"/>
<Item id="42005"/>
<Item id="42006"/>
<Item id="42007"/>
<Item MenuEntryName="Edit" MenuItemName="Cut"/>
<Item MenuEntryName="Edit" MenuItemName="Copy"/>
<Item MenuEntryName="Edit" MenuItemName="Paste"/>
<Item MenuEntryName="Edit" MenuItemName="Delete"/>
<Item MenuEntryName="Edit" MenuItemName="Select all"/>
<Item id="0"/>
<Item id="43016"/>
<Item id="43017"/>

View File

@ -703,7 +703,6 @@
<WidgetStyle name="Brace highlight style" styleID="34" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="12" />
<WidgetStyle name="Bad brace colour" styleID="35" fgColor="800000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WidgetStyle name="Current line background colour" styleID="0" bgColor="E8E8FF" />
<WidgetStyle name="Mark colour" styleID="0" fgColor="C00000" bgColor="FFFF00" />
<WidgetStyle name="Selected text colour" styleID="0" bgColor="C0C0C0" />
<WidgetStyle name="Caret colour" styleID="2069" fgColor="8000FF" />
<WidgetStyle name="Edge colour" styleID="0" fgColor="80FFFF" />

240
PowerEditor/src/xpm_icons.h Normal file
View File

@ -0,0 +1,240 @@
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
static char * acTop_xpm[] = {
"12 12 56 1",
" c #FFFFFF",
". c #8AB2E9",
"+ c #CCDCF6",
"@ c #80ABEA",
"# c #7DA9E8",
"$ c #C7DAF3",
"% c #79A7E6",
"& c #ADC8EF",
"* c #87B0E8",
"= c #BBD2F0",
"- c #6EA0E2",
"; c #A8C7EE",
"> c #A3C2ED",
", c #75A4E3",
"' c #A7C4EB",
") c #6297E1",
"! c #A1C1EC",
"~ c #92B7E8",
"{ c #99BBE9",
"] c #6197DD",
"^ c #96B9E6",
"/ c #538EDB",
"( c #99BBEA",
"_ c #80AAE3",
": c #81ABE3",
"< c #8AB1E4",
"[ c #4B88D6",
"} c #4882D1",
"| c #4384D6",
"1 c #90B5E7",
"2 c #74A3E0",
"3 c #77A4E0",
"4 c #81ABE2",
"5 c #437FD3",
"6 c #7FA2DF",
"7 c #3577D2",
"8 c #87AFE4",
"9 c #72A1DF",
"0 c #7CA9E1",
"a c #3F7AD0",
"b c #85A4DE",
"c c #FBFCFE",
"d c #236ECD",
"e c #7EA8E1",
"f c #79A6E0",
"g c #3D77D0",
"h c #87A4DC",
"i c #1A62C9",
"j c #75A3DF",
"k c #3C74CF",
"l c #8DA6DE",
"m c #1859C4",
"n c #3B71CC",
"o c #8EA5DD",
"p c #164EC0",
"q c #92A7DD",
" .+ ",
" @#$ ",
" %&*= ",
" -;>,' ",
" )!~{]^ ",
" /(_:<[} ",
" |123456 ",
" 7890abc ",
" defgh ",
" ijkl ",
" mno ",
" pq "};
static char * acBottom_xpm[] = {
"12 12 54 1",
" c #FFFFFF",
". c #C4D7F3",
"+ c #72A1E3",
"@ c #C1D6F2",
"# c #6397E1",
"$ c #5990DD",
"% c #BBD2F0",
"& c #7AA6E5",
"* c #9ABDEA",
"= c #4A87D9",
"- c #B1CAEE",
"; c #75A4E3",
"> c #99BBE9",
", c #95B9E8",
"' c #3A7CD4",
") c #A9C6EC",
"! c #71A0E0",
"~ c #86AFE5",
"{ c #8DB2E6",
"] c #2A72CF",
"^ c #73A0E0",
"/ c #6B9DE0",
"( c #95B8E8",
"_ c #81ABE3",
": c #72A1DF",
"< c #83ADE3",
"[ c #1B65C9",
"} c #5F95DC",
"| c #8BB3E5",
"1 c #77A4E0",
"2 c #679ADC",
"3 c #7AA6E1",
"4 c #195CC6",
"5 c #FCFDFE",
"6 c #8DB2E4",
"7 c #4885D6",
"8 c #7CA9E1",
"9 c #6698DB",
"0 c #71A1DE",
"a c #1752C0",
"b c #88ABE0",
"c c #3D77D0",
"d c #6E9FDD",
"e c #699BDC",
"f c #1547BD",
"g c #8DA6DE",
"h c #376BC9",
"i c #6295DA",
"j c #1440B9",
"k c #8DA0DB",
"l c #315FC4",
"m c #1339B7",
"n c #909FDA",
"o c #1233B4",
" .+ ",
" @#$ ",
" %&*= ",
" -;>,' ",
" )!>~{] ",
" ^/(_:<[ ",
" (}|1234 ",
" 567890a ",
" bcdef ",
" ghij ",
" klm ",
" no "};
/* XPM */
static char * bookmark_xpm[] = {
"15 15 64 1",
" c None",
". c #FE0000",
"+ c #9DD3D2",
"@ c #2DC7C9",
"# c #00A0A6",
"$ c #007A76",
"% c #50C4C6",
"& c #02C4C6",
"* c #81C6C7",
"= c #1DBCD9",
"- c #9CCFDA",
"; c #CAECF2",
"> c #8FC8C9",
", c #003236",
"' c #006A96",
") c #0092E6",
"! c #47B0E1",
"~ c #53BAE5",
"{ c #19C5C7",
"] c #003B68",
"^ c #00358E",
"/ c #0048A0",
"( c #005FA8",
"_ c #0065C4",
": c #002040",
"< c #003690",
"[ c #003F9E",
"} c #005BB0",
"| c #004BA8",
"1 c #000636",
"2 c #0040A0",
"3 c #0061C4",
"4 c #0078E8",
"5 c #008AF4",
"6 c #001656",
"7 c #0053B0",
"8 c #0081EE",
"9 c #0994FF",
"0 c #23A4FF",
"a c #1197FF",
"b c #00316E",
"c c #49B4FF",
"d c #53BCFF",
"e c #35ACFF",
"f c #59C2FF",
"g c #6BC8FD",
"h c #62C5FE",
"i c #003B78",
"j c #73D1FD",
"k c #7BD7FD",
"l c #A3D7D7",
"m c #008490",
"n c #003F80",
"o c #0983FF",
"p c #7BDAFD",
"q c #1990FF",
"r c #BEE6E8",
"s c #004A74",
"t c #0088E8",
"u c #19A0FF",
"v c #B6E4E2",
"w c #3DC7C9",
"x c #12C2C4",
"y c #64C6C5",
" +@#$#@+ ",
" %&**+**&% ",
" %&=-;;;-=&% ",
" >,')!~~~!)',> ",
" {]^/(___(/^]{ ",
" :^<[}___}|<^: ",
" 12|3455543|21 ",
" 67389000a8376 ",
" b|8a0cddea8|b ",
" '[5edfghde9[' ",
" >i4cgjkjgc8i> ",
" lmnofjpkfqnml ",
" r*@s(tut(s@*r ",
" v*w{x&x{w*v ",
" l*yyy*l "};

View File

@ -598,10 +598,6 @@
RelativePath="..\src\MISC\RegExt\regExtDlgRc.h"
>
</File>
<File
RelativePath="..\src\resource.h"
>
</File>
<File
RelativePath="..\src\MISC\RegExt\resource.h"
>
@ -610,6 +606,10 @@
RelativePath="..\src\WinControls\Preference\resource.h"
>
</File>
<File
RelativePath="..\src\resource.h"
>
</File>
<File
RelativePath="..\src\WinControls\StaticDialog\RunDlg\RunDlg.h"
>
@ -750,6 +750,10 @@
RelativePath="..\src\WinControls\ColourPicker\WordStyleDlg.h"
>
</File>
<File
RelativePath="..\src\xpm_icons.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"