From b3377ee4f2e8215b58024d8907a3f5e0fa7de754 Mon Sep 17 00:00:00 2001 From: JavaZeroo <71128095+JavaZeroo@users.noreply.github.com> Date: Fri, 30 Oct 2026 05:53:54 +0800 Subject: [PATCH] diag(qt): log the bytes that reach the session behind TERMFORGE_QT_INPUT_LOG refs #155 Records the hex of every successful key-path send so an IME experiment can tell whether Ctrl-C produced any byte at all. --- src/qt/terminal_widget.hpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/qt/terminal_widget.hpp b/src/qt/terminal_widget.hpp index b1316741..875c5319 100644 --- a/src/qt/terminal_widget.hpp +++ b/src/qt/terminal_widget.hpp @@ -1,4 +1,4 @@ -// Qt terminal geometry follows the current font; semantics stay in the model. +// Qt terminal geometry follows the current font; semantics stay in the model. #pragma once #include "terminal_session.hpp" @@ -122,10 +122,23 @@ class TerminalWidget final : public QWidget { } if (!character_text) bytes = next.finish() + bytes; if (bytes.empty() || model_.send(bytes)) { + if (!bytes.empty()) input_log(bytes); keyboard_ = next; event->accept(); } else event->ignore(); } + // Opt-in observation for the input path: records the exact bytes that + // reached the session so an IME experiment can be checked without guessing. + static void input_log(const std::string& bytes) { + static const char* path = std::getenv("TERMFORGE_QT_INPUT_LOG"); + if (path == nullptr) return; + FILE* stream = std::fopen(path, "ab"); + if (stream == nullptr) return; + std::fprintf(stream, "{\"bytes\":%d,\"hex\":\"", static_cast(bytes.size())); + for (const char ch : bytes) std::fprintf(stream, "%02x", static_cast(ch)); + std::fprintf(stream, "\"}\n"); + std::fclose(stream); + } // The candidate window needs the caret cell, not the widget origin. QVariant inputMethodQuery(Qt::InputMethodQuery query) const override { if (query == Qt::ImCursorRectangle && grid_ready_) {