当前位置: 首页>>代码示例>>C++>>正文


C++ NppParameters::getScintillaKeyList方法代码示例

本文整理汇总了C++中NppParameters::getScintillaKeyList方法的典型用法代码示例。如果您正苦于以下问题:C++ NppParameters::getScintillaKeyList方法的具体用法?C++ NppParameters::getScintillaKeyList怎么用?C++ NppParameters::getScintillaKeyList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NppParameters的用法示例。


在下文中一共展示了NppParameters::getScintillaKeyList方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updateKeys

void ScintillaAccelerator::updateKeys() 
{
	NppParameters *pNppParam = NppParameters::getInstance();
	vector<ScintillaKeyMap> & map = pNppParam->getScintillaKeyList();
	size_t mapSize = map.size();
	size_t index;

	for(int i = 0; i < _nrScintillas; ++i)
	{
		::SendMessage(_vScintillas[i], SCI_CLEARALLCMDKEYS, 0, 0);
		for(int32_t j = static_cast<int32_t>(mapSize) - 1; j >= 0; j--) //reverse order, top of the list has highest priority
		{	
			ScintillaKeyMap skm = map[j];
			if (skm.isEnabled()) 
			{		//no validating, scintilla accepts more keys
				size_t size = skm.getSize();
				for(index = 0; index < size; ++index)
					::SendMessage(_vScintillas[i], SCI_ASSIGNCMDKEY, skm.toKeyDef(index), skm.getScintillaKeyID());
			}
			if (skm.getMenuCmdID() != 0) 
			{
				updateMenuItemByID(skm, skm.getMenuCmdID());
			}
			if (j == 0)	//j is unsigned, so default method doesnt work
				break;
		}
	}
}
开发者ID:AndychenCL,项目名称:notepad-plus-plus,代码行数:28,代码来源:shortcut.cpp

示例2: changeShortcutLang

void NativeLangSpeaker::changeShortcutLang()
{
	if (!_nativeLangA) return;

	NppParameters * pNppParam = NppParameters::getInstance();
	vector<CommandShortcut> & mainshortcuts = pNppParam->getUserShortcuts();
	vector<ScintillaKeyMap> & scinshortcuts = pNppParam->getScintillaKeyList();

	TiXmlNodeA *shortcuts = _nativeLangA->FirstChild("Shortcuts");
	if (!shortcuts) return;

	shortcuts = shortcuts->FirstChild("Main");
	if (!shortcuts) return;

	TiXmlNodeA *entriesRoot = shortcuts->FirstChild("Entries");
	if (!entriesRoot) return;

	for (TiXmlNodeA *childNode = entriesRoot->FirstChildElement("Item");
		childNode ;
		childNode = childNode->NextSibling("Item") )
	{
		TiXmlElementA *element = childNode->ToElement();
		int index, id;
		if (element->Attribute("index", &index) && element->Attribute("id", &id))
		{
			if (index > -1 && static_cast<size_t>(index) < mainshortcuts.size()) //valid index only
			{
				const char *name = element->Attribute("name");
				CommandShortcut & csc = mainshortcuts[index];
				if (csc.getID() == (unsigned long)id) 
				{
					WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
					const wchar_t * nameW = wmc->char2wchar(name, _nativeLangEncoding);
					csc.setName(nameW);
				}
			}
		}
	}

	//Scintilla
	shortcuts = _nativeLangA->FirstChild("Shortcuts");
	if (!shortcuts) return;

	shortcuts = shortcuts->FirstChild("Scintilla");
	if (!shortcuts) return;

	entriesRoot = shortcuts->FirstChild("Entries");
	if (!entriesRoot) return;

	for (TiXmlNodeA *childNode = entriesRoot->FirstChildElement("Item");
		childNode ;
		childNode = childNode->NextSibling("Item") )
	{
		TiXmlElementA *element = childNode->ToElement();
		int index;
		if (element->Attribute("index", &index))
		{
			if (index > -1 && static_cast<size_t>(index) < scinshortcuts.size()) //valid index only
			{
				const char *name = element->Attribute("name");
				ScintillaKeyMap & skm = scinshortcuts[index];

				WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
				const wchar_t * nameW = wmc->char2wchar(name, _nativeLangEncoding);
				skm.setName(nameW);
			}
		}
	}

}
开发者ID:SinghRajenM,项目名称:notepad-plus-plus,代码行数:70,代码来源:localization.cpp

示例3: run_dlgProc


//.........这里部分代码省略.........
								_babygrid.setText(row, 1, ucmd.getName());
								_babygrid.setText(row, 2, ucmd.toString().c_str());

								//Notify current Accelerator class to update everything
								nppParam->getAccelerator()->updateShortcuts();
								
							}
							break; }
						case STATE_PLUGIN: {
							//Get PluginCmdShortcut corresponding to row
							vector<PluginCmdShortcut> & shortcuts = nppParam->getPluginCommandList();
							PluginCmdShortcut pcsc = shortcuts[row - 1], prevpcsc = shortcuts[row - 1];
							pcsc.init(_hInst, _hSelf);
							prevpcsc = pcsc;
							if (pcsc.doDialog() != -1 && prevpcsc != pcsc) {	//shortcut was altered
								nppParam->addPluginModifiedIndex(row-1);
								shortcuts[row - 1] = pcsc;
								_babygrid.setText(row, 2, pcsc.toString().c_str());

								//Notify current Accelerator class to update everything
								nppParam->getAccelerator()->updateShortcuts();
								unsigned long cmdID = pcsc.getID();
								ShortcutKey shortcut;
								shortcut._isAlt = pcsc.getKeyCombo()._isAlt;
								shortcut._isCtrl = pcsc.getKeyCombo()._isCtrl;
								shortcut._isShift = pcsc.getKeyCombo()._isShift;
								shortcut._key = pcsc.getKeyCombo()._key;

								::SendMessage(_hParent, NPPM_INTERNAL_PLUGINSHORTCUTMOTIFIED, cmdID, (LPARAM)&shortcut);
							}
							break; }
						case STATE_SCINTILLA: {
							//Get ScintillaKeyMap corresponding to row
							vector<ScintillaKeyMap> & shortcuts = nppParam->getScintillaKeyList();
							ScintillaKeyMap skm = shortcuts[row - 1], prevskm = shortcuts[row-1];
							skm.init(_hInst, _hSelf);
							if (skm.doDialog() != -1 && prevskm != skm) 
							{
								//shortcut was altered
								nppParam->addScintillaModifiedIndex(row-1);
								shortcuts[row-1] = skm;
								_babygrid.setText(row, 2, skm.toString().c_str());

								//Notify current Accelerator class to update key
								nppParam->getScintillaAccelerator()->updateKeys();
							}
							break; 
						}
					}
					return TRUE;
				}
				case IDM_BABYGRID_DELETE :
				{
					NppParameters *nppParam = NppParameters::getInstance();
					if (::MessageBox(_hSelf, TEXT("Are you sure you want to delete this shortcut?"), TEXT("Are you sure?"), MB_OKCANCEL) == IDOK)
					{
						const int row = _babygrid.getSelectedRow();
						int shortcutIndex = row-1;
						DWORD cmdID = 0;
						
						// Menu data
						size_t posBase = 0;
						size_t nbElem = 0;
						HMENU hMenu = NULL;
                        int modifCmd = IDM_SETTING_SHORTCUT_MAPPER_RUN;
						switch(_currentState) 
开发者ID:JSansalone,项目名称:Notepadpp-5.9,代码行数:67,代码来源:ShortcutMapper.cpp

示例4: fillOutBabyGrid

void ShortcutMapper::fillOutBabyGrid()
{
	NppParameters *nppParam = NppParameters::getInstance();
	_babygrid.clear();

	size_t nrItems = 0;

	switch(_currentState) {
		case STATE_MENU: {
			nrItems = nppParam->getUserShortcuts().size();
			_babygrid.setLineColNumber(nrItems, 2);
			break; }
		case STATE_MACRO: {
			nrItems = nppParam->getMacroList().size();
			_babygrid.setLineColNumber(nrItems, 2);
			break; }
		case STATE_USER: {
			nrItems = nppParam->getUserCommandList().size();
			_babygrid.setLineColNumber(nrItems, 2);
			break; }
		case STATE_PLUGIN: {
			nrItems = nppParam->getPluginCommandList().size();
			_babygrid.setLineColNumber(nrItems, 2);
			break; }
		case STATE_SCINTILLA: {
			nrItems = nppParam->getScintillaKeyList().size();
			_babygrid.setLineColNumber(nrItems, 2);
			break; }
	}

	_babygrid.setText(0, 1, TEXT("Name"));
	_babygrid.setText(0, 2, TEXT("Shortcut"));

	switch(_currentState) {
		case STATE_MENU: {
			vector<CommandShortcut> & cshortcuts = nppParam->getUserShortcuts();
			for(size_t i = 0; i < nrItems; i++) {
				_babygrid.setText(i+1, 1, cshortcuts[i].getName());
				_babygrid.setText(i+1, 2, cshortcuts[i].toString().c_str());
			}
            ::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), true);
            ::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), false);
			break; }
		case STATE_MACRO: {
			vector<MacroShortcut> & cshortcuts = nppParam->getMacroList();
			for(size_t i = 0; i < nrItems; i++) {
				_babygrid.setText(i+1, 1, cshortcuts[i].getName());
				_babygrid.setText(i+1, 2, cshortcuts[i].toString().c_str());
			}
            bool shouldBeEnabled = nrItems > 0;
            ::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), shouldBeEnabled);
            ::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), shouldBeEnabled);
			break; }
		case STATE_USER: {
			vector<UserCommand> & cshortcuts = nppParam->getUserCommandList();
			for(size_t i = 0; i < nrItems; i++) {
				_babygrid.setText(i+1, 1, cshortcuts[i].getName());
				_babygrid.setText(i+1, 2, cshortcuts[i].toString().c_str());
			}
            bool shouldBeEnabled = nrItems > 0;
            ::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), shouldBeEnabled);
            ::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), shouldBeEnabled);
			break; }
		case STATE_PLUGIN: {
			vector<PluginCmdShortcut> & cshortcuts = nppParam->getPluginCommandList();
			for(size_t i = 0; i < nrItems; i++) {
				_babygrid.setText(i+1, 1, cshortcuts[i].getName());
				_babygrid.setText(i+1, 2, cshortcuts[i].toString().c_str());
			}
            bool shouldBeEnabled = nrItems > 0;
            ::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), shouldBeEnabled);
            ::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), false);
			break; }
		case STATE_SCINTILLA: {
			vector<ScintillaKeyMap> & cshortcuts = nppParam->getScintillaKeyList();
			for(size_t i = 0; i < nrItems; i++) {
				_babygrid.setText(i+1, 1, cshortcuts[i].getName());
				_babygrid.setText(i+1, 2, cshortcuts[i].toString().c_str());
			}
            ::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), true);
            ::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), false);
			break; }
	}
}
开发者ID:JSansalone,项目名称:Notepadpp-5.9,代码行数:84,代码来源:ShortcutMapper.cpp

示例5: run_dlgProc


//.........这里部分代码省略.........
							pcsc.init(_hInst, _hSelf);
							PluginCmdShortcut prevpcsc = pcsc;
							if (pcsc.doDialog() != -1 && prevpcsc != pcsc)
							{
								//shortcut was altered
								nppParam->addPluginModifiedIndex(row-1);
								shortcuts[row - 1] = pcsc;

								//save the current view
								_lastHomeRow[_currentState] = _babygrid.getHomeRow();
								_lastCursorRow[_currentState] = _babygrid.getSelectedRow();
								fillOutBabyGrid();

								isModified = true;

								//Notify current Accelerator class to update everything
								nppParam->getAccelerator()->updateShortcuts();
								unsigned long cmdID = pcsc.getID();
								ShortcutKey shortcut;
								shortcut._isAlt = pcsc.getKeyCombo()._isAlt;
								shortcut._isCtrl = pcsc.getKeyCombo()._isCtrl;
								shortcut._isShift = pcsc.getKeyCombo()._isShift;
								shortcut._key = pcsc.getKeyCombo()._key;

								::SendMessage(_hParent, NPPM_INTERNAL_PLUGINSHORTCUTMOTIFIED, cmdID, reinterpret_cast<LPARAM>(&shortcut));
								nppParam->setShortcutDirty();
							}
							break;
						}

						case STATE_SCINTILLA:
						{
							//Get ScintillaKeyMap corresponding to row
							vector<ScintillaKeyMap> & shortcuts = nppParam->getScintillaKeyList();
							ScintillaKeyMap skm = shortcuts[row - 1], prevskm = shortcuts[row-1];
							skm.init(_hInst, _hSelf);
							if (skm.doDialog() != -1 && prevskm != skm) 
							{
								//shortcut was altered
								nppParam->addScintillaModifiedIndex(row-1);
								shortcuts[row-1] = skm;

								//save the current view
								_lastHomeRow[_currentState] = _babygrid.getHomeRow();
								_lastCursorRow[_currentState] = _babygrid.getSelectedRow();
								fillOutBabyGrid();
								_babygrid.updateView();

								isModified = true;

								//Notify current Accelerator class to update key
								nppParam->getScintillaAccelerator()->updateKeys();
								nppParam->setShortcutDirty();
							}
							break; 
						}
					}
					if (not isModified)
						::SendMessage(_hSelf, WM_COMMAND, MAKEWPARAM(IDD_BABYGRID_ID1, BGN_ROWCHANGED), row);
					return TRUE;
				}

				case IDM_BABYGRID_DELETE :
				{
					if (_babygrid.getNumberRows() < 1)
						return TRUE;
开发者ID:A-R-C-A,项目名称:notepad-plus-plus,代码行数:67,代码来源:ShortcutMapper.cpp

示例6: findKeyConflicts


//.........这里部分代码省略.........
					{
						retIsConflict = true;
						if (keyConflictLocation == nullptr)
							return retIsConflict;
						else
						{
							if (not keyConflictLocation->empty())
								*keyConflictLocation += TEXT("\r\n");
							*keyConflictLocation += tabNames[gridState];
							*keyConflictLocation += TEXT("  |  ");
							*keyConflictLocation += numToStr(itemIndex + 1);
							*keyConflictLocation += TEXT("   ");
							*keyConflictLocation += vShortcuts[itemIndex].getName();
							*keyConflictLocation += TEXT("  ( ");
							*keyConflictLocation += vShortcuts[itemIndex].toString();
							*keyConflictLocation += TEXT(" )");
						}
					}
				}
				break;
			} //case STATE_USER
			case STATE_PLUGIN:
			{
				vector<PluginCmdShortcut> & vShortcuts = nppParam->getPluginCommandList();
				size_t nrItems = vShortcuts.size();
				for (size_t itemIndex = 0; itemIndex < nrItems; ++itemIndex)
				{
					if (not vShortcuts[itemIndex].isEnabled()) //no key assignment
						continue;

					if ((itemIndex == itemIndexToTest) && (gridState == static_cast<size_t>(_currentState))) //don't catch oneself
						continue;

					if (isConflict(vShortcuts[itemIndex].getKeyCombo(), itemKeyComboToTest))
					{
						retIsConflict = true;
						if (keyConflictLocation == nullptr)
							return retIsConflict;
						else
						{
							if (not keyConflictLocation->empty())
								*keyConflictLocation += TEXT("\r\n");
							*keyConflictLocation += tabNames[gridState];
							*keyConflictLocation += TEXT("  |  ");
							*keyConflictLocation += numToStr(itemIndex + 1);
							*keyConflictLocation += TEXT("   ");
							*keyConflictLocation += vShortcuts[itemIndex].getName();
							*keyConflictLocation += TEXT("  ( ");
							*keyConflictLocation += vShortcuts[itemIndex].toString();
							*keyConflictLocation += TEXT(" )");
						}
					}
				}
				break;
			} //case STATE_PLUGIN
			case STATE_SCINTILLA:
			{
				vector<ScintillaKeyMap> & vShortcuts = nppParam->getScintillaKeyList();
				size_t nrItems = vShortcuts.size();
				for (size_t itemIndex = 0; itemIndex < nrItems; ++itemIndex)
				{
					if (not vShortcuts[itemIndex].isEnabled()) //no key assignment
						continue;

					if ((itemIndex == itemIndexToTest) && (gridState == static_cast<size_t>(_currentState))) //don't catch oneself
						continue;

					size_t sciCombos = vShortcuts[itemIndex].getSize();
					for (size_t sciIndex = 0; sciIndex < sciCombos; ++sciIndex)
					{
						if (isConflict(vShortcuts[itemIndex].getKeyComboByIndex(sciIndex), itemKeyComboToTest))
						{
							retIsConflict = true;
							if (keyConflictLocation == nullptr)
								return retIsConflict;
							else
							{
								if (not keyConflictLocation->empty())
									*keyConflictLocation += TEXT("\r\n");
								*keyConflictLocation += tabNames[gridState];
								*keyConflictLocation += TEXT("  |  ");
								*keyConflictLocation += numToStr(itemIndex + 1);
								if (sciIndex > 0)
									*keyConflictLocation += TEXT("*   ");
								else
									*keyConflictLocation += TEXT("   ");
								*keyConflictLocation += vShortcuts[itemIndex].getName();
								*keyConflictLocation += TEXT("  ( ");
								*keyConflictLocation += vShortcuts[itemIndex].toString(sciIndex);
								*keyConflictLocation += TEXT(" )");
							}
						}
					}
				}
				break;
			} //case STATE_SCINTILLA
		} //switch (gridState)
	} //for (...)
	return retIsConflict;
}
开发者ID:A-R-C-A,项目名称:notepad-plus-plus,代码行数:101,代码来源:ShortcutMapper.cpp

示例7: fillOutBabyGrid

void ShortcutMapper::fillOutBabyGrid()
{
	NppParameters *nppParam = NppParameters::getInstance();
	_babygrid.clear();
	_babygrid.setInitialContent(true);

	size_t nrItems = 0;

	switch(_currentState) {
		case STATE_MENU: {
			nrItems = nppParam->getUserShortcuts().size();
			_babygrid.setLineColNumber(nrItems, 2);
			break; }
		case STATE_MACRO: {
			nrItems = nppParam->getMacroList().size();
			_babygrid.setLineColNumber(nrItems, 2);
			break; }
		case STATE_USER: {
			nrItems = nppParam->getUserCommandList().size();
			_babygrid.setLineColNumber(nrItems, 2);
			break; }
		case STATE_PLUGIN: {
			nrItems = nppParam->getPluginCommandList().size();
			_babygrid.setLineColNumber(nrItems, 2);
			break; }
		case STATE_SCINTILLA: {
			nrItems = nppParam->getScintillaKeyList().size();
			_babygrid.setLineColNumber(nrItems, 2);
			break; }
	}

	_babygrid.setText(0, 1, TEXT("Name"));
	_babygrid.setText(0, 2, TEXT("Shortcut"));

	bool isMarker = false;

	switch(_currentState) {
		case STATE_MENU: {
			vector<CommandShortcut> & cshortcuts = nppParam->getUserShortcuts();
			for(size_t i = 0; i < nrItems; ++i)
			{
				if (findKeyConflicts(nullptr, cshortcuts[i].getKeyCombo(), i))
					isMarker = _babygrid.setMarker(true);

				_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);
			}
            ::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), true);
            ::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), false);
			break; }
		case STATE_MACRO: {
			vector<MacroShortcut> & cshortcuts = nppParam->getMacroList();
			for(size_t i = 0; i < nrItems; ++i)
			{
				if (findKeyConflicts(nullptr, cshortcuts[i].getKeyCombo(), i))
					isMarker = _babygrid.setMarker(true);

				_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);
			}
            bool shouldBeEnabled = nrItems > 0;
            ::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), shouldBeEnabled);
            ::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), shouldBeEnabled);
			break; }
		case STATE_USER: {
			vector<UserCommand> & cshortcuts = nppParam->getUserCommandList();
			for(size_t i = 0; i < nrItems; ++i)
			{
				if (findKeyConflicts(nullptr, cshortcuts[i].getKeyCombo(), i))
					isMarker = _babygrid.setMarker(true);

				_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);
			}
            bool shouldBeEnabled = nrItems > 0;
            ::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), shouldBeEnabled);
            ::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), shouldBeEnabled);
			break; }
		case STATE_PLUGIN: {
			vector<PluginCmdShortcut> & cshortcuts = nppParam->getPluginCommandList();
			for(size_t i = 0; i < nrItems; ++i)
			{
				if (findKeyConflicts(nullptr, cshortcuts[i].getKeyCombo(), i))
					isMarker = _babygrid.setMarker(true);

				_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());
//.........这里部分代码省略.........
开发者ID:A-R-C-A,项目名称:notepad-plus-plus,代码行数:101,代码来源:ShortcutMapper.cpp

示例8: run_dlgProc


//.........这里部分代码省略.........
							//Get PluginCmdShortcut corresponding to index
							vector<PluginCmdShortcut> & shortcuts = nppParam->getPluginCommandList();
							if(shortcuts.empty())
								break;
							PluginCmdShortcut pcsc = shortcuts[index], prevpcsc = shortcuts[index];
							pcsc.init(_hInst, _hSelf);
							pcsc.set_shortcut_info(_currentState,index);
							prevpcsc = pcsc;
							if (pcsc.doDialog() != -1 && prevpcsc != pcsc) {	//shortcut was altered
								nppParam->addPluginModifiedIndex(index);
								generic_string keys=pcsc.toString();
								shortcuts[index] = pcsc;
								ListView_SetItemText(hlistview,selected_row,2,(LPWSTR)keys.c_str());
								update_col_width(keys.c_str(),2);
								//Notify current Accelerator class to update everything
								nppParam->getAccelerator()->updateShortcuts();
								TCHAR str[255];
								if(0<check_in_use(_currentState,index,&pcsc.getKeyCombo(),nppParam,str,sizeof(str)/sizeof(TCHAR)))
									MessageBox(_hSelf,str,L"Duplicates found",MB_OK);

								unsigned long cmdID = pcsc.getID();
								ShortcutKey shortcut;
								shortcut._isAlt = pcsc.getKeyCombo()._isAlt;
								shortcut._isCtrl = pcsc.getKeyCombo()._isCtrl;
								shortcut._isShift = pcsc.getKeyCombo()._isShift;
								shortcut._key = pcsc.getKeyCombo()._key;

								::SendMessage(_hParent, NPPM_INTERNAL_PLUGINSHORTCUTMOTIFIED, cmdID, (LPARAM)&shortcut);
							}
							break; 
						}
						case STATE_SCINTILLA: {
							//Get ScintillaKeyMap corresponding to index
							vector<ScintillaKeyMap> & shortcuts = nppParam->getScintillaKeyList();
							ScintillaKeyMap skm = shortcuts[index], prevskm = shortcuts[index];
							skm.init(_hInst, _hSelf);
							skm.set_shortcut_info(_currentState,index);
							if (skm.doDialog() != -1 && prevskm != skm) 
							{
								//shortcut was altered
								nppParam->addScintillaModifiedIndex(index);
								shortcuts[index] = skm;
								int i,max;
								TCHAR str[40]={0};
								max=skm.getSize();
								for(i=0;i<max;i++){
									generic_string keys=skm.toString(i);
									_sntprintf_s(str,sizeof(str)/sizeof(TCHAR),_TRUNCATE,L"%s%s%c",str,keys.c_str(),i<(max-1)?L';':L'');
								}
								ListView_SetItemText(hlistview,selected_row,2,(LPWSTR)str);
								update_col_width(str,2);
								if(max>0){
									TCHAR str[255];
									KeyCombo skmkc=skm.getKeyComboByIndex(0);
									if(0<check_in_use(_currentState,index,&skmkc,nppParam,str,sizeof(str)/sizeof(TCHAR)))
										MessageBox(_hSelf,str,L"Duplicates found",MB_OK);
								}
								//Notify current Accelerator class to update key
								nppParam->getScintillaAccelerator()->updateKeys();
							}
							break; 
						}
					}
					return TRUE;
				}
				case IDC_SHORTCUT_DELETE :
开发者ID:pinchyCZN,项目名称:notepad,代码行数:67,代码来源:ShortcutMapper.cpp

示例9: disable_selected

int ShortcutMapper::disable_selected(int disable)
{
	int i,count,sel=0;
	NppParameters *nppParam = NppParameters::getInstance();
	count=ListView_GetItemCount(hlistview);
	for(i=0;i<count;i++){
		if(ListView_GetItemState(hlistview,i,LVIS_SELECTED)==LVIS_SELECTED){
			int	index=getitemindex(i);
			switch(_currentState) {
			case STATE_MENU:
				{
					vector<CommandShortcut> & shortcuts = nppParam->getUserShortcuts();
					CommandShortcut csc = shortcuts[index];
					if(disable){
						sel+=csc.Disable();
						shortcuts[index]=csc;
					}
					else
						sel+=csc.isEnabled();
				}
				break;
			case STATE_MACRO:
				{
					vector<MacroShortcut> & shortcuts = nppParam->getMacroList();
					MacroShortcut msc = shortcuts[index];
					if(disable){
						sel+=msc.Disable();
						shortcuts[index]=msc;
					}
					else
						sel+=msc.isEnabled();
				}
				break;
			case STATE_USER:
				{
					vector<UserCommand> & shortcuts = nppParam->getUserCommandList();
					UserCommand ucmd = shortcuts[index];
					if(disable){
						sel+=ucmd.Disable();
						shortcuts[index]=ucmd;
					}
					else
						sel+=ucmd.isEnabled();
				}
				break;
			case STATE_PLUGIN:
				{
					vector<PluginCmdShortcut> & shortcuts = nppParam->getPluginCommandList();
					if(shortcuts.empty())
						break;
					PluginCmdShortcut pcsc = shortcuts[index];
					if(disable){
						sel+=pcsc.Disable();
						shortcuts[index]=pcsc;
					}
					else
						sel+=pcsc.isEnabled();
				}
				break;
			case STATE_SCINTILLA:
				{
					vector<ScintillaKeyMap> & shortcuts = nppParam->getScintillaKeyList();
					ScintillaKeyMap skm = shortcuts[index];
					if(disable){
						int j;
						for(j=skm.getSize()-1;j>=0;j--)
							skm.removeKeyComboByIndex(j);
						skm.Disable();
						sel++;
						shortcuts[index]=skm;
					}
					else
						sel+=skm.isEnabled();
				}
				break;
			}
		}
	}
	return sel;
}
开发者ID:pinchyCZN,项目名称:notepad,代码行数:80,代码来源:ShortcutMapper.cpp

示例10: populateShortCuts

void ShortcutMapper::populateShortCuts()
{
	TCHAR filter1[40]={0},filter2[40]={0};
	NppParameters *nppParam = NppParameters::getInstance();
	size_t nrItems = 0;

	switch(_currentState) {
		case STATE_MENU: {
			nrItems = nppParam->getUserShortcuts().size();
			break; }
		case STATE_MACRO: {
			nrItems = nppParam->getMacroList().size();
			break; }
		case STATE_USER: {
			nrItems = nppParam->getUserCommandList().size();
			break; }
		case STATE_PLUGIN: {
			nrItems = nppParam->getPluginCommandList().size();
			break; }
		case STATE_SCINTILLA: {
			nrItems = nppParam->getScintillaKeyList().size();
			break; }
	}
	ListView_DeleteAllItems(hlistview);

	if(nrItems==0){
        ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), false);
        ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DISABLE), false);
        ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false);
		return;
	}
	else
		::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DISABLE), true);

	switch(_currentState) {
		case STATE_MENU: {
            ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), true);
            ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false);
			break; }
		case STATE_MACRO: {
            bool shouldBeEnabled = nrItems > 0;
            ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), shouldBeEnabled);
            ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), shouldBeEnabled);
			break; }
		case STATE_USER: {
            bool shouldBeEnabled = nrItems > 0;
            ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), shouldBeEnabled);
            ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), shouldBeEnabled);
			break; }
		case STATE_PLUGIN: {
            bool shouldBeEnabled = nrItems > 0;
            ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), shouldBeEnabled);
            ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false);
			break; }
		case STATE_SCINTILLA: {
            ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), true);
            ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false);
			break; }
	}
	int index=0;
	int widths[3];
	widths[0]=gettextwidth(hlistview,L"Index");
	widths[1]=gettextwidth(hlistview,L"Name");
	widths[2]=gettextwidth(hlistview,L"Shortcut");
	GetWindowText(GetDlgItem(_hSelf,IDC_SHORTCUT_FILTER1),filter1,sizeof(filter2)/sizeof(TCHAR));
	GetWindowText(GetDlgItem(_hSelf,IDC_SHORTCUT_FILTER2),filter2,sizeof(filter2)/sizeof(TCHAR));
	_tcslwr(filter1);
	_tcslwr(filter2);

	for(size_t i = 0; i < nrItems; i++) {
		TCHAR keys[40]={0};
		const TCHAR *name=GetShortcutName(_currentState,i,nppParam);
		GetShortcutKeys(_currentState,i,nppParam,keys,sizeof(keys)/sizeof(TCHAR));
		if((filter1[0]==L'\0' && filter2[0]==L'\0') 
			|| (filter1[0]!=L'\0' && CheckFilter(name,filter1))
			|| (filter2[0]!=L'\0' && CheckFilter(keys,filter2))){
			TCHAR str[10]={0};
			LV_ITEM lvitem={0};
			int w;
			_sntprintf_s(str,sizeof(str)/sizeof(TCHAR),_TRUNCATE,L"%i",i);
			w=gettextwidth(hlistview,str);
			if(w>widths[0])
				widths[0]=w;
			w=gettextwidth(hlistview,name);
			if(w>widths[1])
				widths[1]=w;
			w=gettextwidth(hlistview,keys);
			if(w>widths[2])
				widths[2]=w;

			lvitem.mask=LVIF_TEXT|LVIF_PARAM;
			lvitem.iItem=index;
			lvitem.pszText=(LPWSTR)str;
			lvitem.lParam=i;
			ListView_InsertItem(hlistview,&lvitem);
			lvitem.mask=LVIF_TEXT;
			lvitem.iSubItem=1;
			lvitem.pszText=(LPWSTR)name;
			ListView_SetItem(hlistview,&lvitem);
			lvitem.iSubItem=2;
//.........这里部分代码省略.........
开发者ID:pinchyCZN,项目名称:notepad,代码行数:101,代码来源:ShortcutMapper.cpp

示例11: fillOutBabyGrid

void ShortcutMapper::fillOutBabyGrid()
{
	assert(_babygrid);

	NppParameters *nppParam = NppParameters::getInstance();
	_babygrid->clear();

	size_t nrItems = 0;

	switch(_currentState) {
		case STATE_MENU: {
			nrItems = nppParam->getUserShortcuts().size();
			_babygrid->setLineColNumber(nrItems, 2);
			break; }
		case STATE_MACRO: {
			nrItems = nppParam->getMacroList().size();
			_babygrid->setLineColNumber(nrItems, 2);
			break; }
		case STATE_USER: {
			nrItems = nppParam->getUserCommandList().size();
			_babygrid->setLineColNumber(nrItems, 2);
			break; }
		case STATE_PLUGIN: {
			nrItems = nppParam->getPluginCommandList().size();
			_babygrid->setLineColNumber(nrItems, 2);
			break; }
		case STATE_SCINTILLA: {
			nrItems = nppParam->getScintillaKeyList().size();
			_babygrid->setLineColNumber(nrItems, 2);
			break; }
	}

	_babygrid->setText(0, 1, TEXT("Name"));
	_babygrid->setText(0, 2, TEXT("Shortcut"));

	switch(_currentState) {
		case STATE_MENU: {
			std::vector<CommandShortcut> & cshortcuts = nppParam->getUserShortcuts();
			for(size_t i = 0; i < nrItems; i++) {
				_babygrid->setText(i+1, 1, cshortcuts[i].getName());
				_babygrid->setText(i+1, 2, cshortcuts[i].toString().c_str());
			}
			break; }
		case STATE_MACRO: {
			std::vector<MacroShortcut> & cshortcuts = nppParam->getMacroList();
			for(size_t i = 0; i < nrItems; i++) {
				_babygrid->setText(i+1, 1, cshortcuts[i].getName());
				_babygrid->setText(i+1, 2, cshortcuts[i].toString().c_str());
			}
			break; }
		case STATE_USER: {
			std::vector<UserCommand> & cshortcuts = nppParam->getUserCommandList();
			for(size_t i = 0; i < nrItems; i++) {
				_babygrid->setText(i+1, 1, cshortcuts[i].getName());
				_babygrid->setText(i+1, 2, cshortcuts[i].toString().c_str());
			}
			break; }
		case STATE_PLUGIN: {
			std::vector<PluginCmdShortcut> & cshortcuts = nppParam->getPluginCommandList();
			for(size_t i = 0; i < nrItems; i++) {
				_babygrid->setText(i+1, 1, cshortcuts[i].getName());
				_babygrid->setText(i+1, 2, cshortcuts[i].toString().c_str());
			}
			break; }
		case STATE_SCINTILLA: {
			std::vector<ScintillaKeyMap> & cshortcuts = nppParam->getScintillaKeyList();
			for(size_t i = 0; i < nrItems; i++) {
				_babygrid->setText(i+1, 1, cshortcuts[i].getName());
				_babygrid->setText(i+1, 2, cshortcuts[i].toString().c_str());
			}
			break; }
	}
}
开发者ID:TodWulff,项目名称:npp-community,代码行数:73,代码来源:ShortcutMapper.cpp


注:本文中的NppParameters::getScintillaKeyList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。