mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-20 04:14:40 +02:00
parent
b47de8048d
commit
360d45db1a
@ -770,6 +770,12 @@ generic_string stringToUpper(generic_string strToConvert)
|
|||||||
return strToConvert;
|
return strToConvert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generic_string stringToLower(generic_string strToConvert)
|
||||||
|
{
|
||||||
|
std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(), ::towlower);
|
||||||
|
return strToConvert;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
generic_string stringReplace(generic_string subject, const generic_string& search, const generic_string& replace)
|
generic_string stringReplace(generic_string subject, const generic_string& search, const generic_string& replace)
|
||||||
{
|
{
|
||||||
|
@ -172,6 +172,7 @@ generic_string PathRemoveFileSpec(generic_string & path);
|
|||||||
generic_string PathAppend(generic_string &strDest, const generic_string & str2append);
|
generic_string PathAppend(generic_string &strDest, const generic_string & str2append);
|
||||||
COLORREF getCtrlBgColor(HWND hWnd);
|
COLORREF getCtrlBgColor(HWND hWnd);
|
||||||
generic_string stringToUpper(generic_string strToConvert);
|
generic_string stringToUpper(generic_string strToConvert);
|
||||||
|
generic_string stringToLower(generic_string strToConvert);
|
||||||
generic_string stringReplace(generic_string subject, const generic_string& search, const generic_string& replace);
|
generic_string stringReplace(generic_string subject, const generic_string& search, const generic_string& replace);
|
||||||
std::vector<generic_string> stringSplit(const generic_string& input, const generic_string& delimiter);
|
std::vector<generic_string> stringSplit(const generic_string& input, const generic_string& delimiter);
|
||||||
generic_string stringJoin(const std::vector<generic_string>& strings, const generic_string& separator);
|
generic_string stringJoin(const std::vector<generic_string>& strings, const generic_string& separator);
|
||||||
|
@ -97,6 +97,7 @@ generic_string ShortcutMapper::getTabString(size_t i) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ShortcutMapper::initBabyGrid() {
|
void ShortcutMapper::initBabyGrid() {
|
||||||
RECT rect;
|
RECT rect;
|
||||||
getClientRect(rect);
|
getClientRect(rect);
|
||||||
@ -136,11 +137,53 @@ void ShortcutMapper::initBabyGrid() {
|
|||||||
NppParameters::getInstance()->getNativeLangSpeaker()->changeDlgLang(_hSelf, "ShortcutMapper");
|
NppParameters::getInstance()->getNativeLangSpeaker()->changeDlgLang(_hSelf, "ShortcutMapper");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generic_string ShortcutMapper::getTextFromCombo(HWND hCombo)
|
||||||
|
{
|
||||||
|
const int NB_MAX(128);
|
||||||
|
TCHAR str[NB_MAX](TEXT("\0"));
|
||||||
|
::SendMessage(hCombo, WM_GETTEXT, NB_MAX, reinterpret_cast<LPARAM>(str));
|
||||||
|
generic_string res(str);
|
||||||
|
return stringToLower(res);
|
||||||
|
};
|
||||||
|
|
||||||
|
bool ShortcutMapper::isFilterValid(Shortcut sc)
|
||||||
|
{
|
||||||
|
bool match = false;
|
||||||
|
generic_string shortcut_name = stringToLower(generic_string(sc.getName()));
|
||||||
|
if (_shortcutFilter.empty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// test the filter on the shortcut name
|
||||||
|
size_t match_pos = shortcut_name.find(_shortcutFilter);
|
||||||
|
if (match_pos != std::string::npos){
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ShortcutMapper::isFilterValid(PluginCmdShortcut sc)
|
||||||
|
{
|
||||||
|
// Do like a classic search on shortcut name, then search on the plugin name.
|
||||||
|
Shortcut shortcut = sc;
|
||||||
|
bool match = false;
|
||||||
|
generic_string module_name = stringToLower(generic_string(sc.getModuleName()));
|
||||||
|
if (isFilterValid(shortcut)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
size_t match_pos = module_name.find(_shortcutFilter);
|
||||||
|
if (match_pos != std::string::npos){
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
|
||||||
void ShortcutMapper::fillOutBabyGrid()
|
void ShortcutMapper::fillOutBabyGrid()
|
||||||
{
|
{
|
||||||
NppParameters *nppParam = NppParameters::getInstance();
|
NppParameters *nppParam = NppParameters::getInstance();
|
||||||
_babygrid.clear();
|
_babygrid.clear();
|
||||||
_babygrid.setInitialContent(true);
|
_babygrid.setInitialContent(true);
|
||||||
|
_shortcutIndex.clear();
|
||||||
|
|
||||||
size_t nbItems = 0;
|
size_t nbItems = 0;
|
||||||
NativeLangSpeaker* nativeLangSpeaker = nppParam->getNativeLangSpeaker();
|
NativeLangSpeaker* nativeLangSpeaker = nppParam->getNativeLangSpeaker();
|
||||||
@ -193,24 +236,33 @@ void ShortcutMapper::fillOutBabyGrid()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isMarker = false;
|
bool isMarker = false;
|
||||||
|
size_t cs_index = 0;
|
||||||
|
_shortcutFilter = getTextFromCombo(::GetDlgItem(_hSelf, IDC_BABYGRID_FILTER));
|
||||||
|
|
||||||
switch(_currentState)
|
switch(_currentState)
|
||||||
{
|
{
|
||||||
case STATE_MENU:
|
case STATE_MENU:
|
||||||
{
|
{
|
||||||
vector<CommandShortcut> & cshortcuts = nppParam->getUserShortcuts();
|
vector<CommandShortcut> & cshortcuts = nppParam->getUserShortcuts();
|
||||||
|
cs_index = 1;
|
||||||
for (size_t i = 0; i < nbItems; ++i)
|
for (size_t i = 0; i < nbItems; ++i)
|
||||||
{
|
{
|
||||||
if (findKeyConflicts(nullptr, cshortcuts[i].getKeyCombo(), i))
|
if (isFilterValid(cshortcuts[i]))
|
||||||
isMarker = _babygrid.setMarker(true);
|
{
|
||||||
|
if (findKeyConflicts(nullptr, cshortcuts[i].getKeyCombo(), i))
|
||||||
|
isMarker = _babygrid.setMarker(true);
|
||||||
|
|
||||||
_babygrid.setText(i + 1, 1, cshortcuts[i].getName());
|
_babygrid.setText(cs_index, 1, cshortcuts[i].getName());
|
||||||
if (cshortcuts[i].isEnabled()) //avoid empty strings for better performance
|
if (cshortcuts[i].isEnabled()) //avoid empty strings for better performance
|
||||||
_babygrid.setText(i + 1, 2, cshortcuts[i].toString().c_str());
|
_babygrid.setText(cs_index, 2, cshortcuts[i].toString().c_str());
|
||||||
_babygrid.setText(i + 1, 3, cshortcuts[i].getCategory());
|
_babygrid.setText(cs_index, 3, cshortcuts[i].getCategory());
|
||||||
if (isMarker)
|
if (isMarker)
|
||||||
isMarker = _babygrid.setMarker(false);
|
isMarker = _babygrid.setMarker(false);
|
||||||
|
_shortcutIndex.push_back(i);
|
||||||
|
cs_index++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
_babygrid.setLineColNumber(cs_index - 1 , 3);
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), true);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), true);
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_CLEAR), true);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_CLEAR), true);
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), false);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), false);
|
||||||
@ -220,18 +272,25 @@ void ShortcutMapper::fillOutBabyGrid()
|
|||||||
case STATE_MACRO:
|
case STATE_MACRO:
|
||||||
{
|
{
|
||||||
vector<MacroShortcut> & cshortcuts = nppParam->getMacroList();
|
vector<MacroShortcut> & cshortcuts = nppParam->getMacroList();
|
||||||
|
cs_index = 1;
|
||||||
for(size_t i = 0; i < nbItems; ++i)
|
for(size_t i = 0; i < nbItems; ++i)
|
||||||
{
|
{
|
||||||
if (findKeyConflicts(nullptr, cshortcuts[i].getKeyCombo(), i))
|
if (isFilterValid(cshortcuts[i]))
|
||||||
isMarker = _babygrid.setMarker(true);
|
{
|
||||||
|
if (findKeyConflicts(nullptr, cshortcuts[i].getKeyCombo(), i))
|
||||||
|
isMarker = _babygrid.setMarker(true);
|
||||||
|
|
||||||
_babygrid.setText(i+1, 1, cshortcuts[i].getName());
|
_babygrid.setText(cs_index, 1, cshortcuts[i].getName());
|
||||||
if (cshortcuts[i].isEnabled()) //avoid empty strings for better performance
|
if (cshortcuts[i].isEnabled()) //avoid empty strings for better performance
|
||||||
_babygrid.setText(i+1, 2, cshortcuts[i].toString().c_str());
|
_babygrid.setText(cs_index, 2, cshortcuts[i].toString().c_str());
|
||||||
|
|
||||||
if (isMarker)
|
if (isMarker)
|
||||||
isMarker = _babygrid.setMarker(false);
|
isMarker = _babygrid.setMarker(false);
|
||||||
|
_shortcutIndex.push_back(i);
|
||||||
|
cs_index++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
_babygrid.setLineColNumber(cs_index - 1 , 2);
|
||||||
bool shouldBeEnabled = nbItems > 0;
|
bool shouldBeEnabled = nbItems > 0;
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), shouldBeEnabled);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), shouldBeEnabled);
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_CLEAR), shouldBeEnabled);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_CLEAR), shouldBeEnabled);
|
||||||
@ -242,18 +301,26 @@ void ShortcutMapper::fillOutBabyGrid()
|
|||||||
case STATE_USER:
|
case STATE_USER:
|
||||||
{
|
{
|
||||||
vector<UserCommand> & cshortcuts = nppParam->getUserCommandList();
|
vector<UserCommand> & cshortcuts = nppParam->getUserCommandList();
|
||||||
|
cs_index = 1;
|
||||||
for(size_t i = 0; i < nbItems; ++i)
|
for(size_t i = 0; i < nbItems; ++i)
|
||||||
{
|
{
|
||||||
if (findKeyConflicts(nullptr, cshortcuts[i].getKeyCombo(), i))
|
if (isFilterValid(cshortcuts[i]))
|
||||||
isMarker = _babygrid.setMarker(true);
|
{
|
||||||
|
if (findKeyConflicts(nullptr, cshortcuts[i].getKeyCombo(), i))
|
||||||
|
isMarker = _babygrid.setMarker(true);
|
||||||
|
|
||||||
_babygrid.setText(i+1, 1, cshortcuts[i].getName());
|
_babygrid.setText(cs_index, 1, cshortcuts[i].getName());
|
||||||
if (cshortcuts[i].isEnabled()) //avoid empty strings for better performance
|
if (cshortcuts[i].isEnabled()) //avoid empty strings for better performance
|
||||||
_babygrid.setText(i+1, 2, cshortcuts[i].toString().c_str());
|
_babygrid.setText(cs_index, 2, cshortcuts[i].toString().c_str());
|
||||||
|
|
||||||
if (isMarker)
|
if (isMarker)
|
||||||
isMarker = _babygrid.setMarker(false);
|
isMarker = _babygrid.setMarker(false);
|
||||||
|
_shortcutIndex.push_back(i);
|
||||||
|
cs_index++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
_babygrid.setLineColNumber(cs_index - 1 , 2);
|
||||||
|
|
||||||
bool shouldBeEnabled = nbItems > 0;
|
bool shouldBeEnabled = nbItems > 0;
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), shouldBeEnabled);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), shouldBeEnabled);
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_CLEAR), shouldBeEnabled);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_CLEAR), shouldBeEnabled);
|
||||||
@ -264,19 +331,26 @@ void ShortcutMapper::fillOutBabyGrid()
|
|||||||
case STATE_PLUGIN:
|
case STATE_PLUGIN:
|
||||||
{
|
{
|
||||||
vector<PluginCmdShortcut> & cshortcuts = nppParam->getPluginCommandList();
|
vector<PluginCmdShortcut> & cshortcuts = nppParam->getPluginCommandList();
|
||||||
|
cs_index = 1;
|
||||||
for(size_t i = 0; i < nbItems; ++i)
|
for(size_t i = 0; i < nbItems; ++i)
|
||||||
{
|
{
|
||||||
if (findKeyConflicts(nullptr, cshortcuts[i].getKeyCombo(), i))
|
if (isFilterValid(cshortcuts[i]))
|
||||||
isMarker = _babygrid.setMarker(true);
|
{
|
||||||
|
if (findKeyConflicts(nullptr, cshortcuts[i].getKeyCombo(), i))
|
||||||
|
isMarker = _babygrid.setMarker(true);
|
||||||
|
|
||||||
_babygrid.setText(i+1, 1, cshortcuts[i].getName());
|
_babygrid.setText(cs_index, 1, cshortcuts[i].getName());
|
||||||
if (cshortcuts[i].isEnabled()) //avoid empty strings for better performance
|
if (cshortcuts[i].isEnabled()) //avoid empty strings for better performance
|
||||||
_babygrid.setText(i+1, 2, cshortcuts[i].toString().c_str());
|
_babygrid.setText(cs_index, 2, cshortcuts[i].toString().c_str());
|
||||||
_babygrid.setText(i+1, 3, cshortcuts[i].getModuleName());
|
_babygrid.setText(cs_index, 3, cshortcuts[i].getModuleName());
|
||||||
|
|
||||||
if (isMarker)
|
if (isMarker)
|
||||||
isMarker = _babygrid.setMarker(false);
|
isMarker = _babygrid.setMarker(false);
|
||||||
|
_shortcutIndex.push_back(i);
|
||||||
|
cs_index++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
_babygrid.setLineColNumber(cs_index - 1 , 3);
|
||||||
bool shouldBeEnabled = nbItems > 0;
|
bool shouldBeEnabled = nbItems > 0;
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), shouldBeEnabled);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), shouldBeEnabled);
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_CLEAR), shouldBeEnabled);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_CLEAR), shouldBeEnabled);
|
||||||
@ -287,28 +361,35 @@ void ShortcutMapper::fillOutBabyGrid()
|
|||||||
case STATE_SCINTILLA:
|
case STATE_SCINTILLA:
|
||||||
{
|
{
|
||||||
vector<ScintillaKeyMap> & cshortcuts = nppParam->getScintillaKeyList();
|
vector<ScintillaKeyMap> & cshortcuts = nppParam->getScintillaKeyList();
|
||||||
|
cs_index=1;
|
||||||
for(size_t i = 0; i < nbItems; ++i)
|
for(size_t i = 0; i < nbItems; ++i)
|
||||||
{
|
{
|
||||||
if (cshortcuts[i].isEnabled())
|
if (isFilterValid(cshortcuts[i]))
|
||||||
{
|
{
|
||||||
size_t sciCombos = cshortcuts[i].getSize();
|
if (cshortcuts[i].isEnabled())
|
||||||
for (size_t sciIndex = 0; sciIndex < sciCombos; ++sciIndex)
|
|
||||||
{
|
{
|
||||||
if (findKeyConflicts(nullptr, cshortcuts[i].getKeyComboByIndex(sciIndex), i))
|
size_t sciCombos = cshortcuts[i].getSize();
|
||||||
|
for (size_t sciIndex = 0; sciIndex < sciCombos; ++sciIndex)
|
||||||
{
|
{
|
||||||
isMarker = _babygrid.setMarker(true);
|
if (findKeyConflicts(nullptr, cshortcuts[i].getKeyComboByIndex(sciIndex), i))
|
||||||
break;
|
{
|
||||||
|
isMarker = _babygrid.setMarker(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_babygrid.setText(cs_index, 1, cshortcuts[i].getName());
|
||||||
|
if (cshortcuts[i].isEnabled()) //avoid empty strings for better performance
|
||||||
|
_babygrid.setText(cs_index, 2, cshortcuts[i].toString().c_str());
|
||||||
|
|
||||||
|
if (isMarker)
|
||||||
|
isMarker = _babygrid.setMarker(false);
|
||||||
|
_shortcutIndex.push_back(i);
|
||||||
|
cs_index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
_babygrid.setText(i+1, 1, cshortcuts[i].getName());
|
|
||||||
if (cshortcuts[i].isEnabled()) //avoid empty strings for better performance
|
|
||||||
_babygrid.setText(i+1, 2, cshortcuts[i].toString().c_str());
|
|
||||||
|
|
||||||
if (isMarker)
|
|
||||||
isMarker = _babygrid.setMarker(false);
|
|
||||||
}
|
}
|
||||||
|
_babygrid.setLineColNumber(cs_index - 1 , 2);
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), true);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), true);
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_CLEAR), false);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_CLEAR), false);
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), false);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), false);
|
||||||
@ -382,12 +463,22 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
::MapWindowPoints(NULL, _hSelf, (LPPOINT)&rect, 2);
|
::MapWindowPoints(NULL, _hSelf, (LPPOINT)&rect, 2);
|
||||||
::SetWindowPos(moveHwnd, NULL, rect.left + addWidth, rect.top + addHeight, 0, 0, SWP_NOSIZE | flags);
|
::SetWindowPos(moveHwnd, NULL, rect.left + addWidth, rect.top + addHeight, 0, 0, SWP_NOSIZE | flags);
|
||||||
}
|
}
|
||||||
// Move and resize IDC_BABYGRID_INFO
|
HWND moveHwnd = ::GetDlgItem(_hSelf, IDC_BABYGRID_STATIC);
|
||||||
|
::GetWindowRect(moveHwnd, &rect);
|
||||||
|
::MapWindowPoints(NULL, _hSelf, (LPPOINT)&rect, 2);
|
||||||
|
::SetWindowPos(moveHwnd, NULL, rect.left, rect.top + addHeight, 0, 0, SWP_NOSIZE | flags);
|
||||||
|
|
||||||
|
// Move and resize IDC_BABYGRID_INFO and IDC_BABYGRID_FILTER
|
||||||
// Move the Y position, Resize the width
|
// Move the Y position, Resize the width
|
||||||
HWND resizeHwnd = ::GetDlgItem(_hSelf, IDC_BABYGRID_INFO);
|
HWND resizeHwnd = ::GetDlgItem(_hSelf, IDC_BABYGRID_INFO);
|
||||||
::GetWindowRect(resizeHwnd, &rect);
|
::GetWindowRect(resizeHwnd, &rect);
|
||||||
::MapWindowPoints(NULL, _hSelf, (LPPOINT)&rect, 2);
|
::MapWindowPoints(NULL, _hSelf, (LPPOINT)&rect, 2);
|
||||||
::SetWindowPos(resizeHwnd, NULL, rect.left, rect.top + addHeight, rect.right - rect.left + addWidth, rect.bottom - rect.top, flags);
|
::SetWindowPos(resizeHwnd, NULL, rect.left, rect.top + addHeight, rect.right - rect.left + addWidth, rect.bottom - rect.top, flags);
|
||||||
|
|
||||||
|
resizeHwnd = ::GetDlgItem(_hSelf, IDC_BABYGRID_FILTER);
|
||||||
|
::GetWindowRect(resizeHwnd, &rect);
|
||||||
|
::MapWindowPoints(NULL, _hSelf, (LPPOINT)&rect, 2);
|
||||||
|
::SetWindowPos(resizeHwnd, NULL, rect.left, rect.top + addHeight, rect.right - rect.left + addWidth, rect.bottom - rect.top, flags);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -473,6 +564,7 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
|
|
||||||
NppParameters *nppParam = NppParameters::getInstance();
|
NppParameters *nppParam = NppParameters::getInstance();
|
||||||
int row = _babygrid.getSelectedRow();
|
int row = _babygrid.getSelectedRow();
|
||||||
|
size_t shortcutIndex = _shortcutIndex[row-1];
|
||||||
bool isModified = false;
|
bool isModified = false;
|
||||||
|
|
||||||
switch(_currentState)
|
switch(_currentState)
|
||||||
@ -481,11 +573,11 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
{
|
{
|
||||||
//Get CommandShortcut corresponding to row
|
//Get CommandShortcut corresponding to row
|
||||||
vector<CommandShortcut> & shortcuts = nppParam->getUserShortcuts();
|
vector<CommandShortcut> & shortcuts = nppParam->getUserShortcuts();
|
||||||
CommandShortcut csc = shortcuts[row - 1];
|
CommandShortcut csc = shortcuts[shortcutIndex];
|
||||||
csc.clear();
|
csc.clear();
|
||||||
shortcuts[row - 1] = csc;
|
shortcuts[shortcutIndex] = csc;
|
||||||
//shortcut was altered
|
//shortcut was altered
|
||||||
nppParam->addUserModifiedIndex(row - 1);
|
nppParam->addUserModifiedIndex(shortcutIndex);
|
||||||
|
|
||||||
//save the current view
|
//save the current view
|
||||||
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
||||||
@ -504,9 +596,9 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
{
|
{
|
||||||
//Get MacroShortcut corresponding to row
|
//Get MacroShortcut corresponding to row
|
||||||
vector<MacroShortcut> & shortcuts = nppParam->getMacroList();
|
vector<MacroShortcut> & shortcuts = nppParam->getMacroList();
|
||||||
MacroShortcut msc = shortcuts[row - 1];
|
MacroShortcut msc = shortcuts[shortcutIndex];
|
||||||
msc.clear();
|
msc.clear();
|
||||||
shortcuts[row - 1] = msc;
|
shortcuts[shortcutIndex] = msc;
|
||||||
//save the current view
|
//save the current view
|
||||||
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
||||||
_lastCursorRow[_currentState] = _babygrid.getSelectedRow();
|
_lastCursorRow[_currentState] = _babygrid.getSelectedRow();
|
||||||
@ -524,11 +616,11 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
{
|
{
|
||||||
//Get UserCommand corresponding to row
|
//Get UserCommand corresponding to row
|
||||||
vector<UserCommand> & shortcuts = nppParam->getUserCommandList();
|
vector<UserCommand> & shortcuts = nppParam->getUserCommandList();
|
||||||
UserCommand ucmd = shortcuts[row - 1];
|
UserCommand ucmd = shortcuts[shortcutIndex];
|
||||||
ucmd.clear();
|
ucmd.clear();
|
||||||
|
|
||||||
//shortcut was altered
|
//shortcut was altered
|
||||||
shortcuts[row - 1] = ucmd;
|
shortcuts[shortcutIndex] = ucmd;
|
||||||
|
|
||||||
//save the current view
|
//save the current view
|
||||||
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
||||||
@ -547,11 +639,11 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
{
|
{
|
||||||
//Get PluginCmdShortcut corresponding to row
|
//Get PluginCmdShortcut corresponding to row
|
||||||
vector<PluginCmdShortcut> & shortcuts = nppParam->getPluginCommandList();
|
vector<PluginCmdShortcut> & shortcuts = nppParam->getPluginCommandList();
|
||||||
PluginCmdShortcut pcsc = shortcuts[row - 1];
|
PluginCmdShortcut pcsc = shortcuts[shortcutIndex];
|
||||||
pcsc.clear();
|
pcsc.clear();
|
||||||
//shortcut was altered
|
//shortcut was altered
|
||||||
nppParam->addPluginModifiedIndex(row - 1);
|
nppParam->addPluginModifiedIndex(shortcutIndex);
|
||||||
shortcuts[row - 1] = pcsc;
|
shortcuts[shortcutIndex] = pcsc;
|
||||||
|
|
||||||
//save the current view
|
//save the current view
|
||||||
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
||||||
@ -595,6 +687,7 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
|
|
||||||
NppParameters *nppParam = NppParameters::getInstance();
|
NppParameters *nppParam = NppParameters::getInstance();
|
||||||
int row = _babygrid.getSelectedRow();
|
int row = _babygrid.getSelectedRow();
|
||||||
|
size_t shortcutIndex = _shortcutIndex[row-1];
|
||||||
bool isModified = false;
|
bool isModified = false;
|
||||||
|
|
||||||
switch(_currentState)
|
switch(_currentState)
|
||||||
@ -603,13 +696,13 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
{
|
{
|
||||||
//Get CommandShortcut corresponding to row
|
//Get CommandShortcut corresponding to row
|
||||||
vector<CommandShortcut> & shortcuts = nppParam->getUserShortcuts();
|
vector<CommandShortcut> & shortcuts = nppParam->getUserShortcuts();
|
||||||
CommandShortcut csc = shortcuts[row - 1], prevcsc = shortcuts[row - 1];
|
CommandShortcut csc = shortcuts[shortcutIndex], prevcsc = shortcuts[shortcutIndex];
|
||||||
csc.init(_hInst, _hSelf);
|
csc.init(_hInst, _hSelf);
|
||||||
if (csc.doDialog() != -1 && prevcsc != csc)
|
if (csc.doDialog() != -1 && prevcsc != csc)
|
||||||
{
|
{
|
||||||
//shortcut was altered
|
//shortcut was altered
|
||||||
nppParam->addUserModifiedIndex(row - 1);
|
nppParam->addUserModifiedIndex(shortcutIndex);
|
||||||
shortcuts[row - 1] = csc;
|
shortcuts[shortcutIndex] = csc;
|
||||||
|
|
||||||
//save the current view
|
//save the current view
|
||||||
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
||||||
@ -629,12 +722,12 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
{
|
{
|
||||||
//Get MacroShortcut corresponding to row
|
//Get MacroShortcut corresponding to row
|
||||||
vector<MacroShortcut> & shortcuts = nppParam->getMacroList();
|
vector<MacroShortcut> & shortcuts = nppParam->getMacroList();
|
||||||
MacroShortcut msc = shortcuts[row - 1], prevmsc = shortcuts[row - 1];
|
MacroShortcut msc = shortcuts[shortcutIndex], prevmsc = shortcuts[shortcutIndex];
|
||||||
msc.init(_hInst, _hSelf);
|
msc.init(_hInst, _hSelf);
|
||||||
if (msc.doDialog() != -1 && prevmsc != msc)
|
if (msc.doDialog() != -1 && prevmsc != msc)
|
||||||
{
|
{
|
||||||
//shortcut was altered
|
//shortcut was altered
|
||||||
shortcuts[row - 1] = msc;
|
shortcuts[shortcutIndex] = msc;
|
||||||
|
|
||||||
//save the current view
|
//save the current view
|
||||||
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
||||||
@ -654,13 +747,13 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
{
|
{
|
||||||
//Get UserCommand corresponding to row
|
//Get UserCommand corresponding to row
|
||||||
vector<UserCommand> & shortcuts = nppParam->getUserCommandList();
|
vector<UserCommand> & shortcuts = nppParam->getUserCommandList();
|
||||||
UserCommand ucmd = shortcuts[row - 1];
|
UserCommand ucmd = shortcuts[shortcutIndex];
|
||||||
ucmd.init(_hInst, _hSelf);
|
ucmd.init(_hInst, _hSelf);
|
||||||
UserCommand prevucmd = ucmd;
|
UserCommand prevucmd = ucmd;
|
||||||
if (ucmd.doDialog() != -1 && prevucmd != ucmd)
|
if (ucmd.doDialog() != -1 && prevucmd != ucmd)
|
||||||
{
|
{
|
||||||
//shortcut was altered
|
//shortcut was altered
|
||||||
shortcuts[row - 1] = ucmd;
|
shortcuts[shortcutIndex] = ucmd;
|
||||||
|
|
||||||
//save the current view
|
//save the current view
|
||||||
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
||||||
@ -680,14 +773,14 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
{
|
{
|
||||||
//Get PluginCmdShortcut corresponding to row
|
//Get PluginCmdShortcut corresponding to row
|
||||||
vector<PluginCmdShortcut> & shortcuts = nppParam->getPluginCommandList();
|
vector<PluginCmdShortcut> & shortcuts = nppParam->getPluginCommandList();
|
||||||
PluginCmdShortcut pcsc = shortcuts[row - 1];
|
PluginCmdShortcut pcsc = shortcuts[shortcutIndex];
|
||||||
pcsc.init(_hInst, _hSelf);
|
pcsc.init(_hInst, _hSelf);
|
||||||
PluginCmdShortcut prevpcsc = pcsc;
|
PluginCmdShortcut prevpcsc = pcsc;
|
||||||
if (pcsc.doDialog() != -1 && prevpcsc != pcsc)
|
if (pcsc.doDialog() != -1 && prevpcsc != pcsc)
|
||||||
{
|
{
|
||||||
//shortcut was altered
|
//shortcut was altered
|
||||||
nppParam->addPluginModifiedIndex(row - 1);
|
nppParam->addPluginModifiedIndex(shortcutIndex);
|
||||||
shortcuts[row - 1] = pcsc;
|
shortcuts[shortcutIndex] = pcsc;
|
||||||
|
|
||||||
//save the current view
|
//save the current view
|
||||||
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
||||||
@ -715,13 +808,13 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
{
|
{
|
||||||
//Get ScintillaKeyMap corresponding to row
|
//Get ScintillaKeyMap corresponding to row
|
||||||
vector<ScintillaKeyMap> & shortcuts = nppParam->getScintillaKeyList();
|
vector<ScintillaKeyMap> & shortcuts = nppParam->getScintillaKeyList();
|
||||||
ScintillaKeyMap skm = shortcuts[row - 1], prevskm = shortcuts[row - 1];
|
ScintillaKeyMap skm = shortcuts[shortcutIndex], prevskm = shortcuts[shortcutIndex];
|
||||||
skm.init(_hInst, _hSelf);
|
skm.init(_hInst, _hSelf);
|
||||||
if (skm.doDialog() != -1 && prevskm != skm)
|
if (skm.doDialog() != -1 && prevskm != skm)
|
||||||
{
|
{
|
||||||
//shortcut was altered
|
//shortcut was altered
|
||||||
nppParam->addScintillaModifiedIndex(row - 1);
|
nppParam->addScintillaModifiedIndex((int)shortcutIndex);
|
||||||
shortcuts[row - 1] = skm;
|
shortcuts[shortcutIndex] = skm;
|
||||||
|
|
||||||
//save the current view
|
//save the current view
|
||||||
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
||||||
@ -760,7 +853,7 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
if (res == IDOK)
|
if (res == IDOK)
|
||||||
{
|
{
|
||||||
const int row = _babygrid.getSelectedRow();
|
const int row = _babygrid.getSelectedRow();
|
||||||
int shortcutIndex = row-1;
|
size_t shortcutIndex = _shortcutIndex[row-1];
|
||||||
DWORD cmdID = 0;
|
DWORD cmdID = 0;
|
||||||
|
|
||||||
// Menu data
|
// Menu data
|
||||||
@ -994,6 +1087,14 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case IDC_BABYGRID_FILTER:
|
||||||
|
{
|
||||||
|
if (HIWORD(wParam) == EN_CHANGE)
|
||||||
|
{
|
||||||
|
fillOutBabyGrid();
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,9 @@ enum GridState {STATE_MENU, STATE_MACRO, STATE_USER, STATE_PLUGIN, STATE_SCINTIL
|
|||||||
|
|
||||||
class ShortcutMapper : public StaticDialog {
|
class ShortcutMapper : public StaticDialog {
|
||||||
public:
|
public:
|
||||||
ShortcutMapper() : _currentState(STATE_MENU), StaticDialog() {};
|
ShortcutMapper() : _currentState(STATE_MENU), StaticDialog() {
|
||||||
|
_shortcutFilter = TEXT("");
|
||||||
|
};
|
||||||
~ShortcutMapper() {};
|
~ShortcutMapper() {};
|
||||||
|
|
||||||
void init(HINSTANCE hInst, HWND parent, GridState initState = STATE_MENU) {
|
void init(HINSTANCE hInst, HWND parent, GridState initState = STATE_MENU) {
|
||||||
@ -62,6 +64,10 @@ public:
|
|||||||
bool findKeyConflicts(__inout_opt generic_string * const keyConflictLocation,
|
bool findKeyConflicts(__inout_opt generic_string * const keyConflictLocation,
|
||||||
const KeyCombo & itemKeyCombo, const size_t & itemIndex) const;
|
const KeyCombo & itemKeyCombo, const size_t & itemIndex) const;
|
||||||
|
|
||||||
|
generic_string ShortcutMapper::getTextFromCombo(HWND hCombo);
|
||||||
|
bool ShortcutMapper::isFilterValid(Shortcut);
|
||||||
|
bool ShortcutMapper::isFilterValid(PluginCmdShortcut sc);
|
||||||
|
|
||||||
protected :
|
protected :
|
||||||
INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
@ -74,6 +80,8 @@ private:
|
|||||||
|
|
||||||
const static int _nbTab = 5;
|
const static int _nbTab = 5;
|
||||||
generic_string _tabNames[_nbTab];
|
generic_string _tabNames[_nbTab];
|
||||||
|
generic_string _shortcutFilter;
|
||||||
|
std::vector<size_t> _shortcutIndex;
|
||||||
|
|
||||||
//save/restore the last view
|
//save/restore the last view
|
||||||
std::vector<size_t> _lastHomeRow;
|
std::vector<size_t> _lastHomeRow;
|
||||||
|
14
PowerEditor/src/WinControls/Grid/ShortcutMapper.rc
Normal file → Executable file
14
PowerEditor/src/WinControls/Grid/ShortcutMapper.rc
Normal file → Executable file
@ -33,17 +33,19 @@
|
|||||||
#define IDC_STATIC -1
|
#define IDC_STATIC -1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
IDD_SHORTCUTMAPPER_DLG DIALOGEX 0, 0, 450, 344
|
IDD_SHORTCUTMAPPER_DLG DIALOGEX 0, 0, 450, 355
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
|
||||||
WS_SYSMENU | WS_MAXIMIZEBOX | WS_THICKFRAME
|
WS_SYSMENU | WS_MAXIMIZEBOX | WS_THICKFRAME
|
||||||
//EXSTYLE WS_EX_TOOLWINDOW
|
//EXSTYLE WS_EX_TOOLWINDOW
|
||||||
CAPTION "Shortcut mapper"
|
CAPTION "Shortcut mapper"
|
||||||
FONT 8, TEXT("MS Shell Dlg"), 400, 0, 0x1
|
FONT 8, TEXT("MS Shell Dlg"), 400, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
CONTROL "",IDC_BABYGRID_TABBAR,"SysTabControl32",WS_TABSTOP,4,6,384,12
|
CONTROL "",IDC_BABYGRID_TABBAR,"SysTabControl32",WS_TABSTOP,4,6,384,12
|
||||||
DEFPUSHBUTTON "Modify",IDM_BABYGRID_MODIFY,118,319,47,14
|
DEFPUSHBUTTON "Modify",IDM_BABYGRID_MODIFY,118,330,47,14
|
||||||
DEFPUSHBUTTON "Clear", IDM_BABYGRID_CLEAR,172,319,47,14
|
DEFPUSHBUTTON "Clear",IDM_BABYGRID_CLEAR,172,330,47,14
|
||||||
DEFPUSHBUTTON "Delete", IDM_BABYGRID_DELETE, 226, 319, 47, 14
|
DEFPUSHBUTTON "Delete",IDM_BABYGRID_DELETE,226,330,47,14
|
||||||
DEFPUSHBUTTON "Close",IDOK,280,319,47,14
|
DEFPUSHBUTTON "Close",IDOK,280,330,47,14
|
||||||
EDITTEXT IDC_BABYGRID_INFO,4,279,440,29,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP
|
EDITTEXT IDC_BABYGRID_INFO,4,279,440,29,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP
|
||||||
|
RTEXT "Filter :",IDC_BABYGRID_STATIC,4,310,25,12
|
||||||
|
EDITTEXT IDC_BABYGRID_FILTER,30,310,415,12,ES_AUTOHSCROLL | ES_WANTRETURN | NOT WS_BORDER,WS_EX_STATICEDGE
|
||||||
END
|
END
|
||||||
|
@ -34,7 +34,9 @@
|
|||||||
#define IDM_BABYGRID_MODIFY (IDD_SHORTCUTMAPPER_DLG + 2)
|
#define IDM_BABYGRID_MODIFY (IDD_SHORTCUTMAPPER_DLG + 2)
|
||||||
#define IDM_BABYGRID_DELETE (IDD_SHORTCUTMAPPER_DLG + 3)
|
#define IDM_BABYGRID_DELETE (IDD_SHORTCUTMAPPER_DLG + 3)
|
||||||
#define IDC_BABYGRID_TABBAR (IDD_SHORTCUTMAPPER_DLG + 4)
|
#define IDC_BABYGRID_TABBAR (IDD_SHORTCUTMAPPER_DLG + 4)
|
||||||
#define IDC_BABYGRID_INFO (IDD_SHORTCUTMAPPER_DLG + 5)
|
#define IDC_BABYGRID_INFO (IDD_SHORTCUTMAPPER_DLG + 5)
|
||||||
#define IDM_BABYGRID_CLEAR (IDD_SHORTCUTMAPPER_DLG + 6)
|
#define IDM_BABYGRID_CLEAR (IDD_SHORTCUTMAPPER_DLG + 6)
|
||||||
|
#define IDC_BABYGRID_STATIC (IDD_SHORTCUTMAPPER_DLG + 7)
|
||||||
|
#define IDC_BABYGRID_FILTER (IDD_SHORTCUTMAPPER_DLG + 8)
|
||||||
|
|
||||||
#endif// SHORTCUTMAPPER_RC_H
|
#endif// SHORTCUTMAPPER_RC_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user