Created
January 23, 2009 06:28
-
-
Save rkumar/50914 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example ncurses program that should print all combinations of foreground | |
# color on background color but doesn't work. | |
# Make your terminal 256 characters wide for best view. | |
require 'rubygems' | |
require 'ncurses' | |
screen = Ncurses.initscr | |
Ncurses.noecho | |
Ncurses.cbreak | |
Ncurses.start_color | |
screen.addstr(Ncurses.COLORS.to_s) | |
screen.getch | |
Ncurses.curs_set 0 | |
Ncurses.move 0, 0 | |
Ncurses.clear | |
Ncurses.refresh | |
cc = Ncurses.COLORS | |
begin | |
color_count = 0 | |
cc.times do |bg| | |
cc.times do |fg| | |
Ncurses.init_pair(color_count, fg, bg) | |
screen.attron(Ncurses.COLOR_PAIR(color_count)) | |
screen.addstr("#") | |
screen.attroff(Ncurses.COLOR_PAIR(color_count)) | |
color_count += 1 | |
end | |
screen.addstr("== #{bg} ===\n") | |
#if bg % 8 == 0 | |
# Ncurses.refresh | |
ch = screen.getch | |
break if ch == ?q | |
Ncurses.clear | |
color_count = 0 | |
#end | |
end | |
=begin | |
color_count.times do |i| | |
screen.attrset(Ncurses.COLOR_PAIR(i)) | |
screen.addstr("#") | |
end | |
=end | |
ensure | |
Ncurses.endwin | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment