6.12.3 Constants

The curses module defines the following data members:

version
A string representing the current version of the module. Also available as __version__.

Several constants are available to specify character cell attributes:

Attribute Meaning 
A_ALTCHARSETAlternate character set mode.
A_BLINKBlink mode.
A_BOLDBold mode.
A_DIMDim mode.
A_NORMALNormal attribute.
A_STANDOUTStandout mode.
A_UNDERLINEUnderline mode.

Keys are referred to by integer constants with names starting with "KEY_". The exact keycaps available are system dependent.

Key constant Key 
KEY_MINMinimum key value
KEY_BREAK Break key (unreliable)
KEY_DOWN Down-arrow
KEY_UP Up-arrow
KEY_LEFT Left-arrow
KEY_RIGHT Right-arrow
KEY_HOME Home key (upward+left arrow)
KEY_BACKSPACE Backspace (unreliable)
KEY_F0 Function keys. Up to 64 function keys are supported.
KEY_Fn Value of function key n
KEY_DL Delete line
KEY_IL Insert line
KEY_DC Delete character
KEY_IC Insert char or enter insert mode
KEY_EIC Exit insert char mode
KEY_CLEAR Clear screen
KEY_EOS Clear to end of screen
KEY_EOL Clear to end of line
KEY_SF Scroll 1 line forward
KEY_SR Scroll 1 line backward (reverse)
KEY_NPAGE Next page
KEY_PPAGE Previous page
KEY_STAB Set tab
KEY_CTAB Clear tab
KEY_CATAB Clear all tabs
KEY_ENTER Enter or send (unreliable)
KEY_SRESET Soft (partial) reset (unreliable)
KEY_RESET Reset or hard reset (unreliable)
KEY_PRINT Print
KEY_LL Home down or bottom (lower left)
KEY_A1 Upper left of keypad
KEY_A3 Upper right of keypad
KEY_B2 Center of keypad
KEY_C1 Lower left of keypad
KEY_C3 Lower right of keypad
KEY_BTAB Back tab
KEY_BEG Beg (beginning)
KEY_CANCEL Cancel
KEY_CLOSE Close
KEY_COMMAND Cmd (command)
KEY_COPY Copy
KEY_CREATE Create
KEY_END End
KEY_EXIT Exit
KEY_FIND Find
KEY_HELP Help
KEY_MARK Mark
KEY_MESSAGE Message
KEY_MOVE Move
KEY_NEXT Next
KEY_OPEN Open
KEY_OPTIONS Options
KEY_PREVIOUS Prev (previous)
KEY_REDO Redo
KEY_REFERENCE Ref (reference)
KEY_REFRESH Refresh
KEY_REPLACE Replace
KEY_RESTART Restart
KEY_RESUME Resume
KEY_SAVE Save
KEY_SBEG Shifted Beg (beginning)
KEY_SCANCEL Shifted Cancel
KEY_SCOMMAND Shifted Command
KEY_SCOPY Shifted Copy
KEY_SCREATE Shifted Create
KEY_SDC Shifted Delete char
KEY_SDL Shifted Delete line
KEY_SELECT Select
KEY_SEND Shifted End
KEY_SEOL Shifted Clear line
KEY_SEXIT Shifted Dxit
KEY_SFIND Shifted Find
KEY_SHELP Shifted Help
KEY_SHOME Shifted Home
KEY_SIC Shifted Input
KEY_SLEFT Shifted Left arrow
KEY_SMESSAGE Shifted Message
KEY_SMOVE Shifted Move
KEY_SNEXT Shifted Next
KEY_SOPTIONS Shifted Options
KEY_SPREVIOUS Shifted Prev
KEY_SPRINT Shifted Print
KEY_SREDO Shifted Redo
KEY_SREPLACE Shifted Replace
KEY_SRIGHT Shifted Right arrow
KEY_SRSUME Shifted Resume
KEY_SSAVE Shifted Save
KEY_SSUSPEND Shifted Suspend
KEY_SUNDO Shifted Undo
KEY_SUSPEND Suspend
KEY_UNDO Undo
KEY_MOUSE Mouse event has occurred
KEY_RESIZE Terminal resize event
KEY_MAXMaximum key value

On VT100s and their software emulations, such as X terminal emulators, there are normally at least four function keys (KEY_F1, KEY_F2, KEY_F3, KEY_F4) available, and the arrow keys mapped to KEY_UP, KEY_DOWN, KEY_LEFT and KEY_RIGHT in the obvious way. If your machine has a PC keybboard, it is safe to expect arrow keys and twelve function keys (older PC keyboards may have only ten function keys); also, the following keypad mappings are standard:

Keycap Constant 
InsertKEY_IC
DeleteKEY_DC
HomeKEY_HOME
EndKEY_END
Page UpKEY_NPAGE
Page DownKEY_PPAGE

The following table lists characters from the alternate character set. These are inherited from the VT100 terminal, and will generally be available on software emulations such as X terminals. When there is no graphic available, curses falls back on a crude printable ASCII approximation. Note: These are available only after initscr() has been called.

ACS code Meaning 
ACS_BBSSalternate name for upper right corner
ACS_BLOCKsolid square block
ACS_BOARDboard of squares
ACS_BSBSalternate name for horizontal line
ACS_BSSBalternate name for upper left corner
ACS_BSSSalternate name for top tee
ACS_BTEEbottom tee
ACS_BULLETbullet
ACS_CKBOARDchecker board (stipple)
ACS_DARROWarrow pointing down
ACS_DEGREEdegree symbol
ACS_DIAMONDdiamond
ACS_GEQUALgreater-than-or-equal-to
ACS_HLINEhorizontal line
ACS_LANTERNlantern symbol
ACS_LARROWleft arrow
ACS_LEQUALless-than-or-equal-to
ACS_LLCORNERlower left-hand corner
ACS_LRCORNERlower right-hand corner
ACS_LTEEleft tee
ACS_NEQUALnot-equal sign
ACS_PIletter pi
ACS_PLMINUSplus-or-minus sign
ACS_PLUSbig plus sign
ACS_RARROWright arrow
ACS_RTEEright tee
ACS_S1scan line 1
ACS_S3scan line 3
ACS_S7scan line 7
ACS_S9scan line 9
ACS_SBBSalternate name for lower right corner
ACS_SBSBalternate name for vertical line
ACS_SBSSalternate name for right tee
ACS_SSBBalternate name for lower left corner
ACS_SSBSalternate name for bottom tee
ACS_SSSBalternate name for left tee
ACS_SSSSalternate name for crossover or big plus
ACS_STERLINGpound sterling
ACS_TTEEtop tee
ACS_UARROWup arrow
ACS_ULCORNERupper left corner
ACS_URCORNERupper right corner
ACS_VLINEvertical line

The following table lists the predefined colors:

Constant Color 
COLOR_BLACKBlack
COLOR_BLUEBlue
COLOR_CYANCyan (light greenish blue)
COLOR_GREENGreen
COLOR_MAGENTAMagenta (purplish red)
COLOR_REDRed
COLOR_WHITEWhite
COLOR_YELLOWYellow