Class Buffer

java.lang.Object
org.aesh.readline.Buffer

public final class Buffer extends Object
Buffer to keep track of text and cursor position in the console. Is using ANSI-codes to clear text and move cursor in the terminal.
Author:
Ståle W. Pedersen
  • Constructor Details

    • Buffer

      public Buffer(Buffer buf)
  • Method Details

    • getCursorLocator

      public CursorLocator getCursorLocator()
    • get

      public int get(int pos)
    • cursor

      public int cursor()
    • multiCursor

      public int multiCursor()
    • isMasking

      public boolean isMasking()
    • isMultiLine

      public boolean isMultiLine()
    • asString

      public String asString()
    • reset

      public void reset()
    • setIsPromptDisplayed

      public void setIsPromptDisplayed(boolean isPromptDisplayed)
    • forceSetDeltaChangedAtEndOfBuffer

      public void forceSetDeltaChangedAtEndOfBuffer(boolean delta)
    • disablePrompt

      public void disablePrompt(boolean disable)
      Need to disable prompt in calculations involving search.
      Parameters:
      disable - prompt or not
    • isPromptDisabled

      public boolean isPromptDisabled()
    • prompt

      public Prompt prompt()
    • length

      public int length()
    • setMultiLine

      public void setMultiLine(boolean multi)
    • invalidateCursorLocation

      public void invalidateCursorLocation()
      Some completion occured, do not try to compute character index location. This could be revisited to implement a strategy.
    • updateMultiLineBuffer

      public void updateMultiLineBuffer()
    • insert

      public void insert(Consumer<int[]> out, int[] data, int width)
      Insert text at cursor position
      Parameters:
      data - text
    • insert

      public void insert(Consumer<int[]> out, int data, int width)
      Insert at cursor position.
      Parameters:
      data - char
    • move

      public void move(Consumer<int[]> out, int move, int termWidth)
      Move the cursor left if the param is negative, right if its positive.
      Parameters:
      out - stream
      move - where to move
      termWidth - terminal width
    • move

      public void move(Consumer<int[]> out, int move, int termWidth, boolean viMode)
      Move the cursor left if the param is negative, right if its positive. If viMode is true, the cursor will not move beyond the current buffer size
      Parameters:
      out - stream
      move - where to move
      termWidth - terminal width
      viMode - edit mode (vi or emacs)
    • moveNumberOfColumns

      public static int[] moveNumberOfColumns(int column, char direction)
    • getLineMasked

      public int[] getLineMasked()
    • clear

      public void clear()
    • replace

      public void replace(Consumer<int[]> out, String line, int width)
      Replace the entire current buffer with the given line. The new line will be pushed to the consumer Cursor will be moved to the end of the new buffer line
      Parameters:
      out - stream
      line - new buffer line
      width - term width
    • replace

      public void replace(Consumer<int[]> out, int[] line, int width)
    • multiLine

      public int[] multiLine()
    • delete

      public void delete(Consumer<int[]> out, int delta, int width)
      Delete from cursor position and backwards if delta is invalid input: '<' 0 Delete from cursor position and forwards if delta is > 0
      Parameters:
      delta - difference
    • delete

      public void delete(Consumer<int[]> out, int delta, int width, boolean viMode)
    • insert

      public void insert(Consumer<int[]> out, String str, int width)
      Write a string to the line and update cursor accordingly
      Parameters:
      out - consumer
      str - string
    • replace

      public void replace(Consumer<int[]> out, char rChar)
      Replace the current character