public class KeybindingsManager
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static @NotNull java.lang.String |
CHARACTER
The source identification string for per-character key bindings.
|
static @NotNull java.lang.String |
DEFAULT
The source identification string for default key bindings.
|
static @NotNull java.lang.String |
GLOBAL
The source identification string for global key bindings.
|
Constructor and Description |
---|
KeybindingsManager(@NotNull java.nio.file.Path keybindingsFileVersion2,
@NotNull java.nio.file.Path keybindingsFileVersion1,
@NotNull GUICommandFactory guiCommandFactory)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
createKeyBinding(boolean perCharacter,
@NotNull CommandList cmdList)
Starts creating a new key binding.
|
boolean |
escPressed()
Processes a pressed ESC key.
|
@NotNull java.util.Map<KeyBinding,java.lang.String> |
getBindings(@NotNull java.util.function.Predicate<KeyBinding> predicate)
Searches bindings having a command text starting with the specified
value.
|
boolean |
handleKeyPress(@NotNull KeyEvent2 e)
Processes a key pressed event.
|
boolean |
keyPressed(@NotNull KeyEvent2 keyEvent)
Processes a key pressed event.
|
boolean |
keyReleased()
Processes a key released event.
|
void |
loadGlobalKeybindings()
Loads the global key bindings from the backing file.
|
void |
loadPerCharacterBindings(@NotNull java.lang.CharSequence hostname,
@NotNull java.lang.CharSequence character)
Loads the per-character key bindings.
|
boolean |
removeKeyBinding(boolean perCharacter)
Starts to remove a key binding.
|
void |
saveGlobalKeybindings()
Saves the global key bindings to the backing file.
|
void |
setDefaultKeyBindings(@NotNull KeyBindings defaultKeyBindings)
Sets the default
KeyBindings of the currently active skin. |
void |
unloadPerCharacterBindings()
Unloads (clears and saves) the per-character key bindings.
|
boolean |
windowClosing()
Should be called when the main window is closing.
|
@NotNull public static final @NotNull java.lang.String DEFAULT
@NotNull public static final @NotNull java.lang.String GLOBAL
@NotNull public static final @NotNull java.lang.String CHARACTER
public KeybindingsManager(@NotNull @NotNull java.nio.file.Path keybindingsFileVersion2, @NotNull @NotNull java.nio.file.Path keybindingsFileVersion1, @NotNull @NotNull GUICommandFactory guiCommandFactory)
keybindingsFileVersion2
- the global keybindings filekeybindingsFileVersion1
- the global fallback keybindings fileguiCommandFactory
- the gui command factory for creating commandspublic void setDefaultKeyBindings(@NotNull @NotNull KeyBindings defaultKeyBindings)
KeyBindings
of the currently active skin.defaultKeyBindings
- the default key bindingspublic boolean removeKeyBinding(boolean perCharacter)
perCharacter
- whether a per-character key binding should be
removedpublic boolean windowClosing()
public boolean createKeyBinding(boolean perCharacter, @NotNull @NotNull CommandList cmdList)
perCharacter
- whether a per-character key bindings should be
createdcmdList
- the commands for the key bindingpublic void loadPerCharacterBindings(@NotNull @NotNull java.lang.CharSequence hostname, @NotNull @NotNull java.lang.CharSequence character)
hostname
- the character's hostnamecharacter
- the character's namepublic void unloadPerCharacterBindings()
public void saveGlobalKeybindings()
public void loadGlobalKeybindings()
public boolean keyReleased()
public boolean keyPressed(@NotNull @NotNull KeyEvent2 keyEvent)
keyEvent
- the key eventpublic boolean escPressed()
public boolean handleKeyPress(@NotNull @NotNull KeyEvent2 e)
e
- the key event@NotNull public @NotNull java.util.Map<KeyBinding,java.lang.String> getBindings(@NotNull @NotNull java.util.function.Predicate<KeyBinding> predicate)
predicate
- the predicate for selecting keybindings