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