 |
Crossfire JXClient, Trunk
|
Go to the documentation of this file.
23 package com.realtime.crossfire.jxclient.gui.keybindings;
28 import java.io.IOException;
29 import java.nio.file.Path;
31 import java.util.TreeMap;
32 import java.util.function.Predicate;
33 import org.jetbrains.annotations.NotNull;
34 import org.jetbrains.annotations.Nullable;
52 public static final String
GLOBAL =
"g";
149 if (bindings ==
null) {
178 }
catch (
final IOException ex) {
180 System.err.println(
"Cannot read keybindings file for "+character+
" on "+hostname+
": "+ex.getMessage());
287 public Map<KeyBinding, String>
getBindings(@NotNull
final Predicate<KeyBinding> predicate) {
288 final Map<KeyBinding, String> matches =
new TreeMap<>();
300 boolean used =
false;
302 if (check.equals(candidate)) {
308 matches.put(candidate,
GLOBAL);
313 boolean used =
false;
315 if (check.equals(candidate)) {
321 matches.put(candidate,
DEFAULT);
KeyBindingState keyBindingState
The current key binding state.
KeyBindings defaultKeyBindings
The default KeyBindings of the currently active skin.
static Path getKeybindingsFileVersion2(@Nullable final CharSequence hostname, @Nullable final CharSequence character)
Returns the keybindings file.
final KeyBindings globalKeyBindings
The global key bindings.
KeyBindings getKeyBindings(final boolean perCharacter)
Returns the active key bindings.
boolean keyReleased()
Processes a key released event.
final GUICommandFactory guiCommandFactory
The GUICommandFactory for creating commands.
void setDefaultKeyBindings(@NotNull final KeyBindings defaultKeyBindings)
Sets the default KeyBindings of the currently active skin.
KeybindingsManager(@NotNull final Path keybindingsFileVersion2, @NotNull final Path keybindingsFileVersion1, @NotNull final GUICommandFactory guiCommandFactory)
Creates a new instance.
Represents a pressed or released key.
static final String DEFAULT
The source identification string for default key bindings.
Manages a set of key bindings.
static final String GLOBAL
The source identification string for global key bindings.
Abstract base class for key bindings.
boolean keyPressed(@NotNull final KeyEvent2 keyEvent)
Processes a key pressed event.
boolean handleKeyPress(@NotNull final KeyEvent2 e)
Executes a "key press" event.
Utility class to return references to settings files.
Map< KeyBinding, String > getBindings(@NotNull final Predicate< KeyBinding > predicate)
Searches bindings having a command text starting with the specified value.
boolean handleKeyPress(@NotNull final KeyEvent2 e)
Processes a key pressed event.
boolean removeKeyBinding(final boolean perCharacter)
Starts to remove a key binding.
boolean windowClosing()
Should be called when the main window is closing.
KeyBindings characterKeyBindings
The key bindings for the current user.
boolean createKeyBinding(final boolean perCharacter, @NotNull final CommandList cmdList)
Starts creating a new key binding.
A list of GUICommand instances.
static final String CHARACTER
The source identification string for per-character key bindings.
void keyPressed(@NotNull final KeyEvent2 keyEvent)
Records a binding by key code.
boolean keyReleased()
Records a key released event.
void saveGlobalKeybindings()
Saves the global key bindings to the backing file.
void unloadPerCharacterBindings()
Unloads (clears and saves) the per-character key bindings.
void loadKeyBindings()
Loads the key bindings from the given file.
boolean escPressed()
Processes a pressed ESC key.
static Path getKeybindingsFileVersion1(@Nullable final CharSequence hostname, @Nullable final CharSequence character)
Returns the fallback keybindings file.
Manages the state for the key binding dialog.
void loadPerCharacterBindings(@NotNull final CharSequence hostname, @NotNull final CharSequence character)
Loads the per-character key bindings.
void saveKeyBindings()
Saves the key bindings to the given file.
Factory for creating GUICommand instances from string representation.
Collection< KeyBinding > getBindings(@NotNull final Predicate< KeyBinding > predicate)
Returns all key bindings matching a given predicate.
void loadGlobalKeybindings()
Loads the global key bindings from the backing file.