KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > sp > jedit > buffer > BufferChangeListener


1 /*
2  * BufferChangeListener.java - Buffer listener interface
3  * :tabSize=8:indentSize=8:noTabs=false:
4  * :folding=explicit:collapseFolds=1:
5  *
6  * Copyright (C) 2001, 2003 Slava Pestov
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21  */

22
23 package org.gjt.sp.jedit.buffer;
24
25 import org.gjt.sp.jedit.Buffer;
26
27 /**
28  * A interface for notification of changes to buffer text. While the
29  * {@link org.gjt.sp.jedit.msg.BufferUpdate} EditBus message is used for
30  * general buffer state changes, this interface is used for events which are
31  * fired frequently, or for which performance is essential.<p>
32  *
33  * Because this interface is subject to change in the future, you
34  * should subclass <code>BufferChangeAdapter</code> instead of
35  * implementing it directly.
36  *
37  * @author Slava Pestov
38  * @version $Id: BufferChangeListener.java 5225 2005-07-04 05:53:03Z spestov $
39  * @since jEdit 4.0pre1
40  */

41 public interface BufferChangeListener
42 {
43     //{{{ foldLevelChanged() method
44
/**
45      * Called when line fold levels change.
46      * @param buffer The buffer in question
47      * @param startLine The start line number
48      * @param endLine The end line number
49      * @since jEdit 4.0pre1
50      */

51     void foldLevelChanged(Buffer buffer, int startLine, int endLine);
52     //}}}
53

54     //{{{ contentInserted() method
55
/**
56      * Called when text is inserted into the buffer.
57      * @param buffer The buffer in question
58      * @param startLine The first line
59      * @param offset The start offset, from the beginning of the buffer
60      * @param numLines The number of lines inserted
61      * @param length The number of characters inserted
62      * @since jEdit 4.0pre1
63      */

64     void contentInserted(Buffer buffer, int startLine, int offset,
65         int numLines, int length);
66     //}}}
67

68     //{{{ contentRemoved() method
69
/**
70      * Called when text is removed from the buffer.
71      * @param buffer The buffer in question
72      * @param startLine The first line
73      * @param offset The start offset, from the beginning of the buffer
74      * @param numLines The number of lines removed
75      * @param length The number of characters removed
76      * @since jEdit 4.0pre1
77      */

78     void contentRemoved(Buffer buffer, int startLine, int offset,
79         int numLines, int length);
80     //}}}
81

82     //{{{ preContentRemoved() method
83
/**
84      * Called when text is about to be removed from the buffer, but is
85      * still present.
86      * @param buffer The buffer in question
87      * @param startLine The first line
88      * @param offset The start offset, from the beginning of the buffer
89      * @param numLines The number of lines to be removed
90      * @param length The number of characters to be removed
91      * @since jEdit 4.2pre1
92      */

93     public void preContentRemoved(Buffer buffer, int startLine, int offset,
94         int numLines, int length);
95     //}}}
96

97     //{{{ transactionComplete() method
98
/**
99      * Called after an undo or compound edit has finished. The text area
100      * uses this event to queue up and collapse cleanup operations so they
101      * are only run once during a long transaction (such as a "Replace All"
102      * operation.)
103      *
104      * @param buffer The buffer in question
105      * @since jEdit 4.0pre6
106      */

107     void transactionComplete(Buffer buffer);
108     //}}}
109

110     //{{{ foldHandlerChanged() method
111
/**
112      * Called to notify the text area that folds need to be collapsed if
113      * the "collapseFolds" property is set. This method is called after the
114      * buffer has been loaded, and also if the user changes the fold
115      * handler.
116      *
117      * @param buffer The buffer in question
118      * @since jEdit 4.2pre2
119      */

120     void foldHandlerChanged(Buffer buffer);
121     //}}}
122

123     //{{{ foldHandlerChanged() method
124
/**
125      * Called to notify the text area that the buffer has been reloaded.
126      *
127      * @param buffer The buffer in question
128      * @since jEdit 4.3pre1
129      */

130     void bufferLoaded(Buffer buffer);
131     //}}}
132

133     //{{{ Compatibility with older jEdit plugins
134
public class Adapter implements BufferListener
135     {
136         private BufferChangeListener delegate;
137
138         //{{{ Adapter constructor
139
public Adapter(BufferChangeListener delegate)
140         {
141             this.delegate = delegate;
142         } //}}}
143

144         //{{{ getDelegate() method
145
public BufferChangeListener getDelegate()
146         {
147             return delegate;
148         } //}}}
149

150         //{{{ foldLevelChanged() method
151
/**
152          * Called when line fold levels change.
153          * @param buffer The buffer in question
154          * @param startLine The start line number
155          * @param endLine The end line number
156          * @since jEdit 4.3pre3
157          */

158         public void foldLevelChanged(JEditBuffer buffer, int startLine, int endLine)
159         {
160             delegate.foldLevelChanged((Buffer)buffer,startLine,endLine);
161         } //}}}
162

163         //{{{ contentInserted() method
164
/**
165          * Called when text is inserted into the buffer.
166          * @param buffer The buffer in question
167          * @param startLine The first line
168          * @param offset The start offset, from the beginning of the buffer
169          * @param numLines The number of lines inserted
170          * @param length The number of characters inserted
171          * @since jEdit 4.3pre3
172          */

173         public void contentInserted(JEditBuffer buffer, int startLine, int offset,
174             int numLines, int length)
175         {
176             delegate.contentInserted((Buffer)buffer,startLine,offset,numLines,length);
177         } //}}}
178

179         //{{{ contentRemoved() method
180
/**
181          * Called when text is removed from the buffer.
182          * @param buffer The buffer in question
183          * @param startLine The first line
184          * @param offset The start offset, from the beginning of the buffer
185          * @param numLines The number of lines removed
186          * @param length The number of characters removed
187          * @since jEdit 4.3pre3
188          */

189         public void contentRemoved(JEditBuffer buffer, int startLine, int offset,
190             int numLines, int length)
191         {
192             delegate.contentRemoved((Buffer)buffer,startLine,offset,numLines,length);
193         } //}}}
194

195         //{{{ preContentRemoved() method
196
/**
197          * Called when text is about to be removed from the buffer, but is
198          * still present.
199          * @param buffer The buffer in question
200          * @param startLine The first line
201          * @param offset The start offset, from the beginning of the buffer
202          * @param numLines The number of lines to be removed
203          * @param length The number of characters to be removed
204          * @since jEdit 4.3pre3
205          */

206         public void preContentRemoved(JEditBuffer buffer, int startLine, int offset,
207             int numLines, int length)
208         {
209             delegate.preContentRemoved((Buffer)buffer,startLine,offset,numLines,length);
210         } //}}}
211

212         //{{{ transactionComplete() method
213
/**
214          * Called after an undo or compound edit has finished. The text area
215          * uses this event to queue up and collapse cleanup operations so they
216          * are only run once during a long transaction (such as a "Replace All"
217          * operation.)
218          *
219          * @param buffer The buffer in question
220          * @since jEdit 4.3pre3
221          */

222         public void transactionComplete(JEditBuffer buffer)
223         {
224             delegate.transactionComplete((Buffer)buffer);
225         } //}}}
226

227         //{{{ foldHandlerChanged() method
228
/**
229          * Called to notify the text area that folds need to be collapsed if
230          * the "collapseFolds" property is set. This method is called after the
231          * buffer has been loaded, and also if the user changes the fold
232          * handler.
233          *
234          * @param buffer The buffer in question
235          * @since jEdit 4.3pre3
236          */

237         public void foldHandlerChanged(JEditBuffer buffer)
238         {
239             delegate.foldHandlerChanged((Buffer)buffer);
240         } //}}}
241

242         //{{{ foldHandlerChanged() method
243
/**
244          * Called to notify the text area that the buffer has been reloaded.
245          *
246          * @param buffer The buffer in question
247          * @since jEdit 4.3pre3
248          */

249         public void bufferLoaded(JEditBuffer buffer)
250         {
251             delegate.bufferLoaded((Buffer)buffer);
252         } //}}}
253
} //}}}
254
}
255
Popular Tags