summaryrefslogtreecommitdiff
path: root/examples/color_scheme.rb
blob: 5c00c9a616aee60eb8eeb8c883979d6272cfa5db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env ruby -w

# color_scheme.rb
#
#  Created by Jeremy Hinegardner on 2007-01-24
#  Copyright 2007 Jeremy Hinegardner.  All rights reserved

require "rubygems"
require "highline/import"

# Create a color scheme, naming color patterns with symbol names.
ft = HighLine::ColorScheme.new do |cs|
  cs[:headline] = %i[bold yellow on_black]
  cs[:horizontal_line] = %i[bold white on_blue]
  cs[:even_row]        = [:green]
  cs[:odd_row]         = [:magenta]
end

# Assign that color scheme to HighLine...
HighLine.color_scheme = ft

# ...and use it.
say("<%= color('Headline', :headline) %>")
say("<%= color('-'*20, :horizontal_line) %>")

# Setup a toggle for rows.
i = true
("A".."D").each do |row|
  row_color = i ? :even_row : :odd_row
  say("<%= color('#{row}', '#{row_color}') %>")
  i = !i
end