Skip to content

feat: add DisableCaps() for individual terminal cap control - #100

Open
mikeschinkel wants to merge 1 commit into
charmbracelet:mainfrom
mikeschinkel:feat/disable-caps
Open

feat: add DisableCaps() for individual terminal cap control#100
mikeschinkel wants to merge 1 commit into
charmbracelet:mainfrom
mikeschinkel:feat/disable-caps

Conversation

@mikeschinkel

@mikeschinkel mikeschinkel commented Mar 25, 2026

Copy link
Copy Markdown

Summary

  • Add DisableCaps(...Capability) method to TerminalRenderer to allow disabling specific terminal capabilities
  • Export capability constants such as CapCBT, CapREP, CapECH, etc. so callers can reference them
  • Support UV_DISABLE_CAPS=CBT,REP environment var so end users can adjust for edge-case terminals without code changes

Motivation

xtermCaps() maps TERM values to capability sets, but some terminal emulators report a standard TERM (e.g. xterm-256color) while not correctly implementing all the capabilities that implies. Currently there is no way to selectively disable specific optimizations — the only workaround is overriding TERM to a less capable terminal type, which degrades the entire rendering pipeline (e.g. losing TrueColor).

This PR adds fine-grained control: disable only the problematic capability while keeping everything else at full quality.

Example: JetBrains GoLand and all IntelliJ-based IDEs use JediTerm, which reports as xterm-256color but mishandles CBT (Cursor Backward Tab), causing invalid rendering. A follow-up PR will add auto-detection for known problematic terminals like JediTerm; this PR provides the underlying API that makes that possible, plus a manual escape hatch for terminals not yet auto-detected.

Usage

Programmatic:

renderer.DisableCaps(uv.CapCBT)

Environment variable (useful for debugging):

UV_DISABLE_CAPS=CBT,REP myapp

Changes

  • disable_caps.go — New file. Exports Capability type alias, 10 capability constants (CapVPA, CapHPA, CapCHA, CapCHT, CapCBT, CapREP, CapECH, CapICH, CapSD, CapSU), the DisableCaps() method, and applyDisableCaps() for env var support.
  • disable_caps_test.go — New file. 4 tests covering single disable, multiple disable, exported constant correctness, and env var parsing.
  • terminal_renderer.go — One-line addition: calls applyDisableCaps() during NewTerminalRenderer() so the env var is respected automatically.

Test plan

  • TestDisableCaps — single capability disable, others unaffected
  • TestDisableCapsMultiple — multiple capabilities disabled simultaneously
  • TestExportedCapabilityConstants — exported constants match internal values
  • TestApplyDisableCapsEnvUV_DISABLE_CAPS env var parsing and application
  • All existing tests pass

Export internal capabilities bitmask as a Capability type
alias with named constants (CapVPA, CapHPA, CapCHA, CapCHT,
CapCBT, CapREP, CapECH, CapICH, CapSD, CapSU) so consumers
can selectively disable specific terminal optimizations.

Add TerminalRenderer.DisableCaps() for programmatic use
and support UV_DISABLE_CAPS environment variable (comma-
separated cap names) for debugging.

This is needed for terminal emulators like JediTerm
(GoLand/IntelliJ) that mishandle specific escape
sequences like CBT (Cursor Backward Tab).
@mikeschinkel mikeschinkel changed the title feat: add DisableCaps() to work around broken GoLand/JetBrains Run/Debug TTY feat: add DisableCaps() for fine-grained terminal capability control Mar 25, 2026
@mikeschinkel mikeschinkel changed the title feat: add DisableCaps() for fine-grained terminal capability control feat: add DisableCaps() for individual terminal cap control Mar 25, 2026
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.

1 participant