Class KeybindingsManager


  • public class KeybindingsManager
    extends java.lang.Object
    Manages key bindings.
    • Constructor Summary

      Constructors 
      Constructor Description
      KeybindingsManager​(@NotNull java.nio.file.Path keybindingsFileVersion2, @NotNull java.nio.file.Path keybindingsFileVersion1, @NotNull GUICommandFactory guiCommandFactory)
      Creates a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean createKeyBinding​(boolean perCharacter, @NotNull CommandList cmdList)
      Starts creating a new key binding.
      boolean escPressed()
      Processes a pressed ESC key.
      java.lang.Iterable<KeyBinding> getBindingsForPartialCommand​(@NotNull java.lang.String command, boolean startOnly)
      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 loadKeybindings()
      Loads the 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 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • KeybindingsManager

        public KeybindingsManager​(@NotNull
                                  @NotNull java.nio.file.Path keybindingsFileVersion2,
                                  @NotNull
                                  @NotNull java.nio.file.Path keybindingsFileVersion1,
                                  @NotNull
                                  @NotNull GUICommandFactory guiCommandFactory)
        Creates a new instance.
        Parameters:
        keybindingsFileVersion2 - the global keybindings file
        keybindingsFileVersion1 - the global fallback keybindings file
        guiCommandFactory - the gui command factory for creating commands
    • Method Detail

      • removeKeyBinding

        public boolean removeKeyBinding​(boolean perCharacter)
        Starts to remove a key binding.
        Parameters:
        perCharacter - whether a per-character key binding should be removed
        Returns:
        whether the key bindings dialog should be opened
      • windowClosing

        public boolean windowClosing()
        Should be called when the main window is closing.
        Returns:
        whether the key bindings dialog should be closed
      • createKeyBinding

        public boolean createKeyBinding​(boolean perCharacter,
                                        @NotNull
                                        @NotNull CommandList cmdList)
        Starts creating a new key binding.
        Parameters:
        perCharacter - whether a per-character key bindings should be created
        cmdList - the commands for the key binding
        Returns:
        whether the key bindings dialog should be opened
      • loadPerCharacterBindings

        public void loadPerCharacterBindings​(@NotNull
                                             @NotNull java.lang.CharSequence hostname,
                                             @NotNull
                                             @NotNull java.lang.CharSequence character)
        Loads the per-character key bindings. This function should be called when a character logs in.
        Parameters:
        hostname - the character's hostname
        character - the character's name
      • unloadPerCharacterBindings

        public void unloadPerCharacterBindings()
        Unloads (clears and saves) the per-character key bindings. This function should be called when a character logs out.
      • saveKeybindings

        public void saveKeybindings()
        Saves the key bindings to the backing file.
      • loadKeybindings

        public void loadKeybindings()
        Loads the key bindings from the backing file.
      • keyReleased

        public boolean keyReleased()
        Processes a key released event.
        Returns:
        whether the event has been consumed
      • keyPressed

        public boolean keyPressed​(@NotNull
                                  @NotNull KeyEvent2 keyEvent)
        Processes a key pressed event.
        Parameters:
        keyEvent - the key event
        Returns:
        whether the event has been consumed
      • escPressed

        public boolean escPressed()
        Processes a pressed ESC key.
        Returns:
        whether the event has been consumed and the key bindings dialog should be closed
      • handleKeyPress

        public boolean handleKeyPress​(@NotNull
                                      @NotNull KeyEvent2 e)
        Processes a key pressed event.
        Parameters:
        e - the key event
        Returns:
        whether the event has been consumed
      • getBindingsForPartialCommand

        public java.lang.Iterable<KeyBinding> getBindingsForPartialCommand​(@NotNull
                                                                           @NotNull java.lang.String command,
                                                                           boolean startOnly)
        Searches bindings having a command text starting with the specified value.
        Parameters:
        command - the text to search for
        startOnly - if true only search the text at the start of the command, else anywhere.
        Returns:
        the matching bindings