Type:
Module
Constants:
VERSION : version

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.)

A_ATTRIBUTES : Character attribute mask

Bit-mask to extract attributes

See ::inch or Curses::Window#inch

A_NORMAL : Attribute mask

Normal display (no highlight)

See ::attrset

A_STANDOUT : Attribute mask

Best highlighting mode of the terminal.

See ::attrset

A_UNDERLINE : Attribute mask

Underlining

See ::attrset

A_REVERSE : Attribute mask

Reverse video

See ::attrset

A_BLINK : Attribute mask

Blinking

See ::attrset

A_DIM : Attribute mask

Half bright

See ::attrset

A_BOLD : Attribute mask

Extra bright or bold

See ::attrset

A_PROTECT : Attribute mask

Protected mode

See ::attrset

A_INVIS : Attribute mask

Invisible or blank mode

See ::attrset

A_ALTCHARSET : Attribute mask

Alternate character set

See ::attrset

A_CHARTEXT : Attribute mask

Bit-mask to extract a character

See ::attrset

A_HORIZONTAL : Attribute mask

horizontal highlight

Check system curs_attr(3x) for support

A_LEFT : Attribute mask

left highlight

Check system curs_attr(3x) for support

A_LOW : Attribute mask

low highlight

Check system curs_attr(3x) for support

A_RIGHT : Attribute mask

right highlight

Check system curs_attr(3x) for support

A_TOP : Attribute mask

top highlight

Check system curs_attr(3x) for support

A_VERTICAL : Attribute mask

vertical highlight

Check system curs_attr(3x) for support

A_COLOR : Character attribute mask

Bit-mask to extract color-pair field information

See ::inch or Curses::Window#inch

COLORS : UINT2NUM(COLORS)

Number of the colors available

COLOR_BLACK : UINT2NUM(COLOR_BLACK)

Value of the color black

COLOR_RED : UINT2NUM(COLOR_RED)

Value of the color red

COLOR_GREEN : UINT2NUM(COLOR_GREEN)

Value of the color green

COLOR_YELLOW : UINT2NUM(COLOR_YELLOW)

Value of the color yellow

COLOR_BLUE : UINT2NUM(COLOR_BLUE)

Value of the color blue

COLOR_MAGENTA : UINT2NUM(COLOR_MAGENTA)

Value of the color magenta

COLOR_CYAN : UINT2NUM(COLOR_CYAN)

Value of the color cyan

COLOR_WHITE : UINT2NUM(COLOR_WHITE)

Value of the color white

BUTTON1_PRESSED : Mouse event mask

mouse button 1 down

See ::getmouse

BUTTON1_RELEASED : Mouse event mask

mouse button 1 up

See ::getmouse

BUTTON1_CLICKED : Mouse event mask

mouse button 1 clicked

See ::getmouse

BUTTON1_DOUBLE_CLICKED : Mouse event mask

mouse button 1 double clicked

See ::getmouse

BUTTON1_TRIPLE_CLICKED : Mouse event mask

mouse button 1 triple clicked

See ::getmouse

BUTTON2_PRESSED : Mouse event mask

mouse button 2 down

See ::getmouse

BUTTON2_RELEASED : Mouse event mask

mouse button 2 up

See ::getmouse

BUTTON2_CLICKED : Mouse event mask

mouse button 2 clicked

See ::getmouse

BUTTON2_DOUBLE_CLICKED : Mouse event mask

mouse button 2 double clicked

See ::getmouse

BUTTON2_TRIPLE_CLICKED : Mouse event mask

mouse button 2 triple clicked

See ::getmouse

BUTTON3_PRESSED : Mouse event mask

mouse button 3 down

See ::getmouse

BUTTON3_RELEASED : Mouse event mask

mouse button 3 up

See ::getmouse

BUTTON3_CLICKED : Mouse event mask

mouse button 3 clicked

See ::getmouse

BUTTON3_DOUBLE_CLICKED : Mouse event mask

mouse button 3 double clicked

See ::getmouse

BUTTON3_TRIPLE_CLICKED : Mouse event mask

mouse button 3 triple clicked

See ::getmouse

BUTTON4_PRESSED : Mouse event mask

mouse button 4 down

See ::getmouse

BUTTON4_RELEASED : Mouse event mask

mouse button 4 up

See ::getmouse

BUTTON4_CLICKED : Mouse event mask

mouse button 4 clicked

See ::getmouse

BUTTON4_DOUBLE_CLICKED : Mouse event mask

mouse button 4 double clicked

See ::getmouse

BUTTON4_TRIPLE_CLICKED : Mouse event mask

mouse button 4 triple clicked

See ::getmouse

BUTTON_SHIFT : Mouse event mask

shift was down during button state change

See ::getmouse

BUTTON_CTRL : Mouse event mask

control was down during button state change

See ::getmouse

BUTTON_ALT : Mouse event mask

alt was down during button state change

See ::getmouse

ALL_MOUSE_EVENTS : Mouse event mask

report all button state changes

See ::getmouse

REPORT_MOUSE_POSITION : Mouse event mask

report mouse movement

See ::getmouse

KEY_MOUSE : UINT2NUM(KEY_MOUSE)

Mouse event read

KEY_MIN : UINT2NUM(KEY_MIN)

The minimum allowed curses key value.

KEY_BREAK : UINT2NUM(KEY_BREAK)

Break key

KEY_DOWN : UINT2NUM(KEY_DOWN)

the down arrow key

KEY_UP : UINT2NUM(KEY_UP)

the up arrow key

KEY_LEFT : UINT2NUM(KEY_LEFT)

the left arrow key

KEY_RIGHT : UINT2NUM(KEY_RIGHT)

the right arrow key

KEY_HOME : UINT2NUM(KEY_HOME)

Home key (upward+left arrow)

KEY_BACKSPACE : UINT2NUM(KEY_BACKSPACE)

Backspace

KEY_DL : UINT2NUM(KEY_DL)

Delete line

KEY_IL : UINT2NUM(KEY_IL)

Insert line

KEY_DC : UINT2NUM(KEY_DC)

Delete character

KEY_IC : UINT2NUM(KEY_IC)

Insert char or enter insert mode

KEY_EIC : UINT2NUM(KEY_EIC)

Enter insert char mode

KEY_CLEAR : UINT2NUM(KEY_CLEAR)

Clear Screen

KEY_EOS : UINT2NUM(KEY_EOS)

Clear to end of screen

KEY_EOL : UINT2NUM(KEY_EOL)

Clear to end of line

KEY_SF : UINT2NUM(KEY_SF)

Scroll 1 line forward

KEY_SR : UINT2NUM(KEY_SR)

Scroll 1 line backware (reverse)

KEY_NPAGE : UINT2NUM(KEY_NPAGE)

Next page

KEY_PPAGE : UINT2NUM(KEY_PPAGE)

Previous page

KEY_STAB : UINT2NUM(KEY_STAB)

Set tab

KEY_CTAB : UINT2NUM(KEY_CTAB)

Clear tab

KEY_CATAB : UINT2NUM(KEY_CATAB)

Clear all tabs

KEY_ENTER : UINT2NUM(KEY_ENTER)

Enter or send

KEY_SRESET : UINT2NUM(KEY_SRESET)

Soft (partial) reset

KEY_RESET : UINT2NUM(KEY_RESET)

Reset or hard reset

KEY_PRINT : UINT2NUM(KEY_PRINT)

Print or copy

KEY_LL : UINT2NUM(KEY_LL)

Home down or bottom (lower left)

KEY_A1 : UINT2NUM(KEY_A1)

Upper left of keypad

KEY_A3 : UINT2NUM(KEY_A3)

Upper right of keypad

KEY_B2 : UINT2NUM(KEY_B2)

Center of keypad

KEY_C1 : UINT2NUM(KEY_C1)

Lower left of keypad

KEY_C3 : UINT2NUM(KEY_C3)

Lower right of keypad

KEY_BTAB : UINT2NUM(KEY_BTAB)

Back tab key

KEY_BEG : UINT2NUM(KEY_BEG)

Beginning key

KEY_CANCEL : UINT2NUM(KEY_CANCEL)

Cancel key

KEY_CLOSE : UINT2NUM(KEY_CLOSE)

Close key

KEY_COMMAND : UINT2NUM(KEY_COMMAND)

Cmd (command) key

KEY_COPY : UINT2NUM(KEY_COPY)

Copy key

KEY_CREATE : UINT2NUM(KEY_CREATE)

Create key

KEY_END : UINT2NUM(KEY_END)

End key

KEY_EXIT : UINT2NUM(KEY_EXIT)

Exit key

KEY_FIND : UINT2NUM(KEY_FIND)

Find key

KEY_HELP : UINT2NUM(KEY_HELP)

Help key

KEY_MARK : UINT2NUM(KEY_MARK)

Mark key

KEY_MESSAGE : UINT2NUM(KEY_MESSAGE)

Message key

KEY_MOVE : UINT2NUM(KEY_MOVE)

Move key

KEY_NEXT : UINT2NUM(KEY_NEXT)

Next object key

KEY_OPEN : UINT2NUM(KEY_OPEN)

Open key

KEY_OPTIONS : UINT2NUM(KEY_OPTIONS)

Options key

KEY_PREVIOUS : UINT2NUM(KEY_PREVIOUS)

Previous object key

KEY_REDO : UINT2NUM(KEY_REDO)

Redo key

KEY_REFERENCE : UINT2NUM(KEY_REFERENCE)

Reference key

KEY_REFRESH : UINT2NUM(KEY_REFRESH)

Refresh key

KEY_REPLACE : UINT2NUM(KEY_REPLACE)

Replace key

KEY_RESTART : UINT2NUM(KEY_RESTART)

Restart key

KEY_RESUME : UINT2NUM(KEY_RESUME)

Resume key

KEY_SAVE : UINT2NUM(KEY_SAVE)

Save key

KEY_SBEG : UINT2NUM(KEY_SBEG)

Shifted beginning key

KEY_SCANCEL : UINT2NUM(KEY_SCANCEL)

Shifted cancel key

KEY_SCOMMAND : UINT2NUM(KEY_SCOMMAND)

Shifted command key

KEY_SCOPY : UINT2NUM(KEY_SCOPY)

Shifted copy key

KEY_SCREATE : UINT2NUM(KEY_SCREATE)

Shifted create key

KEY_SDC : UINT2NUM(KEY_SDC)

Shifted delete char key

KEY_SDL : UINT2NUM(KEY_SDL)

Shifted delete line key

KEY_SELECT : UINT2NUM(KEY_SELECT)

Select key

KEY_SEND : UINT2NUM(KEY_SEND)

Shifted end key

KEY_SEOL : UINT2NUM(KEY_SEOL)

Shifted clear line key

KEY_SEXIT : UINT2NUM(KEY_SEXIT)

Shifted exit key

KEY_SFIND : UINT2NUM(KEY_SFIND)

Shifted find key

KEY_SHELP : UINT2NUM(KEY_SHELP)

Shifted help key

KEY_SHOME : UINT2NUM(KEY_SHOME)

Shifted home key

KEY_SIC : UINT2NUM(KEY_SIC)

Shifted input key

KEY_SLEFT : UINT2NUM(KEY_SLEFT)

Shifted left arrow key

KEY_SMESSAGE : UINT2NUM(KEY_SMESSAGE)

Shifted message key

KEY_SMOVE : UINT2NUM(KEY_SMOVE)

Shifted move key

KEY_SNEXT : UINT2NUM(KEY_SNEXT)

Shifted next key

KEY_SOPTIONS : UINT2NUM(KEY_SOPTIONS)

Shifted options key

KEY_SPREVIOUS : UINT2NUM(KEY_SPREVIOUS)

Shifted previous key

KEY_SPRINT : UINT2NUM(KEY_SPRINT)

Shifted print key

KEY_SREDO : UINT2NUM(KEY_SREDO)

Shifted redo key

KEY_SREPLACE : UINT2NUM(KEY_SREPLACE)

Shifted replace key

KEY_SRIGHT : UINT2NUM(KEY_SRIGHT)

Shifted right arrow key

KEY_SRSUME : UINT2NUM(KEY_SRSUME)

Shifted resume key

KEY_SSAVE : UINT2NUM(KEY_SSAVE)

Shifted save key

KEY_SSUSPEND : UINT2NUM(KEY_SSUSPEND)

Shifted suspend key

KEY_SUNDO : UINT2NUM(KEY_SUNDO)

Shifted undo key

KEY_SUSPEND : UINT2NUM(KEY_SUSPEND)

Suspend key

KEY_UNDO : UINT2NUM(KEY_UNDO)

Undo key

KEY_RESIZE : UINT2NUM(KEY_RESIZE)

Screen Resized

KEY_MAX : UINT2NUM(KEY_MAX)

The maximum allowed curses key value.

Description

An implementation of the CRT screen handling and optimization library.

Structures and such

Classes

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
    
close_screen

close_screen() Class Public methods A program should always call

2015-04-02 05:31:20
ESCDELAY

ESCDELAY() Class Public methods Returns the total time, in milliseconds, for

2015-04-02 04:32:17
use_default_colors

use_default_colors() Class Public methods tells the curses library to use terminal's

2015-04-02 09:20:22
deleteln

deleteln() Class Public methods Delete the line under the cursor.

2015-04-02 06:30:01
raw

raw() Class Public methods Put the terminal into raw mode. Raw

2015-04-02 08:20:35
ESCDELAY=

Curses.ESCDELAY=(value) Class Public methods Sets the

2015-04-02 04:33:02
TABSIZE

TABSIZE() Class Public methods Returns the number of positions in a tab.

2015-04-02 04:35:09
can_change_color?

can_change_color?() Class Public methods Returns true or false

2015-04-02 05:18:23
init_color

init_color(color, r, g, b) Class Public methods Changes the definition of a

2015-04-02 07:04:03
bkgd

bkgd(ch) Class Public methods

2015-04-02 05:13:01