BracketInserter, "mirrored" text in brackets [message #38934] |
Thu, 01 January 2009 03:34 |
Bret Schuhmacher Messages: 26 Registered: July 2009 |
Junior Member |
|
|
This is kind of weird... I borrowed the following code from
BracketInserter verbatim. It does close parens, braces, etc. and puts the
cursor in between the characters, but when I type I get 2 of whatever I
type - one before the cursor, one after, resulting in "mirrored" text. If
I type "abc", I get "abccba", and the cursor is right in the middle the
whole time. FWIW, I yanked the code from a 3.4 source base and applied it
to a 3.2 plugin I'm working on. This is on Windows XP, though it
shouldn't matter. Anyone understand LinkedModeModel well enough to
comment, please?
Thanks,
Bret
LinkedModeModel model = new LinkedModeModel();
model.addLinkingListener(this);
model.addGroup(group);
model.forceInstall();
level.fOffset = offset;
level.fLength = 2;
// set up position tracking for our magic peers
if (fBracketLevelStack.size() == 1) {
document.addPositionCategory(CATEGORY);
document.addPositionUpdater(fUpdater);
}
level.fFirstPosition = new Position(offset , 0);
level.fSecondPosition = new Position(offset + 1, 1);
document.addPosition(CATEGORY, level.fFirstPosition);
document.addPosition(CATEGORY, level.fSecondPosition);
level.fUI = new EditorLinkedModeUI(model, sourceViewer);
level.fUI.setSimpleMode(true);
level.fUI.setExitPolicy(new ExitPolicy(closingCharacter,
getEscapeCharacter(closingCharacter),
fBracketLevelStack));
level.fUI.setExitPosition(sourceViewer, offset + 2, 0,
Integer.MAX_VALUE);
level.fUI.setCyclingMode(LinkedModeUI.CYCLE_NEVER);
level.fUI.enter();
IRegion newSelection = level.fUI.getSelectedRegion();
|
|
|
Powered by
FUDForum. Page generated in 0.02218 seconds