From d0436b9a7b9af2c8c521d6a786376ecce6304275 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Mar 2026 01:38:37 +0000 Subject: [PATCH] Print stdin hint when running interactively without -i argument (fixes #1054) Agent-Logs-Url: https://github.com/BYVoid/OpenCC/sessions/c78e8d52-668f-4683-9439-af68780be669 Co-authored-by: frankslin <748873+frankslin@users.noreply.github.com> --- src/tools/CommandLine.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/tools/CommandLine.cpp b/src/tools/CommandLine.cpp index f0d5f69b2..bfbd64b03 100644 --- a/src/tools/CommandLine.cpp +++ b/src/tools/CommandLine.cpp @@ -18,6 +18,12 @@ #include +#ifdef _WIN32 +#include +#else +#include +#endif + #include "src/CmdLineOutput.hpp" #include "src/Config.hpp" #include "src/Converter.hpp" @@ -45,6 +51,18 @@ FILE* GetOutputStream() { } void ConvertLineByLine() { +#ifdef _WIN32 + if (_isatty(_fileno(stdin))) { + fprintf(stderr, + "Reading from standard input. Press Ctrl+Z then Enter to " + "finish.\n"); + } +#else + if (isatty(fileno(stdin))) { + fprintf(stderr, + "Reading from standard input. Press Ctrl+D to finish.\n"); + } +#endif std::istream& inputStream = std::cin; FILE* fout = GetOutputStream(); bool isFirstLine = true;