Mercurial > projects > dwt-addons
comparison dwtx/jface/text/source/ICharacterPairMatcher.d @ 129:eb30df5ca28b
Added JFace Text sources
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 23 Aug 2008 19:10:48 +0200 |
parents | |
children | c4fb132a086c |
comparison
equal
deleted
inserted
replaced
128:8df1d4193877 | 129:eb30df5ca28b |
---|---|
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 dwtx.jface.text.source.ICharacterPairMatcher; | |
14 | |
15 import dwt.dwthelper.utils; | |
16 | |
17 import dwtx.jface.text.IDocument; | |
18 import dwtx.jface.text.IRegion; | |
19 | |
20 /** | |
21 * A character pair matcher finds to a character at a certain document offset | |
22 * the matching peer character. It is the matchers responsibility to define the | |
23 * concepts of "matching" and "peer". The matching process starts at a given | |
24 * offset. Starting of this offset, the matcher chooses a character close to | |
25 * this offset. The anchor defines whether the chosen character is left or right | |
26 * of the initial offset. The matcher then searches for the matching peer | |
27 * character of the chosen character and if it finds one, delivers the minimal | |
28 * region of the document that contains both characters. | |
29 * | |
30 * @since 2.1 | |
31 */ | |
32 public interface ICharacterPairMatcher { | |
33 | |
34 /** | |
35 * Indicates the anchor value "right". | |
36 */ | |
37 int RIGHT= 0; | |
38 /** | |
39 * Indicates the anchor value "left". | |
40 */ | |
41 int LEFT= 1; | |
42 | |
43 | |
44 /** | |
45 * Disposes this pair matcher. | |
46 */ | |
47 void dispose(); | |
48 | |
49 /** | |
50 * Clears this pair matcher. I.e. the matcher throws away all state it might | |
51 * remember and prepares itself for a new call of the <code>match</code> | |
52 * method. | |
53 */ | |
54 void clear(); | |
55 | |
56 /** | |
57 * Starting at the given offset, the matcher chooses a character close to this offset. | |
58 * The matcher then searches for the matching peer character of the chosen character | |
59 * and if it finds one, returns the minimal region of the document that contains both characters. | |
60 * It returns <code>null</code> if there is no peer character. | |
61 * | |
62 * @param iDocument the document to work on | |
63 * @param i the start offset | |
64 * @return the minimal region containing the peer characters | |
65 */ | |
66 IRegion match(IDocument iDocument, int i); | |
67 | |
68 /** | |
69 * Returns the anchor for the region of the matching peer characters. The anchor | |
70 * says whether the character that has been chosen to search for its peer character | |
71 * has been left or right of the initial offset. | |
72 * | |
73 * @return <code>RIGHT</code> or <code>LEFT</code> | |
74 */ | |
75 int getAnchor(); | |
76 } |