|
|
@ -504,14 +504,13 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
|
|
|
ExternalLangContainer & externalLangContainer = nppParam.getELCFromIndex(i);
|
|
|
|
ExternalLangContainer & externalLangContainer = nppParam.getELCFromIndex(i);
|
|
|
|
|
|
|
|
|
|
|
|
int numLangs = ::GetMenuItemCount(hLangMenu);
|
|
|
|
int numLangs = ::GetMenuItemCount(hLangMenu);
|
|
|
|
const int bufferSize = 100;
|
|
|
|
TCHAR buffer[menuItemStrLenMax]{};
|
|
|
|
TCHAR buffer[bufferSize] = { '\0' };
|
|
|
|
|
|
|
|
const TCHAR* lexerNameW = wmc.char2wchar(externalLangContainer._name.c_str(), CP_ACP);
|
|
|
|
const TCHAR* lexerNameW = wmc.char2wchar(externalLangContainer._name.c_str(), CP_ACP);
|
|
|
|
|
|
|
|
|
|
|
|
int x = 0;
|
|
|
|
int x = 0;
|
|
|
|
for (; (x == 0 || lstrcmp(lexerNameW, buffer) > 0) && x < numLangs; ++x)
|
|
|
|
for (; (x == 0 || lstrcmp(lexerNameW, buffer) > 0) && x < numLangs; ++x)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
::GetMenuString(hLangMenu, x, buffer, bufferSize, MF_BYPOSITION);
|
|
|
|
::GetMenuString(hLangMenu, x, buffer, menuItemStrLenMax, MF_BYPOSITION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
::InsertMenu(hLangMenu, x - 1, MF_BYPOSITION, IDM_LANG_EXTERNAL + i, lexerNameW);
|
|
|
|
::InsertMenu(hLangMenu, x - 1, MF_BYPOSITION, IDM_LANG_EXTERNAL + i, lexerNameW);
|
|
|
@ -587,12 +586,12 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
|
|
|
// Update Scintilla context menu strings (translated)
|
|
|
|
// Update Scintilla context menu strings (translated)
|
|
|
|
vector<MenuItemUnit> & tmp = nppParam.getContextMenuItems();
|
|
|
|
vector<MenuItemUnit> & tmp = nppParam.getContextMenuItems();
|
|
|
|
size_t len = tmp.size();
|
|
|
|
size_t len = tmp.size();
|
|
|
|
TCHAR menuName[64];
|
|
|
|
TCHAR menuName[menuItemStrLenMax];
|
|
|
|
for (size_t i = 0; i < len; ++i)
|
|
|
|
for (size_t i = 0; i < len; ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (tmp[i]._itemName.empty())
|
|
|
|
if (tmp[i]._itemName.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
::GetMenuString(_mainMenuHandle, tmp[i]._cmdID, menuName, 64, MF_BYCOMMAND);
|
|
|
|
::GetMenuString(_mainMenuHandle, tmp[i]._cmdID, menuName, menuItemStrLenMax, MF_BYCOMMAND);
|
|
|
|
tmp[i]._itemName = purgeMenuItemString(menuName);
|
|
|
|
tmp[i]._itemName = purgeMenuItemString(menuName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -605,7 +604,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (tmp2[i]._itemName.empty())
|
|
|
|
if (tmp2[i]._itemName.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
::GetMenuString(_mainMenuHandle, tmp2[i]._cmdID, menuName, 64, MF_BYCOMMAND);
|
|
|
|
::GetMenuString(_mainMenuHandle, tmp2[i]._cmdID, menuName, menuItemStrLenMax, MF_BYCOMMAND);
|
|
|
|
tmp2[i]._itemName = purgeMenuItemString(menuName);
|
|
|
|
tmp2[i]._itemName = purgeMenuItemString(menuName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2613,11 +2612,11 @@ void Notepad_plus::checkLangsMenu(int id) const
|
|
|
|
if (curBuf->isUserDefineLangExt())
|
|
|
|
if (curBuf->isUserDefineLangExt())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const TCHAR *userLangName = curBuf->getUserDefineLangName();
|
|
|
|
const TCHAR *userLangName = curBuf->getUserDefineLangName();
|
|
|
|
TCHAR menuLangName[langNameLenMax];
|
|
|
|
TCHAR menuLangName[menuItemStrLenMax];
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = IDM_LANG_USER + 1 ; i <= IDM_LANG_USER_LIMIT ; ++i)
|
|
|
|
for (int i = IDM_LANG_USER + 1 ; i <= IDM_LANG_USER_LIMIT ; ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (::GetMenuString(_mainMenuHandle, i, menuLangName, langNameLenMax, MF_BYCOMMAND))
|
|
|
|
if (::GetMenuString(_mainMenuHandle, i, menuLangName, menuItemStrLenMax, MF_BYCOMMAND))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!lstrcmp(userLangName, menuLangName))
|
|
|
|
if (!lstrcmp(userLangName, menuLangName))
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -2928,9 +2927,8 @@ void Notepad_plus::setUniModeText()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cmdID += IDM_FORMAT_ENCODE;
|
|
|
|
cmdID += IDM_FORMAT_ENCODE;
|
|
|
|
|
|
|
|
|
|
|
|
const int itemSize = 64;
|
|
|
|
TCHAR uniModeText[menuItemStrLenMax]{};
|
|
|
|
TCHAR uniModeText[itemSize] = {};
|
|
|
|
::GetMenuString(_mainMenuHandle, cmdID, uniModeText, menuItemStrLenMax, MF_BYCOMMAND);
|
|
|
|
::GetMenuString(_mainMenuHandle, cmdID, uniModeText, itemSize, MF_BYCOMMAND);
|
|
|
|
|
|
|
|
uniModeTextString = uniModeText;
|
|
|
|
uniModeTextString = uniModeText;
|
|
|
|
// Remove the shortcut text from the menu text.
|
|
|
|
// Remove the shortcut text from the menu text.
|
|
|
|
const size_t tabPos = uniModeTextString.find_last_of('\t');
|
|
|
|
const size_t tabPos = uniModeTextString.find_last_of('\t');
|
|
|
@ -6732,11 +6730,10 @@ void Notepad_plus::setWorkingDir(const TCHAR *dir)
|
|
|
|
int Notepad_plus::getLangFromMenuName(const TCHAR * langName)
|
|
|
|
int Notepad_plus::getLangFromMenuName(const TCHAR * langName)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int id = 0;
|
|
|
|
int id = 0;
|
|
|
|
const int menuSize = 64;
|
|
|
|
TCHAR menuLangName[menuItemStrLenMax];
|
|
|
|
TCHAR menuLangName[menuSize];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ( int i = IDM_LANG_C; i <= IDM_LANG_USER; ++i )
|
|
|
|
for ( int i = IDM_LANG_C; i <= IDM_LANG_USER; ++i )
|
|
|
|
if ( ::GetMenuString( _mainMenuHandle, i, menuLangName, menuSize, MF_BYCOMMAND ) )
|
|
|
|
if ( ::GetMenuString( _mainMenuHandle, i, menuLangName, menuItemStrLenMax, MF_BYCOMMAND ) )
|
|
|
|
if ( !lstrcmp( langName, menuLangName ) )
|
|
|
|
if ( !lstrcmp( langName, menuLangName ) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
id = i;
|
|
|
|
id = i;
|
|
|
@ -6746,7 +6743,7 @@ int Notepad_plus::getLangFromMenuName(const TCHAR * langName)
|
|
|
|
if ( id == 0 )
|
|
|
|
if ( id == 0 )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for ( int i = IDM_LANG_USER + 1; i <= IDM_LANG_USER_LIMIT; ++i )
|
|
|
|
for ( int i = IDM_LANG_USER + 1; i <= IDM_LANG_USER_LIMIT; ++i )
|
|
|
|
if ( ::GetMenuString( _mainMenuHandle, i, menuLangName, menuSize, MF_BYCOMMAND ) )
|
|
|
|
if ( ::GetMenuString( _mainMenuHandle, i, menuLangName, menuItemStrLenMax, MF_BYCOMMAND ) )
|
|
|
|
if ( !lstrcmp( langName, menuLangName ) )
|
|
|
|
if ( !lstrcmp( langName, menuLangName ) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
id = i;
|
|
|
|
id = i;
|
|
|
@ -6762,13 +6759,12 @@ generic_string Notepad_plus::getLangFromMenu(const Buffer * buf)
|
|
|
|
|
|
|
|
|
|
|
|
int id;
|
|
|
|
int id;
|
|
|
|
generic_string userLangName;
|
|
|
|
generic_string userLangName;
|
|
|
|
const int nbChar = 32;
|
|
|
|
TCHAR menuLangName[menuItemStrLenMax]{};
|
|
|
|
TCHAR menuLangName[nbChar];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
id = (NppParameters::getInstance()).langTypeToCommandID( buf->getLangType() );
|
|
|
|
id = (NppParameters::getInstance()).langTypeToCommandID( buf->getLangType() );
|
|
|
|
if ( ( id != IDM_LANG_USER ) || !( buf->isUserDefineLangExt() ) )
|
|
|
|
if ( ( id != IDM_LANG_USER ) || !( buf->isUserDefineLangExt() ) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
::GetMenuString(_mainMenuHandle, id, menuLangName, nbChar-1, MF_BYCOMMAND);
|
|
|
|
::GetMenuString(_mainMenuHandle, id, menuLangName, menuItemStrLenMax, MF_BYCOMMAND);
|
|
|
|
userLangName = menuLangName;
|
|
|
|
userLangName = menuLangName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -6822,12 +6818,12 @@ bool Notepad_plus::reloadLang()
|
|
|
|
// Update scintilla context menu strings
|
|
|
|
// Update scintilla context menu strings
|
|
|
|
vector<MenuItemUnit> & tmp = nppParam.getContextMenuItems();
|
|
|
|
vector<MenuItemUnit> & tmp = nppParam.getContextMenuItems();
|
|
|
|
size_t len = tmp.size();
|
|
|
|
size_t len = tmp.size();
|
|
|
|
TCHAR menuName[64];
|
|
|
|
TCHAR menuName[menuItemStrLenMax];
|
|
|
|
for (size_t i = 0 ; i < len ; ++i)
|
|
|
|
for (size_t i = 0 ; i < len ; ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (tmp[i]._itemName == TEXT(""))
|
|
|
|
if (tmp[i]._itemName == TEXT(""))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
::GetMenuString(_mainMenuHandle, tmp[i]._cmdID, menuName, 64, MF_BYCOMMAND);
|
|
|
|
::GetMenuString(_mainMenuHandle, tmp[i]._cmdID, menuName, menuItemStrLenMax, MF_BYCOMMAND);
|
|
|
|
tmp[i]._itemName = purgeMenuItemString(menuName);
|
|
|
|
tmp[i]._itemName = purgeMenuItemString(menuName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -8557,8 +8553,8 @@ void Notepad_plus::updateCommandShortcuts()
|
|
|
|
|
|
|
|
|
|
|
|
if (menuName.length() == 0)
|
|
|
|
if (menuName.length() == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TCHAR szMenuName[64];
|
|
|
|
TCHAR szMenuName[menuItemStrLenMax];
|
|
|
|
if (::GetMenuString(_mainMenuHandle, csc.getID(), szMenuName, _countof(szMenuName), MF_BYCOMMAND))
|
|
|
|
if (::GetMenuString(_mainMenuHandle, csc.getID(), szMenuName, menuItemStrLenMax, MF_BYCOMMAND))
|
|
|
|
menuName = purgeMenuItemString(szMenuName, true);
|
|
|
|
menuName = purgeMenuItemString(szMenuName, true);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
menuName = csc.getShortcutName();
|
|
|
|
menuName = csc.getShortcutName();
|
|
|
|