From 0f05234334d8959ed30f1918f8742f2e22b4101c Mon Sep 17 00:00:00 2001
From: Martin Oberhuber
- * This class may be instantiated; it is not intended to be subclassed.
- * Not to be implemented by clients.
- * @author Michael Scharf
*
* EXPERIMENTAL. This class or interface has been added as
- * part of a work in progress. There is no guarantee that this API will
- * work or that it will remain the same. Please do not use this API without
- * consulting with the Target Management team.
+ * part of a work in progress. There is no guarantee that this API will work or
+ * that it will remain the same. Please do not use this API without consulting
+ * with the Target Management
+ * team.
* Note: Implementations of this interface has to be thread safe.
- * Note: This interface is not intended to be implemented by clients.
+ * A writable matrix of characters and {@link Style}. This is intended to be
+ * the low level representation of the text of a Terminal. Higher layers are
+ * responsible to fill the text and styles into this representation.
+ *
+ * Note: Implementations of this interface has to be thread safe.
+ * To illustrate shift, here is some sample data:
*
- * Solution: Take a snapshot of the terminal and use the snapshot to draw
- * the content. There is no danger that the data structure get changed while
- * you draw. There are also methods to find out what has changed to minimize
- * the number of lines that get redrawn. Drawing optimization: To optimize redrawing of changed lines, this class keeps
- * track of lines that have changed since the previous snapshot. Scroll optimization: Often new lines are appended at the bottom of the
- * terminal and the rest of the lines are scrolled up. In this case all lines would be
- * marked as changed. To optimize for this
- * case, {@link #updateSnapshot(boolean)} can be called with '\000'
chars
+ * Shifts some lines up or down. The "empty" space is filled with '\000'
chars
* and null
{@link Style}
*
@@ -100,7 +101,7 @@ public interface ITerminalTextData extends ITerminalTextDataReadOnly {
* 0 aaaa
* 1 cccc
* 2 dddd
- * 3
+ * 3
* 4 eeee
*
*
@@ -108,7 +109,7 @@ public interface ITerminalTextData extends ITerminalTextDataReadOnly {
* Shift a region of 3 lines down by one line shift(1,3,1)
*
* 0 aaaa
- * 1
+ * 1
* 2 bbbb
* 3 cccc
* 4 eeee
@@ -119,7 +120,7 @@ public interface ITerminalTextData extends ITerminalTextDataReadOnly {
* Negative number means scroll down, positive scroll up (see example above).
*/
void scroll(int startLine, int size, int shift);
-
+
/**Adds a new line to the terminal. If maxHeigth is reached, the entire terminal
* will be scrolled. Else a line will be added.
*/
@@ -145,7 +146,7 @@ public interface ITerminalTextData extends ITerminalTextDataReadOnly {
* @param length
*/
void copyRange(ITerminalTextData source, int sourceStartLine, int destStartLine,int length);
-
+
void setCursorLine(int line);
void setCursorColumn(int column);
}
\ No newline at end of file
diff --git a/org.eclipse.tm.terminal/src/org/eclipse/tm/terminal/model/ITerminalTextDataSnapshot.java b/org.eclipse.tm.terminal/src/org/eclipse/tm/terminal/model/ITerminalTextDataSnapshot.java
index 7d4065e7581..652e1041407 100644
--- a/org.eclipse.tm.terminal/src/org/eclipse/tm/terminal/model/ITerminalTextDataSnapshot.java
+++ b/org.eclipse.tm.terminal/src/org/eclipse/tm/terminal/model/ITerminalTextDataSnapshot.java
@@ -1,11 +1,11 @@
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems, Inc. 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
+ * 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:
+ * Contributors:
* Michael Scharf (Wind River) - initial API and implementation
*******************************************************************************/
package org.eclipse.tm.terminal.model;
@@ -13,62 +13,73 @@ package org.eclipse.tm.terminal.model;
/**
* This class maintains a snapshot of an instance of {@link ITerminalTextData}.
* While the {@link ITerminalTextData} continues changing, the snapshot remains
- * unchanged until the next snapshot is taken by calling {@link #updateSnapshot(boolean)}.
- * This is important, because the {@link ITerminalTextData} might get
- * modified by another thread. Suppose you would want to draw the content of
- * the {@link ITerminalTextData} using the following loop:
+ * unchanged until the next snapshot is taken by calling
+ * {@link #updateSnapshot(boolean)}. This is important, because the
+ * {@link ITerminalTextData} might get modified by another thread. Suppose you
+ * would want to draw the content of the {@link ITerminalTextData} using the
+ * following loop:
+ *
*
- * for(int line=0;line<term.getHeight();line++)
- * for(int column=0; column<term.getWidth();column++)
- * drawCharacter(column,line,term.getChar(column,line),term.getStyle(column,line));
+ * for (int line = 0; line < term.getHeight(); line++)
+ * for (int column = 0; column < term.getWidth(); column++)
+ * drawCharacter(column, line, term.getChar(column, line), term.getStyle(column, line));
*
- * This might fail because the background thread could change the dimensions of the
- * {@link ITerminalTextData} while you iterate the loop. One solution would be to
- * put a synchronized(term){}
statement around the code. This has
- * two problems: 1. you would have to know about the internals of the synchronisation
- * of {@link ITerminalTextData}. 2. The other thread that changes {@link ITerminalTextData}
- * is blocked while the potentially slow drawing is done.
+ *
+ * This might fail because the background thread could change the dimensions of
+ * the {@link ITerminalTextData} while you iterate the loop. One solution would
+ * be to put a synchronized(term){}
statement around the code.
+ * This has two problems: 1. you would have to know about the internals of the
+ * synchronisation of {@link ITerminalTextData}. 2. The other thread that
+ * changes {@link ITerminalTextData} is blocked while the potentially slow
+ * drawing is done.
*
- * // iterate over the potentially changed lines
- * for(int line=snap.getFirstChangedLine();line<=snap.getLastChangedLine();line++)
- * // redraw only if the line has changed
- * if(snap.hasLineChanged(line))
- * for(int column=0; column<snap.getWidth();column++)
- * drawCharacter(column,line,snap.getChar(column,line),snap.getStyle(column,line));
- *
- *
- * true
for
- * the detectScrolling
parameter. The object will keep track of scrolling.
- * The UI must first handle the scrolling and then use the {@link #hasLineChanged(int)}
- * method to determine scrolling:
- *
- * // scroll the visible region of the UI before drawing the changed lines.
- * doUIScrolling(snap.getScrollChangeY(),snap.getScrollChangeN(),snap.getScrollChangeShift());
- * // iterate over the potentially changed lines
- * for(int line=snap.getFirstChangedLine();line<=snap.getFirstChangedLine();line++)
- * // redraw only if the line has changed
- * if(snap.hasLineChanged(line))
- * for(int column=0; column<snap.getWidth();column++)
- * drawCharacter(column,line,snap.getChar(column,line),snap.getStyle(column,line));
- *
+ * Solution: Take a snapshot of the terminal and use the snapshot to
+ * draw the content. There is no danger that the data structure get changed
+ * while you draw. There are also methods to find out what has changed to
+ * minimize the number of lines that get redrawn.
*
Note: This interface is not intended to be implemented by clients.
- *Threading Note: This class is not thread save! All methods have to be called by - * the a same thread, that created the instance by calling - * {@link ITerminalTextDataReadOnly#makeSnapshot()}.
+ *+ * Drawing optimization: To optimize redrawing of changed lines, this + * class keeps track of lines that have changed since the previous snapshot. + *
+ * + *+ * // iterate over the potentially changed lines + * for (int line = snap.getFirstChangedLine(); line <= snap.getLastChangedLine(); line++) + * // redraw only if the line has changed + * if (snap.hasLineChanged(line)) + * for (int column = 0; column < snap.getWidth(); column++) + * drawCharacter(column, line, snap.getChar(column, line), snap.getStyle(column, line)); + *+ * + *
+ * Scroll optimization: Often new lines are appended at the bottom of
+ * the terminal and the rest of the lines are scrolled up. In this case all
+ * lines would be marked as changed. To optimize for this case,
+ * {@link #updateSnapshot(boolean)} can be called with true
for
+ * the detectScrolling
parameter. The object will keep track of
+ * scrolling. The UI must first handle the scrolling and then use the
+ * {@link #hasLineChanged(int)} method to determine scrolling:
+ *
+ *
+ * // scroll the visible region of the UI <b>before</b> drawing the changed lines. + * doUIScrolling(snap.getScrollChangeY(), snap.getScrollChangeN(), snap.getScrollChangeShift()); + * // iterate over the potentially changed lines + * for (int line = snap.getFirstChangedLine(); line <= snap.getFirstChangedLine(); line++) + * // redraw only if the line has changed + * if (snap.hasLineChanged(line)) + * for (int column = 0; column < snap.getWidth(); column++) + * drawCharacter(column, line, snap.getChar(column, line), snap.getStyle(column, line)); + *+ * + *
+ * Threading Note: This class is not thread safe! All methods have to be + * called by the a same thread, that created the instance by calling + * {@link ITerminalTextDataReadOnly#makeSnapshot()}. + *
+ * + * @noimplement This interface is not intended to be implemented by clients. */ public interface ITerminalTextDataSnapshot extends ITerminalTextDataReadOnly { /** @@ -79,7 +90,7 @@ public interface ITerminalTextDataSnapshot extends ITerminalTextDataReadOnly { * is called and a new snapshot needs to be updated again. ** A typical terminal view would not update the snapshot immediately - * after the {@link #snapshotOutOfDate(ITerminalTextDataSnapshot)} has been called. It would introduce a + * after the {@link #snapshotOutOfDate(ITerminalTextDataSnapshot)} has been called. It would introduce a * delay to update the UI (and the snapshot} 10 or 20 times per second. * *
Make sure you don't spend too much time in this method. @@ -94,7 +105,7 @@ public interface ITerminalTextDataSnapshot extends ITerminalTextDataReadOnly { } void addListener(SnapshotOutOfDateListener listener); void removeListener(SnapshotOutOfDateListener listener); - + /** * Ends the listening to the {@link ITerminalTextData}. After this * has been called no new snapshot data is collected. @@ -115,11 +126,11 @@ public interface ITerminalTextDataSnapshot extends ITerminalTextDataReadOnly { void setInterestWindow(int startLine, int size); int getInterestWindowStartLine(); int getInterestWindowSize(); - + /** * Create a new snapshot of the {@link ITerminalTextData}. It will efficiently * copy the data of the {@link ITerminalTextData} into an internal representation. - * The snapshot also keeps track of the changes since the previous snapshot. + * The snapshot also keeps track of the changes since the previous snapshot. *
With the methods {@link #getFirstChangedLine()}, {@link #getLastChangedLine()} and * {@link #hasLineChanged(int)} * you can find out what has changed in the current snapshot since the previous snapshot. @@ -134,9 +145,9 @@ public interface ITerminalTextDataSnapshot extends ITerminalTextDataReadOnly { /** * @return The first line changed in this snapshot compared - * to the previous snapshot. + * to the previous snapshot. * - *
Note: If no line has changed, this + *
Note: If no line has changed, this * returns {@link Integer#MAX_VALUE} * *
Note: if {@link #updateSnapshot(boolean)} has been called with true
,
@@ -171,11 +182,11 @@ public interface ITerminalTextDataSnapshot extends ITerminalTextDataReadOnly {
* @return true if the line has changed since the previous snapshot
*/
boolean hasLineChanged(int line);
-
+
boolean hasDimensionsChanged();
-
+
/**
- * @return true if the terminal has changed (and not just the
+ * @return true if the terminal has changed (and not just the
* window of interest)
*/
boolean hasTerminalChanged();
@@ -203,7 +214,7 @@ public interface ITerminalTextDataSnapshot extends ITerminalTextDataReadOnly {
* to the previous snapshot. See also {@link ITerminalTextData#scroll(int, int, int)}
*/
int getScrollWindowShift();
-
+
/**
* @return The {@link ITerminalTextData} on that this instance is observing.
*/