Class BufferImpl

java.lang.Object
org.jline.reader.impl.BufferImpl
All Implemented Interfaces:
Buffer

public class BufferImpl extends Object implements Buffer
A holder for a StringBuilder that also contains the current cursor position.
Since:
2.0
Author:
Marc Prud'hommeaux, Jason Dillon
  • Constructor Details

    • BufferImpl

      public BufferImpl()
    • BufferImpl

      public BufferImpl(int size)
  • Method Details

    • copy

      public BufferImpl copy()
      Specified by:
      copy in interface Buffer
    • cursor

      public int cursor()
      Specified by:
      cursor in interface Buffer
    • length

      public int length()
      Specified by:
      length in interface Buffer
    • currChar

      public boolean currChar(int ch)
      Specified by:
      currChar in interface Buffer
    • currChar

      public int currChar()
      Specified by:
      currChar in interface Buffer
    • prevChar

      public int prevChar()
      Specified by:
      prevChar in interface Buffer
    • nextChar

      public int nextChar()
      Specified by:
      nextChar in interface Buffer
    • atChar

      public int atChar(int i)
      Specified by:
      atChar in interface Buffer
    • write

      public void write(int c)
      Write the specific character into the buffer, setting the cursor position ahead one.
      Specified by:
      write in interface Buffer
      Parameters:
      c - the character to insert
    • write

      public void write(int c, boolean overTyping)
      Write the specific character into the buffer, setting the cursor position ahead one. The text may overwrite or insert based on the current setting of overTyping.
      Specified by:
      write in interface Buffer
      Parameters:
      c - the character to insert
    • write

      public void write(CharSequence str)
      Insert the specified chars into the buffer, setting the cursor to the end of the insertion point.
      Specified by:
      write in interface Buffer
    • write

      public void write(CharSequence str, boolean overTyping)
      Specified by:
      write in interface Buffer
    • clear

      public boolean clear()
      Specified by:
      clear in interface Buffer
    • substring

      public String substring(int start)
      Specified by:
      substring in interface Buffer
    • substring

      public String substring(int start, int end)
      Specified by:
      substring in interface Buffer
    • upToCursor

      public String upToCursor()
      Specified by:
      upToCursor in interface Buffer
    • cursor

      public boolean cursor(int position)
      Move the cursor position to the specified absolute index.
      Specified by:
      cursor in interface Buffer
    • move

      public int move(int num)
      Move the cursor where characters.
      Specified by:
      move in interface Buffer
      Parameters:
      num - If less than 0, move abs(where) to the left, otherwise move where to the right.
      Returns:
      The number of spaces we moved
    • up

      public boolean up()
      Specified by:
      up in interface Buffer
    • down

      public boolean down()
      Specified by:
      down in interface Buffer
    • moveXY

      public boolean moveXY(int dx, int dy)
      Specified by:
      moveXY in interface Buffer
    • backspace

      public int backspace(int num)
      Issue num backspaces.
      Specified by:
      backspace in interface Buffer
      Returns:
      the number of characters backed up
    • backspace

      public boolean backspace()
      Issue a backspace.
      Specified by:
      backspace in interface Buffer
      Returns:
      true if successful
    • delete

      public int delete(int num)
      Specified by:
      delete in interface Buffer
    • delete

      public boolean delete()
      Specified by:
      delete in interface Buffer
    • toString

      public String toString()
      Specified by:
      toString in interface Buffer
      Overrides:
      toString in class Object
    • copyFrom

      public void copyFrom(Buffer buf)
      Specified by:
      copyFrom in interface Buffer
    • zeroOut

      public void zeroOut()
      Description copied from interface: Buffer
      Clear any internal buffer.
      Specified by:
      zeroOut in interface Buffer