* Remove bindings for an action.
*
* @param console the console whose bindings are to be changed
*/
private void removeBindings(TextConsole console) {
ConsoleKeyEventBindings bindings = console.getKeyEventBindings();
// This throws an unchecked exception if the action is not supplied. It signals
// a bug in the command syntax and should be allowed to propagate to the shell.
KeyboardReaderAction action = argAction.getValue();
if (argVkSpec.isSet() || argCharacter.isSet()) {
// If virtual key names were supplied, remove only those bindings.
if (argVkSpec.isSet()) {
for (VirtualKey vk : argVkSpec.getValues()) {
bindings.unsetVKAction(vk);
}
}
if (argCharacter.isSet()) {
for (char ch : argCharacter.getValues()) {
bindings.unsetCharAction(ch);
}
}
} else {
// Otherwise remove all bindings for the action.
int count = 0;
List<Character> chars = buildCharMap(bindings).get(action);
if (chars != null) {
for (char ch : chars) {
bindings.unsetCharAction(ch);
count++;
}
}
List<VirtualKey> vks = buildVKMap(bindings).get(action);
if (vks != null) {
for (VirtualKey vk : vks) {
bindings.unsetVKAction(vk);
count++;
}
}
if (count == 0) {
err.format(err_no_bind, action);