BufferListener (jEdit API Documentation)
Date: 2017-03-18

org.gjt.sp.jedit.buffer

## Interface BufferListener

- All Known Implementing Classes:
    BufferAdapter, ElasticTabStopBufferListener

      public interface BufferListener

  A interface for notification of changes to buffer text.

  This interface is new in jEdit 4.3pre3. The text area was made independent of the rest of jEdit, and thus this class could no longer depend on `org.gjt.sp.jedit.Buffer`.

  While the `BufferUpdate` EditBus message is used for general buffer state changes, this interface is used for events which are fired frequently, or for which performance is essential.

  Because this interface is subject to change in the future, you should subclass `BufferAdapter` instead of implementing it directly.

  Since:
    jEdit 4.3pre3

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `bufferLoaded(JEditBuffer buffer)` Called to notify the text area that the buffer has been reloaded.
    `void` | `contentInserted(JEditBuffer buffer, int startLine, int offset, int numLines, int length)` Called when text is inserted into the buffer.
    `void` | `contentRemoved(JEditBuffer buffer, int startLine, int offset, int numLines, int length)` Called when text is removed from the buffer.
    `void` | `foldHandlerChanged(JEditBuffer buffer)` Called to notify the text area that folds need to be collapsed if the "collapseFolds" property is set.
    `void` | `foldLevelChanged(JEditBuffer buffer, int startLine, int endLine)` Called when line fold levels change.
    `void` | `preContentInserted(JEditBuffer buffer, int startLine, int offset, int numLines, int length)` Called when text is about to be inserted in the buffer.
    `void` | `preContentRemoved(JEditBuffer buffer, int startLine, int offset, int numLines, int length)` Called when text is about to be removed from the buffer, but is still present.
    `void` | `transactionComplete(JEditBuffer buffer)` Called after an undo or compound edit has finished.

- - ### Method Detail

    - #### foldLevelChanged

          void foldLevelChanged(JEditBuffer buffer,
                                int startLine,
                                int endLine)

      Called when line fold levels change.
      Parameters:
        `buffer` - The buffer in question
        `startLine` - The start line number
        `endLine` - The end line number
      Since:
        jEdit 4.3pre3

    - #### contentInserted

          void contentInserted(JEditBuffer buffer,
                               int startLine,
                               int offset,
                               int numLines,
                               int length)

      Called when text is inserted into the buffer.
      Parameters:
        `buffer` - The buffer in question
        `startLine` - The first line
        `offset` - The start offset, from the beginning of the buffer
        `numLines` - The number of lines inserted
        `length` - The number of characters inserted
      Since:
        jEdit 4.3pre3

    - #### contentRemoved

          void contentRemoved(JEditBuffer buffer,
                              int startLine,
                              int offset,
                              int numLines,
                              int length)

      Called when text is removed from the buffer.
      Parameters:
        `buffer` - The buffer in question
        `startLine` - The first line
        `offset` - The start offset, from the beginning of the buffer
        `numLines` - The number of lines removed
        `length` - The number of characters removed
      Since:
        jEdit 4.3pre3

    - #### preContentInserted

          void preContentInserted(JEditBuffer buffer,
                                  int startLine,
                                  int offset,
                                  int numLines,
                                  int length)

      Called when text is about to be inserted in the buffer.
      Parameters:
        `buffer` - The buffer in question
        `startLine` - The first line
        `offset` - The start offset, from the beginning of the buffer
        `numLines` - The number of lines inserted
        `length` - The number of characters inserted
      Since:
        jEdit 4.3pre11

    - #### preContentRemoved

          void preContentRemoved(JEditBuffer buffer,
                                 int startLine,
                                 int offset,
                                 int numLines,
                                 int length)

      Called when text is about to be removed from the buffer, but is still present.
      Parameters:
        `buffer` - The buffer in question
        `startLine` - The first line
        `offset` - The start offset, from the beginning of the buffer
        `numLines` - The number of lines to be removed
        `length` - The number of characters to be removed
      Since:
        jEdit 4.3pre3

    - #### transactionComplete

          void transactionComplete(JEditBuffer buffer)

      Called after an undo or compound edit has finished. The text area uses this event to queue up and collapse cleanup operations so they are only run once during a long transaction (such as a "Replace All" operation.)
      Parameters:
        `buffer` - The buffer in question
      Since:
        jEdit 4.3pre3

    - #### foldHandlerChanged

          void foldHandlerChanged(JEditBuffer buffer)

      Called to notify the text area that folds need to be collapsed if the "collapseFolds" property is set. This method is called after the buffer has been loaded, and also if the user changes the fold handler.
      Parameters:
        `buffer` - The buffer in question
      Since:
        jEdit 4.3pre3

    - #### bufferLoaded

          void bufferLoaded(JEditBuffer buffer)

      Called to notify the text area that the buffer has been reloaded.
      Parameters:
        `buffer` - The buffer in question
      Since:
        jEdit 4.3pre3