Class TerminalTextBuffer

java.lang.Object
org.springframework.shell.test.jediterm.terminal.model.TerminalTextBuffer

public class TerminalTextBuffer extends Object
Buffer for storing styled text data. Stores only text that fit into one screen XxY, but has scrollBuffer to save history lines and screenBuffer to restore screen after resize. ScrollBuffer stores all lines before the first line currently shown on the screen. TextBuffer stores lines that are shown currently on the screen and they have there(in TextBuffer) their initial length (even if it doesn't fit to screen width).

  • Constructor Details

    • TerminalTextBuffer

      public TerminalTextBuffer(int width, int height, StyleState styleState)
    • TerminalTextBuffer

      public TerminalTextBuffer(int width, int height, StyleState styleState, int historyLinesCount)
  • Method Details

    • addModelListener

      public void addModelListener(TerminalModelListener listener)
    • addTypeAheadModelListener

      public void addTypeAheadModelListener(TerminalModelListener listener)
    • removeModelListener

      public void removeModelListener(TerminalModelListener listener)
    • removeTypeAheadModelListener

      public void removeTypeAheadModelListener(TerminalModelListener listener)
    • deleteCharacters

      public void deleteCharacters(int x, int y, int count)
    • insertBlankCharacters

      public void insertBlankCharacters(int x, int y, int count)
    • writeString

      public void writeString(int x, int y, CharBuffer str)
    • addLine

      public void addLine(TerminalLine line)
    • scrollArea

      public void scrollArea(int scrollRegionTop, int dy, int scrollRegionBottom)
    • getStyleLines

      public String getStyleLines()
    • getLine

      public TerminalLine getLine(int index)
      Returns terminal lines. Negative indexes are for history buffer. Non-negative for screen buffer.
      Parameters:
      index - index of line
      Returns:
      history lines for index<0, screen line for index>=0
    • getScreen

      public List<String> getScreen()
    • processScreenLines

      public void processScreenLines(int yStart, int yCount, StyledTextConsumer consumer)
    • lock

      public void lock()
    • unlock

      public void unlock()
    • tryLock

      public boolean tryLock()
    • getWidth

      public int getWidth()
    • getHeight

      public int getHeight()
    • getHistoryLinesCount

      public int getHistoryLinesCount()
    • getScreenLinesCount

      public int getScreenLinesCount()
    • getBuffersCharAt

      public char getBuffersCharAt(int x, int y)
    • getStyleAt

      public TextStyle getStyleAt(int x, int y)
    • getStyledCharAt

      public Pair<Character,TextStyle> getStyledCharAt(int x, int y)
    • getCharAt

      public char getCharAt(int x, int y)
    • isUsingAlternateBuffer

      public boolean isUsingAlternateBuffer()
    • useAlternateBuffer

      public void useAlternateBuffer(boolean enabled)
    • getHistoryBuffer

      public LinesBuffer getHistoryBuffer()
    • insertLines

      public void insertLines(int y, int count, int scrollRegionBottom)
    • deleteLines

      public LinesBuffer deleteLines(int y, int count, int scrollRegionBottom)
    • clearLines

      public void clearLines(int startRow, int endRow)
    • eraseCharacters

      public void eraseCharacters(int leftX, int rightX, int y)
    • clearAll

      public void clearAll()
    • processHistoryAndScreenLines

      public void processHistoryAndScreenLines(int scrollOrigin, int maximalLinesToProcess, StyledTextConsumer consumer)
      Parameters:
      scrollOrigin - row where a scrolling window starts, should be in the range [-history_lines_count, 0]
    • clearHistory

      public void clearHistory()
    • findScreenLineIndex

      public int findScreenLineIndex(TerminalLine line)
    • clearTypeAheadPredictions

      public void clearTypeAheadPredictions()