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