- java.lang.Object
-
- org.jline.keymap.BindingReader
-
public class BindingReader extends Object
The BindingReader will transform incoming chars into key bindings- Author:
- Guillaume Nodet
-
-
Field Summary
Fields Modifier and Type Field Description protected StringlastBindingprotected StringBuilderopBufferprotected Deque<Integer>pushBackCharprotected NonBlockingReaderreader
-
Constructor Summary
Constructors Constructor Description BindingReader(NonBlockingReader reader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetCurrentBuffer()StringgetLastBinding()intpeekCharacter(long timeout)<T> TreadBinding(KeyMap<T> keys)Read from the input stream and decode an operation from the key map.<T> TreadBinding(KeyMap<T> keys, KeyMap<T> local)<T> TreadBinding(KeyMap<T> keys, KeyMap<T> local, boolean block)intreadCharacter()Read a codepoint from the terminal.intreadCharacterBuffered()StringreadStringUntil(String sequence)voidrunMacro(String macro)
-
-
-
Field Detail
-
reader
protected final NonBlockingReader reader
-
opBuffer
protected final StringBuilder opBuffer
-
lastBinding
protected 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
nullif the end of stream has been reached
-
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(String macro)
-
getCurrentBuffer
public String getCurrentBuffer()
-
getLastBinding
public String getLastBinding()
-
-