From bc4a631baeb37f941cb2ed5ebc461aa081db400d Mon Sep 17 00:00:00 2001 From: Matan Ziv-Av Date: Sat, 21 May 2022 20:01:37 +0300 Subject: [PATCH] Support iTerm2 ReportCellSize OSC --- src/Vt102Emulation.cpp | 15 +++++++++++++++ src/Vt102Emulation.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/Vt102Emulation.cpp b/src/Vt102Emulation.cpp index 51bc8154..66061832 100644 --- a/src/Vt102Emulation.cpp +++ b/src/Vt102Emulation.cpp @@ -799,6 +799,10 @@ void Vt102Emulation::processSessionAttributeRequest(int tokenSize) } if (attribute == 1337) { + if (value.startsWith(QLatin1String("ReportCellSize"))) { + iTermReportCellSize(); + return; + } if (!value.startsWith(QLatin1String("File="))) { return; } @@ -1581,6 +1585,17 @@ void Vt102Emulation::reportPixelSize() sendString(tmp); } +void Vt102Emulation::iTermReportCellSize() +{ + char tmp[50]; + snprintf(tmp, + sizeof(tmp), + "\033]1337;ReportCellSize=%d.0;%d.0;1.0\007", + _currentScreen->currentTerminalDisplay()->terminalFont()->fontHeight(), + _currentScreen->currentTerminalDisplay()->terminalFont()->fontWidth()); + sendString(tmp); +} + void Vt102Emulation::reportCellSize() { char tmp[30]; diff --git a/src/Vt102Emulation.h b/src/Vt102Emulation.h index db14f72d..661473f5 100644 --- a/src/Vt102Emulation.h +++ b/src/Vt102Emulation.h @@ -163,6 +163,7 @@ private: void reportCursorPosition(); void reportPixelSize(); void reportCellSize(); + void iTermReportCellSize(); void reportSize(); void reportColor(int c, QColor color); void reportTerminalParms(int p);