Class InputDecoder
java.lang.Object
com.googlecode.lanterna.input.InputDecoder
Used to read the input stream character by character and generate
Key objects to be put in the input queue.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<CharacterPattern> private booleanprivate final Readerprivate int -
Constructor Summary
ConstructorsConstructorDescriptionInputDecoder(Reader source) Creates a new input decoder using a specified Reader as the source to read characters from -
Method Summary
Modifier and TypeMethodDescriptionvoidaddProfile(KeyDecodingProfile profile) Adds another key decoding profile to this InputDecoder, which means all patterns from the profile will be used when decoding input.private CharacterPattern.MatchinggetBestMatch(List<Character> characterSequence) getNextCharacter(boolean blockingIO) Reads and decodes the next key stroke from the input streamReturns a collection of all patterns registered in this InputDecoder.intqueries the current timeoutUnits value.booleanremovePattern(CharacterPattern pattern) Removes one pattern from the list of patterns in this InputDecodervoidsetTimeoutUnits(int units) Sets the number of 1/4-second units for how long to try to get further input to complete an escape-sequence for a special Key.
-
Field Details
-
source
-
bytePatterns
-
currentMatching
-
seenEOF
private boolean seenEOF -
timeoutUnits
private int timeoutUnits
-
-
Constructor Details
-
InputDecoder
Creates a new input decoder using a specified Reader as the source to read characters from- Parameters:
source- Reader to read characters from, will be wrapped by a BufferedReader
-
-
Method Details
-
addProfile
Adds another key decoding profile to this InputDecoder, which means all patterns from the profile will be used when decoding input.- Parameters:
profile- Profile to add
-
getPatterns
Returns a collection of all patterns registered in this InputDecoder.- Returns:
- Collection of patterns in the InputDecoder
-
removePattern
Removes one pattern from the list of patterns in this InputDecoder- Parameters:
pattern- Pattern to remove- Returns:
trueif the supplied pattern was found and was removed, otherwisefalse
-
setTimeoutUnits
public void setTimeoutUnits(int units) Sets the number of 1/4-second units for how long to try to get further input to complete an escape-sequence for a special Key. Negative numbers are mapped to 0 (no wait at all), and unreasonably high values are mapped to a maximum of 240 (1 minute).- Parameters:
units- New timeout to use, in 250ms units
-
getTimeoutUnits
public int getTimeoutUnits()queries the current timeoutUnits value. One unit is 1/4 second.- Returns:
- The timeout this InputDecoder will use when waiting for additional input, in units of 1/4 seconds
-
getNextCharacter
Reads and decodes the next key stroke from the input stream- Parameters:
blockingIO- If set totrue, the call will not return until it has read at least oneKeyStroke- Returns:
- Key stroke read from the input stream, or
nullif none - Throws:
IOException- If there was an I/O error when reading from the input stream
-
getBestMatch
-