Sha256: ee8a41c9318e9c2b9290cf71d225108f96bf5d73ba8bfacb5739d0291cebed03

Contents?: true

Size: 621 Bytes

Versions: 3

Compression:

Stored size: 621 Bytes

Contents

#!/usr/bin/env ruby

require "curses"
include Curses

# The TERM environment variable should be set to xterm-256color etc. to
# use 256 colors.  Curses.colors returns the color numbers of the terminal.

begin
  init_screen

  if !Curses.has_colors?
    addstr "This Terminal does not support colors!"
  else
    start_color

    addstr "This Terminal supports #{colors} colors.\n"

    Curses.colors.times { |i|
      Curses.init_pair(i, i, 0)
      attrset(color_pair(i))
      addstr("#{i.to_s.rjust(3)} ")
      addstr("\n") if i == 15 || (i > 16 && (i - 15) % 36 == 0)
    }
  end

  getch

ensure
  close_screen
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
curses-1.4.7 sample/colors.rb
curses-1.4.6 sample/colors.rb
curses-1.4.5 sample/colors.rb