Identifies curses library version.
-
âncurses 5.9.20110404â
-
âPDCurses 3.4 - Public Domain 2008â
-
âcurses (SVR4)â (System V curses)
-
âcurses (unknown)â (The original BSD curses? NetBSD maybe.)
Bit-mask to extract attributes
See ::inch or Curses::Window#inch
Normal display (no highlight)
See ::attrset
Best highlighting mode of the terminal.
See ::attrset
Underlining
See ::attrset
Reverse video
See ::attrset
Blinking
See ::attrset
Half bright
See ::attrset
Extra bright or bold
See ::attrset
Protected mode
See ::attrset
Invisible or blank mode
See ::attrset
Alternate character set
See ::attrset
Bit-mask to extract a character
See ::attrset
horizontal highlight
Check system curs_attr(3x) for support
left highlight
Check system curs_attr(3x) for support
low highlight
Check system curs_attr(3x) for support
right highlight
Check system curs_attr(3x) for support
top highlight
Check system curs_attr(3x) for support
vertical highlight
Check system curs_attr(3x) for support
Bit-mask to extract color-pair field information
See ::inch or Curses::Window#inch
Number of the colors available
Value of the color black
Value of the color red
Value of the color green
Value of the color yellow
Value of the color blue
Value of the color magenta
Value of the color cyan
Value of the color white
mouse button 1 down
See ::getmouse
mouse button 1 up
See ::getmouse
mouse button 1 clicked
See ::getmouse
mouse button 1 double clicked
See ::getmouse
mouse button 1 triple clicked
See ::getmouse
mouse button 2 down
See ::getmouse
mouse button 2 up
See ::getmouse
mouse button 2 clicked
See ::getmouse
mouse button 2 double clicked
See ::getmouse
mouse button 2 triple clicked
See ::getmouse
mouse button 3 down
See ::getmouse
mouse button 3 up
See ::getmouse
mouse button 3 clicked
See ::getmouse
mouse button 3 double clicked
See ::getmouse
mouse button 3 triple clicked
See ::getmouse
mouse button 4 down
See ::getmouse
mouse button 4 up
See ::getmouse
mouse button 4 clicked
See ::getmouse
mouse button 4 double clicked
See ::getmouse
mouse button 4 triple clicked
See ::getmouse
shift was down during button state change
See ::getmouse
control was down during button state change
See ::getmouse
alt was down during button state change
See ::getmouse
report all button state changes
See ::getmouse
report mouse movement
See ::getmouse
Mouse event read
The minimum allowed curses key value.
Break key
the down arrow key
the up arrow key
the left arrow key
the right arrow key
Home key (upward+left arrow)
Backspace
Delete line
Insert line
Delete character
Insert char or enter insert mode
Enter insert char mode
Clear Screen
Clear to end of screen
Clear to end of line
Scroll 1 line forward
Scroll 1 line backware (reverse)
Next page
Previous page
Set tab
Clear tab
Clear all tabs
Enter or send
Soft (partial) reset
Reset or hard reset
Print or copy
Home down or bottom (lower left)
Upper left of keypad
Upper right of keypad
Center of keypad
Lower left of keypad
Lower right of keypad
Back tab key
Beginning key
Cancel key
Close key
Cmd (command) key
Copy key
Create key
End key
Exit key
Find key
Help key
Mark key
Message key
Move key
Next object key
Open key
Options key
Previous object key
Redo key
Reference key
Refresh key
Replace key
Restart key
Resume key
Save key
Shifted beginning key
Shifted cancel key
Shifted command key
Shifted copy key
Shifted create key
Shifted delete char key
Shifted delete line key
Select key
Shifted end key
Shifted clear line key
Shifted exit key
Shifted find key
Shifted help key
Shifted home key
Shifted input key
Shifted left arrow key
Shifted message key
Shifted move key
Shifted next key
Shifted options key
Shifted previous key
Shifted print key
Shifted redo key
Shifted replace key
Shifted right arrow key
Shifted resume key
Shifted save key
Shifted suspend key
Shifted undo key
Suspend key
Undo key
Screen Resized
The maximum allowed curses key value.
Description
An implementation of the CRT screen handling and optimization library.
Structures and such
Classes
-
Curses::Window - class with the means to draw a window or box
-
Curses::MouseEvent - class for collecting mouse events
Modules
- Curses
-
The curses implementation
- Curses::Key
-
Collection of constants for keypress events
Examples
-
hello.rb
#!/usr/local/bin/ruby require "curses" include Curses def show_message(message) width = message.length + 6 win = Window.new(5, width, (lines - 5) / 2, (cols - width) / 2) win.box(?|, ?-) win.setpos(2, 3) win.addstr(message) win.refresh win.getch win.close end init_screen begin crmode # show_message("Hit any key") setpos((lines - 5) / 2, (cols - 10) / 2) addstr("Hit any key") refresh getch show_message("Hello, World!") refresh ensure close_screen end
-
rain.rb
#!/usr/local/bin/ruby # rain for a curses test require "curses" include Curses def onsig(sig) close_screen exit sig end def ranf rand(32767).to_f / 32767 end # main # for i in %w[HUP INT QUIT TERM] if trap(i, "SIG_IGN") != 0 then # 0 for SIG_IGN trap(i) {|sig| onsig(sig) } end end init_screen nl noecho srand xpos = {} ypos = {} r = lines - 4 c = cols - 4 for i in 0 .. 4 xpos[i] = (c * ranf).to_i + 2 ypos[i] = (r * ranf).to_i + 2 end i = 0 while TRUE x = (c * ranf).to_i + 2 y = (r * ranf).to_i + 2 setpos(y, x); addstr(".") setpos(ypos[i], xpos[i]); addstr("o") i = if i == 0 then 4 else i - 1 end setpos(ypos[i], xpos[i]); addstr("O") i = if i == 0 then 4 else i - 1 end setpos(ypos[i] - 1, xpos[i]); addstr("-") setpos(ypos[i], xpos[i] - 1); addstr("|.|") setpos(ypos[i] + 1, xpos[i]); addstr("-") i = if i == 0 then 4 else i - 1 end setpos(ypos[i] - 2, xpos[i]); addstr("-") setpos(ypos[i] - 1, xpos[i] - 1); addstr("/ \\") setpos(ypos[i], xpos[i] - 2); addstr("| O |") setpos(ypos[i] + 1, xpos[i] - 1); addstr("\\ /") setpos(ypos[i] + 2, xpos[i]); addstr("-") i = if i == 0 then 4 else i - 1 end setpos(ypos[i] - 2, xpos[i]); addstr(" ") setpos(ypos[i] - 1, xpos[i] - 1); addstr(" ") setpos(ypos[i], xpos[i] - 2); addstr(" ") setpos(ypos[i] + 1, xpos[i] - 1); addstr(" ") setpos(ypos[i] + 2, xpos[i]); addstr(" ") xpos[i] = x ypos[i] = y refresh sleep(0.5) end # end of main