Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Allow/Default use of ANSI color codes on Windows

オープン
#3,003 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

@Ext3h がすでに取り組んでいます。

2025年7月21日 から。

  • #3004 @Ext3h による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cpp
領域
testing-qa

調査の方向性

まず CATCH_INTERNAL_HAS_ISATTY と Windows のカラー処理パスを見つけ、stdout とコンソールモードがどのように初期化されるかを確認します。バッファリングされた stdout を含め、既存の Windows および ANSI 出力の動作を確認し、レガシー属性 API を使わずに Windows ターミナルで ANSI カラーが確実に使用されることを完了条件とします。

索引モデルが issue の本文から書いたものです。

説明

Description
With a little snippet during initialization, Windows 10 and newer support ANSI color codes out of the box:

#ifdef _WIN32
    HANDLE outputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
    DWORD mode = 0;
    if (GetConsoleMode(outputHandle, &mode))
    {
        mode |= ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING;
        SetConsoleMode(outputHandle, mode);
    }
#endif // _WIN32

The CATCH_INTERNAL_HAS_ISATTY is somewhat malformed - Windows has isatty too (in header #include <io.h> instead of #include <unistd.h>) - but what it doesn't have is STDOUT_FILENO so the portable solution for that is isatty(fileno(stdout)).

On Windows 10 or newer (or in case that covers ALL support Windows platforms: For every Windows-platform in general), the ANSI color code support should be preferred unconditionally over the legacy text attribute API.

Additional context
This avoids a lot of issues you'd otherwise have with the Windows terminal handling - among others that setting colors via SetConsoleTextAttribute on Windows breaks horribly when the application under test is enabling output buffering for stdout as the legacy API for color codes only every works as long as stdout is byte-buffered only.

主要言語
C++
スター
21.5k
フォーク
3.5k
平均マージ
3日 5時間
マージ済み PR(30日)
4

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

catchorg/Catch2 のほかの issue

catchorg/Catch2 の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。