Lines 303-324
Link Here
|
303 |
this.caretPosition = caretPosition; |
303 |
this.caretPosition = caretPosition; |
304 |
} |
304 |
} |
305 |
|
305 |
|
|
|
306 |
/** |
307 |
* Gets the replaced text. This is the text that was selected |
308 |
* by the user and it is replaced by inserted text. |
309 |
* |
310 |
* <p>The selected text is removed from document before <code>insert</code> method. |
311 |
* |
312 |
* @return The replaced text. |
313 |
*/ |
314 |
public String getReplacedText() { |
315 |
return replacedText; |
316 |
} |
317 |
|
306 |
// ------------------------------------------------------------------- |
318 |
// ------------------------------------------------------------------- |
307 |
// Private implementation |
319 |
// Private implementation |
308 |
// ------------------------------------------------------------------- |
320 |
// ------------------------------------------------------------------- |
309 |
|
321 |
|
310 |
private String insertionText = null; |
322 |
private String insertionText = null; |
|
|
323 |
private String replacedText = null; |
311 |
private int caretPosition = -1; |
324 |
private int caretPosition = -1; |
312 |
|
325 |
|
313 |
private MutableContext(JTextComponent c, Position offset, String typedText) { |
326 |
private MutableContext(JTextComponent c, Position offset, String typedText, String replacedText) { |
314 |
super(c, offset, typedText); |
327 |
super(c, offset, typedText); |
|
|
328 |
this.replacedText = replacedText; |
315 |
} |
329 |
} |
316 |
|
330 |
|
317 |
private static final class Accessor extends TypingHooksSpiAccessor { |
331 |
private static final class Accessor extends TypingHooksSpiAccessor { |
318 |
|
332 |
|
319 |
@Override |
333 |
@Override |
320 |
public MutableContext createTtiContext(JTextComponent c, Position offset, String typedText) { |
334 |
public MutableContext createTtiContext(JTextComponent c, Position offset, String typedText, String replacedText) { |
321 |
return new MutableContext(c, offset, typedText); |
335 |
return new MutableContext(c, offset, typedText, replacedText); |
322 |
} |
336 |
} |
323 |
|
337 |
|
324 |
@Override |
338 |
@Override |