Class AeshConsoleBuffer
java.lang.Object
org.aesh.readline.AeshConsoleBuffer
- All Implemented Interfaces:
ConsoleBuffer
Default implementation of the ConsoleBuffer interface for managing console input and output.
- Author:
- Ståle W. Pedersen
-
Constructor Summary
ConstructorsConstructorDescriptionAeshConsoleBuffer(Connection connection, Prompt prompt, EditMode editMode, History history, CompletionHandler completionHandler, boolean ansi, CursorListener listener) Creates a new AeshConsoleBuffer. -
Method Summary
Modifier and TypeMethodDescriptionvoidWill add the current action to the undo stackbuffer()Get the input buffer containing the current line being edited.voidChange case on the char located at the cursor positionvoidclear(boolean includeBuffer) Clear an ansi terminal.Get the completion handler for tab completion.voiddelete(int delta) Delete from cursor position back or forth depending on the value of delta.voiddownCase()Down case the char located at the cursor positionvoiddrawLine()Print the contents of the current buffer to the consolevoidForce a rewrite of the prompt even though it might not be neededhistory()Get the command history manager.voidinsert(int[] insert) Insert at the end of the BuffervoidInsert a String into the buffer at a specific pointvoidmoveCursor(int where) Move the cursor either back or forth.Get the paste manager for copy/paste operations.voidreplace(int[] line) Replace the entire current buffer with the given line The new line will be pushed to the Connection Cursor will be moved to the end of the new buffer linevoidReplace the entire current buffer with the given line The new line will be pushed to the Connection Cursor will be moved to the end of the new buffer linevoidreset()Clear all content in the Buffer and reset all datavoidSpecify the promptvoidSet the terminal size.size()Get the current terminal size.Get the undo manager for undo/redo operations.voidupCase()Up case the char located at the cursor positionvoidwriteChar(char input) Write a single character to the buffer.voidwriteChars(int[] input) Write code points to the buffer.voidwriteOut(int[] out) Write code points directly to the connection output stream.voidWrite a string directly to the connection output stream.voidwriteString(String input) Write a string to the buffer.
-
Constructor Details
-
AeshConsoleBuffer
public AeshConsoleBuffer(Connection connection, Prompt prompt, EditMode editMode, History history, CompletionHandler completionHandler, boolean ansi, CursorListener listener) Creates a new AeshConsoleBuffer.- Parameters:
connection- the terminal connectionprompt- the initial prompteditMode- the editing mode (vi or emacs)history- the command history, or null to use a new in-memory historycompletionHandler- the tab completion handleransi- whether ANSI mode is enabledlistener- the cursor movement listener, or null
-
-
Method Details
-
history
Description copied from interface:ConsoleBufferGet the command history manager.- Specified by:
historyin interfaceConsoleBuffer- Returns:
- the history manager
-
completer
Description copied from interface:ConsoleBufferGet the completion handler for tab completion.- Specified by:
completerin interfaceConsoleBuffer- Returns:
- the completion handler
-
setSize
Description copied from interface:ConsoleBufferSet the terminal size.- Specified by:
setSizein interfaceConsoleBuffer- Parameters:
size- the new terminal size
-
size
Description copied from interface:ConsoleBufferGet the current terminal size.- Specified by:
sizein interfaceConsoleBuffer- Returns:
- the terminal size
-
buffer
Description copied from interface:ConsoleBufferGet the input buffer containing the current line being edited.- Specified by:
bufferin interfaceConsoleBuffer- Returns:
- the input buffer
-
undoManager
Description copied from interface:ConsoleBufferGet the undo manager for undo/redo operations.- Specified by:
undoManagerin interfaceConsoleBuffer- Returns:
- the undo manager
-
addActionToUndoStack
public void addActionToUndoStack()Description copied from interface:ConsoleBufferWill add the current action to the undo stack- Specified by:
addActionToUndoStackin interfaceConsoleBuffer
-
pasteManager
Description copied from interface:ConsoleBufferGet the paste manager for copy/paste operations.- Specified by:
pasteManagerin interfaceConsoleBuffer- Returns:
- the paste manager
-
moveCursor
public void moveCursor(int where) Description copied from interface:ConsoleBufferMove the cursor either back or forth. Boundary checks will be done to make sure that the cursor do not go OB.- Specified by:
moveCursorin interfaceConsoleBuffer- Parameters:
where- < 0 move back, where > 0 move forward
-
drawLine
public void drawLine()Description copied from interface:ConsoleBufferPrint the contents of the current buffer to the console- Specified by:
drawLinein interfaceConsoleBuffer
-
drawLineForceDisplay
public void drawLineForceDisplay()Description copied from interface:ConsoleBufferForce a rewrite of the prompt even though it might not be needed- Specified by:
drawLineForceDisplayin interfaceConsoleBuffer
-
writeChar
public void writeChar(char input) Description copied from interface:ConsoleBufferWrite a single character to the buffer.- Specified by:
writeCharin interfaceConsoleBuffer- Parameters:
input- the character to write
-
writeOut
Description copied from interface:ConsoleBufferWrite a string directly to the connection output stream.- Specified by:
writeOutin interfaceConsoleBuffer- Parameters:
out- the string to write
-
writeOut
public void writeOut(int[] out) Description copied from interface:ConsoleBufferWrite code points directly to the connection output stream.- Specified by:
writeOutin interfaceConsoleBuffer- Parameters:
out- the code points to write
-
writeChars
public void writeChars(int[] input) Description copied from interface:ConsoleBufferWrite code points to the buffer.- Specified by:
writeCharsin interfaceConsoleBuffer- Parameters:
input- the code points to write
-
writeString
Description copied from interface:ConsoleBufferWrite a string to the buffer.- Specified by:
writeStringin interfaceConsoleBuffer- Parameters:
input- the string to write
-
setPrompt
Description copied from interface:ConsoleBufferSpecify the prompt- Specified by:
setPromptin interfaceConsoleBuffer- Parameters:
prompt- new prompt
-
insert
Description copied from interface:ConsoleBufferInsert a String into the buffer at a specific point- Specified by:
insertin interfaceConsoleBuffer- Parameters:
insert- inputposition- point in the buffer
-
insert
public void insert(int[] insert) Description copied from interface:ConsoleBufferInsert at the end of the Buffer- Specified by:
insertin interfaceConsoleBuffer- Parameters:
insert- data
-
delete
public void delete(int delta) Description copied from interface:ConsoleBufferDelete from cursor position back or forth depending on the value of delta. Delta < 0 delete backwards, delta > 0 delete forwards.- Specified by:
deletein interfaceConsoleBuffer- Parameters:
delta- specify which direction and how far to delete
-
upCase
public void upCase()Description copied from interface:ConsoleBufferUp case the char located at the cursor position- Specified by:
upCasein interfaceConsoleBuffer
-
downCase
public void downCase()Description copied from interface:ConsoleBufferDown case the char located at the cursor position- Specified by:
downCasein interfaceConsoleBuffer
-
changeCase
public void changeCase()Description copied from interface:ConsoleBufferChange case on the char located at the cursor position- Specified by:
changeCasein interfaceConsoleBuffer
-
replace
public void replace(int[] line) Description copied from interface:ConsoleBufferReplace the entire current buffer with the given line The new line will be pushed to the Connection Cursor will be moved to the end of the new buffer line- Specified by:
replacein interfaceConsoleBuffer- Parameters:
line- input
-
replace
Description copied from interface:ConsoleBufferReplace the entire current buffer with the given line The new line will be pushed to the Connection Cursor will be moved to the end of the new buffer line- Specified by:
replacein interfaceConsoleBuffer- Parameters:
line- input
-
reset
public void reset()Description copied from interface:ConsoleBufferClear all content in the Buffer and reset all data- Specified by:
resetin interfaceConsoleBuffer
-
clear
public void clear(boolean includeBuffer) Description copied from interface:ConsoleBufferClear an ansi terminal. Set includeBuffer to true if the current buffer should be printed again after clear.- Specified by:
clearin interfaceConsoleBuffer- Parameters:
includeBuffer- if true include the current buffer line
-