[NEW] Add separator menu item for plugin menu (if _pFunc == NULL).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@159 f5eea248-9336-0410-98b8-ebc06183d4e3
remotes/patch_testing@481
Don Ho 17 years ago
parent 2830dc0304
commit bfa6932d19

@ -90,11 +90,11 @@ bool PluginsManager::loadPlugins(const char *dir)
if ((!pi->_funcItems) || (pi->_nbFuncItem <= 0)) if ((!pi->_funcItems) || (pi->_nbFuncItem <= 0))
throw string("Missing \"FuncItems\" array, or the nb of Function Item is not set correctly"); throw string("Missing \"FuncItems\" array, or the nb of Function Item is not set correctly");
/*
for (int c = 0 ; c < pi->_nbFuncItem ; c++) for (int c = 0 ; c < pi->_nbFuncItem ; c++)
if (!pi->_funcItems[c]._pFunc) if (!pi->_funcItems[c]._pFunc)
throw string("\"FuncItems\" array is not set correctly"); throw string("\"FuncItems\" array is not set correctly");
*/
pi->_pluginMenu = ::CreateMenu(); pi->_pluginMenu = ::CreateMenu();
pi->_pFuncSetInfo(_nppData); pi->_pFuncSetInfo(_nppData);
@ -206,7 +206,7 @@ void PluginsManager::setMenu(HMENU hMenu, const char *menuName)
{ {
_pluginsCommands.push_back(PluginCommand(_pluginInfos[i]->_moduleName, j, _pluginInfos[i]->_funcItems[j]._pFunc)); _pluginsCommands.push_back(PluginCommand(_pluginInfos[i]->_moduleName, j, _pluginInfos[i]->_funcItems[j]._pFunc));
int cmdID = ID_PLUGINS_CMD + (_pluginsCommands.size() - 1); int cmdID = ID_PLUGINS_CMD + (_pluginsCommands.size() - 1);
_pluginInfos[i]->_funcItems[j]._cmdID = cmdID; _pluginInfos[i]->_funcItems[j]._cmdID = (_pluginInfos[i]->_funcItems[j]._pFunc == NULL)?0:cmdID;
string itemName = _pluginInfos[i]->_funcItems[j]._itemName; string itemName = _pluginInfos[i]->_funcItems[j]._itemName;
if (_pluginInfos[i]->_funcItems[j]._pShKey) if (_pluginInfos[i]->_funcItems[j]._pShKey)
@ -222,7 +222,9 @@ void PluginsManager::setMenu(HMENU hMenu, const char *menuName)
PluginCmdShortcut pcs(Shortcut(itemName.c_str(), false, false, false, 0x00), cmdID, _pluginInfos[i]->_moduleName, j); //VK_NULL and everything disabled, the menu name is left alone PluginCmdShortcut pcs(Shortcut(itemName.c_str(), false, false, false, 0x00), cmdID, _pluginInfos[i]->_moduleName, j); //VK_NULL and everything disabled, the menu name is left alone
pluginCmdSCList.push_back(pcs); pluginCmdSCList.push_back(pcs);
} }
::InsertMenu(_pluginInfos[i]->_pluginMenu, j, MF_BYPOSITION, cmdID, itemName.c_str()); unsigned int flag = MF_BYPOSITION | ((_pluginInfos[i]->_funcItems[j]._pFunc == NULL)?MF_SEPARATOR:0);
::InsertMenu(_pluginInfos[i]->_pluginMenu, j, flag, (_pluginInfos[i]->_funcItems[j]._pFunc == NULL)?0:cmdID, itemName.c_str());
if (_pluginInfos[i]->_funcItems[j]._init2Check) if (_pluginInfos[i]->_funcItems[j]._init2Check)
::CheckMenuItem(_hPluginsMenu, cmdID, MF_BYCOMMAND | MF_CHECKED); ::CheckMenuItem(_hPluginsMenu, cmdID, MF_BYCOMMAND | MF_CHECKED);
} }

@ -20,138 +20,6 @@
#include <string> #include <string>
#include <algorithm> #include <algorithm>
/*
DWORD ShortToLongPathName(LPCTSTR lpszShortPath, LPTSTR lpszLongPath, DWORD cchBuffer)
{
// Catch null pointers.
if (!lpszShortPath || !lpszLongPath)
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
// Check whether the input path is valid.
if (0xffffffff == GetFileAttributes(lpszShortPath))
return 0;
// Special characters.
char const sep = '\\';
char const colon = ':';
// Make some short aliases for basic_strings of TCHAR.
typedef std::basic_string<TCHAR> tstring;
typedef tstring::traits_type traits;
typedef tstring::size_type size;
size const npos = tstring::npos;
// Copy the short path into the work buffer and convert forward
// slashes to backslashes.
tstring path = lpszShortPath;
std::replace(path.begin(), path.end(), '/', sep);
// We need a couple of markers for stepping through the path.
size left = 0;
size right = 0;
// Parse the first bit of the path.
if (path.length() >= 2 && isalpha(path[0]) && colon == path[1]) // Drive letter?
{
if (2 == path.length()) // 'bare' drive letter
{
right = npos; // skip main block
}
else if (sep == path[2]) // drive letter + backslash
{
// FindFirstFile doesn't like "X:\"
if (3 == path.length())
{
right = npos; // skip main block
}
else
{
left = right = 3;
}
}
else return 0; // parsing failure
}
else if (path.length() >= 1 && sep == path[0])
{
if (1 == path.length()) // 'bare' backslash
{
right = npos; // skip main block
}
else
{
if (sep == path[1]) // is it UNC?
{
// Find end of machine name
right = path.find_first_of(sep, 2);
if (npos == right)
return 0;
// Find end of share name
right = path.find_first_of(sep, right + 1);
if (npos == right)
return 0;
}
++right;
}
}
// else FindFirstFile will handle relative paths
// The data block for FindFirstFile.
WIN32_FIND_DATA fd;
// Main parse block - step through path.
while (npos != right)
{
left = right; // catch up
// Find next separator.
right = path.find_first_of(sep, right);
// Temporarily replace the separator with a null character so that
// the path so far can be passed to FindFirstFile.
if (npos != right)
path[right] = 0;
// See what FindFirstFile makes of the path so far.
HANDLE hf = FindFirstFile(path.c_str(), &fd);
if (INVALID_HANDLE_VALUE == hf)
return 0;
FindClose(hf);
// Put back the separator.
if (npos != right)
path[right] = sep;
// The file was found - replace the short name with the long.
size old_len = (npos == right) ? path.length() - left : right - left;
size new_len = traits::length(fd.cFileName);
path.replace(left, old_len, fd.cFileName, new_len);
// More to do?
if (npos != right)
{
// Yes - move past separator .
right = left + new_len + 1;
// Did we overshoot the end? (i.e. path ends with a separator).
if (right >= path.length())
right = npos;
}
}
// If buffer is too small then return the required size.
if (cchBuffer <= path.length())
return path.length() + 1;
// Copy the buffer and return the number of characters copied.
traits::copy(lpszLongPath, path.c_str(), path.length() + 1);
return path.length();
}
*/
void systemMessage(const char *title) void systemMessage(const char *title)
{ {
LPVOID lpMsgBuf; LPVOID lpMsgBuf;

Loading…
Cancel
Save