Home » Eclipse Projects » Eclipse Platform » BracketInserter, "mirrored" text in brackets
BracketInserter, "mirrored" text in brackets [message #333732] |
Tue, 30 December 2008 13:13 |
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". FWIW, I yanked the code from a 3.4 install
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();
|
|
|
Re: BracketInserter, "mirrored" text in brackets [message #333774 is a reply to message #333732] |
Mon, 05 January 2009 08:34 |
Tom Hofmann Messages: 770 Registered: July 2009 |
Senior Member |
|
|
Bret,
did you also use an ExclusivePositionUpdater for your position updater?
-tom
Bret Schuhmacher wrote:
> 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". FWIW, I yanked the
> code from a 3.4 install 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();
>
|
|
|
Goto Forum:
Current Time: Fri Nov 08 21:56:26 GMT 2024
Powered by FUDForum. Page generated in 0.03853 seconds
|