Skip to content

Commit

Permalink
Fix bug with tab switching and implement wrapping of tabs on left/rig…
Browse files Browse the repository at this point in the history
…ht switches
  • Loading branch information
Yaraslaut committed Dec 18, 2024
1 parent 46f74e9 commit ebddfba
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
26 changes: 17 additions & 9 deletions src/contour/TerminalSessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,9 @@ void TerminalSessionManager::switchToTabLeft()
{
setSession(currentSessionIndex - 1);
}
}

void TerminalSessionManager::switchToTab(int position)
{
managerLog()(std::format(
"switchToTab from {} to {} (out of {})", getCurrentSessionIndex(), position - 1, _sessions.size()));

if (1 <= position && position <= static_cast<int>(_sessions.size()))
else // wrap
{
setSession(position - 1);
setSession(_sessions.size() - 1);
}
}

Expand All @@ -129,6 +122,21 @@ void TerminalSessionManager::switchToTabRight()
{
setSession(currentSessionIndex + 1);
}
else // wrap
{
setSession(0);
}
}

void TerminalSessionManager::switchToTab(int position)
{
managerLog()(std::format(
"switchToTab from {} to {} (out of {})", getCurrentSessionIndex(), position - 1, _sessions.size()));

if (1 <= position && position <= static_cast<int>(_sessions.size()))
{
setSession(position - 1);
}
}

void TerminalSessionManager::closeTab()
Expand Down
10 changes: 7 additions & 3 deletions src/contour/display/TerminalDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ void TerminalDisplay::setSession(TerminalSession* newSession)
window()->setFlag(Qt::FramelessWindowHint, !profile().showTitleBar.value());

if (!_renderer)
{

_renderer = make_unique<vtrasterizer::Renderer>(
_session->profile().terminalSize.value(),
sanitizeFontDescription(profile().fonts.value(), fontDPI()),
Expand All @@ -323,9 +325,11 @@ void TerminalDisplay::setSession(TerminalSession* newSession)
// TODO: , WindowMargin(windowMargin_.left, windowMargin_.bottom);
);

applyFontDPI();
updateImplicitSize();
updateMinimumSize();
// setup once with the renderer creation
applyFontDPI();
updateImplicitSize();
updateMinimumSize();
}

_session->attachDisplay(*this); // NB: Requires Renderer to be instanciated to retrieve grid metrics.

Expand Down
4 changes: 2 additions & 2 deletions src/contour/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,8 @@ void applyResize(vtbackend::ImageSize newPixelSize,
TerminalSession& session,
vtrasterizer::Renderer& renderer)
{
if (*newPixelSize.width == 0 || *newPixelSize.height == 0)
return;
if (*newPixelSize.width == 0
|| *newPixelSize.height == 0) return;

auto const oldPageSize = session.terminal().pageSize();
auto const newPageSize = pageSizeForPixels(
Expand Down

0 comments on commit ebddfba

Please sign in to comment.