129
|
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
|
131
|
14
|
|
15 import dwtx.jface.text.formatter.MultiPassContentFormatter; // packageimport
|
|
16 import dwtx.jface.text.formatter.ContextBasedFormattingStrategy; // packageimport
|
|
17 import dwtx.jface.text.formatter.FormattingContext; // packageimport
|
|
18 import dwtx.jface.text.formatter.IContentFormatterExtension; // packageimport
|
|
19 import dwtx.jface.text.formatter.IFormattingStrategyExtension; // packageimport
|
|
20 import dwtx.jface.text.formatter.IContentFormatter; // packageimport
|
|
21 import dwtx.jface.text.formatter.FormattingContextProperties; // packageimport
|
|
22 import dwtx.jface.text.formatter.ContentFormatter; // packageimport
|
|
23 import dwtx.jface.text.formatter.IFormattingContext; // packageimport
|
|
24
|
129
|
25 module dwtx.jface.text.formatter.IFormattingStrategy;
|
|
26
|
|
27 import dwt.dwthelper.utils;
|
|
28
|
|
29
|
|
30 /**
|
|
31 * A formatting strategy is assumed to be specialized on formatting text
|
|
32 * of a particular content type. Each formatting process calls the strategy's
|
|
33 * methods in the following sequence:
|
|
34 * <ul>
|
|
35 * <li><code>formatterStarts</code>
|
|
36 * <li><code>format</code>
|
|
37 * <li><code>formatterStops</code>
|
|
38 * </ul>
|
|
39 * <p>
|
|
40 * This interface must be implemented by clients. Implementers should be registered with
|
|
41 * a content formatter in order get involved in the formatting process.</p>
|
|
42 */
|
|
43 public interface IFormattingStrategy {
|
|
44
|
|
45 /**
|
|
46 * Informs the strategy about the start of a formatting process in which it will
|
|
47 * participate.
|
|
48 *
|
|
49 * @param initialIndentation the indent string of the first line at which the
|
|
50 * overall formatting process starts.
|
|
51 */
|
|
52 void formatterStarts(String initialIndentation);
|
|
53
|
|
54 /**
|
|
55 * Formats the given string. During the formatting process this strategy must update
|
|
56 * the given character positions according to the changes applied to the given string.
|
|
57 *
|
|
58 * @param content the initial string to be formatted
|
|
59 * @param isLineStart indicates whether the beginning of content is a line start in its document
|
|
60 * @param indentation the indentation string to be used
|
|
61 * @param positions the character positions to be updated
|
|
62 * @return the formatted string
|
|
63 */
|
|
64 String format(String content, bool isLineStart, String indentation, int[] positions);
|
|
65
|
|
66 /**
|
|
67 * Informs the strategy that the formatting process in which it has participated
|
|
68 * has been finished.
|
|
69 */
|
|
70 void formatterStops();
|
|
71 }
|