1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.swt.custom;
12
13 import org.eclipse.swt.SWT;
14 import org.eclipse.swt.widgets.Composite;
15
16
17
18
19
20
21
22
23 public class JaretStyledText extends StyledText {
24
25 public JaretStyledText(Composite arg0, int arg1) {
26 super(arg0, arg1);
27 }
28
29 public void setCaretOffsetJaret(int offset) {
30 checkWidget();
31 int length = getCharCount();
32
33 if (length > 0 && offset != caretOffset) {
34 if (offset < 0) {
35 caretOffset = 0;
36 } else if (offset > length) {
37 caretOffset = length;
38 } else {
39 if (isLineDelimiter(offset)) {
40 SWT.error(SWT.ERROR_INVALID_ARGUMENT);
41 }
42 caretOffset = offset;
43 }
44 }
45 setCaretLocation();
46 }
47 }