Skip to content

Add ColorScheme to Term - #280

Open
heaths wants to merge 1 commit into
cli:trunkfrom
heaths:issue279
Open

Add ColorScheme to Term#280
heaths wants to merge 1 commit into
cli:trunkfrom
heaths:issue279

Conversation

@heaths

@heaths heaths commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Resolves #279

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

Review tier: Lite
Findings: 1 Medium severity · 2 Low severity

New issues introduced by this change (3)
Severity Finding
Low severity pkg/​term/​color.go — In ColorScheme, the field name Is256Enabled is inconsistent with the existing…
Low severity pkg/​term/​color_test.go — This test case is currently exercising the inaccessible gray-path because Accessible defaults…
Medium severity pkg/​term/​env.go — PR description says this “Resolves #279”, but the new Term.ColorScheme() API is not yet used…
What changed in this PR

Adds a ColorScheme API to pkg/term so callers can derive consistent ANSI styling behavior (including accessibility and theme awareness) from the current terminal environment.

Changes:

  • Introduces term.ColorScheme with common color/style helpers (muted, highlight, icons, reset).
  • Adds Term.ColorScheme() plus exported theme constants (NoTheme, LightTheme, DarkTheme).
  • Adds unit tests covering the new ColorScheme behaviors.
File Description
pkg/​term/​env.go Adds exported theme constants and a Term.ColorScheme() constructor that threads through theme, accessibility, and color capability flags.
pkg/​term/​color.go Introduces the new ColorScheme type and its ANSI styling helpers.
pkg/​term/​color_test.go Adds tests validating ColorScheme output behavior across themes and capabilities.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/term/color.go
Comment thread pkg/term/color_test.go
want string
}{
{name: "disabled returns plain text", cs: ColorScheme{ColorEnabled: false}, want: "plain"},
{name: "default theme no color", cs: ColorScheme{ColorEnabled: true, Theme: NoTheme}, want: "plain"},
Comment thread pkg/term/env.go
Comment on lines +157 to +161
// ColorScheme returns the [ColorScheme] for the current Term.
func (t Term) ColorScheme() ColorScheme {
return ColorScheme{
Accessible: color.IsAccessibleColorsEnabled(),
ColorEnabled: t.colorEnabled,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for ColorScheme

2 participants