1 /*******************************************************************************
2 * Copyright (c) 2000, 2012 IBM Corporation and others.
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
9 * SPDX-License-Identifier: EPL-2.0
12 * IBM Corporation - initial API and implementation
13 *******************************************************************************/
14 package org.eclipse.swt.custom;
17 import org.eclipse.swt.events.*;
20 * This event is sent to BidiSegmentListeners when a line is to
21 * be measured or rendered in a bidi locale.
22 * The segments field can be used in conjunction with the segmentsChars
23 * field or by itself. Setting only the segmentsChars field has no effect.
24 * When used by itself, the segments field specify text ranges in the line
25 * that should be treated as separate segments for bidi reordering. Each
26 * segment will be reordered and rendered separately.
28 * The elements in the segments field specify the start offset of
29 * a segment relative to the start of the line. They must follow
30 * the following rules:</p>
32 * <li>elements must be in ascending order and must not have duplicates
33 * <li>elements must not exceed the line length
35 * In addition, the first element may be set to zero and the last element may
36 * be set to the end of the line but this is not required.
38 * The segments field may be left null if the entire line should
41 * A BidiSegmentListener may be used when adjacent segments of
42 * right-to-left text should not be reordered relative to each other.
43 * For example, within a Java editor, you may wish multiple
44 * right-to-left string literals to be reordered differently than the
45 * bidi algorithm specifies.
49 * stored line = "R1R2R3" + "R4R5R6"
50 * R1 to R6 are right-to-left characters. The quotation marks
51 * are part of the line text. The line is 13 characters long.
54 * entire line will be reordered and thus the two R2L segments
55 * swapped (as per the bidi algorithm).
56 * visual line (rendered on screen) = "R6R5R4" + "R3R2R1"
58 * segments = [0, 5, 8]
59 * "R1R2R3" will be reordered, followed by [blank]+[blank] and
61 * visual line = "R3R2R1" + "R6R5R4"
65 * The segments and segmentsChars fields can be used together to obtain different
66 * types of bidi reordering and text display. The application can use these two fields
67 * to insert Unicode Control Characters in specific offsets in the line, the character
68 * at segmentsChars[i] is inserted at the offset specified by segments[i]. When both fields
69 * are set, the rules for the segments field are less restrictive:
72 * <li>elements must be in ascending order, duplicates are allowed
73 * <li>elements must not exceed the line length
76 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
78 public class BidiSegmentEvent extends SegmentEvent {
80 static final long serialVersionUID = -3712986188155944253L;
82 BidiSegmentEvent(StyledTextEvent e) {