Module: Reviewer::Output::AnsiStyles
- Included in:
- Printer
- Defined in:
- lib/reviewer/output/printer.rb
Overview
ANSI terminal escape sequences for styled console output. Extracted from Printer so style definitions are separated from printing mechanics.
Constant Summary collapse
- ESC =
"\e["- RESET =
"#{ESC}0m".freeze
- WEIGHTS =
Weight codes
{ default: 0, bold: 1, light: 2, italic: 3 }.freeze
- COLORS =
Color codes
{ black: 30, red: 31, green: 32, yellow: 33, blue: 34, magenta: 35, cyan: 36, gray: 37, default: 39 }.freeze
- STYLE_DEFS =
Style definitions: [weight, color]
{ success_bold: %i[bold green], success: %i[default green], success_light: %i[light green], error: %i[bold red], failure: %i[default red], warning: %i[bold yellow], warning_light: %i[light yellow], source: %i[italic default], bold: %i[default default], default: %i[default default], muted: %i[light gray] }.freeze
- STYLES =
Pre-computed ANSI escape strings for each style
STYLE_DEFS.transform_values do |weight_key, color_key| "#{ESC}#{WEIGHTS.fetch(weight_key)};#{COLORS.fetch(color_key)}m" end.freeze