1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-09 01:05:38 +02:00

helper method added to be used in "New Detail Formatter.." in the debugger variables view

This commit is contained in:
Michael Scharf 2007-10-11 15:39:20 +00:00
parent b84df5798a
commit ed15760bd9
3 changed files with 63 additions and 14 deletions

View file

@ -15,6 +15,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import org.eclipse.tm.terminal.model.ITerminalTextData; import org.eclipse.tm.terminal.model.ITerminalTextData;
import org.eclipse.tm.terminal.model.ITerminalTextDataReadOnly;
import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot; import org.eclipse.tm.terminal.model.ITerminalTextDataSnapshot;
import org.eclipse.tm.terminal.model.LineSegment; import org.eclipse.tm.terminal.model.LineSegment;
import org.eclipse.tm.terminal.model.Style; import org.eclipse.tm.terminal.model.Style;
@ -31,6 +32,40 @@ public class TerminalTextData implements ITerminalTextData {
public TerminalTextDataSnapshot[] fSnapshots=new TerminalTextDataSnapshot[0]; public TerminalTextDataSnapshot[] fSnapshots=new TerminalTextDataSnapshot[0];
private int fCursorColumn; private int fCursorColumn;
private int fCursorLine; private int fCursorLine;
/**
* Debug helper method -- use as "New Detail Formatter.." in the
* debugger variables view:
* <pre>TerminalTextData.toMultiLineText(this,0,200))</pre>
* @param term the terminal
* @param start start line to show
* @param len number of lines to show -- negative numbers means show all
* @return a string representation of the content
*/
static public String toMultiLineText(ITerminalTextDataReadOnly term, int start, int len) {
if(len<0)
len=term.getHeight();
StringBuffer buff=new StringBuffer();
int width=term.getWidth();
int n=Math.min(len,term.getHeight()-start);
for (int line = start; line < n; line++) {
if(line>0)
buff.append("\n"); //$NON-NLS-1$
for (int column = 0; column < width; column++) {
buff.append(term.getChar(line, column));
}
}
return buff.toString().replaceAll("\000+", ""); //$NON-NLS-1$//$NON-NLS-2$
}
/**
* Show the first 100 lines
* see {@link #toMultiLineText(ITerminalTextDataReadOnly, int, int)}
* @param term
* @return a string representaron of the terminal
*/
static public String toMultiLineText(ITerminalTextDataReadOnly term) {
return toMultiLineText(term, 0, 100);
}
public TerminalTextData() { public TerminalTextData() {
this(new TerminalTextDataFastScroll()); this(new TerminalTextDataFastScroll());

View file

@ -168,7 +168,7 @@ abstract public class AbstractTextCanvasModel implements ITextCanvasModel {
} }
} }
public void setVisibleRectangle(int startLine, int startCol, int height, int width) { public void setVisibleRectangle(int startLine, int startCol, int height, int width) {
fSnapshot.setInterestWindow(Math.max(0,startLine), Math.max(1,Math.min(fSnapshot.getHeight(),height))); fSnapshot.setInterestWindow(Math.max(0,startLine), Math.max(1,height));
update(); update();
} }
protected void showCursor(boolean show) { protected void showCursor(boolean show) {

View file

@ -45,6 +45,20 @@ abstract public class GridCanvas extends VirtualCanvas {
} }
public void setBounds(int x, int y, int width, int height) {
// adjust the height so that there are no characters cut
// Maybe it would be better to use a custom Layout...
int shiftH=0;
if(getCellHeight()!=0)
shiftH=height % getCellHeight();
super.setBounds(x, y+shiftH, width, height-shiftH);
}
public void setBounds(Rectangle rect) {
// just to be sure our set bounds is called!
setBounds(rect.x,rect.y,rect.width,rect.height);
}
/** template method paint. /** template method paint.
* iterates over all cells in the clipping rectangle and paints them. * iterates over all cells in the clipping rectangle and paints them.
*/ */
@ -159,11 +173,11 @@ abstract public class GridCanvas extends VirtualCanvas {
int cellY=virtualYToCell(y); int cellY=virtualYToCell(y);
// End coordinates // End coordinates
int xE=virtualXToCell(x+fCellWidth+width-1); int xE=virtualXToCell(x+fCellWidth+width-1);
if(xE>getCols()) // if(xE>getCols())
xE=getCols(); // xE=getCols();
int yE=virtualYToCell(y+fCellHeight+height-1); int yE=virtualYToCell(y+fCellHeight+height-1);
if(yE>getRows()) // if(yE>getRows())
yE=getRows(); // yE=getRows();
visibleCellRectangleChanged(cellX,cellY,xE-cellX,yE-cellY); visibleCellRectangleChanged(cellX,cellY,xE-cellX,yE-cellY);
} }