155
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2005 IBM Corporation and others.
|
|
3 * All rights reserved. This program and the accompanying materials
|
|
4 * are made available under the terms of the Eclipse Public License v1.0
|
|
5 * which accompanies this distribution, and is available at
|
|
6 * http://www.eclipse.org/legal/epl-v10.html
|
|
7 *
|
|
8 * Contributors:
|
|
9 * IBM Corporation - initial API and implementation
|
|
10 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
|
12 *******************************************************************************/
|
|
13 module dwt.custom.BidiSegmentEvent;
|
|
14
|
|
15
|
|
16 import dwt.events.TypedEvent;
|
|
17 import dwt.custom.StyledTextEvent;
|
|
18
|
|
19 /**
|
|
20 * This event is sent to BidiSegmentListeners when a line is to
|
|
21 * be measured or rendered in a bidi locale. The segments field is
|
|
22 * used to specify text ranges in the line that should be treated as
|
|
23 * separate segments for bidi reordering. Each segment will be reordered
|
|
24 * and rendered separately.
|
|
25 * <p>
|
|
26 * The elements in the segments field specify the start offset of
|
|
27 * a segment relative to the start of the line. They must follow
|
|
28 * the following rules:
|
|
29 * <ul>
|
|
30 * <li>first element must be 0
|
|
31 * <li>elements must be in ascending order and must not have duplicates
|
|
32 * <li>elements must not exceed the line length
|
|
33 * </ul>
|
|
34 * In addition, the last element may be set to the end of the line
|
|
35 * but this is not required.
|
|
36 *
|
|
37 * The segments field may be left null if the entire line should
|
|
38 * be reordered as is.
|
|
39 * </p>
|
|
40 * A BidiSegmentListener may be used when adjacent segments of
|
|
41 * right-to-left text should not be reordered relative to each other.
|
|
42 * For example, within a Java editor, you may wish multiple
|
|
43 * right-to-left string literals to be reordered differently than the
|
|
44 * bidi algorithm specifies.
|
|
45 *
|
|
46 * Example:
|
|
47 * <pre>
|
|
48 * stored line = "R1R2R3" + "R4R5R6"
|
|
49 * R1 to R6 are right-to-left characters. The quotation marks
|
|
50 * are part of the line text. The line is 13 characters long.
|
|
51 *
|
|
52 * segments = null:
|
|
53 * entire line will be reordered and thus the two R2L segments
|
|
54 * swapped (as per the bidi algorithm).
|
|
55 * visual line (rendered on screen) = "R6R5R4" + "R3R2R1"
|
|
56 *
|
|
57 * segments = [0, 5, 8]
|
|
58 * "R1R2R3" will be reordered, followed by [blank]+[blank] and
|
|
59 * "R4R5R6".
|
|
60 * visual line = "R3R2R1" + "R6R5R4"
|
|
61 * </pre>
|
|
62 */
|
|
63 public class BidiSegmentEvent : TypedEvent {
|
|
64
|
|
65 /**
|
|
66 * line start offset
|
|
67 */
|
|
68 public int lineOffset;
|
|
69
|
|
70 /**
|
|
71 * line text
|
|
72 */
|
|
73 public char[] lineText;
|
|
74
|
|
75 /**
|
|
76 * bidi segments, see above
|
|
77 */
|
|
78 public int[] segments;
|
|
79
|
|
80 this(StyledTextEvent e) {
|
|
81 super(cast(Object)e);
|
|
82 lineOffset = e.detail;
|
|
83 lineText = e.text;
|
|
84 }
|
|
85 }
|