1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-14 12:35:22 +02:00

bug 205679: [terminal] Before the terminal is connected, the cursor and scrollbar are wrong

https://bugs.eclipse.org/bugs/show_bug.cgi?id=205679
This commit is contained in:
Michael Scharf 2007-10-08 21:12:57 +00:00
parent ab379497f4
commit c96b764980
3 changed files with 39 additions and 16 deletions

View file

@ -78,14 +78,34 @@ public class VT100EmulatorBackend implements IVT100EmulatorBackend {
if(lines==fLines && cols==fColumns) if(lines==fLines && cols==fColumns)
return; // nothing to do return; // nothing to do
// cursor line from the bottom // cursor line from the bottom
int cl=fLines-getCursorLine(); int cl=lines-(fLines-getCursorLine());
int cc=getCursorColumn(); int cc=getCursorColumn();
int newLines=Math.max(lines,fTerminal.getHeight());
// if the terminal has no history, then resize by
// setting the size to the new size
if(fTerminal.getHeight()==fLines) {
if(lines<fLines) {
cl+=fLines-lines;
newLines=lines;
// shrink by cutting empty lines at the bottom
// int firstNoneEmptyLine;
// for (firstNoneEmptyLine = fTerminal.getHeight(); firstNoneEmptyLine <= 0; firstNoneEmptyLine--) {
// LineSegment[] segments = fTerminal.getLineSegments(firstNoneEmptyLine, 0, fTerminal.getWidth());
// if(segments.length>1)
// break;
// // is the line empty?
// if(segments[0].getText().replaceAll("[\000 ]+", "").length()==0)
// break;
// }
} else {
cl+=fLines-lines;
}
}
fLines=lines; fLines=lines;
fColumns=cols; fColumns=cols;
// make the terminal at least as high as we need lines // make the terminal at least as high as we need lines
fTerminal.setDimensions(Math.max(fLines,fTerminal.getHeight()), fColumns); fTerminal.setDimensions(newLines, fColumns);
setCursor(fLines-cl, cc); setCursor(cl, cc);
} }
} }

View file

@ -163,11 +163,13 @@ public class TextCanvas extends GridCanvas {
} }
protected void onResize() { protected void onResize() {
// if(!isShowHScrollBar()) {
if(fResizeListener!=null) { if(fResizeListener!=null) {
Rectangle bonds=getClientArea(); Rectangle bonds=getClientArea();
int lines=bonds.height/getCellHeight(); int lines=bonds.height/getCellHeight();
int columns=bonds.width/getCellWidth(); int columns=bonds.width/getCellWidth();
// when the view is minimised, its size is set to 0
// we don't sent this to the terminal!
if(lines>0 && columns>0) {
if(columns<fMinColumns) { if(columns<fMinColumns) {
if(!isHorizontalBarVisble()) { if(!isHorizontalBarVisble()) {
setHorizontalBarVisible(true); setHorizontalBarVisible(true);
@ -184,12 +186,9 @@ public class TextCanvas extends GridCanvas {
} }
if(lines<fMinLines) if(lines<fMinLines)
lines=fMinLines; lines=fMinLines;
// if(lines>0 && columns>0 && (lines!=getRows()||columns!=getCols())) {
if(lines>0 && columns>0) {
fResizeListener.sizeChanged(lines, columns); fResizeListener.sizeChanged(lines, columns);
} }
} }
// }
super.onResize(); super.onResize();
calculateGrid(); calculateGrid();
} }

View file

@ -318,14 +318,18 @@ public abstract class VirtualCanvas extends Canvas {
Point size= getSize(); Point size= getSize();
Rectangle clientArea= getClientArea(); Rectangle clientArea= getClientArea();
ScrollBar horizontal= getHorizontalBar(); ScrollBar horizontal= getHorizontalBar();
if(horizontal.isVisible()) { // even if setVisible was called on the scrollbar, isVisible
// returns false if its parent is not visible.
if(!isVisible() || horizontal.isVisible()) {
horizontal.setPageIncrement(clientArea.width - horizontal.getIncrement()); horizontal.setPageIncrement(clientArea.width - horizontal.getIncrement());
int max= fVirtualBounds.width + (size.x - clientArea.width); int max= fVirtualBounds.width + (size.x - clientArea.width);
horizontal.setMaximum(max); horizontal.setMaximum(max);
horizontal.setThumb(size.x > max ? max : size.x); horizontal.setThumb(size.x > max ? max : size.x);
} }
ScrollBar vertical= getVerticalBar(); ScrollBar vertical= getVerticalBar();
if(vertical.isVisible()) { // even if setVisible was called on the scrollbar, isVisible
// returns false if its parent is not visible.
if(!isVisible() || vertical.isVisible()) {
vertical.setPageIncrement(clientArea.height - vertical.getIncrement()); vertical.setPageIncrement(clientArea.height - vertical.getIncrement());
int max= fVirtualBounds.height + (size.y - clientArea.height); int max= fVirtualBounds.height + (size.y - clientArea.height);
vertical.setMaximum(max); vertical.setMaximum(max);