nodejs / nodejs/node

TTY detection foreground/background color

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

まだ誰も着手していません。

feature request
主要言語
JavaScript
スター
122k
フォーク
37.3k
平均マージ
4日 2時間
マージ済み PR(30日)
283

説明

What is the problem this feature will solve?

For tty’s if you output any text in black, particularly when doing TUI’s one is likely to get a rude awakening when they discover that their users are using dark mode and none of that text is visible because it’s jet black on a charcoal gray background. It would be best in such cases to simply print this text in the default foreground color, but that does not guarantee that other colors will be high contrast. For instance dark blue on charcoal gray, or yellow text on iTerm's default eggshell white background, versus orange which shows well on both light and dark mode terminals.

What is the feature you are proposing to solve the problem?

Add a function to write stream to query the foreground color the way color depth can be queried. And if at all possible, also the background color.

What alternatives have you considered?

Workarounds include:

  • setting a background color and printing over it, but that makes the text/graphic look more important than it is
  • resetting the tty codes rather than setting “black” - but this fails if you are looking for a more general case of high contrast colors, like dark gray on a bright background and light gray on a dark one.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

調査の方向性

実装ファイルもテストも指定されていません。まず、端末の色深度を問い合わせる既存の stream API を見つけ、次に、サポート対象のプラットフォーム全体で TTY の動作がどのように扱われているかを確認してください。定義された stream 関数で前景色を問い合わせられ、可能な場合は背景色も問い合わせられ、関連するケースがカバーされていれば完了です。

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

評価

技術スタック
node.js
領域
cli
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

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

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