diff dwtx/jface/text/ITextSelection.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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwtx/jface/text/ITextSelection.d	Sat Aug 23 19:10:48 2008 +0200
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
+ *******************************************************************************/
+module dwtx.jface.text.ITextSelection;
+
+import dwt.dwthelper.utils;
+
+
+
+import dwtx.jface.viewers.ISelection;
+
+
+/**
+ * This interface represents a textual selection. A text selection is a range of
+ * characters. Although a text selection is a snapshot taken at a particular
+ * point in time, it must not copy the line information and the selected text
+ * from the selection provider.
+ * <p>
+ * If, for example, the selection provider is a text viewer (
+ * {@link dwtx.jface.text.ITextViewer}), and a text selection is created
+ * for the range [5, 10], the line formation for the 5th character must not be
+ * determined and remembered at the point of creation. It can rather be
+ * determined at the point, when <code>getStartLine</code> is called. If the
+ * source viewer range [0, 15] has been changed in the meantime between the
+ * creation of the text selection object and the invocation of
+ * <code>getStartLine</code>, the returned line number may differ from the
+ * line number of the 5th character at the point of creation of the text
+ * selection object.
+ * <p>
+ * The contract of this interface is that weak in order to allow for efficient
+ * implementations.</p>
+ * <p>
+ * Clients may implement this interface or use the default implementation
+ * provided by {@link dwtx.jface.text.TextSelection}.</p>
+ *
+ * @see dwtx.jface.text.TextSelection
+ */
+public interface ITextSelection : ISelection {
+
+    /**
+     * Returns the offset of the selected text.
+     *
+     * @return the offset of the selected text
+     */
+    int getOffset();
+
+    /**
+     * Returns the length of the selected text.
+     *
+     * @return the length of the selected text
+     */
+    int getLength();
+
+    /**
+     * Returns number of the line containing the offset of the selected text.
+     * If the underlying text has been changed between the creation of this
+     * selection object and the call of this method, the value returned might
+     * differ from what it would have been at the point of creation.
+     *
+     * @return the start line of this selection or <code>-1</code> if there is no valid line information
+     */
+    int getStartLine();
+
+    /**
+     * Returns the number of the line containing the last character of the selected text.
+     * If the underlying text has been changed between the creation of this
+     * selection object and the call of this method, the value returned might
+     * differ from what it would have been at the point of creation.
+     *
+     * @return the end line of this selection or <code>-1</code> if there is no valid line information
+     */
+    int getEndLine();
+
+    /**
+     * Returns the selected text.
+     * If the underlying text has been changed between the creation of this
+     * selection object and the call of this method, the value returned might
+     * differ from what it would have been at the point of creation.
+     *
+     * @return the selected text or <code>null</code> if there is no valid text information
+     */
+    String getText();
+}
+