示例#1
0
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;
}