Package org.jline.keymap
Class BindingReader
- java.lang.Object
-
- org.jline.keymap.BindingReader
-
public class BindingReader extends java.lang.Object
The BindingReader will transform incoming chars into key bindings- Author:
- Guillaume Nodet
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
lastBinding
protected java.lang.StringBuilder
opBuffer
protected java.util.Deque<java.lang.Integer>
pushBackChar
protected NonBlockingReader
reader
-
Constructor Summary
Constructors Constructor Description BindingReader(NonBlockingReader reader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getCurrentBuffer()
java.lang.String
getLastBinding()
int
peekCharacter(long timeout)
<T> T
readBinding(KeyMap<T> keys)
Read from the input stream and decode an operation from the key map.<T> T
readBinding(KeyMap<T> keys, KeyMap<T> local)
<T> T
readBinding(KeyMap<T> keys, KeyMap<T> local, boolean block)
int
readCharacter()
Read a codepoint from the terminal.int
readCharacterBuffered()
java.lang.String
readStringUntil(java.lang.String sequence)
void
runMacro(java.lang.String macro)
-
-
-
Field Detail
-
reader
protected final NonBlockingReader reader
-
opBuffer
protected final java.lang.StringBuilder opBuffer
-
pushBackChar
protected final java.util.Deque<java.lang.Integer> pushBackChar
-
lastBinding
protected java.lang.String lastBinding
-
-
Constructor Detail
-
BindingReader
public BindingReader(NonBlockingReader reader)
-
-
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 theKeyMap.getNomatch()
binding. Unicode (>= 128) characters will be matched toKeyMap.getUnicode()
. If the current key sequence is ambiguous, i.e. the sequence is bound but it's also a prefix to other sequences, then theKeyMap.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
-
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()
-
-