Class BindingReader


  • public class BindingReader
    extends java.lang.Object
    The BindingReader will transform incoming chars into key bindings
    Author:
    Guillaume Nodet
    • Field Detail

      • opBuffer

        protected final java.lang.StringBuilder opBuffer
      • pushBackChar

        protected final java.util.Deque<java.lang.Integer> pushBackChar
      • lastBinding

        protected java.lang.String lastBinding
    • Method Detail

      • readBinding

        public <T> T readBinding​(KeyMap<T> keys)
        Read from the input stream and decode an operation from the key map. The input stream will be read character by character until a matching binding can be found. Characters that can't possibly be matched to any binding will be send with the KeyMap.getNomatch() binding. Unicode (>= 128) characters will be matched to KeyMap.getUnicode(). If the current key sequence is ambiguous, i.e. the sequence is bound but it's also a prefix to other sequences, then the KeyMap.getAmbiguousTimeout() timeout will be used to wait for another incoming character. If a character comes, the disambiguation will be done. If the timeout elapses and no character came in, or if the timeout is <= 0, the current bound operation will be returned.
        Type Parameters:
        T - the type of bindings to be read
        Parameters:
        keys - the KeyMap to use for decoding the input stream
        Returns:
        the decoded binding or null if the end of stream has been reached
      • readBinding

        public <T> T readBinding​(KeyMap<T> keys,
                                 KeyMap<T> local)
      • readBinding

        public <T> T readBinding​(KeyMap<T> keys,
                                 KeyMap<T> local,
                                 boolean block)
      • readStringUntil

        public java.lang.String readStringUntil​(java.lang.String sequence)
      • readCharacter

        public int readCharacter()
        Read a codepoint from the terminal.
        Returns:
        the character, or -1 if an EOF is received.
      • readCharacterBuffered

        public int readCharacterBuffered()
      • peekCharacter

        public int peekCharacter​(long timeout)
      • runMacro

        public void runMacro​(java.lang.String macro)
      • getCurrentBuffer

        public java.lang.String getCurrentBuffer()
      • getLastBinding

        public java.lang.String getLastBinding()