diff --git a/src/apps/terminal/SmartTabView.cpp b/src/apps/terminal/SmartTabView.cpp index 9b79c48d0d..f13dc52adf 100644 --- a/src/apps/terminal/SmartTabView.cpp +++ b/src/apps/terminal/SmartTabView.cpp @@ -70,24 +70,22 @@ SmartTabView::MouseDown(BPoint point) if (CountTabs() > 1) { int32 tabIndex = _ClickedTabIndex(point); - if (tabIndex >= 0) { - int32 buttons = 0; - int32 clickCount = 0; - Window()->CurrentMessage()->FindInt32("buttons", &buttons); - Window()->CurrentMessage()->FindInt32("clicks", &clickCount); + int32 buttons = 0; + int32 clickCount = 0; + Window()->CurrentMessage()->FindInt32("buttons", &buttons); + Window()->CurrentMessage()->FindInt32("clicks", &clickCount); - if ((buttons & B_PRIMARY_MOUSE_BUTTON) != 0 && clickCount == 2) { - if (fListener != NULL) - fListener->TabDoubleClicked(this, point, tabIndex); - } else if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) { - if (fListener != NULL) - fListener->TabRightClicked(this, point, tabIndex); - handled = true; - } else if ((buttons & B_TERTIARY_MOUSE_BUTTON) != 0) { - if (fListener != NULL) - fListener->TabMiddleClicked(this, point, tabIndex); - handled = true; - } + if ((buttons & B_PRIMARY_MOUSE_BUTTON) != 0 && clickCount == 2) { + if (fListener != NULL) + fListener->TabDoubleClicked(this, point, tabIndex); + } else if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) { + if (fListener != NULL) + fListener->TabRightClicked(this, point, tabIndex); + handled = true; + } else if ((buttons & B_TERTIARY_MOUSE_BUTTON) != 0) { + if (fListener != NULL) + fListener->TabMiddleClicked(this, point, tabIndex); + handled = true; } } diff --git a/src/apps/terminal/TermWindow.cpp b/src/apps/terminal/TermWindow.cpp index c189c8c293..0cfc552933 100644 --- a/src/apps/terminal/TermWindow.cpp +++ b/src/apps/terminal/TermWindow.cpp @@ -688,16 +688,7 @@ TermWindow::MessageReceived(BMessage *message) } case kNewTab: - if (fTabView->CountTabs() < kMaxTabs) { - if (fFullScreen) - _ActiveTermView()->ScrollBar()->Show(); - - ActiveProcessInfo info; - if (_ActiveTermView()->GetActiveProcessInfo(info)) - _AddTab(NULL, info.CurrentDirectory()); - else - _AddTab(NULL); - } + _NewTab(); break; case kCloseView: @@ -837,6 +828,22 @@ TermWindow::_DoPrint() } +void +TermWindow::_NewTab() +{ + if (fTabView->CountTabs() < kMaxTabs) { + if (fFullScreen) + _ActiveTermView()->ScrollBar()->Show(); + + ActiveProcessInfo info; + if (_ActiveTermView()->GetActiveProcessInfo(info)) + _AddTab(NULL, info.CurrentDirectory()); + else + _AddTab(NULL); + } +} + + void TermWindow::_AddTab(Arguments* args, const BString& currentDirectory) { @@ -1029,20 +1036,29 @@ TermWindow::TabSelected(SmartTabView* tabView, int32 index) void TermWindow::TabDoubleClicked(SmartTabView* tabView, BPoint point, int32 index) { - // TODO:... + if (index >= 0) { + // TODO: Open the change title dialog! + } else { + // not clicked on a tab -- create a new one + _NewTab(); + } } void TermWindow::TabMiddleClicked(SmartTabView* tabView, BPoint point, int32 index) { - _RemoveTab(index); + if (index >= 0) + _RemoveTab(index); } void TermWindow::TabRightClicked(SmartTabView* tabView, BPoint point, int32 index) { + if (index < 0) + return; + TermView* termView = _TermViewAt(index); if (termView == NULL) return; diff --git a/src/apps/terminal/TermWindow.h b/src/apps/terminal/TermWindow.h index 64ac687292..30ee797bd7 100644 --- a/src/apps/terminal/TermWindow.h +++ b/src/apps/terminal/TermWindow.h @@ -96,6 +96,7 @@ private: void _GetPreferredFont(BFont &font); status_t _DoPageSetup(); void _DoPrint(); + void _NewTab(); void _AddTab(Arguments* args, const BString& currentDirectory = BString());