Patch by romain: Fix one particular problem where the terminal buffer area could

go out of sync when switching between tabs. Closes #5969, thanks a lot!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36875 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2010-05-20 12:10:44 +00:00
parent ffb873afec
commit 70af7b97a5
2 changed files with 35 additions and 25 deletions

View File

@ -208,6 +208,8 @@ TermView::TermView(int rows, int columns, int32 argc, const char** argv,
if (status != B_OK)
throw status;
ResizeToPreferred();
// TODO: Don't show the dragger, since replicant capabilities
// don't work very well ATM.
/*
@ -1026,6 +1028,13 @@ TermView::AttachedToWindow()
{
fMouseButtons = 0;
// update the terminal size because it may have changed while the TermView
// was detached from the window. On such conditions FrameResized was not
// called when the resize occured
int rows;
int columns;
GetTermSizeFromRect(Bounds(), &rows, &columns);
SetTermSize(rows, columns);
MakeFocus(true);
if (fScrollBar) {
fScrollBar->SetSteps(fFontHeight, fFontHeight * fRows);

View File

@ -805,6 +805,32 @@ TermWindow::_AddTab(Arguments *args)
session->windowTitle = fInitialTitle;
fSessions.AddItem(session);
int width, height;
view->GetFontSize(&width, &height);
float minimumHeight = -1;
if (fMenubar)
minimumHeight += fMenubar->Bounds().Height() + 1;
if (fTabView && fTabView->CountTabs() > 0)
minimumHeight += fTabView->TabHeight() + 1;
SetSizeLimits(MIN_COLS * width - 1, MAX_COLS * width - 1,
minimumHeight + MIN_ROWS * height - 1,
minimumHeight + MAX_ROWS * height - 1);
// TODO: The size limit computation is apparently broken, since
// the terminal can be resized smaller than MIN_ROWS/MIN_COLS!
// If it's the first time we're called, setup the window
if (fTabView->CountTabs() == 0) {
float viewWidth, viewHeight;
containerView->GetPreferredSize(&viewWidth, &viewHeight);
// Resize Window
ResizeTo(viewWidth + B_V_SCROLL_BAR_WIDTH,
viewHeight + fMenubar->Bounds().Height() + 1);
// NOTE: Width is one pixel too small, since the scroll view
// is one pixel wider than its parent.
}
BTab *tab = new BTab;
fTabView->AddTab(scrollView, tab);
tab->SetLabel(session->name.String());
@ -822,31 +848,6 @@ TermWindow::_AddTab(Arguments *args)
_SetTermColors(containerView);
int width, height;
view->GetFontSize(&width, &height);
float minimumHeight = -1;
if (fMenubar)
minimumHeight += fMenubar->Bounds().Height() + 1;
if (fTabView && fTabView->CountTabs() > 1)
minimumHeight += fTabView->TabHeight() + 1;
SetSizeLimits(MIN_COLS * width - 1, MAX_COLS * width - 1,
minimumHeight + MIN_ROWS * height - 1,
minimumHeight + MAX_ROWS * height - 1);
// TODO: The size limit computation is apparently broken, since
// the terminal can be resized smaller than MIN_ROWS/MIN_COLS!
// If it's the first time we're called, setup the window
if (fTabView->CountTabs() == 1) {
float viewWidth, viewHeight;
containerView->GetPreferredSize(&viewWidth, &viewHeight);
// Resize Window
ResizeTo(viewWidth + B_V_SCROLL_BAR_WIDTH,
viewHeight + fMenubar->Bounds().Height() + 1);
// NOTE: Width is one pixel too small, since the scroll view
// is one pixel wider than its parent.
}
// TODO: No fTabView->Select(tab); ?
fTabView->Select(fTabView->CountTabs() - 1);
} catch (...) {