001: /*
002: * BufferChangeListener.java - Buffer listener interface
003: * :tabSize=8:indentSize=8:noTabs=false:
004: * :folding=explicit:collapseFolds=1:
005: *
006: * Copyright (C) 2001, 2003 Slava Pestov
007: *
008: * This program is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU General Public License
010: * as published by the Free Software Foundation; either version 2
011: * of the License, or any later version.
012: *
013: * This program is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016: * GNU General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public License
019: * along with this program; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
021: */
022:
023: package org.gjt.sp.jedit.buffer;
024:
025: import org.gjt.sp.jedit.Buffer;
026:
027: /**
028: * A interface for notification of changes to buffer text. While the
029: * {@link org.gjt.sp.jedit.msg.BufferUpdate} EditBus message is used for
030: * general buffer state changes, this interface is used for events which are
031: * fired frequently, or for which performance is essential.<p>
032: *
033: * Because this interface is subject to change in the future, you
034: * should subclass <code>BufferChangeAdapter</code> instead of
035: * implementing it directly.
036: *
037: * @author Slava Pestov
038: * @version $Id: BufferChangeListener.java 10708 2007-09-21 19:41:03Z kpouer $
039: * @since jEdit 4.0pre1
040: */
041: public interface BufferChangeListener {
042: //{{{ foldLevelChanged() method
043: /**
044: * Called when line fold levels change.
045: * @param buffer The buffer in question
046: * @param startLine The start line number
047: * @param endLine The end line number
048: * @since jEdit 4.0pre1
049: */
050: void foldLevelChanged(Buffer buffer, int startLine, int endLine);
051:
052: //}}}
053:
054: //{{{ contentInserted() method
055: /**
056: * Called when text is inserted into the buffer.
057: * @param buffer The buffer in question
058: * @param startLine The first line
059: * @param offset The start offset, from the beginning of the buffer
060: * @param numLines The number of lines inserted
061: * @param length The number of characters inserted
062: * @since jEdit 4.0pre1
063: */
064: void contentInserted(Buffer buffer, int startLine, int offset,
065: int numLines, int length);
066:
067: //}}}
068:
069: //{{{ contentRemoved() method
070: /**
071: * Called when text is removed from the buffer.
072: * @param buffer The buffer in question
073: * @param startLine The first line
074: * @param offset The start offset, from the beginning of the buffer
075: * @param numLines The number of lines removed
076: * @param length The number of characters removed
077: * @since jEdit 4.0pre1
078: */
079: void contentRemoved(Buffer buffer, int startLine, int offset,
080: int numLines, int length);
081:
082: //}}}
083:
084: //{{{ preContentRemoved() method
085: /**
086: * Called when text is about to be removed from the buffer, but is
087: * still present.
088: * @param buffer The buffer in question
089: * @param startLine The first line
090: * @param offset The start offset, from the beginning of the buffer
091: * @param numLines The number of lines to be removed
092: * @param length The number of characters to be removed
093: * @since jEdit 4.2pre1
094: */
095: public void preContentRemoved(Buffer buffer, int startLine,
096: int offset, int numLines, int length);
097:
098: //}}}
099:
100: //{{{ transactionComplete() method
101: /**
102: * Called after an undo or compound edit has finished. The text area
103: * uses this event to queue up and collapse cleanup operations so they
104: * are only run once during a long transaction (such as a "Replace All"
105: * operation.)
106: *
107: * @param buffer The buffer in question
108: * @since jEdit 4.0pre6
109: */
110: void transactionComplete(Buffer buffer);
111:
112: //}}}
113:
114: //{{{ foldHandlerChanged() method
115: /**
116: * Called to notify the text area that folds need to be collapsed if
117: * the "collapseFolds" property is set. This method is called after the
118: * buffer has been loaded, and also if the user changes the fold
119: * handler.
120: *
121: * @param buffer The buffer in question
122: * @since jEdit 4.2pre2
123: */
124: void foldHandlerChanged(Buffer buffer);
125:
126: //}}}
127:
128: //{{{ foldHandlerChanged() method
129: /**
130: * Called to notify the text area that the buffer has been reloaded.
131: *
132: * @param buffer The buffer in question
133: * @since jEdit 4.3pre1
134: */
135: void bufferLoaded(Buffer buffer);
136:
137: //}}}
138:
139: //{{{ Compatibility with older jEdit plugins
140: public class Adapter implements BufferListener {
141: private BufferChangeListener delegate;
142:
143: //{{{ Adapter constructor
144: public Adapter(BufferChangeListener delegate) {
145: this .delegate = delegate;
146: } //}}}
147:
148: //{{{ getDelegate() method
149: public BufferChangeListener getDelegate() {
150: return delegate;
151: } //}}}
152:
153: //{{{ foldLevelChanged() method
154: /**
155: * Called when line fold levels change.
156: * @param buffer The buffer in question
157: * @param startLine The start line number
158: * @param endLine The end line number
159: * @since jEdit 4.3pre3
160: */
161: public void foldLevelChanged(JEditBuffer buffer, int startLine,
162: int endLine) {
163: delegate.foldLevelChanged((Buffer) buffer, startLine,
164: endLine);
165: } //}}}
166:
167: //{{{ contentInserted() method
168: /**
169: * Called when text is inserted into the buffer.
170: * @param buffer The buffer in question
171: * @param startLine The first line
172: * @param offset The start offset, from the beginning of the buffer
173: * @param numLines The number of lines inserted
174: * @param length The number of characters inserted
175: * @since jEdit 4.3pre3
176: */
177: public void contentInserted(JEditBuffer buffer, int startLine,
178: int offset, int numLines, int length) {
179: delegate.contentInserted((Buffer) buffer, startLine,
180: offset, numLines, length);
181: } //}}}
182:
183: //{{{ contentRemoved() method
184: /**
185: * Called when text is removed from the buffer.
186: * @param buffer The buffer in question
187: * @param startLine The first line
188: * @param offset The start offset, from the beginning of the buffer
189: * @param numLines The number of lines removed
190: * @param length The number of characters removed
191: * @since jEdit 4.3pre3
192: */
193: public void contentRemoved(JEditBuffer buffer, int startLine,
194: int offset, int numLines, int length) {
195: delegate.contentRemoved((Buffer) buffer, startLine, offset,
196: numLines, length);
197: } //}}}
198:
199: /**
200: * Called when text is about to be inserted in the buffer.
201: *
202: * @param buffer The buffer in question
203: * @param startLine The first line
204: * @param offset The start offset, from the beginning of the buffer
205: * @param numLines The number of lines inserted
206: * @param length The number of characters inserted
207: * @since jEdit 4.3pre11
208: */
209: public void preContentInserted(JEditBuffer buffer,
210: int startLine, int offset, int numLines, int length) {
211: }
212:
213: //{{{ preContentRemoved() method
214: /**
215: * Called when text is about to be removed from the buffer, but is
216: * still present.
217: * @param buffer The buffer in question
218: * @param startLine The first line
219: * @param offset The start offset, from the beginning of the buffer
220: * @param numLines The number of lines to be removed
221: * @param length The number of characters to be removed
222: * @since jEdit 4.3pre3
223: */
224: public void preContentRemoved(JEditBuffer buffer,
225: int startLine, int offset, int numLines, int length) {
226: delegate.preContentRemoved((Buffer) buffer, startLine,
227: offset, numLines, length);
228: } //}}}
229:
230: //{{{ transactionComplete() method
231: /**
232: * Called after an undo or compound edit has finished. The text area
233: * uses this event to queue up and collapse cleanup operations so they
234: * are only run once during a long transaction (such as a "Replace All"
235: * operation.)
236: *
237: * @param buffer The buffer in question
238: * @since jEdit 4.3pre3
239: */
240: public void transactionComplete(JEditBuffer buffer) {
241: delegate.transactionComplete((Buffer) buffer);
242: } //}}}
243:
244: //{{{ foldHandlerChanged() method
245: /**
246: * Called to notify the text area that folds need to be collapsed if
247: * the "collapseFolds" property is set. This method is called after the
248: * buffer has been loaded, and also if the user changes the fold
249: * handler.
250: *
251: * @param buffer The buffer in question
252: * @since jEdit 4.3pre3
253: */
254: public void foldHandlerChanged(JEditBuffer buffer) {
255: delegate.foldHandlerChanged((Buffer) buffer);
256: } //}}}
257:
258: //{{{ foldHandlerChanged() method
259: /**
260: * Called to notify the text area that the buffer has been reloaded.
261: *
262: * @param buffer The buffer in question
263: * @since jEdit 4.3pre3
264: */
265: public void bufferLoaded(JEditBuffer buffer) {
266: delegate.bufferLoaded((Buffer) buffer);
267: } //}}}
268: } //}}}
269: }
|