132 |
// collapse elements if the removal spans more than 1 line |
// collapse elements if the removal spans more than 1 line |
133 |
Element newEl = createLeafElement(rootElement, |
Element newEl = createLeafElement(rootElement, |
134 |
SimpleAttributeSet.EMPTY, |
SimpleAttributeSet.EMPTY, |
135 |
start, end - len); |
start, end); |
136 |
rootElement.replace(i1, i2 - i1, new Element[]{ newEl }); |
rootElement.replace(i1, i2 - i1 + 1, new Element[]{ newEl }); |
137 |
} |
} |
138 |
} |
} |
139 |
|
|
147 |
Element root = getDefaultRootElement(); |
Element root = getDefaultRootElement(); |
148 |
return root.getElement(root.getElementIndex(pos)); |
return root.getElement(root.getElementIndex(pos)); |
149 |
} |
} |
150 |
|
|
151 |
|
/** |
152 |
|
* Inserts a string into the document. If the document property |
153 |
|
* '<code>filterNewLines</code>' is set to <code>Boolean.TRUE</code>, then |
154 |
|
* all newlines in the inserted string are replaced by space characters, |
155 |
|
* otherwise the superclasses behaviour is executed. |
156 |
|
* |
157 |
|
* Inserting content causes a write lock to be acquired during this method |
158 |
|
* call. |
159 |
|
* |
160 |
|
* @param offs the offset at which to insert the string |
161 |
|
* @param str the string to be inserted |
162 |
|
* @param atts the text attributes of the string to be inserted |
163 |
|
* |
164 |
|
* @throws BadLocationException |
165 |
|
*/ |
166 |
|
public void insertString(int offs, String str, AttributeSet atts) |
167 |
|
throws BadLocationException |
168 |
|
{ |
169 |
|
String string = str; |
170 |
|
if (Boolean.TRUE.equals(getProperty("filterNewlines"))) |
171 |
|
string = str.replaceAll("\n", " "); |
172 |
|
super.insertString(offs, string, atts); |
173 |
|
} |
174 |
} |
} |