22 package com.realtime.crossfire.jxclient.gui.keybindings;
28 import java.io.IOException;
29 import java.util.Collection;
30 import java.util.HashSet;
31 import org.jetbrains.annotations.NotNull;
32 import org.jetbrains.annotations.Nullable;
73 keyBindings =
new KeyBindings(keybindingsFile, guiCommandFactory);
83 if (perCharacter && characterKeyBindings == null) {
87 keyBindingState =
new KeyBindingState(characterKeyBindings, perCharacter ? null : keyBindings, null);
96 if (keyBindingState == null) {
100 keyBindingState = null;
113 if (bindings == null) {
142 }
catch (
final IOException ex) {
143 characterKeyBindings = null;
144 System.err.println(
"Cannot read keybindings file for "+character+
" on "+hostname+
": "+ex.getMessage());
150 }
catch (
final IOException ex) {
151 assert characterKeyBindings != null;
152 System.err.println(
"Cannot read keybindings file "+characterKeyBindings.
getFile()+
": "+ex.getMessage());
161 if (characterKeyBindings != null) {
164 }
catch (
final IOException ex) {
165 assert characterKeyBindings != null;
166 System.err.println(
"Cannot write keybindings file "+characterKeyBindings.
getFile()+
": "+ex.getMessage());
168 characterKeyBindings = null;
178 }
catch (
final IOException ex) {
179 System.err.println(
"Cannot write keybindings file "+keyBindings.
getFile()+
": "+ex.getMessage());
191 }
catch (
final IOException ex) {
192 System.err.println(
"Cannot read keybindings file "+keyBindings.
getFile()+
": "+ex.getMessage());
203 if (keyBindingState == null) {
211 keyBindingState = null;
221 if (keyBindingState == null) {
235 if (keyBindingState == null) {
239 keyBindingState = null;
250 if (characterKeyBindings != null && characterKeyBindings.
handleKeyPress(e)) {
266 final Collection<KeyBinding> matches =
new HashSet<>();
272 if (characterKeyBindings != null) {
277 boolean used =
false;
279 if (check.equals(candidate)) {
285 matches.add(candidate);
KeyBindings characterKeyBindings
The key bindings for the current user.
KeyBindings getKeyBindings(final boolean perCharacter)
Returns the active key bindings.
Iterable< KeyBinding > getBindingsForPartialCommand(@NotNull final String command, final boolean startOnly)
Searches bindings having a command text starting with the specified value.
Utility class to return references to settings files.
boolean removeKeyBinding(final boolean perCharacter)
Starts to remove a key binding.
final KeyBindings keyBindings
The global key bindings.
void keyPressed(@NotNull final KeyEvent2 keyEvent)
Records a binding by key code.
boolean windowClosing()
Should be called when the main window is closing.
boolean keyReleased()
Records a key released event.
boolean createKeyBinding(final boolean perCharacter, @NotNull final CommandList cmdList)
Starts creating a new key binding.
Represents a pressed or released key.
boolean handleKeyPress(@NotNull final KeyEvent2 e)
Processes a key pressed event.
KeybindingsManager(@NotNull final File keybindingsFile, @NotNull final GUICommandFactory guiCommandFactory)
Creates a new instance.
void saveKeyBindings()
Saves the key bindings to the given file.
void loadKeybindings()
Loads the key bindings from the backing file.
final GUICommandFactory guiCommandFactory
The GUICommandFactory for creating commands.
static File getKeybindingsFile(@Nullable final CharSequence hostname, @Nullable final CharSequence character)
Returns the keybindings file.
Manages the state for the key binding dialog.
void saveKeybindings()
Saves the key bindings to the backing file.
boolean keyReleased()
Processes a key released event.
Factory for creating GUICommand instances from string representation.
Collection< KeyBinding > getBindingsForPartialCommand(@NotNull final String command, final boolean startOnly)
Search bindings having a command text starting with the specified value.
KeyBindingState keyBindingState
The current key binding state.
boolean escPressed()
Processes a pressed ESC key.
void loadKeyBindings()
Loads the key bindings from the given file.
Abstract base class for key bindings.
void unloadPerCharacterBindings()
Unloads (clears and saves) the per-character key bindings.
boolean keyPressed(@NotNull final KeyEvent2 keyEvent)
Processes a key pressed event.
A list of GUICommand instances.
File getFile()
Returns the file for saving the bindings;.
Manages a set of key bindings.
boolean handleKeyPress(@NotNull final KeyEvent2 e)
Executes a "key press" event.
void loadPerCharacterBindings(@NotNull final CharSequence hostname, @NotNull final CharSequence character)
Loads the per-character key bindings.