Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 160175 Details for
Bug 230854
[Bidi] support for text input widgets
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Preliminary patch for Text II - modified
230854_7.diff (text/plain), 26.85 KB, created by
Lina Kemmel
on 2010-02-25 06:25:45 EST
(
hide
)
Description:
Preliminary patch for Text II - modified
Filename:
MIME Type:
Creator:
Lina Kemmel
Created:
2010-02-25 06:25:45 EST
Size:
26.85 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.swt >Index: Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BidiSegmentEvent.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BidiSegmentEvent.java,v >retrieving revision 1.14 >diff -u -r1.14 BidiSegmentEvent.java >--- Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BidiSegmentEvent.java 24 Nov 2009 15:18:21 -0000 1.14 >+++ Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BidiSegmentEvent.java 25 Feb 2010 10:57:40 -0000 >@@ -72,36 +72,20 @@ > * </p> > * > * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> >+ * >+// * @deprecated use {@link SegmentEvent} instead. > */ >-public class BidiSegmentEvent extends TypedEvent { >+public class BidiSegmentEvent extends SegmentEvent { > > /** > * line start offset > */ > public int lineOffset; > >- /** >- * line text >- */ >- public String lineText; >- >- /** >- * bidi segments, see above >- */ >- public int[] segments; >- >- /** >- * characters to be used in the segment boundaries (optional) >- * >- * since 3.6 >- */ >- public char[] segmentsChars; >- > static final long serialVersionUID = 3257846571587547957L; > > BidiSegmentEvent(StyledTextEvent e) { > super(e); > lineOffset = e.detail; >- lineText = e.text; > } > } >Index: Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java,v >retrieving revision 1.188 >diff -u -r1.188 Text.java >--- Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java 23 Oct 2009 19:24:37 -0000 1.188 >+++ Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java 25 Feb 2010 11:13:26 -0000 >@@ -14,6 +14,9 @@ > import org.eclipse.swt.internal.win32.*; > import org.eclipse.swt.*; > import org.eclipse.swt.graphics.*; >+import org.eclipse.swt.dnd.Clipboard; >+import org.eclipse.swt.dnd.TextTransfer; >+import org.eclipse.swt.dnd.Transfer; > import org.eclipse.swt.events.*; > > /** >@@ -56,9 +59,18 @@ > */ > public class Text extends Scrollable { > int tabs, oldStart, oldEnd; >- boolean doubleClick, ignoreModify, ignoreVerify, ignoreCharacter; >+ boolean doubleClick, ignoreModify, ignoreVerify, ignoreCharacter, ignoreSegments; > String message; > >+ int[] segments = null; >+ char[] segmentsChars = null; >+ Clipboard clipboard = null; >+ >+ // XXX The following three variables are also required for StyledText, move them to some shared space >+ static final int LineGetSegments = 3007; >+ private static final char LTR_MARK = '\u200e'; >+ private static final char RTL_MARK = '\u200f'; >+ > /** > * The maximum number of characters that can be entered > * into a text widget. >@@ -262,6 +274,20 @@ > } > break; > } >+ case OS.WM_COPY: { >+ if (segments != null) { >+ ignoreSegments = true; >+ Point selection = getSelection(); >+ String segmentsText = getText(selection.x, selection.y); >+ ignoreSegments = false; >+ String text = getNormalizedText(segmentsText, selection.x, selection.y); >+ if (!segmentsText.equals(text)) { >+ if (clipboard == null || clipboard.isDisposed()) clipboard = new Clipboard(display); >+ clipboard.setContents(new Object[] {text}, new Transfer[] {TextTransfer.getInstance()}); >+ } >+ } >+ break; >+ } > } > return code; > } >@@ -304,6 +330,31 @@ > > /** > * Adds the listener to the collection of listeners who will >+ * be notified when the receiver's text is verified, by sending >+ * it one of the messages defined in the <code>SegmentListener</code> >+ * interface. >+ * >+ * @param listener the listener which should be notified >+ * >+ * @exception IllegalArgumentException <ul> >+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> >+ * </ul> >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ * >+ * @see SegmentListener >+ * @see #removeSegmentListener >+ */ >+public void addSegmentListener (SegmentListener listener) { >+ checkWidget (); >+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); >+ addListener(LineGetSegments, new TextSegmentListener(listener)); >+} >+ >+/** >+ * Adds the listener to the collection of listeners who will > * be notified when the control is selected by the user, by sending > * it one of the messages defined in the <code>SelectionListener</code> > * interface. >@@ -383,6 +434,9 @@ > checkWidget (); > if (string == null) error (SWT.ERROR_NULL_ARGUMENT); > string = Display.withCrLf (string); >+ if (hooks(LineGetSegments) || filters(LineGetSegments)) { >+ deprocessText(); >+ } > int length = OS.GetWindowTextLength (handle); > if (hooks (SWT.Verify) || filters (SWT.Verify)) { > string = verifyText (string, length, length, null); >@@ -405,6 +459,11 @@ > OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer); > ignoreCharacter = false; > OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0); >+ >+ if (hooks(LineGetSegments) || filters(LineGetSegments)) { >+ sendEvent(LineGetSegments); >+ processText(); >+ } > } > > static int checkStyle (int style) { >@@ -574,6 +633,27 @@ > return OS.GetSysColor ((bits & OS.ES_READONLY) != 0 ? OS.COLOR_3DFACE : OS.COLOR_WINDOW); > } > >+void deprocessText() { >+ if (segments == null || segments.length == 0) return; >+ Point selection = getSelection(); >+ String text = getText(); >+ int/*64*/ limit = ((int/*64*/)OS.SendMessage (handle, OS.EM_GETLIMITTEXT, 0, 0) - segments.length ) & 0x7FFFFFFF; >+ OS.SendMessage (handle, OS.EM_SETLIMITTEXT, limit, 0); >+ segments = null; >+ segmentsChars = null; >+ TCHAR buffer = new TCHAR (getCodePage (), text, true); >+ OS.SetWindowText (handle, buffer); >+ setSelection(selection); >+} >+ >+public void dispose() { >+ if (clipboard != null && !clipboard.isDisposed()) { >+ clipboard.dispose(); >+ clipboard = null; >+ } >+ super.dispose(); >+} >+ > boolean dragDetect (int /*long*/ hwnd, int x, int y, boolean filter, boolean [] detect, boolean [] consume) { > if (filter) { > int [] start = new int [1], end = new int [1]; >@@ -705,7 +785,9 @@ > * If EM_POSFROMCHAR fails for any other reason, return > * pixel coordinates (0,0). > */ >+ ignoreSegments = true; > int position = getCaretPosition (); >+ ignoreSegments = false; > int /*long*/ caretPos = OS.SendMessage (handle, OS.EM_POSFROMCHAR, position, 0); > if (caretPos == -1) { > caretPos = 0; >@@ -797,6 +879,7 @@ > if (caretLine == endLine) caret = end [0]; > } > } >+ if (!ignoreSegments) caret = untranslateOffset (caret); > if (!OS.IsUnicode && OS.IsDBLocale) caret = mbcsToWcsPos (caret); > return caret; > } >@@ -814,6 +897,7 @@ > public int getCharCount () { > checkWidget (); > int length = OS.GetWindowTextLength (handle); >+ if (!ignoreSegments && segments != null) length -= segments.length; > if (!OS.IsUnicode && OS.IsDBLocale) length = mbcsToWcsPos (length); > return length; > } >@@ -995,10 +1079,65 @@ > if (point == null) error (SWT.ERROR_NULL_ARGUMENT); > int /*long*/ lParam = OS.MAKELPARAM (point.x, point.y); > int position = OS.LOWORD (OS.SendMessage (handle, OS.EM_CHARFROMPOS, 0, lParam)); >+ if (!ignoreSegments) position = untranslateOffset(position); > if (!OS.IsUnicode && OS.IsDBLocale) position = mbcsToWcsPos (position); > return position; > } > >+String getSegmentsText(String text) { // XXX This can likely be moved to some cross-platform code part >+ //String text = getText(); >+ if (text == null || segments == null) return text; >+ int length = text.length(); >+ if (length == 0) return text; >+ int nSegments = segments.length; >+ if (nSegments == 0) return text; >+ >+ char[] oldChars = new char[length]; >+ text.getChars(0, length, oldChars, 0); >+ char[] newChars = new char[length + nSegments]; >+ int charCount = 0, segmentCount = 0; >+ char defaultSeparator = getOrientation() == SWT.RIGHT_TO_LEFT ? RTL_MARK : LTR_MARK; >+ while (charCount < length) { >+ if (segmentCount < nSegments && charCount == segments[segmentCount]) { >+ char separator = segmentsChars != null && segmentsChars.length > segmentCount ? segmentsChars[segmentCount] : defaultSeparator; >+ newChars[charCount + segmentCount++] = separator; >+ } else { >+ newChars[charCount + segmentCount] = oldChars[charCount++]; >+ } >+ } >+ while (segmentCount < nSegments) { >+ segments[segmentCount] = charCount; >+ char separator = segmentsChars != null && segmentsChars.length > segmentCount ? segmentsChars[segmentCount] : defaultSeparator; >+ newChars[charCount + segmentCount++] = separator; >+ } >+ return new String(newChars, 0, newChars.length); >+} >+ >+String getNormalizedText(String text, int start, int end) { // XXX This can likely be moved to cross-platform code >+ //String text = getText(); >+ if (text == null || segments == null) return text; >+ int length = text.length(); >+ if (length == 0) return text; >+ int nSegments = segments.length; >+ if (nSegments == 0) return text; >+ if (end == -1) end = length; >+ if (start > segments[nSegments - 1] || end <= segments[0]) return text; >+ char[] oldChars = new char[length]; >+ text.getChars(0, length, oldChars, 0); >+ char[] newChars = new char[length]; >+ int segmentCount = 0, segmentSubCount = 0; >+ while (start - segmentCount > segments[segmentCount]) segmentCount++; >+ for (int i = 0; i < length; i++) { >+ if (segmentCount < nSegments && i + start - segmentCount == segments[segmentCount]) { >+ ++segmentCount; >+ ++segmentSubCount; >+ } else { >+ newChars[i - segmentSubCount] = oldChars[i]; >+ } >+ } >+ return new String(newChars, 0, newChars.length - segmentSubCount); >+} >+ > /** > * Returns a <code>Point</code> whose x coordinate is the > * character position representing the start of the selected >@@ -1021,6 +1160,10 @@ > checkWidget (); > int [] start = new int [1], end = new int [1]; > OS.SendMessage (handle, OS.EM_GETSEL, start, end); >+ if (!ignoreSegments) { >+ start [0] = untranslateOffset (start [0]); >+ end [0] = untranslateOffset (end [0]); >+ } > if (!OS.IsUnicode && OS.IsDBLocale) { > start [0] = mbcsToWcsPos (start [0]); > end [0] = mbcsToWcsPos (end [0]); >@@ -1063,6 +1206,10 @@ > if (start [0] == end [0]) return ""; > TCHAR buffer = new TCHAR (getCodePage (), length + 1); > OS.GetWindowText (handle, buffer, length + 1); >+ if (!ignoreSegments && segments != null) { >+ String text = buffer.toString (start [0], end [0] - start [0]); >+ return getNormalizedText(text, start [0], end [0]); >+ } > return buffer.toString (start [0], end [0] - start [0]); > } > >@@ -1120,7 +1267,12 @@ > if (length == 0) return ""; > TCHAR buffer = new TCHAR (getCodePage (), length + 1); > OS.GetWindowText (handle, buffer, length + 1); >- return buffer.toString (0, length); >+ String text = buffer.toString (0, length); >+ >+ if (!ignoreSegments && (hooks(LineGetSegments) || filters(LineGetSegments))) { >+ return getNormalizedText(text, 0, -1); >+ } >+ return text; > } > > /** >@@ -1175,6 +1327,10 @@ > */ > public int getTextLimit () { > checkWidget (); >+ // TODO: limit >+ if (segments != null) { >+ return ((int)/*64*/OS.SendMessage (handle, OS.EM_GETLIMITTEXT, 0, 0) - segments.length) & 0x7FFFFFFF; >+ } > return (int)/*64*/OS.SendMessage (handle, OS.EM_GETLIMITTEXT, 0, 0) & 0x7FFFFFFF; > } > >@@ -1251,6 +1407,9 @@ > checkWidget (); > if (string == null) error (SWT.ERROR_NULL_ARGUMENT); > string = Display.withCrLf (string); >+ if (hooks(LineGetSegments) || filters(LineGetSegments)) { >+ deprocessText(); >+ } > if (hooks (SWT.Verify) || filters (SWT.Verify)) { > int [] start = new int [1], end = new int [1]; > OS.SendMessage (handle, OS.EM_GETSEL, start, end); >@@ -1272,6 +1431,11 @@ > ignoreCharacter = true; > OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer); > ignoreCharacter = false; >+ >+ if (hooks(LineGetSegments) || filters(LineGetSegments)) { >+ sendEvent(LineGetSegments); >+ processText(); >+ } > } > > int mbcsToWcsPos (int mbcsPos) { >@@ -1332,6 +1496,31 @@ > OS.SendMessage (handle, OS.WM_PASTE, 0, 0); > } > >+void processText() { >+ if (segments == null || segments.length == 0) return; >+ ignoreSegments = true; >+ String text = getText(); >+ String segmentsText = Display.withCrLf (getSegmentsText (text)); >+ Point selection = getSelection(); >+ /* >+ if (!ignoreVerify) { >+ ignoreVerify = true; >+ setText(segmentsText); >+ ignoreVerify = false; >+ } else { >+ setText(segmentsText); >+ } >+ */ >+ ignoreSegments = false; >+ // TODO: limit >+ int/*64*/ limit = ((int/*64*/)OS.SendMessage (handle, OS.EM_GETLIMITTEXT, 0, 0) + segments.length ) & 0x7FFFFFFF; >+ OS.SendMessage (handle, OS.EM_SETLIMITTEXT, limit, 0); >+ if (segmentsText.length() > limit) segmentsText = segmentsText.substring (0, limit); >+ TCHAR buffer = new TCHAR (getCodePage (), segmentsText, true); >+ OS.SetWindowText (handle, buffer); >+ setSelection(selection); >+} >+ > void releaseWidget () { > super.releaseWidget (); > message = null; >@@ -1351,6 +1540,29 @@ > * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> > * </ul> > * >+ * @see SegmentListener >+ * @see #addSegmentListener >+ */ >+public void removeSegmentListener(SegmentListener listener) { >+ checkWidget(); >+ if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); >+ eventTable.unhook (LineGetSegments, listener); >+} >+ >+/** >+ * Removes the listener from the collection of listeners who will >+ * be notified when the receiver's text is modified. >+ * >+ * @param listener the listener which should no longer be notified >+ * >+ * @exception IllegalArgumentException <ul> >+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> >+ * </ul> >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ * > * @see ModifyListener > * @see #addModifyListener > */ >@@ -1778,6 +1990,57 @@ > } > > /** >+ * Sets the offsets of the receiver's text segments. Text segments are used to >+ * override the default behaviour of the bidirectional algorithm. >+ * Bidirectional reordering can happen within a text segment but not >+ * between two adjacent segments. >+ * <p> >+ * Each text segment is determined by two consecutive offsets in the >+ * <code>segments</code> arrays. The first element of the array should >+ * always be zero and the last one should always be equals to length of >+ * the text. >+ * </p> >+ * <p> >+ * When segments characters are set, the segments are the offsets where >+ * the characters are inserted in the text. >+ * <p> >+ * >+ * @param segments the text segments offset >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> >+ * </ul> >+ * >+ * @see #setSegmentsChars(char[]) >+ */ >+public void setSegments(int[] segments) { >+ checkWidget(); >+ this.segments = segments; >+} >+ >+/** >+ * Sets the characters to be used in the segments boundaries. The segments >+ * are set by calling <code>setSegments(int[])</code>. The application can >+ * use this API to insert Unicode Control Characters in the text to control >+ * the display of the text and bidi reordering. The characters are not >+ * accessible by any other API in </code>TextLayout<code>. >+ * >+ * @param segmentsChars the segments characters >+ * >+ * @exception SWTException <ul> >+ * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> >+ * </ul> >+ * >+ * @see #setSegments(int[]) >+ * >+ * @since 3.6 >+ */ >+public void setSegmentsChars(char[] segmentsChars) { >+ checkWidget(); >+ this.segmentsChars = segmentsChars; >+} >+ >+/** > * Sets the selection. > * <p> > * Indexing is zero based. The range of >@@ -1802,6 +2065,7 @@ > */ > public void setSelection (int start) { > checkWidget (); >+ if (!ignoreSegments && segments != null) start = translateOffset(start); > if (!OS.IsUnicode && OS.IsDBLocale) start = wcsToMbcsPos (start); > OS.SendMessage (handle, OS.EM_SETSEL, start, start); > OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0); >@@ -1834,6 +2098,10 @@ > */ > public void setSelection (int start, int end) { > checkWidget (); >+ if (!ignoreSegments && segments != null) { >+ start = translateOffset(start); >+ end = translateOffset(end); >+ } > if (!OS.IsUnicode && OS.IsDBLocale) { > start = wcsToMbcsPos (start); > end = wcsToMbcsPos (end); >@@ -1956,7 +2224,14 @@ > if (string == null) return; > } > int limit = (int)/*64*/OS.SendMessage (handle, OS.EM_GETLIMITTEXT, 0, 0) & 0x7FFFFFFF; >+ if (segments != null) limit -= segments.length; // TODO > if (string.length () > limit) string = string.substring (0, limit); >+ if (hooks(LineGetSegments) || filters(LineGetSegments)) { >+ Event e = new Event(); >+ e.text = string; >+ sendEvent(LineGetSegments, e); >+ string = getSegmentsText(string); >+ } > TCHAR buffer = new TCHAR (getCodePage (), string, true); > OS.SetWindowText (handle, buffer); > /* >@@ -1966,11 +2241,13 @@ > * notify the application that the text has changed. > * The fix is to send the event. > */ >- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); >- if ((bits & OS.ES_MULTILINE) != 0) { >- sendEvent (SWT.Modify); >- // widget could be disposed at this point >- } >+ //if (!ignoreSegments) { >+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); >+ if ((bits & OS.ES_MULTILINE) != 0) { >+ sendEvent (SWT.Modify); >+ // widget could be disposed at this point >+ } >+ //} > } > > /** >@@ -2000,6 +2277,8 @@ > public void setTextLimit (int limit) { > checkWidget (); > if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO); >+ // TODO: limit >+ if (segments != null) limit += segments.length; > OS.SendMessage (handle, OS.EM_SETLIMITTEXT, limit, 0); > } > >@@ -2042,6 +2321,26 @@ > OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0); > } > >+int translateOffset(int offset) { // XXX This can likely be moved to cross-platform code >+ if (segments == null) return offset; >+ int nSegments = segments.length; >+ if (nSegments == 0) return offset; >+ for (int i = 0; i < nSegments && offset - i >= segments[i]; i++) { >+ offset++; >+ } >+ return offset; >+} >+ >+int untranslateOffset(int offset) { // XXX This can likely be moved to cross-platform code >+ if (segments == null) return offset; >+ int nSegments = segments.length; >+ if (nSegments == 0) return offset; >+ for (int i = 0; i < nSegments && offset > segments[i]; i++) { >+ offset--; >+ } >+ return offset; >+} >+ > String verifyText (String string, int start, int end, Event keyEvent) { > if (ignoreVerify) return string; > Event event = new Event (); >@@ -2154,12 +2453,54 @@ > } > > int /*long*/ windowProc (int /*long*/ hwnd, int msg, int /*long*/ wParam, int /*long*/ lParam) { >+ boolean processSegments = false; >+ int result; >+ switch (msg) { >+ case OS.WM_KEYDOWN: { >+ if (hooks(LineGetSegments) || filters(LineGetSegments)) { >+ if (wParam == OS.VK_DELETE) { >+ processSegments = true; >+ } >+ else if ((wParam == OS.VK_RIGHT || wParam == OS.VK_LEFT) >+ && (hooks(LineGetSegments) || filters(LineGetSegments)) >+ && OS.GetKeyState(OS.VK_CONTROL) >= 0 && OS.GetKeyState(OS.VK_MENU) >= 0) { >+ // TODO send key event or handle selection instead >+ processSegments = true; >+ } >+ } >+ break; >+ } >+ case OS.WM_STYLECHANGED: { >+ if (wParam == OS.GWL_EXSTYLE && (hooks(LineGetSegments) || filters(LineGetSegments))) { >+ // TODO: define a STYLESTRUCT >+ int/*long*/[] style = new int/*long*/[2]; >+ OS.MoveMemory(style, lParam, OS.PTR_SIZEOF * 2); >+ processSegments = ((style[0] ^ style[1]) & OS.WS_EX_RTLREADING) != 0; >+ } >+ break; >+ } >+ case OS.WM_PASTE: >+ case OS.WM_CUT: >+ case OS.WM_CLEAR: >+ case OS.WM_UNDO: >+ case OS.WM_CHAR: { >+ processSegments = hooks(LineGetSegments) || filters(LineGetSegments); >+ break; >+ } >+ } >+ if (processSegments) { >+ deprocessText(); >+ } > if (msg == OS.EM_UNDO) { > int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); > if ((bits & OS.ES_MULTILINE) == 0) { >- LRESULT result = wmClipboard (OS.EM_UNDO, wParam, lParam); >- if (result != null) return result.value; >- return callWindowProc (hwnd, OS.EM_UNDO, wParam, lParam); >+ result = wmClipboard (OS.EM_UNDO, wParam, lParam).value; >+ if (result == 0) { >+ result = callWindowProc (hwnd, OS.EM_UNDO, wParam, lParam); >+ } >+ sendEvent(LineGetSegments); >+ processText(); >+ return result; > } > } > if (msg == Display.SWT_RESTORECARET) { >@@ -2167,7 +2508,12 @@ > callWindowProc (hwnd, OS.WM_SETFOCUS, 0, 0); > return 1; > } >- return super.windowProc (hwnd, msg, wParam, lParam); >+ int code = super.windowProc (hwnd, msg, wParam, lParam); >+ if (processSegments) { >+ sendEvent(LineGetSegments, new Event()); >+ processText(); >+ } >+ return code; > } > > LRESULT WM_CHAR (int /*long*/ wParam, int /*long*/ lParam) { >Index: Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java,v >retrieving revision 1.430 >diff -u -r1.430 OS.java >--- Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java 10 Feb 2010 19:22:19 -0000 1.430 >+++ Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java 25 Feb 2010 10:57:42 -0000 >@@ -2114,6 +2114,7 @@ > public static final int WM_SETTINGCHANGE = 0x1A; > public static final int WM_SHOWWINDOW = 0x18; > public static final int WM_SIZE = 0x5; >+ public static final int WM_STYLECHANGED = 0x007D; > public static final int WM_SYSCHAR = 0x106; > public static final int WM_SYSCOLORCHANGE = 0x15; > public static final int WM_SYSCOMMAND = 0x112; >Index: Eclipse SWT/common/org/eclipse/swt/events/SegmentEvent.java >=================================================================== >RCS file: Eclipse SWT/common/org/eclipse/swt/events/SegmentEvent.java >diff -N Eclipse SWT/common/org/eclipse/swt/events/SegmentEvent.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse SWT/common/org/eclipse/swt/events/SegmentEvent.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,42 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2010 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.events; >+ >+import org.eclipse.swt.widgets.Event; >+ >+/** >+ * @since 3.6 >+ * >+ */ >+public class SegmentEvent extends TypedEvent { >+ /** >+ * line text >+ */ >+ public String lineText; >+ >+ /** >+ * bidi segments, see above >+ */ >+ public int[] segments; >+ >+ /** >+ * characters to be employed on the segment boundaries >+ */ >+ public char[] segmentsChars; >+ >+ >+ private static final long serialVersionUID = -89306787890624323L; >+ >+ public SegmentEvent(Event e) { >+ super(e); >+ lineText = e.text; >+ } >+} >Index: Eclipse SWT/common/org/eclipse/swt/widgets/SegmentListener.java >=================================================================== >RCS file: Eclipse SWT/common/org/eclipse/swt/widgets/SegmentListener.java >diff -N Eclipse SWT/common/org/eclipse/swt/widgets/SegmentListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse SWT/common/org/eclipse/swt/widgets/SegmentListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2010 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.widgets; >+ >+import org.eclipse.swt.events.SegmentEvent; >+import org.eclipse.swt.internal.SWTEventListener; >+ >+/** >+ * This listener interface may be implemented in order to receive >+ * SegmentEvents. >+ * @see SegmentEvent >+ */ >+public interface SegmentListener extends SWTEventListener { >+ >+/** >+ * This method is called when a line needs to be reordered for >+ * measuring or rendering in a bidi locale. >+ * <p> >+ * The following event fields are used:<ul> >+ * <li>event.lineText line text (input)</li> >+ * <li>event.segmentsChars characters that should be inserted</li> >+ * <li>event.segments text offsets for segment characters</li></ul> >+ * >+ * @param event the given event >+ * @see SegmentEvent >+ * @see org.eclipse.swt.custom.BidiSegmentListener >+ */ >+public void lineGetSegments(SegmentEvent event); >+ >+} >Index: Eclipse SWT/common/org/eclipse/swt/widgets/TextSegmentListener.java >=================================================================== >RCS file: Eclipse SWT/common/org/eclipse/swt/widgets/TextSegmentListener.java >diff -N Eclipse SWT/common/org/eclipse/swt/widgets/TextSegmentListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse SWT/common/org/eclipse/swt/widgets/TextSegmentListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,44 @@ >+package org.eclipse.swt.widgets; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SegmentEvent; >+import org.eclipse.swt.internal.SWTEventListener; >+ >+public class TextSegmentListener extends TypedListener { >+ /** >+ */ >+ TextSegmentListener(SWTEventListener listener) { >+ super(listener); >+ } >+ /** >+ * Process Text SegmentEvent by invoking the event handler. >+ * >+ * @param e the event to handle >+ */ >+ public void handleEvent(Event e) { >+ >+ switch (e.type) { >+ case Text.LineGetSegments: { >+ if (e.widget instanceof Text) { >+ Text text = (Text)e.widget; // TODO use another event instead >+ text.checkWidget(); >+ String string = e.text == null ? text.getText() : e.text; >+ SegmentEvent segmentEvent = new SegmentEvent(e); >+ segmentEvent.lineText = string; >+ ((SegmentListener) eventListener).lineGetSegments(segmentEvent); >+ >+ if (segmentEvent.segments != null) { >+ for (int i = 1, segmentCount = segmentEvent.segments.length, lineLength = string.length(); i < segmentCount; i++) { >+ if (segmentEvent.segments[i] < segmentEvent.segments[i - 1] || segmentEvent.segments[i] > lineLength) { >+ SWT.error(SWT.ERROR_INVALID_ARGUMENT); >+ } >+ } >+ } >+ text.setSegments(segmentEvent.segments); // TODO use another event instead >+ text.setSegmentsChars(segmentEvent.segmentsChars); >+ } >+ break; >+ } >+ } >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 230854
:
105752
|
157717
|
158504
|
158513
|
158881
|
158882
|
159820
|
160175
|
160176
|
160483
|
160652
|
160692
|
160693
|
160984
|
161174
|
162293
|
163180
|
178628
|
178635
|
179537
|
179540
|
179583
|
180564
|
185633
|
188252
|
188611
|
188635
|
191558
|
191583
|
191823
|
191860
|
193759
|
194112
|
204679
|
204835
|
204836