Class AeshConsoleBuffer

java.lang.Object
org.aesh.readline.AeshConsoleBuffer
All Implemented Interfaces:
ConsoleBuffer

public class AeshConsoleBuffer extends Object implements ConsoleBuffer
Default implementation of the ConsoleBuffer interface for managing console input and output.
Author:
Ståle W. Pedersen
  • Constructor Summary

    Constructors
    Constructor
    Description
    AeshConsoleBuffer(Connection connection, Prompt prompt, EditMode editMode, History history, CompletionHandler completionHandler, boolean ansi, CursorListener listener)
    Creates a new AeshConsoleBuffer.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Will add the current action to the undo stack
    Get the input buffer containing the current line being edited.
    void
    Change case on the char located at the cursor position
    void
    clear(boolean includeBuffer)
    Clear an ansi terminal.
    Get the completion handler for tab completion.
    void
    delete(int delta)
    Delete from cursor position back or forth depending on the value of delta.
    void
    Down case the char located at the cursor position
    void
    Print the contents of the current buffer to the console
    void
    Force a rewrite of the prompt even though it might not be needed
    Get the command history manager.
    void
    insert(int[] insert)
    Insert at the end of the Buffer
    void
    insert(String insert, int position)
    Insert a String into the buffer at a specific point
    void
    moveCursor(int where)
    Move the cursor either back or forth.
    Get the paste manager for copy/paste operations.
    void
    replace(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 line
    void
    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 line
    void
    Clear all content in the Buffer and reset all data
    void
    setPrompt(Prompt prompt)
    Specify the prompt
    void
    setSize(Size size)
    Set the terminal size.
    Get the current terminal size.
    Get the undo manager for undo/redo operations.
    void
    Up case the char located at the cursor position
    void
    writeChar(char input)
    Write a single character to the buffer.
    void
    writeChars(int[] input)
    Write code points to the buffer.
    void
    writeOut(int[] out)
    Write code points directly to the connection output stream.
    void
    Write a string directly to the connection output stream.
    void
    Write a string to the buffer.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 connection
      prompt - the initial prompt
      editMode - the editing mode (vi or emacs)
      history - the command history, or null to use a new in-memory history
      completionHandler - the tab completion handler
      ansi - whether ANSI mode is enabled
      listener - the cursor movement listener, or null
  • Method Details

    • history

      public History history()
      Description copied from interface: ConsoleBuffer
      Get the command history manager.
      Specified by:
      history in interface ConsoleBuffer
      Returns:
      the history manager
    • completer

      public CompletionHandler completer()
      Description copied from interface: ConsoleBuffer
      Get the completion handler for tab completion.
      Specified by:
      completer in interface ConsoleBuffer
      Returns:
      the completion handler
    • setSize

      public void setSize(Size size)
      Description copied from interface: ConsoleBuffer
      Set the terminal size.
      Specified by:
      setSize in interface ConsoleBuffer
      Parameters:
      size - the new terminal size
    • size

      public Size size()
      Description copied from interface: ConsoleBuffer
      Get the current terminal size.
      Specified by:
      size in interface ConsoleBuffer
      Returns:
      the terminal size
    • buffer

      public Buffer buffer()
      Description copied from interface: ConsoleBuffer
      Get the input buffer containing the current line being edited.
      Specified by:
      buffer in interface ConsoleBuffer
      Returns:
      the input buffer
    • undoManager

      public UndoManager undoManager()
      Description copied from interface: ConsoleBuffer
      Get the undo manager for undo/redo operations.
      Specified by:
      undoManager in interface ConsoleBuffer
      Returns:
      the undo manager
    • addActionToUndoStack

      public void addActionToUndoStack()
      Description copied from interface: ConsoleBuffer
      Will add the current action to the undo stack
      Specified by:
      addActionToUndoStack in interface ConsoleBuffer
    • pasteManager

      public PasteManager pasteManager()
      Description copied from interface: ConsoleBuffer
      Get the paste manager for copy/paste operations.
      Specified by:
      pasteManager in interface ConsoleBuffer
      Returns:
      the paste manager
    • moveCursor

      public void moveCursor(int where)
      Description copied from interface: ConsoleBuffer
      Move the cursor either back or forth. Boundary checks will be done to make sure that the cursor do not go OB.
      Specified by:
      moveCursor in interface ConsoleBuffer
      Parameters:
      where - < 0 move back, where > 0 move forward
    • drawLine

      public void drawLine()
      Description copied from interface: ConsoleBuffer
      Print the contents of the current buffer to the console
      Specified by:
      drawLine in interface ConsoleBuffer
    • drawLineForceDisplay

      public void drawLineForceDisplay()
      Description copied from interface: ConsoleBuffer
      Force a rewrite of the prompt even though it might not be needed
      Specified by:
      drawLineForceDisplay in interface ConsoleBuffer
    • writeChar

      public void writeChar(char input)
      Description copied from interface: ConsoleBuffer
      Write a single character to the buffer.
      Specified by:
      writeChar in interface ConsoleBuffer
      Parameters:
      input - the character to write
    • writeOut

      public void writeOut(String out)
      Description copied from interface: ConsoleBuffer
      Write a string directly to the connection output stream.
      Specified by:
      writeOut in interface ConsoleBuffer
      Parameters:
      out - the string to write
    • writeOut

      public void writeOut(int[] out)
      Description copied from interface: ConsoleBuffer
      Write code points directly to the connection output stream.
      Specified by:
      writeOut in interface ConsoleBuffer
      Parameters:
      out - the code points to write
    • writeChars

      public void writeChars(int[] input)
      Description copied from interface: ConsoleBuffer
      Write code points to the buffer.
      Specified by:
      writeChars in interface ConsoleBuffer
      Parameters:
      input - the code points to write
    • writeString

      public void writeString(String input)
      Description copied from interface: ConsoleBuffer
      Write a string to the buffer.
      Specified by:
      writeString in interface ConsoleBuffer
      Parameters:
      input - the string to write
    • setPrompt

      public void setPrompt(Prompt prompt)
      Description copied from interface: ConsoleBuffer
      Specify the prompt
      Specified by:
      setPrompt in interface ConsoleBuffer
      Parameters:
      prompt - new prompt
    • insert

      public void insert(String insert, int position)
      Description copied from interface: ConsoleBuffer
      Insert a String into the buffer at a specific point
      Specified by:
      insert in interface ConsoleBuffer
      Parameters:
      insert - input
      position - point in the buffer
    • insert

      public void insert(int[] insert)
      Description copied from interface: ConsoleBuffer
      Insert at the end of the Buffer
      Specified by:
      insert in interface ConsoleBuffer
      Parameters:
      insert - data
    • delete

      public void delete(int delta)
      Description copied from interface: ConsoleBuffer
      Delete from cursor position back or forth depending on the value of delta. Delta < 0 delete backwards, delta > 0 delete forwards.
      Specified by:
      delete in interface ConsoleBuffer
      Parameters:
      delta - specify which direction and how far to delete
    • upCase

      public void upCase()
      Description copied from interface: ConsoleBuffer
      Up case the char located at the cursor position
      Specified by:
      upCase in interface ConsoleBuffer
    • downCase

      public void downCase()
      Description copied from interface: ConsoleBuffer
      Down case the char located at the cursor position
      Specified by:
      downCase in interface ConsoleBuffer
    • changeCase

      public void changeCase()
      Description copied from interface: ConsoleBuffer
      Change case on the char located at the cursor position
      Specified by:
      changeCase in interface ConsoleBuffer
    • replace

      public void replace(int[] line)
      Description copied from interface: ConsoleBuffer
      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 line
      Specified by:
      replace in interface ConsoleBuffer
      Parameters:
      line - input
    • replace

      public void replace(String line)
      Description copied from interface: ConsoleBuffer
      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 line
      Specified by:
      replace in interface ConsoleBuffer
      Parameters:
      line - input
    • reset

      public void reset()
      Description copied from interface: ConsoleBuffer
      Clear all content in the Buffer and reset all data
      Specified by:
      reset in interface ConsoleBuffer
    • clear

      public void clear(boolean includeBuffer)
      Description copied from interface: ConsoleBuffer
      Clear an ansi terminal. Set includeBuffer to true if the current buffer should be printed again after clear.
      Specified by:
      clear in interface ConsoleBuffer
      Parameters:
      includeBuffer - if true include the current buffer line