- java.lang.Object
-
- org.jline.widget.Widgets
-
- Direct Known Subclasses:
AutopairWidgets,AutosuggestionWidgets,TailTipWidgets
public abstract class Widgets extends Object
Create custom widgets by extending Widgets class- Author:
- Matti Rinta-Nikkola
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringAP_BACKWARD_DELETE_CHARprotected static StringAP_INSERTstatic StringAUTOPAIR_TOGGLEstatic StringAUTOSUGGEST_TOGGLEprotected LineReaderreaderstatic StringTAILTIP_PANEstatic StringTAILTIP_TOGGLEprotected static StringTT_ACCEPT_LINE
-
Constructor Summary
Constructors Constructor Description Widgets(LineReader reader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDescription(List<AttributedString> desc)voidaddWidget(String name, Widget widget)Add widget to the LineReadervoidaliasWidget(String orig, String alias)Create alias to widgetList<String>args()Bufferbuffer()voidcallWidget(String name)Call widget.voidclearDescription()Clears terminal status barvoidclearTailTip()Clears command line tail tipStringcurrChar()voiddestroyDescription()Remove terminal status barvoidexecuteWidget(String name)Bind widget to ctrl-alt-x and execute itbooleanexistsWidget(String name)KeyMap<Binding>getKeyMap()StringgetWidget(String name)voidinitDescription(int size)Initialize terminal status barStringlastBinding()Parserparser()StringprevChar()voidputString(String string)voidreplaceBuffer(Buffer buffer)voidsetErrorIndex(int errorIndex)voidsetErrorPattern(Pattern errorPattern)voidsetSuggestionType(LineReader.SuggestionType type)voidsetTailTip(String tailTip)StringtailTip()
-
-
-
Field Detail
-
TAILTIP_TOGGLE
public static final String TAILTIP_TOGGLE
- See Also:
- Constant Field Values
-
TAILTIP_PANE
public static final String TAILTIP_PANE
- See Also:
- Constant Field Values
-
AUTOPAIR_TOGGLE
public static final String AUTOPAIR_TOGGLE
- See Also:
- Constant Field Values
-
AUTOSUGGEST_TOGGLE
public static final String AUTOSUGGEST_TOGGLE
- See Also:
- Constant Field Values
-
AP_INSERT
protected static final String AP_INSERT
- See Also:
- Constant Field Values
-
AP_BACKWARD_DELETE_CHAR
protected static final String AP_BACKWARD_DELETE_CHAR
- See Also:
- Constant Field Values
-
TT_ACCEPT_LINE
protected static final String TT_ACCEPT_LINE
- See Also:
- Constant Field Values
-
reader
protected final LineReader reader
-
-
Constructor Detail
-
Widgets
public Widgets(LineReader reader)
-
-
Method Detail
-
addWidget
public void addWidget(String name, Widget widget)
Add widget to the LineReader- Parameters:
name- the name of widgetwidget- widget
-
callWidget
public void callWidget(String name)
Call widget. System widget will be call if the name does not start with '_' or ends with '-toggle' i.e. '.' will be added at the beginning of the name.- Parameters:
name- widget name
-
executeWidget
public void executeWidget(String name)
Bind widget to ctrl-alt-x and execute it- Parameters:
name- widget name
-
aliasWidget
public void aliasWidget(String orig, String alias)
Create alias to widget- Parameters:
orig- widget original namealias- alias name
-
getWidget
public String getWidget(String name)
- Parameters:
name- widget name or alias- Returns:
- widget name
-
existsWidget
public boolean existsWidget(String name)
- Parameters:
name- widget name or alias- Returns:
- true if widget exists
-
parser
public Parser parser()
- Returns:
- The LineRearer Parser
-
buffer
public Buffer buffer()
- Returns:
- The LineReader Buffer
-
replaceBuffer
public void replaceBuffer(Buffer buffer)
- Parameters:
buffer- buffer that will be copied to the LineReader Buffer
-
prevChar
public String prevChar()
- Returns:
- Buffer's previous character
-
currChar
public String currChar()
- Returns:
- Buffer's current character
-
lastBinding
public String lastBinding()
- Returns:
- LineReader's last binding
-
putString
public void putString(String string)
- Parameters:
string- string to be written into LineReader Buffer
-
tailTip
public String tailTip()
- Returns:
- Command line tail tip.
-
setTailTip
public void setTailTip(String tailTip)
- Parameters:
tailTip- tail tip to be added to the command line
-
setErrorPattern
public void setErrorPattern(Pattern errorPattern)
- Parameters:
errorPattern- error pattern to be set LineReader Highlighter
-
setErrorIndex
public void setErrorIndex(int errorIndex)
- Parameters:
errorIndex- error index to be set LineReader Highlighter
-
clearTailTip
public void clearTailTip()
Clears command line tail tip
-
setSuggestionType
public void setSuggestionType(LineReader.SuggestionType type)
- Parameters:
type- type to be set to the LineReader autosuggestion
-
addDescription
public void addDescription(List<AttributedString> desc)
- Parameters:
desc- Text to be displayed on terminal status bar
-
clearDescription
public void clearDescription()
Clears terminal status bar
-
initDescription
public void initDescription(int size)
Initialize terminal status bar- Parameters:
size- Terminal status bar size in rows
-
destroyDescription
public void destroyDescription()
Remove terminal status bar
-
-