public class KeybindingsManager
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private KeyBindings |
characterKeyBindings
The key bindings for the current user.
|
private GUICommandFactory |
guiCommandFactory
The
GUICommandFactory for creating commands. |
private KeyBindings |
keyBindings
The global key bindings.
|
private KeyBindingState |
keyBindingState
The current key binding state.
|
Constructor and Description |
---|
KeybindingsManager(java.io.File keybindingsFile,
GUICommandFactory guiCommandFactory)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
createKeyBinding(boolean perCharacter,
CommandList cmdList)
Starts creating a new key binding.
|
boolean |
escPressed()
Processes a pressed ESC key.
|
java.lang.Iterable<KeyBinding> |
getBindingsForPartialCommand(java.lang.String command,
boolean startOnly)
Searches bindings having a command text starting with the specified
value.
|
private KeyBindings |
getKeyBindings(boolean perCharacter)
Returns the active key bindings.
|
boolean |
handleKeyPress(KeyEvent2 e)
Processes a key pressed event.
|
boolean |
keyPressed(KeyEvent2 keyEvent)
Processes a key pressed event.
|
boolean |
keyReleased()
Processes a key released event.
|
void |
loadKeybindings()
Loads the key bindings from the backing file.
|
void |
loadPerCharacterBindings(java.lang.CharSequence hostname,
java.lang.CharSequence character)
Loads the per-character key bindings.
|
boolean |
removeKeyBinding(boolean perCharacter)
Starts to remove a key binding.
|
void |
saveKeybindings()
Saves the key bindings to the backing file.
|
void |
unloadPerCharacterBindings()
Unloads (clears and saves) the per-character key bindings.
|
boolean |
windowClosing()
Should be called when the main window is closing.
|
@Nullable private KeyBindings characterKeyBindings
null
if no user is
logged in.@NotNull private final GUICommandFactory guiCommandFactory
GUICommandFactory
for creating commands.@NotNull private final KeyBindings keyBindings
@Nullable private KeyBindingState keyBindingState
null
if no key binding
dialog is active.public KeybindingsManager(@NotNull java.io.File keybindingsFile, @NotNull GUICommandFactory guiCommandFactory)
keybindingsFile
- the global keybindings fileguiCommandFactory
- the gui command factory for creating commandspublic boolean createKeyBinding(boolean perCharacter, @NotNull CommandList cmdList)
perCharacter
- whether a per-character key bindings should be
createdcmdList
- the commands for the key bindingpublic boolean escPressed()
public java.lang.Iterable<KeyBinding> getBindingsForPartialCommand(@NotNull java.lang.String command, boolean startOnly)
command
- the text to search forstartOnly
- if true only search the text at the start of the
command, else anywhere.@Nullable private KeyBindings getKeyBindings(boolean perCharacter)
perCharacter
- if set, return the per-character key bindings; else
return the global bindingsnull
if no per-character bindings
exist because no character is logged inpublic boolean handleKeyPress(@NotNull KeyEvent2 e)
e
- the key eventpublic boolean keyPressed(@NotNull KeyEvent2 keyEvent)
keyEvent
- the key eventpublic boolean keyReleased()
public void loadKeybindings()
public void loadPerCharacterBindings(@NotNull java.lang.CharSequence hostname, @NotNull java.lang.CharSequence character)
hostname
- the character's hostnamecharacter
- the character's namepublic boolean removeKeyBinding(boolean perCharacter)
perCharacter
- whether a per-character key binding should be
removedpublic void saveKeybindings()
public void unloadPerCharacterBindings()
public boolean windowClosing()