Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » BracketInserter, "mirrored" text in brackets
BracketInserter, "mirrored" text in brackets [message #587725] Thu, 01 January 2009 03:34
Bret Schuhmacher is currently offline Bret SchuhmacherFriend
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();
Previous Topic:BracketInserter, "mirrored" text in brackets
Next Topic:Dependency between eclipse plugins?
Goto Forum:
  


Current Time: Mon Jun 14 05:39:12 GMT 2021

Powered by FUDForum. Page generated in 0.02020 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top