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


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

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


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

示例1: updateFullMenu

void Accelerator::updateFullMenu()
{
	NppParameters * pNppParam = NppParameters::getInstance();
	vector<CommandShortcut> commands = pNppParam->getUserShortcuts();
	for(size_t i = 0; i < commands.size(); ++i)
	{
		updateMenuItemByCommand(commands[i]);
	}

	vector<MacroShortcut> mcommands = pNppParam->getMacroList();
	for(size_t i = 0; i < mcommands.size(); ++i)
	{
		updateMenuItemByCommand(mcommands[i]);
	}

	vector<UserCommand> ucommands = pNppParam->getUserCommandList();
	for(size_t i = 0; i < ucommands.size(); ++i)
	{
		updateMenuItemByCommand(ucommands[i]);
	}

	vector<PluginCmdShortcut> pcommands = pNppParam->getPluginCommandList();
	for(size_t i = 0; i < pcommands.size(); ++i)
	{
		updateMenuItemByCommand(pcommands[i]);
	}

	::DrawMenuBar(_hMenuParent);
}
开发者ID:ZhuZhengyi,项目名称:Notepadplusplus,代码行数:29,代码来源:shortcut.cpp

示例2: updateShortcuts

// return true if one of CommandShortcuts is deleted. Otherwise false.
void Accelerator::updateShortcuts() 
{
	vector<int> IFAccIds;
	IFAccIds.push_back(IDM_SEARCH_FINDNEXT);
	IFAccIds.push_back(IDM_SEARCH_FINDPREV);
	IFAccIds.push_back(IDM_SEARCH_FINDINCREMENT);

	NppParameters *pNppParam = NppParameters::getInstance();

	vector<CommandShortcut> & shortcuts = pNppParam->getUserShortcuts();
	vector<MacroShortcut> & macros  = pNppParam->getMacroList();
	vector<UserCommand> & userCommands = pNppParam->getUserCommandList();
	vector<PluginCmdShortcut> & pluginCommands = pNppParam->getPluginCommandList();

	size_t nbMenu = shortcuts.size();
	size_t nbMacro = macros.size();
	size_t nbUserCmd = userCommands.size();
	size_t nbPluginCmd = pluginCommands.size();

	if (_pAccelArray)
		delete [] _pAccelArray;
	_pAccelArray = new ACCEL[nbMenu+nbMacro+nbUserCmd+nbPluginCmd];
	vector<ACCEL> IFAcc;

	int offset = 0;
	size_t i = 0;
	//no validation performed, it might be that invalid shortcuts are being used by default. Allows user to 'hack', might be a good thing
	for(i = 0; i < nbMenu; ++i)
	{
		if (shortcuts[i].isEnabled())
		{
			_pAccelArray[offset].cmd = (WORD)(shortcuts[i].getID());
			_pAccelArray[offset].fVirt = shortcuts[i].getAcceleratorModifiers();
			_pAccelArray[offset].key = shortcuts[i].getKeyCombo()._key;

			// Special extra handling for shortcuts shared by Incremental Find dialog
			if (std::find(IFAccIds.begin(), IFAccIds.end(), shortcuts[i].getID()) != IFAccIds.end())
				IFAcc.push_back(_pAccelArray[offset]);

			++offset;
		}
	}

	for(i = 0; i < nbMacro; ++i)
	{
		if (macros[i].isEnabled()) 
		{
			_pAccelArray[offset].cmd = (WORD)(macros[i].getID());
			_pAccelArray[offset].fVirt = macros[i].getAcceleratorModifiers();
			_pAccelArray[offset].key = macros[i].getKeyCombo()._key;
			++offset;
		}
	}

	for(i = 0; i < nbUserCmd; ++i)
	{
		if (userCommands[i].isEnabled())
		{
			_pAccelArray[offset].cmd = (WORD)(userCommands[i].getID());
			_pAccelArray[offset].fVirt = userCommands[i].getAcceleratorModifiers();
			_pAccelArray[offset].key = userCommands[i].getKeyCombo()._key;
			++offset;
		}
	}

	for(i = 0; i < nbPluginCmd; ++i)
	{
		if (pluginCommands[i].isEnabled())
		{
			_pAccelArray[offset].cmd = (WORD)(pluginCommands[i].getID());
			_pAccelArray[offset].fVirt = pluginCommands[i].getAcceleratorModifiers();
			_pAccelArray[offset].key = pluginCommands[i].getKeyCombo()._key;
			++offset;
		}
	}

	_nbAccelItems = offset;

	updateFullMenu();
	
	//update the table
	if (_hAccTable)
		::DestroyAcceleratorTable(_hAccTable);
	_hAccTable = ::CreateAcceleratorTable(_pAccelArray, _nbAccelItems);

	if (_hIncFindAccTab)
		::DestroyAcceleratorTable(_hIncFindAccTab);

	size_t nb = IFAcc.size();
	ACCEL *tmpAccelArray = new ACCEL[nb];
	for (i = 0; i < nb; ++i)
	{
		tmpAccelArray[i] = IFAcc[i];
	}
	_hIncFindAccTab = ::CreateAcceleratorTable(tmpAccelArray, static_cast<int32_t>(nb));
	delete [] tmpAccelArray;

	return;
}
开发者ID:AndychenCL,项目名称:notepad-plus-plus,代码行数:100,代码来源:shortcut.cpp

示例3: 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

示例4: run_dlgProc

BOOL CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message) 
	{
		case WM_INITDIALOG :
		{
			initBabyGrid();
			initTabs();
			fillOutBabyGrid();
			_babygrid.display();	
			goToCenter();
			return TRUE;
		}

		case WM_NOTIFY: {
			NMHDR nmh = *((NMHDR*)lParam);
			if (nmh.hwndFrom == _hTabCtrl) {
				if (nmh.code == TCN_SELCHANGE) {
					int index = TabCtrl_GetCurSel(_hTabCtrl);
					switch (index) {
						case 0:
							_currentState = STATE_MENU;
							break;
						case 1:
							_currentState = STATE_MACRO;
							break;
						case 2:
							_currentState = STATE_USER;
							break;
						case 3:
							_currentState = STATE_PLUGIN;
							break;
						case 4:
							_currentState = STATE_SCINTILLA;
							break;
					}
					fillOutBabyGrid();
				}
			}
			break; }

		case WM_COMMAND : 
		{
			switch (LOWORD(wParam))
			{
				case IDCANCEL :
				{
					::EndDialog(_hSelf, -1);
					return TRUE;
				}
				case IDOK :
				{
					::EndDialog(_hSelf, 0);
					return TRUE;
				}

				case IDM_BABYGRID_MODIFY :
				{
					NppParameters *nppParam = NppParameters::getInstance();
					int row = _babygrid.getSelectedRow();

					switch(_currentState) {
						case STATE_MENU: {
							//Get CommandShortcut corresponding to row
							vector<CommandShortcut> & shortcuts = nppParam->getUserShortcuts();
							CommandShortcut csc = shortcuts[row - 1], prevcsc = shortcuts[row - 1];
							csc.init(_hInst, _hSelf);
							if (csc.doDialog() != -1 && prevcsc != csc) {	//shortcut was altered
								nppParam->addUserModifiedIndex(row-1);
								shortcuts[row - 1] = csc;
								_babygrid.setText(row, 2, csc.toString().c_str());
								//Notify current Accelerator class to update everything
								nppParam->getAccelerator()->updateShortcuts();
								
							}
							break; }
						case STATE_MACRO: {
							//Get MacroShortcut corresponding to row
							vector<MacroShortcut> & shortcuts = nppParam->getMacroList();
							MacroShortcut msc = shortcuts[row - 1], prevmsc = shortcuts[row - 1];
							msc.init(_hInst, _hSelf);
							if (msc.doDialog() != -1 && prevmsc != msc) {	//shortcut was altered
								shortcuts[row - 1] = msc;
								_babygrid.setText(row, 1, msc.getName());
								_babygrid.setText(row, 2, msc.toString().c_str());

								//Notify current Accelerator class to update everything
								nppParam->getAccelerator()->updateShortcuts();
								
							}
							break; }
						case STATE_USER: {
							//Get UserCommand corresponding to row
							vector<UserCommand> & shortcuts = nppParam->getUserCommandList();
							UserCommand ucmd = shortcuts[row - 1], prevucmd = shortcuts[row - 1];
							ucmd.init(_hInst, _hSelf);
							prevucmd = ucmd;
							if (ucmd.doDialog() != -1 && prevucmd != ucmd) {	//shortcut was altered
								shortcuts[row - 1] = ucmd;
								_babygrid.setText(row, 1, ucmd.getName());
//.........这里部分代码省略.........
开发者ID:JSansalone,项目名称:Notepadpp-5.9,代码行数:101,代码来源:ShortcutMapper.cpp

示例5: findKeyConflicts

bool ShortcutMapper::findKeyConflicts(__inout_opt generic_string * const keyConflictLocation,
										const KeyCombo & itemKeyComboToTest, const size_t & itemIndexToTest) const
{
	if (itemKeyComboToTest._key == NULL) //no key assignment
		return false;

	bool retIsConflict = false; //returns true when a conflict is found
	NppParameters * nppParam = NppParameters::getInstance();

	for (size_t gridState = STATE_MENU; gridState <= STATE_SCINTILLA; ++gridState)
	{
		switch (gridState)
		{
			case STATE_MENU:
			{
				vector<CommandShortcut> & vShortcuts = nppParam->getUserShortcuts();
				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_MENU
			case STATE_MACRO:
			{
				vector<MacroShortcut> & vShortcuts = nppParam->getMacroList();
				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_MACRO
			case STATE_USER:
			{
				vector<UserCommand> & vShortcuts = nppParam->getUserCommandList();
				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
						{
//.........这里部分代码省略.........
开发者ID:A-R-C-A,项目名称:notepad-plus-plus,代码行数:101,代码来源:ShortcutMapper.cpp

示例6: run_dlgProc


//.........这里部分代码省略.........
								nppParam->setShortcutDirty();
							}
							break;
						}

						case STATE_MACRO: 
						{
							//Get MacroShortcut corresponding to row
							vector<MacroShortcut> & shortcuts = nppParam->getMacroList();
							MacroShortcut msc = shortcuts[row - 1], prevmsc = shortcuts[row - 1];
							msc.init(_hInst, _hSelf);
							if (msc.doDialog() != -1 && prevmsc != msc)
							{
								//shortcut was altered
								shortcuts[row - 1] = msc;

								//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();
								nppParam->setShortcutDirty();
							}
							break; 
						}

						case STATE_USER: 
						{
							//Get UserCommand corresponding to row
							vector<UserCommand> & shortcuts = nppParam->getUserCommandList();
							UserCommand ucmd = shortcuts[row - 1];
							ucmd.init(_hInst, _hSelf);
							UserCommand prevucmd = ucmd;
							if (ucmd.doDialog() != -1 && prevucmd != ucmd)
							{	
								//shortcut was altered
								shortcuts[row - 1] = ucmd;

								//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();
								nppParam->setShortcutDirty();
							}
							break; 
						}

						case STATE_PLUGIN:
						{
							//Get PluginCmdShortcut corresponding to row
							vector<PluginCmdShortcut> & shortcuts = nppParam->getPluginCommandList();
							PluginCmdShortcut pcsc = shortcuts[row - 1];
							pcsc.init(_hInst, _hSelf);
							PluginCmdShortcut prevpcsc = pcsc;
							if (pcsc.doDialog() != -1 && prevpcsc != pcsc)
							{
								//shortcut was altered
开发者ID:A-R-C-A,项目名称:notepad-plus-plus,代码行数:67,代码来源: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: updateShortcuts

// return true if one of CommandShortcuts is deleted. Otherwise false.
void Accelerator::updateShortcuts() 
{
	NppParameters *pNppParam = NppParameters::getInstance();

	vector<CommandShortcut> & shortcuts = pNppParam->getUserShortcuts();
	vector<MacroShortcut> & macros  = pNppParam->getMacroList();
	vector<UserCommand> & userCommands = pNppParam->getUserCommandList();
	vector<PluginCmdShortcut> & pluginCommands = pNppParam->getPluginCommandList();

	size_t nbMenu = shortcuts.size();
	size_t nbMacro = macros.size();
	size_t nbUserCmd = userCommands.size();
	size_t nbPluginCmd = pluginCommands.size();

	if (_pAccelArray)
		delete [] _pAccelArray;
	_pAccelArray = new ACCEL[nbMenu+nbMacro+nbUserCmd+nbPluginCmd];

	int offset = 0;
	size_t i = 0;
	//no validation performed, it might be that invalid shortcuts are being used by default. Allows user to 'hack', might be a good thing
	for(i = 0; i < nbMenu; i++) {
		if (shortcuts[i].isEnabled()) {// && shortcuts[i].isValid()) {
			_pAccelArray[offset].cmd = (WORD)(shortcuts[i].getID());
			_pAccelArray[offset].fVirt = shortcuts[i].getAcceleratorModifiers();
			_pAccelArray[offset].key = shortcuts[i].getKeyCombo()._key;
			offset++;
		}
	}

	for(i = 0; i < nbMacro; i++) {
		if (macros[i].isEnabled()) {// && macros[i].isValid()) {
			_pAccelArray[offset].cmd = (WORD)(macros[i].getID());
			_pAccelArray[offset].fVirt = macros[i].getAcceleratorModifiers();
			_pAccelArray[offset].key = macros[i].getKeyCombo()._key;
			offset++;
		}
	}

	for(i = 0; i < nbUserCmd; i++) {
		if (userCommands[i].isEnabled()) {// && userCommands[i].isValid()) {
			_pAccelArray[offset].cmd = (WORD)(userCommands[i].getID());
			_pAccelArray[offset].fVirt = userCommands[i].getAcceleratorModifiers();
			_pAccelArray[offset].key = userCommands[i].getKeyCombo()._key;
			offset++;
		}
	}

	for(i = 0; i < nbPluginCmd; i++) {
		if (pluginCommands[i].isEnabled()) {// && pluginCommands[i].isValid()) {
			_pAccelArray[offset].cmd = (WORD)(pluginCommands[i].getID());
			_pAccelArray[offset].fVirt = pluginCommands[i].getAcceleratorModifiers();
			_pAccelArray[offset].key = pluginCommands[i].getKeyCombo()._key;
			offset++;
		}
	}

	_nbAccelItems = offset;

	updateFullMenu();
	reNew();	//update the table
	return;
}
开发者ID:Tanjas5,项目名称:npp,代码行数:64,代码来源:shortcut.cpp

示例9: run_dlgProc


//.........这里部分代码省略.........
								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,&csc.getKeyCombo(),nppParam,str,sizeof(str)/sizeof(TCHAR)))
									MessageBox(_hSelf,str,L"Duplicates found",MB_OK);
							}
							break; 
						}
						case STATE_MACRO: {
							//Get MacroShortcut corresponding to index
							vector<MacroShortcut> & shortcuts = nppParam->getMacroList();
							MacroShortcut msc = shortcuts[index], prevmsc = shortcuts[index];
							msc.init(_hInst, _hSelf);
							msc.set_shortcut_info(_currentState,index);
							if (msc.doDialog() != -1 && prevmsc != msc) {	//shortcut was altered
								generic_string name=msc.getName();
								generic_string keys=msc.toString();
								shortcuts[index] = msc;
								ListView_SetItemText(hlistview,selected_row,1,(LPWSTR)name.c_str());
								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,&msc.getKeyCombo(),nppParam,str,sizeof(str)/sizeof(TCHAR)))
									MessageBox(_hSelf,str,L"Duplicates found",MB_OK);
							}
							break; 
						}
						case STATE_USER: {
							//Get UserCommand corresponding to index
							vector<UserCommand> & shortcuts = nppParam->getUserCommandList();
							UserCommand ucmd = shortcuts[index], prevucmd = shortcuts[index];
							ucmd.init(_hInst, _hSelf);
							ucmd.set_shortcut_info(_currentState,index);
							prevucmd = ucmd;
							if (ucmd.doDialog() != -1 && prevucmd != ucmd) {	//shortcut was altered
								generic_string name=ucmd.getName();
								generic_string keys=ucmd.toString();
								shortcuts[index] = ucmd;
								ListView_SetItemText(hlistview,selected_row,1,(LPWSTR)name.c_str());
								ListView_SetItemText(hlistview,selected_row,2,(LPWSTR)keys.c_str());
								update_col_width(name.c_str(),1);
								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,&ucmd.getKeyCombo(),nppParam,str,sizeof(str)/sizeof(TCHAR)))
									MessageBox(_hSelf,str,L"Duplicates found",MB_OK);
							}
							break; 
						}
						case STATE_PLUGIN: {
							//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();
开发者ID:pinchyCZN,项目名称:notepad,代码行数:67,代码来源:ShortcutMapper.cpp

示例10: 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

示例11: 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

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