diff options
author | Felipe Heidrich <fheidric> | 2007-03-16 20:24:06 +0000 |
---|---|---|
committer | Felipe Heidrich <fheidric> | 2007-03-16 20:24:06 +0000 |
commit | 3bc7acfa36ee31a19eff8e990b6fe8fea469bc66 (patch) | |
tree | bf684b670ab55d5344546cfc779bd3b263757cf6 | |
parent | 346d32de8a4c22517aef1de182546bdcf6b2b660 (diff) | |
download | eclipse.platform.swt-3bc7acfa36ee31a19eff8e990b6fe8fea469bc66.tar.gz eclipse.platform.swt-3bc7acfa36ee31a19eff8e990b6fe8fea469bc66.tar.xz eclipse.platform.swt-3bc7acfa36ee31a19eff8e990b6fe8fea469bc66.zip |
*** empty log message ***
4 files changed, 166 insertions, 5 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/MovementEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/MovementEvent.java new file mode 100644 index 0000000000..ba7bca8a36 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/MovementEvent.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.custom; + +import org.eclipse.swt.events.*; + +/** + * This event is sent when a new offset is required based on the current + * offset and a movement type. + * + * @since 3.3 + */ +public class MovementEvent extends TypedEvent { + + /** + * line start offset (input) + */ + public int lineOffset; + + /** + * line text (input) + */ + public String lineText; + + /** + * the current offset (input) + */ + public int offset; + + /** + * the new offset (input, output) + */ + public int newOffset; + + /** + * the movement type (input) + */ + public int movement; + + static final long serialVersionUID = 3978765487853324342L; + +public MovementEvent(StyledTextEvent e) { + super(e); + lineOffset = e.detail; + lineText = e.text; + movement = e.count; + offset = e.start; + newOffset = e.end; +} +} + + diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/MovementListener.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/MovementListener.java new file mode 100644 index 0000000000..91f0c95683 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/MovementListener.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.custom; + +import org.eclipse.swt.internal.SWTEventListener; + +/** + * This listener is invoked when a new offset is required based on the current + * offset and a movement type. + * + * @see SWT#MOVEMENT_WORD + * @see SWT#MOVEMENT_WORD_END + * @see SWT#MOVEMENT_WORD_START + * @see SWT#MOVEMENT_CHAR + * @see SWT#MOVEMENT_CLUSTER + * + * @since 3.3 + */ +public interface MovementListener extends SWTEventListener { +/** + * This method is called when a new offset is required based on the current + * offset and a movement type. + * + * <p> + * The following event fields are used:<ul> + * <li>event.lineOffset line start offset (input)</li> + * <li>event.lineText line text (input)</li> + * <li>event.movement the movement type (input)</li> + * <li>event.offset the current offset (input)</li> + * <li>event.newOffset the new offset (input, output)</li> + * </ul> + * + * @param event the event + * + * @see MovementEvent + * @see StyledText#addWordMovementListener(MovementListener) + */ +public void getNextOffset (MovementEvent event); +/** + * This method is called when a new offset is required based on the current + * offset and a movement type. + * + * <p> + * The following event fields are used:<ul> + * <li>event.lineOffset line start offset (input)</li> + * <li>event.lineText line text (input)</li> + * <li>event.movement the movement type (input)</li> + * <li>event.offset the current offset (input)</li> + * <li>event.newOffset the new offset (input, output)</li> + * </ul> + * + * @param event the event + * + * @see MovementEvent + * @see StyledText#addWordMovementListener(MovementListener) + */ +public void getPreviousOffset (MovementEvent event); + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextListener.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextListener.java index 58f5861077..d1039eb4d7 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextListener.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextListener.java @@ -24,7 +24,6 @@ StyledTextListener(SWTEventListener listener) { * Process StyledText events by invoking the event's handler. */ public void handleEvent(Event e) { - TextChangedEvent textChangedEvent; switch (e.type) { case StyledText.ExtendedModify: @@ -61,18 +60,32 @@ public void handleEvent(Event e) { ((VerifyKeyListener) eventListener).verifyKey(verifyEvent); e.doit = verifyEvent.doit; break; - case StyledText.TextChanged: - textChangedEvent = new TextChangedEvent((StyledTextContent) e.data); + case StyledText.TextChanged: { + TextChangedEvent textChangedEvent = new TextChangedEvent((StyledTextContent) e.data); ((TextChangeListener) eventListener).textChanged(textChangedEvent); break; + } case StyledText.TextChanging: TextChangingEvent textChangingEvent = new TextChangingEvent((StyledTextContent) e.data, (StyledTextEvent) e); ((TextChangeListener) eventListener).textChanging(textChangingEvent); break; - case StyledText.TextSet: - textChangedEvent = new TextChangedEvent((StyledTextContent) e.data); + case StyledText.TextSet: { + TextChangedEvent textChangedEvent = new TextChangedEvent((StyledTextContent) e.data); ((TextChangeListener) eventListener).textSet(textChangedEvent); break; + } + case StyledText.WordNext: { + MovementEvent wordBoundaryEvent = new MovementEvent((StyledTextEvent) e); + ((MovementListener) eventListener).getNextOffset(wordBoundaryEvent); + ((StyledTextEvent) e).end = wordBoundaryEvent.newOffset; + break; + } + case StyledText.WordPrevious: { + MovementEvent wordBoundaryEvent = new MovementEvent((StyledTextEvent) e); + ((MovementListener) eventListener).getPreviousOffset(wordBoundaryEvent); + ((StyledTextEvent) e).end = wordBoundaryEvent.newOffset; + break; + } } } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java index ff9360c1fe..e4ee273cd5 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java @@ -3276,6 +3276,27 @@ public class SWT { */ public static final int MOVEMENT_WORD = 1 << 2; + /** + * The word end movement type (value is 1<<3). + * + * @see org.eclipse.swt.graphics.TextLayout#getNextOffset(int, int) + * @see org.eclipse.swt.graphics.TextLayout#getPreviousOffset(int, int) + * + * @since 3.3 + */ + public static final int MOVEMENT_WORD_END = 1 << 3; + + /** + * The word start movement type (value is 1<<4). + * + * @see org.eclipse.swt.graphics.TextLayout#getNextOffset(int, int) + * @see org.eclipse.swt.graphics.TextLayout#getPreviousOffset(int, int) + * + * @since 3.3 + */ + public static final int MOVEMENT_WORD_START = 1 << 4; + + /** * Answers a concise, human readable description of the error code. * |