diff --git a/metainfo.xml b/metainfo.xml
index 50d28abde0..5e9e015dbd 100644
--- a/metainfo.xml
+++ b/metainfo.xml
@@ -112,6 +112,7 @@
Fixes rendering in cases of glyphs with inverted orientation (#1115).
Fixes VT sequence DECSTBM and DECSLRM defaulting parameters (#1164).
Fixes VT sequence DECFRA (#1189).
+ Fixes VT sequence DECSCPP and DECCOLM (#1205).
Adds inheritance of profiles in configuration file based on default profile (#1063).
Clear search term when switch to insert vi mode (#1135)
Delete dpi_scale entry in configuration (#1137)
diff --git a/src/contour/TerminalSession.cpp b/src/contour/TerminalSession.cpp
index 2834adb201..e83e074da5 100644
--- a/src/contour/TerminalSession.cpp
+++ b/src/contour/TerminalSession.cpp
@@ -191,6 +191,7 @@ void TerminalSession::attachDisplay(display::TerminalWidget& newDisplay)
// auto const pixels =
// ImageSize { _display->cellSize().width * boxed_cast(_terminal.pageSize().columns),
// _display->cellSize().height * boxed_cast(_terminal.pageSize().lines) };
+ auto const l = scoped_lock { _terminal };
_terminal.resizeScreen(_terminal.pageSize(), pixels);
_terminal.setRefreshRate(_display->refreshRate());
}
@@ -565,7 +566,7 @@ void TerminalSession::requestWindowResize(LineCount lines, ColumnCount columns)
if (!_display)
return;
- sessionLog()("Application request to resize window: {}x{} px", columns, lines);
+ sessionLog()("Application request to resize window: {}x{}", columns, lines);
_display->post([this, lines, columns]() { _display->resizeWindow(lines, columns); });
}
diff --git a/src/contour/display/TerminalWidget.cpp b/src/contour/display/TerminalWidget.cpp
index 6f8671beb0..0c215d5126 100644
--- a/src/contour/display/TerminalWidget.cpp
+++ b/src/contour/display/TerminalWidget.cpp
@@ -914,7 +914,7 @@ void TerminalWidget::updateSizeProperties()
// implicit width/height
auto const dpr = contentScale();
- auto const implicitViewSize = _renderer->cellSize() * _session->terminal().pageSize() * (1.0 / dpr);
+ auto const implicitViewSize = _renderer->cellSize() * _session->terminal().totalPageSize() * (1.0 / dpr);
setImplicitWidth(unbox(implicitViewSize.width));
setImplicitHeight(unbox(implicitViewSize.height));
@@ -924,7 +924,7 @@ void TerminalWidget::updateSizeProperties()
auto constexpr MinimumGridSize = PageSize { LineCount(5), ColumnCount(10) };
auto const minSize =
ImageSize { Width::cast_from(unbox(gridMetrics().cellSize.width) * *MinimumGridSize.columns),
- Height::cast_from(unbox(gridMetrics().cellSize.width) * *MinimumGridSize.columns) };
+ Height::cast_from(unbox(gridMetrics().cellSize.width) * *MinimumGridSize.lines) };
auto const scaledMinSize = minSize / dpr;
window()->setMinimumSize(QSize(scaledMinSize.width.as(), scaledMinSize.height.as()));
@@ -1114,6 +1114,7 @@ void TerminalWidget::resizeWindow(terminal::Width newWidth, terminal::Height new
* unbox(gridMetrics().cellSize.width)),
terminal::Height::cast_from(unbox(requestedPageSize.lines)
* unbox(gridMetrics().cellSize.height)) };
+ auto const l = scoped_lock { terminal() };
terminal().resizeScreen(requestedPageSize, pixels);
}
@@ -1125,20 +1126,18 @@ void TerminalWidget::resizeWindow(terminal::LineCount newLineCount, terminal::Co
return;
}
- auto requestedPageSize = terminal().pageSize();
+ auto requestedPageSize = terminal().totalPageSize();
if (*newColumnCount)
requestedPageSize.columns = newColumnCount;
if (*newLineCount)
requestedPageSize.lines = newLineCount;
- // setSizePolicy(QSizePolicy::Policy::Fixed, QSizePolicy::Policy::Fixed);
- const_cast(profile()).terminalSize = requestedPageSize;
- _renderer->setPageSize(requestedPageSize);
auto const pixels = terminal::ImageSize {
terminal::Width(unbox(requestedPageSize.columns) * *gridMetrics().cellSize.width),
terminal::Height(unbox(requestedPageSize.lines) * *gridMetrics().cellSize.height)
};
- terminal().resizeScreen(requestedPageSize, pixels);
+
+ window()->resize(QSize(pixels.width.as(), pixels.height.as()));
}
void TerminalWidget::setFonts(terminal::rasterizer::FontDescriptions fontDescriptions)
@@ -1189,6 +1188,7 @@ bool TerminalWidget::setPageSize(PageSize newPageSize)
ImageSize { Width(*gridMetrics().cellSize.width * unbox(profile().terminalSize.columns)),
Height(*gridMetrics().cellSize.width * unbox(profile().terminalSize.columns)) };
_renderer->setPageSize(newPageSize);
+ auto const l = scoped_lock { terminal() };
terminal().resizeScreen(newPageSize, viewSize);
return true;
}
diff --git a/src/contour/helper.cpp b/src/contour/helper.cpp
index 68dce8dd17..bb01b516fe 100644
--- a/src/contour/helper.cpp
+++ b/src/contour/helper.cpp
@@ -434,6 +434,8 @@ void applyResize(terminal::ImageSize newPixelSize,
auto const viewSize = cellSize * newPageSize;
displayLog()("Applying resize: {} (new pixel size) {} (view size)", newPixelSize, viewSize);
+ auto const l = scoped_lock { terminal };
+
if (newPageSize == terminal.pageSize())
return;
diff --git a/src/vtbackend/Screen.cpp b/src/vtbackend/Screen.cpp
index 8d55f5711d..95da90c462 100644
--- a/src/vtbackend/Screen.cpp
+++ b/src/vtbackend/Screen.cpp
@@ -3545,8 +3545,14 @@ ApplyResult Screen::apply(FunctionDefinition const& function, Sequence con
case DECSCPP:
if (auto const columnCount = seq.param_or(0, 80); columnCount == 80 || columnCount == 132)
{
- // EXTENSION: only 80 and 132 are specced, but we allow any.
- _terminal.resizeColumns(ColumnCount(columnCount), false);
+ // If the cursor is beyond the width of the new page,
+ // then the cursor moves to the right column of the new page.
+ if (*cursor().position.column >= columnCount)
+ cursor().position.column = ColumnOffset::cast_from(columnCount) - 1;
+
+ _terminal.requestWindowResize(
+ PageSize { _terminal.totalPageSize().lines,
+ ColumnCount::cast_from(columnCount ? columnCount : 80) });
return ApplyResult::Ok;
}
else
diff --git a/src/vtbackend/Terminal.cpp b/src/vtbackend/Terminal.cpp
index 47c31feffc..ad5a61fc42 100644
--- a/src/vtbackend/Terminal.cpp
+++ b/src/vtbackend/Terminal.cpp
@@ -1096,12 +1096,6 @@ void Terminal::tick(chrono::steady_clock::time_point now) noexcept
}
void Terminal::resizeScreen(PageSize totalPageSize, optional pixels)
-{
- auto const _ = std::lock_guard { *this };
- resizeScreenInternal(totalPageSize, pixels);
-}
-
-void Terminal::resizeScreenInternal(PageSize totalPageSize, std::optional pixels)
{
// NOTE: This will only resize the currently active buffer.
// Any other buffer will be resized when it is switched to.
@@ -1138,31 +1132,6 @@ void Terminal::resizeScreenInternal(PageSize totalPageSize, std::optional(_settings.pageSize.lines) - LineOffset(1)); // DECSTBM
- setLeftRightMargin({}, unbox(_settings.pageSize.columns) - ColumnOffset(1)); // DECRLM
-
- // Erases all data in page memory
- clearScreen();
- }
-
- // resets vertical split screen mode (DECLRMM) to unavailable
- setMode(DECMode::LeftRightMargin, false); // DECSLRM
-
- // Pre-resize in case the event callback right after is not actually resizing the window
- // (e.g. either by choice or because the window manager does not allow that, such as tiling WMs).
- auto const newSize = PageSize { _settings.pageSize.lines, newColumnCount };
- auto const pixels = cellPixelSize() * newSize;
- resizeScreen(newSize, pixels);
-
- requestWindowResize(newSize);
-}
-
void Terminal::verifyState()
{
#if !defined(NDEBUG)
@@ -1531,20 +1500,36 @@ void Terminal::setMode(DECMode mode, bool enable)
}
break;
case DECMode::Origin: _currentScreen.get().cursor().originMode = enable; break;
- case DECMode::Columns132:
+ case DECMode::Columns132: {
if (!isModeEnabled(DECMode::AllowColumns80to132))
- break;
- if (enable != isModeEnabled(DECMode::Columns132))
{
- auto const clear = enable != isModeEnabled(mode);
+ terminalLog()("Ignoring DECCOLM because DECCOLM is not allowed by mode setting.");
+ break;
+ }
- // sets the number of columns on the page to 80 or 132 and selects the
- // corresponding 80- or 132-column font
- auto const columns = ColumnCount(enable ? 132 : 80);
+ // sets the number of columns on the page to 80 or 132 and selects the
+ // corresponding 80- or 132-column font
+ auto const columns = ColumnCount(enable ? 132 : 80);
- resizeColumns(columns, clear);
- }
- break;
+ terminalLog()("DECCOLM: Setting columns to {}", columns);
+
+ // Sets the left, right, top and bottom scrolling margins to their default positions.
+ setTopBottomMargin(std::nullopt, std::nullopt); // DECSTBM
+ setLeftRightMargin(std::nullopt, std::nullopt); // DECRLM
+
+ // resets vertical split screen mode (DECLRMM) to unavailable
+ setMode(DECMode::LeftRightMargin, false); // DECSLRM
+
+ // DECCOLM clears data from the status line if the status line is set to host-writable.
+ if (_state.statusDisplayType == StatusDisplayType::HostWritable)
+ _hostWritableStatusLineScreen.clearScreen();
+
+ // Erases all data in page memory
+ clearScreen();
+
+ requestWindowResize(PageSize { totalPageSize().lines, columns });
+ }
+ break;
case DECMode::BatchedRendering:
if (_state.modes.enabled(DECMode::BatchedRendering) != enable)
synchronizedOutput(enable);
@@ -1975,7 +1960,7 @@ void Terminal::setStatusDisplay(StatusDisplayType statusDisplayType)
_state.statusDisplayType = statusDisplayType;
if (statusLineVisibleBefore != statusLineVisibleAfter)
- resizeScreenInternal(_settings.pageSize, nullopt);
+ resizeScreen(_settings.pageSize, nullopt);
}
void Terminal::setActiveStatusDisplay(ActiveStatusDisplay activeDisplay)
diff --git a/src/vtbackend/Terminal.h b/src/vtbackend/Terminal.h
index f67f54bb75..4b65828bb0 100644
--- a/src/vtbackend/Terminal.h
+++ b/src/vtbackend/Terminal.h
@@ -241,10 +241,6 @@ class Terminal
/// Important! In case a status line is currently visible, the status line count is being
/// accumulated into the screen size, too.
void resizeScreen(PageSize totalPageSize, std::optional pixels = std::nullopt);
- void resizeScreenInternal(PageSize totalPageSize, std::optional pixels);
-
- /// Implements semantics for DECCOLM / DECSCPP.
- void resizeColumns(ColumnCount newColumnCount, bool clear);
void clearScreen();
|