Skip to content

Instantly share code, notes, and snippets.

@fowlmouth
Created July 1, 2013 22:19
Show Gist options
  • Save fowlmouth/5905133 to your computer and use it in GitHub Desktop.
Save fowlmouth/5905133 to your computer and use it in GitHub Desktop.
NCurses wrapper
#***************************************************************************
# Copyright (c) 1998-2010,2011 Free Software Foundation, Inc. *
# *
# Permission is hereby granted, free of charge, to any person obtaining a *
# copy of this software and associated documentation files (the *
# "Software"), to deal in the Software without restriction, including *
# without limitation the rights to use, copy, modify, merge, publish, *
# distribute, distribute with modifications, sublicense, and/or sell *
# copies of the Software, and to permit persons to whom the Software is *
# furnished to do so, subject to the following conditions: *
# *
# The above copyright notice and this permission notice shall be included *
# in all copies or substantial portions of the Software. *
# *
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
# IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
# THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
# *
# Except as contained in this notice, the name(s) of the above copyright *
# holders shall not be used in advertising or otherwise to promote the *
# sale, use or other dealings in this Software without prior written *
# authorization. *
# **************************************************************************
#***************************************************************************
# Author: Zeyd M. Ben-Halim <[email protected]> 1992,1995 *
# and: Eric S. Raymond <[email protected]> *
# and: Thomas E. Dickey 1996-on *
# **************************************************************************
# $Id: curses.h.in,v 1.220 2011/01/22 19:47:20 tom Exp $
# These are defined only in curses.h, and are used for conditional compiles
const
NCURSES_VERSION_MAJOR* = 5
NCURSES_VERSION_MINOR* = 9
NCURSES_VERSION_PATCH* = 20110404
# This is defined in more than one ncurses header, for identification
const
NCURSES_VERSION* = "5.9"
#
# Identify the mouse encoding version.
#
const
NCURSES_MOUSE_VERSION* = 1
#
# Definitions to facilitate DLL's.
#
#
# User-definable tweak to disable the include of <stdbool.h>.
#
when not(defined(NCURSES_ENABLE_STDBOOL_H)):
const
NCURSES_ENABLE_STDBOOL_H* = 1
#
# NCURSES_ATTR_T is used to quiet compiler warnings when building ncurses
# configured using --disable-macros.
#
when defined(NCURSES_NOMACROS):
when not(defined(NCURSES_ATTR_T)):
const
NCURSES_ATTR_T* = attr_t
when not(defined(NCURSES_ATTR_T)):
const
NCURSES_ATTR_T* = int
#
# Expands to 'const' if ncurses is configured using --enable-const. Note that
# doing so makes it incompatible with other implementations of X/Open Curses.
#
#const
# NCURSES_INLINE* = inline
#
# The internal type used for color values
#
const
NCURSES_COLOR_T* = cshort
#
# Definition used to make WINDOW and similar structs opaque.
#
when not(defined(NCURSES_OPAQUE)):
const
NCURSES_OPAQUE* = 0
#
# The reentrant code relies on the opaque setting, but adds features.
#
when not(defined(NCURSES_REENTRANT)):
const
NCURSES_REENTRANT* = 0
#
# Control whether bindings for interop support are added.
#
const
NCURSES_INTEROP_FUNCS* = 0
#
# The internal type used for window dimensions.
#
type
NCURSES_SIZE_T* = cshort
#
# Control whether tparm() supports varargs or fixed-parameter list.
#
const
NCURSES_TPARM_VARARGS* = 1
#
# NCURSES_CH_T is used in building the library, but not used otherwise in
# this header file, since that would make the normal/wide-character versions
# of the header incompatible.
#
when false:# 0 and defined(_LP64):
type
chtype* = cuint
mmask_t* = cuint
else:
type
chtype* = culong
mmask_t* = culong
type
NCURSES_CH_T* = chtype
#
# We need FILE, etc. Include this before checking any feature symbols.
#
#
# With XPG4, you must define _XOPEN_SOURCE_EXTENDED, it is redundant (or
# conflicting) when _XOPEN_SOURCE is 500 or greater.
#
discard """ when defined(_XOPEN_SOURCE_EXTENDED) or defined(_XPG5):
const
NCURSES_WIDECHAR* = true
when defined(NCURSES_WIDECHAR): """
# X/Open and SVr4 specify that curses implements 'bool'. However, C++ may also
# implement it. If so, we must use the C++ compiler's type to avoid conflict
# with other interfaces.
#
# A further complication is that <stdbool.h> may declare 'bool' to be a
# different type, such as an enum which is not necessarily compatible with
# C++. If we have <stdbool.h>, make 'bool' a macro, so users may #undef it.
# Otherwise, let it remain a typedef to avoid conflicts with other #define's.
# In either case, make a typedef for NCURSES_BOOL which can be used if needed
# from either C or C++.
#
discard """ const
TRUE* = 1
const
FALSE* = 0
type
NCURSES_BOOL* = cuchar
when defined(__cplusplus): # __cplusplus, etc.
# use the C++ compiler's bool type
const
NCURSES_BOOL* = bool
else:
when NCURSES_ENABLE_STDBOOL_H:
# use whatever the C compiler decides bool really is
const
NCURSES_BOOL* = bool
else:
# there is no predefined bool - use our own
const
bool* = NCURSES_BOOL """
type NCURSES_BOOL * = bool
# colors
const
COLOR_BLACK* = 0
COLOR_RED* = 1
COLOR_GREEN* = 2
COLOR_YELLOW* = 3
COLOR_BLUE* = 4
COLOR_MAGENTA* = 5
COLOR_CYAN* = 6
COLOR_WHITE* = 7
# line graphics
#when 0 or NCURSES_REENTRANT:
# NCURSES_WRAPPED_VAR(chtype * , acs_map)
#else:
# # THIS SHOULD BE {.importc, nodecl.}!
# #extern chtype acs_map[];
var acs_map {.importc,nodecl.}: ptr array[255, chtype]
##define NCURSES_ACS(c) (acs_map[NCURSES_CAST(unsigned char,c)])
template NCURSES_ACS(c:char): expr = acs_map[c.int]
# VT100 symbols begin here
template ACS_ULCORNER*: expr = NCURSES_ACS('l') # upper left corner
template ACS_LLCORNER*: expr = NCURSES_ACS('m') # lower left corner
template ACS_URCORNER*: expr = NCURSES_ACS('k') # upper right corner
template ACS_LRCORNER*: expr = NCURSES_ACS('j') # lower right corner
template ACS_LTEE*: expr = NCURSES_ACS('t') # tee pointing right
template ACS_RTEE*: expr = NCURSES_ACS('u') # tee pointing left
template ACS_BTEE*: expr = NCURSES_ACS('v') # tee pointing up
template ACS_TTEE*: expr = NCURSES_ACS('w') # tee pointing down
template ACS_HLINE*: expr = NCURSES_ACS('q') # horizontal line
template ACS_VLINE*: expr = NCURSES_ACS('x') # vertical line
template ACS_PLUS*: expr = NCURSES_ACS('n') # large plus or crossover
template ACS_S1*: expr = NCURSES_ACS('o') # scan line 1
template ACS_S9*: expr = NCURSES_ACS('s') # scan line 9
template ACS_DIAMOND*: expr = NCURSES_ACS('`') # diamond
template ACS_CKBOARD*: expr = NCURSES_ACS('a') # checker board (stipple)
template ACS_DEGREE*: expr = NCURSES_ACS('f') # degree symbol
template ACS_PLMINUS*: expr = NCURSES_ACS('g') # plus/minus
template ACS_BULLET*: expr = NCURSES_ACS('~') # bullet
# Teletype 5410v1 symbols begin here
template ACS_LARROW*: expr = NCURSES_ACS(',') # arrow pointing left
template ACS_RARROW*: expr = NCURSES_ACS('+') # arrow pointing right
template ACS_DARROW*: expr = NCURSES_ACS('.') # arrow pointing down
template ACS_UARROW*: expr = NCURSES_ACS('-') # arrow pointing up
template ACS_BOARD*: expr = NCURSES_ACS('h') # board of squares
template ACS_LANTERN*: expr = NCURSES_ACS('i') # lantern symbol
template ACS_BLOCK*: expr = NCURSES_ACS('0') # solid square block
#
# These aren't documented, but a lot of System Vs have them anyway
# (you can spot pprryyzz{{||}} in a lot of AT&T terminfo strings).
# The ACS_names may not match AT&T's, our source didn't know them.
#
template ACS_S3*: expr = NCURSES_ACS('p') # scan line 3
template ACS_S7*: expr = NCURSES_ACS('r') # scan line 7
template ACS_LEQUAL*: expr = NCURSES_ACS('y') # less/equal
template ACS_GEQUAL*: expr = NCURSES_ACS('z') # greater/equal
template ACS_PI*: expr = NCURSES_ACS('{') # Pi
template ACS_NEQUAL*: expr = NCURSES_ACS('|') # not equal
template ACS_STERLING*: expr = NCURSES_ACS('}') # UK pound sign
#
# Line drawing ACS names are of the form ACS_trbl, where t is the top, r
# is the right, b is the bottom, and l is the left. t, r, b, and l might
# be B (blank), S (single), D (double), or T (thick). The subset defined
# here only uses B and S.
#
template ACS_BSSB*: expr = ACS_ULCORNER
template ACS_SSBB*: expr = ACS_LLCORNER
template ACS_BBSS*: expr = ACS_URCORNER
template ACS_SBBS*: expr = ACS_LRCORNER
template ACS_SBSS*: expr = ACS_RTEE
template ACS_SSSB*: expr = ACS_LTEE
template ACS_SSBS*: expr = ACS_BTEE
template ACS_BSSS*: expr = ACS_TTEE
template ACS_BSBS*: expr = ACS_HLINE
template ACS_SBSB*: expr = ACS_VLINE
template ACS_SSSS*: expr = ACS_PLUS
const
ERR* = (- 1)
const
OK* = (0)
# values for the _flags member
const
F_SUBWIN* = 0x00000001 # is this a sub-window?
F_ENDLINE* = 0x00000002 # is the window flush right?
F_FULLWIN* = 0x00000004 # is the window full-screen?
F_SCROLLWIN* = 0x00000008 # bottom edge is at screen bottom?
F_ISPAD* = 0x00000010 # is this window a pad?
F_HASMOVED* = 0x00000020 # has cursor moved since last refresh?
F_WRAPPED* = 0x00000040 # cursor was just wrappped
#
# this value is used in the firstchar and lastchar fields to mark
# unchanged lines
#
const
F_NOCHANGE* = - 1
#
# this value is used in the oldindex field to mark lines created by insertions
# and scrolls.
#
const
F_NEWINDEX* = - 1
type
attr_t* = chtype
# ...must be at least as wide as chtype
when defined(NCURSES_WIDECHAR):
#when 0:
# when defined(mblen): # libutf8.h defines it w/o undefining first
#when 0:
when 0:
type
wchar_t* = cushort
when 0:
type
wint_t* = cuint
#
# cchar_t stores an array of CCHARW_MAX wide characters. The first is
# normally a spacing character. The others are non-spacing. If those
# (spacing and nonspacing) do not fill the array, a null L'\0' follows.
# Otherwise, a null is assumed to follow when extracting via getcchar().
#
const
CCHARW_MAX* = 5
type
cchar_t* {.pure, final.} = object
attr*: attr_t
chars*: array[0..CCHARW_MAX - 1, wchar_t] ##if 0
##undef NCURSES_EXT_COLORS
##define NCURSES_EXT_COLORS 20110404
ext_color*: cint # color pair, must be more than 16-bits
##endif
when not NCURSES_OPAQUE:
type
ldat* {.pure, final.} = object
type
pdat* {.pure, final.} = object
pad_y*: NCURSES_SIZE_T
pad_x*: NCURSES_SIZE_T
pad_top*: NCURSES_SIZE_T
pad_left*: NCURSES_SIZE_T
pad_bottom*: NCURSES_SIZE_T
pad_right*: NCURSES_SIZE_T
type
WINDOW* {.pure, final.} = object
cury*: NCURSES_SIZE_T
curx*: NCURSES_SIZE_T # current cursor position\
# window location and size
maxy*: NCURSES_SIZE_T
maxx*: NCURSES_SIZE_T # maximums of x and y, NOT window size
begy*: NCURSES_SIZE_T
begx*: NCURSES_SIZE_T # screen coords of upper-left-hand corner
flags*: cshort # window state flags \
# attribute tracking
attrs*: attr_t # current attribute for non-space character
bkgd*: chtype # current background char/attribute pair\
# option values set by user
notimeout*: bool # no time out on function-key entry?
clear*: bool # consider all data in the window invalid?
leaveok*: bool # OK to not reset cursor on exit?
scroll*: bool # OK to scroll this window?
idlok*: bool # OK to use insert/delete line?
idcok*: bool # OK to use insert/delete char?
immed*: bool # window in immed mode? (not yet used)
sync*: bool # window in sync mode?
use_keypad*: bool # process function keys into KEY_ symbols?
delay*: cint # 0 = nodelay, <0 = blocking, >0 = delay
line*: ptr ldat # the actual line data \
# global screen state
regtop*: NCURSES_SIZE_T # top line of scrolling region
regbottom*: NCURSES_SIZE_T # bottom line of scrolling region \
# these are used only if this is a sub-window
parx*: cint # x coordinate of this window in parent
pary*: cint # y coordinate of this window in parent
parent*: ptr WINDOW # pointer to parent if a sub-window \
# these are used only if this is a pad
pad*: pdat
yoffset*: NCURSES_SIZE_T # real begy is _begy + _yoffset \
##ifdef NCURSES_WIDECHAR
bkgrnd*: cchar # current background char/attribute pair \
when false: ##if 0
color*: cint # current color-pair for non-space character \
##endif
##endif
#
# This is an extension to support events...
#
when 1:
when defined(NCURSES_WGETCH_EVENTS):
when not defined(__BEOS__) or defined(__HAIKU__):
# Fix _nc_timed_wait() on BEOS...
const
NCURSES_EVENT_VERSION* = 1
#
# Bits to set in _nc_event.data.flags
#
const
_NC_EVENT_TIMEOUT_MSEC* = 1
_NC_EVENT_FILE* = 2
_NC_EVENT_FILE_READABLE* = 2
when 0: # Not supported yet...
const
_NC_EVENT_FILE_WRITABLE* = 4
_NC_EVENT_FILE_EXCEPTION* = 8
type
_nc_event_file* {.pure, final.} = object
flags*: cuint
fd*: cint
result*: cuint
# _NC_EVENT_FILE
type
_nc_event_data* {.pure, final.} = object
timeout_msec*: clong # _NC_EVENT_TIMEOUT_MSEC
# _NC_EVENT_FILE
_nc_event* {.pure, final.} = object
type*: cint
data*: _nc_event_data
_nc_eventlist* {.pure, final.} = object
count*: cint
result_flags*: cint # _NC_EVENT_TIMEOUT_MSEC or _NC_EVENT_FILE_READABLE
events*: array[0..1 - 1, ptr _nc_event]
proc wgetch_events*(a2: ptr WINDOW; a3: ptr _nc_eventlist): cint {.cdecl.}
# experimental
proc wgetnstr_events*(a2: ptr WINDOW; a3: cstring; a4: cint;
a5: ptr _nc_eventlist): cint {.cdecl.}
# experimental
#
# GCC (and some other compilers) define '__attribute__'; we're using this
# macro to alert the compiler to flag inconsistencies in printf/scanf-like
# function calls. Just in case '__attribute__' isn't defined, make a dummy.
# Old versions of G++ do not accept it anyway, at least not consistently with
# GCC.
#
#
# We cannot define these in ncurses_cfg.h, since they require parameters to be
# passed (that is non-portable). If you happen to be using gcc with warnings
# enabled, define
# GCC_PRINTF
# GCC_SCANF
# to improve checking of calls to printw(), etc.
#
#
# Curses uses a helper function. Define our type for this to simplify
# extending it for the sp-funcs feature.
#
type
NCURSES_OUTC* = proc (a2: cint): cint
#
# Function prototypes. This is the complete X/Open Curses list of required
# functions. Those marked `generated' will have sources generated from the
# macro definitions later in this file, in order to satisfy XPG4.2
# requirements.
#
proc addch*(a2: chtype): cint {.cdecl.}
# generated
proc addchnstr*(a2: ptr chtype; a3: cint): cint {.cdecl.}
# generated
proc addchstr*(a2: ptr chtype): cint {.cdecl.}
# generated
proc addnstr*(a2: cstring; a3: cint): cint {.cdecl.}
# generated
proc addstr*(a2: cstring): cint {.cdecl.}
# generated
proc attroff*(a2: NCURSES_ATTR_T): cint {.cdecl.}
# generated
proc attron*(a2: NCURSES_ATTR_T): cint {.cdecl.}
# generated
proc attrset*(a2: NCURSES_ATTR_T): cint {.cdecl.}
# generated
proc attr_get*(a2: ptr attr_t; a3: ptr cshort; a4: pointer): cint {.cdecl.}
# generated
proc attr_off*(a2: attr_t; a3: pointer): cint {.cdecl.}
# generated
proc attr_on*(a2: attr_t; a3: pointer): cint {.cdecl.}
# generated
proc attr_set*(a2: attr_t; a3: cshort; a4: pointer): cint {.cdecl.}
# generated
proc baudrate*(): cint {.cdecl.}
# implemented
proc beep*(): cint {.cdecl.}
# implemented
proc bkgd*(a2: chtype): cint {.cdecl.}
# generated
proc bkgdset*(a2: chtype) {.cdecl.}
# generated
proc border*(a2: chtype; a3: chtype; a4: chtype; a5: chtype; a6: chtype;
a7: chtype; a8: chtype; a9: chtype): cint {.cdecl.}
# generated
proc box*(a2: ptr WINDOW; a3: chtype; a4: chtype): cint {.cdecl.}
# generated
proc can_change_color*(): bool {.cdecl.}
# implemented
proc cbreak*(): cint {.cdecl.}
# implemented
proc chgat*(a2: cint; a3: attr_t; a4: cshort; a5: pointer): cint {.cdecl.}
# generated
proc clear*(): cint {.cdecl.}
# generated
proc clearok*(a2: ptr WINDOW; a3: bool): cint {.cdecl.}
# implemented
proc clrtobot*(): cint {.cdecl.}
# generated
proc clrtoeol*(): cint {.cdecl.}
# generated
proc color_content*(a2: cshort; a3: ptr cshort; a4: ptr cshort; a5: ptr cshort): cint {.
cdecl.}
# implemented
proc color_set*(a2: cshort; a3: pointer): cint {.cdecl.}
# generated
proc COLOR_PAIR*(a2: cint): cint {.cdecl.}
# generated
proc copywin*(a2: ptr WINDOW; a3: ptr WINDOW; a4: cint; a5: cint; a6: cint;
a7: cint; a8: cint; a9: cint; a10: cint): cint {.cdecl.}
# implemented
proc curs_set*(a2: cint): cint {.cdecl.}
# implemented
proc def_prog_mode*(): cint {.cdecl.}
# implemented
proc def_shell_mode*(): cint {.cdecl.}
# implemented
proc delay_output*(a2: cint): cint {.cdecl.}
# implemented
proc delch*(): cint {.cdecl.}
# generated
proc delscreen*(a2: ptr SCREEN) {.cdecl.}
# implemented
proc delwin*(a2: ptr WINDOW): cint {.cdecl.}
# implemented
proc deleteln*(): cint {.cdecl.}
# generated
proc derwin*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cint): ptr WINDOW {.
cdecl.}
# implemented
proc doupdate*(): cint {.cdecl.}
# implemented
proc dupwin*(a2: ptr WINDOW): ptr WINDOW {.cdecl.}
# implemented
proc echo*(): cint {.cdecl.}
# implemented
proc echochar*(a2: chtype): cint {.cdecl.}
# generated
proc erase*(): cint {.cdecl.}
# generated
proc endwin*(): cint {.cdecl.}
# implemented
proc erasechar*(): char {.cdecl.}
# implemented
proc filter*() {.cdecl.}
# implemented
proc flash*(): cint {.cdecl.}
# implemented
proc flushinp*(): cint {.cdecl.}
# implemented
proc getbkgd*(a2: ptr WINDOW): chtype {.cdecl.}
# generated
proc getch*(): cint {.cdecl.}
# generated
proc getnstr*(a2: cstring; a3: cint): cint {.cdecl.}
# generated
proc getstr*(a2: cstring): cint {.cdecl.}
# generated
proc getwin*(a2: ptr FILE): ptr WINDOW {.cdecl.}
# implemented
proc halfdelay*(a2: cint): cint {.cdecl.}
# implemented
proc has_colors*(): bool {.cdecl.}
# implemented
proc has_ic*(): bool {.cdecl.}
# implemented
proc has_il*(): bool {.cdecl.}
# implemented
proc hline*(a2: chtype; a3: cint): cint {.cdecl.}
# generated
proc idcok*(a2: ptr WINDOW; a3: bool) {.cdecl.}
# implemented
proc idlok*(a2: ptr WINDOW; a3: bool): cint {.cdecl.}
# implemented
proc immedok*(a2: ptr WINDOW; a3: bool) {.cdecl.}
# implemented
proc inch*(): chtype {.cdecl.}
# generated
proc inchnstr*(a2: ptr chtype; a3: cint): cint {.cdecl.}
# generated
proc inchstr*(a2: ptr chtype): cint {.cdecl.}
# generated
proc initscr*(): ptr WINDOW {.cdecl.}
# implemented
proc init_color*(a2: cshort; a3: cshort; a4: cshort; a5: cshort): cint {.cdecl.}
# implemented
proc init_pair*(a2: cshort; a3: cshort; a4: cshort): cint {.cdecl.}
# implemented
proc innstr*(a2: cstring; a3: cint): cint {.cdecl.}
# generated
proc insch*(a2: chtype): cint {.cdecl.}
# generated
proc insdelln*(a2: cint): cint {.cdecl.}
# generated
proc insertln*(): cint {.cdecl.}
# generated
proc insnstr*(a2: cstring; a3: cint): cint {.cdecl.}
# generated
proc insstr*(a2: cstring): cint {.cdecl.}
# generated
proc instr*(a2: cstring): cint {.cdecl.}
# generated
proc intrflush*(a2: ptr WINDOW; a3: bool): cint {.cdecl.}
# implemented
proc isendwin*(): bool {.cdecl.}
# implemented
proc is_linetouched*(a2: ptr WINDOW; a3: cint): bool {.cdecl.}
# implemented
proc is_wintouched*(a2: ptr WINDOW): bool {.cdecl.}
# implemented
proc keyname*(a2: cint): cstring {.cdecl.}
# implemented
proc keypad*(a2: ptr WINDOW; a3: bool): cint {.cdecl.}
# implemented
proc killchar*(): char {.cdecl.}
# implemented
proc leaveok*(a2: ptr WINDOW; a3: bool): cint {.cdecl.}
# implemented
proc longname*(): cstring {.cdecl.}
# implemented
proc meta*(a2: ptr WINDOW; a3: bool): cint {.cdecl.}
# implemented
proc move*(a2: cint; a3: cint): cint {.cdecl.}
# generated
proc mvaddch*(a2: cint; a3: cint; a4: chtype): cint {.cdecl.}
# generated
proc mvaddchnstr*(a2: cint; a3: cint; a4: ptr chtype; a5: cint): cint {.cdecl.}
# generated
proc mvaddchstr*(a2: cint; a3: cint; a4: ptr chtype): cint {.cdecl.}
# generated
proc mvaddnstr*(a2: cint; a3: cint; a4: cstring; a5: cint): cint {.cdecl.}
# generated
proc mvaddstr*(a2: cint; a3: cint; a4: cstring): cint {.cdecl.}
# generated
proc mvchgat*(a2: cint; a3: cint; a4: cint; a5: attr_t; a6: cshort;
a7: pointer): cint {.cdecl.}
# generated
proc mvcur*(a2: cint; a3: cint; a4: cint; a5: cint): cint {.cdecl.}
# implemented
proc mvdelch*(a2: cint; a3: cint): cint {.cdecl.}
# generated
proc mvderwin*(a2: ptr WINDOW; a3: cint; a4: cint): cint {.cdecl.}
# implemented
proc mvgetch*(a2: cint; a3: cint): cint {.cdecl.}
# generated
proc mvgetnstr*(a2: cint; a3: cint; a4: cstring; a5: cint): cint {.cdecl.}
# generated
proc mvgetstr*(a2: cint; a3: cint; a4: cstring): cint {.cdecl.}
# generated
proc mvhline*(a2: cint; a3: cint; a4: chtype; a5: cint): cint {.cdecl.}
# generated
proc mvinch*(a2: cint; a3: cint): chtype {.cdecl.}
# generated
proc mvinchnstr*(a2: cint; a3: cint; a4: ptr chtype; a5: cint): cint {.cdecl.}
# generated
proc mvinchstr*(a2: cint; a3: cint; a4: ptr chtype): cint {.cdecl.}
# generated
proc mvinnstr*(a2: cint; a3: cint; a4: cstring; a5: cint): cint {.cdecl.}
# generated
proc mvinsch*(a2: cint; a3: cint; a4: chtype): cint {.cdecl.}
# generated
proc mvinsnstr*(a2: cint; a3: cint; a4: cstring; a5: cint): cint {.cdecl.}
# generated
proc mvinsstr*(a2: cint; a3: cint; a4: cstring): cint {.cdecl.}
# generated
proc mvinstr*(a2: cint; a3: cint; a4: cstring): cint {.cdecl.}
# generated
proc mvprintw*(a2: cint; a3: cint; a4: cstring): cint {.cdecl, varargs.}
# implemented
proc mvscanw*(a2: cint; a3: cint; a4: cstring): cint {.cdecl, varargs.}
# implemented
proc mvvline*(a2: cint; a3: cint; a4: chtype; a5: cint): cint {.cdecl.}
# generated
proc mvwaddch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: chtype): cint {.cdecl.}
# generated
proc mvwaddchnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr chtype;
a6: cint): cint {.cdecl.}
# generated
proc mvwaddchstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr chtype): cint {.
cdecl.}
# generated
proc mvwaddnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint {.
cdecl.}
# generated
proc mvwaddstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint {.cdecl.}
# generated
proc mvwchgat*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: attr_t;
a7: cshort; a8: pointer): cint {.cdecl.}
# generated
proc mvwdelch*(a2: ptr WINDOW; a3: cint; a4: cint): cint {.cdecl.}
# generated
proc mvwgetch*(a2: ptr WINDOW; a3: cint; a4: cint): cint {.cdecl.}
# generated
proc mvwgetnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint {.
cdecl.}
# generated
proc mvwgetstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint {.cdecl.}
# generated
proc mvwhline*(a2: ptr WINDOW; a3: cint; a4: cint; a5: chtype; a6: cint): cint {.
cdecl.}
# generated
proc mvwin*(a2: ptr WINDOW; a3: cint; a4: cint): cint {.cdecl.}
# implemented
proc mvwinch*(a2: ptr WINDOW; a3: cint; a4: cint): chtype {.cdecl.}
# generated
proc mvwinchnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr chtype; a6: cint): cint {.
cdecl.}
# generated
proc mvwinchstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: ptr chtype): cint {.
cdecl.}
# generated
proc mvwinnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint {.
cdecl.}
# generated
proc mvwinsch*(a2: ptr WINDOW; a3: cint; a4: cint; a5: chtype): cint {.cdecl.}
# generated
proc mvwinsnstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring; a6: cint): cint {.
cdecl.}
# generated
proc mvwinsstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint {.cdecl.}
# generated
proc mvwinstr*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint {.cdecl.}
# generated
proc mvwprintw*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint {.
cdecl, varargs.}
# implemented
proc mvwscanw*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cstring): cint {.cdecl,
varargs.}
# implemented
proc mvwvline*(a2: ptr WINDOW; a3: cint; a4: cint; a5: chtype; a6: cint): cint {.
cdecl.}
# generated
proc napms*(a2: cint): cint {.cdecl.}
# implemented
proc newpad*(a2: cint; a3: cint): ptr WINDOW {.cdecl.}
# implemented
proc newterm*(a2: cstring; a3: ptr FILE; a4: ptr FILE): ptr SCREEN {.cdecl.}
# implemented
proc newwin*(a2: cint; a3: cint; a4: cint; a5: cint): ptr WINDOW {.cdecl.}
# implemented
proc nl*(): cint {.cdecl.}
# implemented
proc nocbreak*(): cint {.cdecl.}
# implemented
proc nodelay*(a2: ptr WINDOW; a3: bool): cint {.cdecl.}
# implemented
proc noecho*(): cint {.cdecl.}
# implemented
proc nonl*(): cint {.cdecl.}
# implemented
proc noqiflush*() {.cdecl.}
# implemented
proc noraw*(): cint {.cdecl.}
# implemented
proc notimeout*(a2: ptr WINDOW; a3: bool): cint {.cdecl.}
# implemented
proc overlay*(a2: ptr WINDOW; a3: ptr WINDOW): cint {.cdecl.}
# implemented
proc overwrite*(a2: ptr WINDOW; a3: ptr WINDOW): cint {.cdecl.}
# implemented
proc pair_content*(a2: cshort; a3: ptr cshort; a4: ptr cshort): cint {.cdecl.}
# implemented
proc PAIR_NUMBER*(a2: cint): cint {.cdecl.}
# generated
proc pechochar*(a2: ptr WINDOW; a3: chtype): cint {.cdecl.}
# implemented
proc pnoutrefresh*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cint;
a7: cint; a8: cint): cint {.cdecl.}
# implemented
proc prefresh*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cint;
a7: cint; a8: cint): cint {.cdecl.}
# implemented
proc printw*(a2: cstring): cint {.cdecl, varargs.}
# implemented
proc putwin*(a2: ptr WINDOW; a3: ptr FILE): cint {.cdecl.}
# implemented
proc qiflush*() {.cdecl.}
# implemented
proc raw*(): cint {.cdecl.}
# implemented
proc redrawwin*(a2: ptr WINDOW): cint {.cdecl.}
# generated
proc refresh*(): cint {.cdecl.}
# generated
proc resetty*(): cint {.cdecl.}
# implemented
proc reset_prog_mode*(): cint {.cdecl.}
# implemented
proc reset_shell_mode*(): cint {.cdecl.}
# implemented
type
ripoffline_param_cb* = proc (a2: ptr WINDOW; a3: cint): cint
proc ripoffline*(a1: cint; a2: ripoffline_param_cb): cint {.cdecl.}
# implemented
proc savetty*(): cint {.cdecl.}
# implemented
proc scanw*(a2: cstring): cint {.cdecl, varargs.}
proc scr_dump*(a2: cstring): cint {.cdecl.}
# implemented
proc scr_init*(a2: cstring): cint {.cdecl.}
# implemented
proc scrl*(a2: cint): cint {.cdecl.}
# generated
proc scroll*(a2: ptr WINDOW): cint {.cdecl.}
# generated
proc scrollok*(a2: ptr WINDOW; a3: bool): cint {.cdecl.}
# implemented
proc scr_restore*(a2: cstring): cint {.cdecl.}
# implemented
proc scr_set*(a2: cstring): cint {.cdecl.}
# implemented
proc setscrreg*(a2: cint; a3: cint): cint {.cdecl.}
# generated
proc set_term*(a2: ptr SCREEN): ptr SCREEN {.cdecl.}
# implemented
proc slk_attroff*(a2: chtype): cint {.cdecl.}
# implemented
proc slk_attr_off*(a2: attr_t; a3: pointer): cint {.cdecl.}
# generated:WIDEC
proc slk_attron*(a2: chtype): cint {.cdecl.}
# implemented
proc slk_attr_on*(a2: attr_t; a3: pointer): cint {.cdecl.}
# generated:WIDEC
proc slk_attrset*(a2: chtype): cint {.cdecl.}
# implemented
proc slk_attr*(): attr_t {.cdecl.}
# implemented
proc slk_attr_set*(a2: attr_t; a3: cshort; a4: pointer): cint {.cdecl.}
# implemented
proc slk_clear*(): cint {.cdecl.}
# implemented
proc slk_color*(a2: cshort): cint {.cdecl.}
# implemented
proc slk_init*(a2: cint): cint {.cdecl.}
# implemented
proc slk_label*(a2: cint): cstring {.cdecl.}
# implemented
proc slk_noutrefresh*(): cint {.cdecl.}
# implemented
proc slk_refresh*(): cint {.cdecl.}
# implemented
proc slk_restore*(): cint {.cdecl.}
# implemented
proc slk_set*(a2: cint; a3: cstring; a4: cint): cint {.cdecl.}
# implemented
proc slk_touch*(): cint {.cdecl.}
# implemented
proc standout*(): cint {.cdecl.}
# generated
proc standend*(): cint {.cdecl.}
# generated
proc start_color*(): cint {.cdecl.}
# implemented
proc subpad*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cint): ptr WINDOW {.
cdecl.}
# implemented
proc subwin*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint; a6: cint): ptr WINDOW {.
cdecl.}
# implemented
proc syncok*(a2: ptr WINDOW; a3: bool): cint {.cdecl.}
# implemented
proc termattrs*(): chtype {.cdecl.}
# implemented
proc termname*(): cstring {.cdecl.}
# implemented
proc timeout*(a2: cint) {.cdecl.}
# generated
proc touchline*(a2: ptr WINDOW; a3: cint; a4: cint): cint {.cdecl.}
# generated
proc touchwin*(a2: ptr WINDOW): cint {.cdecl.}
# generated
proc typeahead*(a2: cint): cint {.cdecl.}
# implemented
proc ungetch*(a2: cint): cint {.cdecl.}
# implemented
proc untouchwin*(a2: ptr WINDOW): cint {.cdecl.}
# generated
proc use_env*(a2: bool) {.cdecl.}
# implemented
proc vidattr*(a2: chtype): cint {.cdecl.}
# implemented
proc vidputs*(a2: chtype; a3: NCURSES_OUTC): cint {.cdecl.}
# implemented
proc vline*(a2: chtype; a3: cint): cint {.cdecl.}
# generated
proc vwprintw*(a2: ptr WINDOW; a3: cstring; a4: va_list): cint {.cdecl.}
# implemented
proc vw_printw*(a2: ptr WINDOW; a3: cstring; a4: va_list): cint {.cdecl.}
# generated
proc vwscanw*(a2: ptr WINDOW; a3: cstring; a4: va_list): cint {.cdecl.}
# implemented
proc vw_scanw*(a2: ptr WINDOW; a3: cstring; a4: va_list): cint {.cdecl.}
# generated
proc waddch*(a2: ptr WINDOW; a3: chtype): cint {.cdecl.}
# implemented
proc waddchnstr*(a2: ptr WINDOW; a3: ptr chtype; a4: cint): cint {.cdecl.}
# implemented
proc waddchstr*(a2: ptr WINDOW; a3: ptr chtype): cint {.cdecl.}
# generated
proc waddnstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint {.cdecl.}
# implemented
proc waddstr*(a2: ptr WINDOW; a3: cstring): cint {.cdecl.}
# generated
proc wattron*(a2: ptr WINDOW; a3: cint): cint {.cdecl.}
# generated
proc wattroff*(a2: ptr WINDOW; a3: cint): cint {.cdecl.}
# generated
proc wattrset*(a2: ptr WINDOW; a3: cint): cint {.cdecl.}
# generated
proc wattr_get*(a2: ptr WINDOW; a3: ptr attr_t; a4: ptr cshort; a5: pointer): cint {.
cdecl.}
# generated
proc wattr_on*(a2: ptr WINDOW; a3: attr_t; a4: pointer): cint {.cdecl.}
# implemented
proc wattr_off*(a2: ptr WINDOW; a3: attr_t; a4: pointer): cint {.cdecl.}
# implemented
proc wattr_set*(a2: ptr WINDOW; a3: attr_t; a4: cshort; a5: pointer): cint {.
cdecl.}
# generated
proc wbkgd*(a2: ptr WINDOW; a3: chtype): cint {.cdecl.}
# implemented
proc wbkgdset*(a2: ptr WINDOW; a3: chtype) {.cdecl.}
# implemented
proc wborder*(a2: ptr WINDOW; a3: chtype; a4: chtype; a5: chtype; a6: chtype;
a7: chtype; a8: chtype; a9: chtype; a10: chtype): cint {.cdecl.}
# implemented
proc wchgat*(a2: ptr WINDOW; a3: cint; a4: attr_t; a5: cshort; a6: pointer): cint {.
cdecl.}
# implemented
proc wclear*(a2: ptr WINDOW): cint {.cdecl.}
# implemented
proc wclrtobot*(a2: ptr WINDOW): cint {.cdecl.}
# implemented
proc wclrtoeol*(a2: ptr WINDOW): cint {.cdecl.}
# implemented
proc wcolor_set*(a2: ptr WINDOW; a3: cshort; a4: pointer): cint {.cdecl.}
# implemented
proc wcursyncup*(a2: ptr WINDOW) {.cdecl.}
# implemented
proc wdelch*(a2: ptr WINDOW): cint {.cdecl.}
# implemented
proc wdeleteln*(a2: ptr WINDOW): cint {.cdecl.}
# generated
proc wechochar*(a2: ptr WINDOW; a3: chtype): cint {.cdecl.}
# implemented
proc werase*(a2: ptr WINDOW): cint {.cdecl.}
# implemented
proc wgetch*(a2: ptr WINDOW): cint {.cdecl.}
# implemented
proc wgetnstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint {.cdecl.}
# implemented
proc wgetstr*(a2: ptr WINDOW; a3: cstring): cint {.cdecl.}
# generated
proc whline*(a2: ptr WINDOW; a3: chtype; a4: cint): cint {.cdecl.}
# implemented
proc winch*(a2: ptr WINDOW): chtype {.cdecl.}
# implemented
proc winchnstr*(a2: ptr WINDOW; a3: ptr chtype; a4: cint): cint {.cdecl.}
# implemented
proc winchstr*(a2: ptr WINDOW; a3: ptr chtype): cint {.cdecl.}
# generated
proc winnstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint {.cdecl.}
# implemented
proc winsch*(a2: ptr WINDOW; a3: chtype): cint {.cdecl.}
# implemented
proc winsdelln*(a2: ptr WINDOW; a3: cint): cint {.cdecl.}
# implemented
proc winsertln*(a2: ptr WINDOW): cint {.cdecl.}
# generated
proc winsnstr*(a2: ptr WINDOW; a3: cstring; a4: cint): cint {.cdecl.}
# implemented
proc winsstr*(a2: ptr WINDOW; a3: cstring): cint {.cdecl.}
# generated
proc winstr*(a2: ptr WINDOW; a3: cstring): cint {.cdecl.}
# generated
proc wmove*(a2: ptr WINDOW; a3: cint; a4: cint): cint {.cdecl.}
# implemented
proc wnoutrefresh*(a2: ptr WINDOW): cint {.cdecl.}
# implemented
proc wprintw*(a2: ptr WINDOW; a3: cstring): cint {.cdecl, varargs.}
proc wredrawln*(a2: ptr WINDOW; a3: cint; a4: cint): cint {.cdecl.}
# implemented
proc wrefresh*(a2: ptr WINDOW): cint {.cdecl.}
# implemented
proc wscanw*(a2: ptr WINDOW; a3: cstring): cint {.cdecl, varargs.}
proc wscrl*(a2: ptr WINDOW; a3: cint): cint {.cdecl.}
# implemented
proc wsetscrreg*(a2: ptr WINDOW; a3: cint; a4: cint): cint {.cdecl.}
# implemented
proc wstandout*(a2: ptr WINDOW): cint {.cdecl.}
# generated
proc wstandend*(a2: ptr WINDOW): cint {.cdecl.}
# generated
proc wsyncdown*(a2: ptr WINDOW) {.cdecl.}
# implemented
proc wsyncup*(a2: ptr WINDOW) {.cdecl.}
# implemented
proc wtimeout*(a2: ptr WINDOW; a3: cint) {.cdecl.}
# implemented
proc wtouchln*(a2: ptr WINDOW; a3: cint; a4: cint; a5: cint): cint {.cdecl.}
# implemented
proc wvline*(a2: ptr WINDOW; a3: chtype; a4: cint): cint {.cdecl.}
# implemented
#
# These are also declared in <term.h>:
#
proc tigetflag*(a2: cstring): cint {.cdecl.}
# implemented
proc tigetnum*(a2: cstring): cint {.cdecl.}
# implemented
proc tigetstr*(a2: cstring): cstring {.cdecl.}
# implemented
proc putp*(a2: cstring): cint {.cdecl.}
# implemented
when NCURSES_TPARM_VARARGS:
proc tparm*(a2: cstring): cstring {.cdecl, varargs.}
# special
else:
proc tparm*(a2: cstring; a3: clong; a4: clong; a5: clong; a6: clong;
a7: clong; a8: clong; a9: clong; a10: clong; a11: clong): cstring {.
cdecl.}
# special
proc tparm_varargs*(a2: cstring): cstring {.cdecl, varargs.}
# special
proc tiparm*(a2: cstring): cstring {.cdecl, varargs.}
# special
#
# These functions are not in X/Open, but we use them in macro definitions:
#
proc getattrs*(a2: ptr WINDOW): cint {.cdecl.}
# generated
proc getcurx*(a2: ptr WINDOW): cint {.cdecl.}
# generated
proc getcury*(a2: ptr WINDOW): cint {.cdecl.}
# generated
proc getbegx*(a2: ptr WINDOW): cint {.cdecl.}
# generated
proc getbegy*(a2: ptr WINDOW): cint {.cdecl.}
# generated
proc getmaxx*(a2: ptr WINDOW): cint {.cdecl.}
# generated
proc getmaxy*(a2: ptr WINDOW): cint {.cdecl.}
# generated
proc getparx*(a2: ptr WINDOW): cint {.cdecl.}
# generated
proc getpary*(a2: ptr WINDOW): cint {.cdecl.}
# generated
#
# vid_attr() was implemented originally based on a draft of X/Open curses.
#
when not(defined(NCURSES_WIDECHAR)):
template vid_attr*(a, pair, opts: expr): expr =
vidattr(a)
#
# These functions are extensions - not in X/Open Curses.
#
when 1:
const
NCURSES_EXT_FUNCS* = 20110404
type
NCURSES_WINDOW_CB* = proc (a2: ptr WINDOW; a3: pointer): cint
NCURSES_SCREEN_CB* = proc (a2: ptr SCREEN; a3: pointer): cint
proc is_term_resized*(a2: cint; a3: cint): bool {.cdecl.}
proc keybound*(a2: cint; a3: cint): cstring {.cdecl.}
proc curses_version*(): cstring {.cdecl.}
proc assume_default_colors*(a2: cint; a3: cint): cint {.cdecl.}
proc define_key*(a2: cstring; a3: cint): cint {.cdecl.}
proc get_escdelay*(): cint {.cdecl.}
proc key_defined*(a2: cstring): cint {.cdecl.}
proc keyok*(a2: cint; a3: bool): cint {.cdecl.}
proc resize_term*(a2: cint; a3: cint): cint {.cdecl.}
proc resizeterm*(a2: cint; a3: cint): cint {.cdecl.}
proc set_escdelay*(a2: cint): cint {.cdecl.}
proc set_tabsize*(a2: cint): cint {.cdecl.}
proc use_default_colors*(): cint {.cdecl.}
proc use_extended_names*(a2: bool): cint {.cdecl.}
proc use_legacy_coding*(a2: cint): cint {.cdecl.}
proc use_screen*(a2: ptr SCREEN; a3: NCURSES_SCREEN_CB; a4: pointer): cint {.
cdecl.}
proc use_window*(a2: ptr WINDOW; a3: NCURSES_WINDOW_CB; a4: pointer): cint {.
cdecl.}
proc wresize*(a2: ptr WINDOW; a3: cint; a4: cint): cint {.cdecl.}
proc nofilter*() {.cdecl.}
#
# These extensions provide access to information stored in the WINDOW even
# when NCURSES_OPAQUE is set:
#
proc wgetparent*(a2: ptr WINDOW): ptr WINDOW {.cdecl.}
# generated
proc is_cleared*(a2: ptr WINDOW): bool {.cdecl.}
# generated
proc is_idcok*(a2: ptr WINDOW): bool {.cdecl.}
# generated
proc is_idlok*(a2: ptr WINDOW): bool {.cdecl.}
# generated
proc is_immedok*(a2: ptr WINDOW): bool {.cdecl.}
# generated
proc is_keypad*(a2: ptr WINDOW): bool {.cdecl.}
# generated
proc is_leaveok*(a2: ptr WINDOW): bool {.cdecl.}
# generated
proc is_nodelay*(a2: ptr WINDOW): bool {.cdecl.}
# generated
proc is_notimeout*(a2: ptr WINDOW): bool {.cdecl.}
# generated
proc is_pad*(a2: ptr WINDOW): bool {.cdecl.}
# generated
proc is_scrollok*(a2: ptr WINDOW): bool {.cdecl.}
# generated
proc is_subwin*(a2: ptr WINDOW): bool {.cdecl.}
# generated
proc is_syncok*(a2: ptr WINDOW): bool {.cdecl.}
# generated
proc wgetscrreg*(a2: ptr WINDOW; a3: ptr cint; a4: ptr cint): cint {.cdecl.}
# generated
else:
template curses_version*(: expr): expr =
NCURSES_VERSION
# attributes
const
NCURSES_ATTR_SHIFT* = 8
template NCURSES_BITS*(mask, shift: expr): expr =
((mask) shl ((shift) + NCURSES_ATTR_SHIFT))
const
A_NORMAL* = (1 - 1)
A_ATTRIBUTES* = NCURSES_BITS(not (1 - 1), 0)
A_CHARTEXT* = (NCURSES_BITS(1, 0) - 1)
A_COLOR* = NCURSES_BITS(((1) shl 8) - 1, 0)
A_STANDOUT* = NCURSES_BITS(1, 8)
A_UNDERLINE* = NCURSES_BITS(1, 9)
A_REVERSE* = NCURSES_BITS(1, 10)
A_BLINK* = NCURSES_BITS(1, 11)
A_DIM* = NCURSES_BITS(1, 12)
A_BOLD* = NCURSES_BITS(1, 13)
A_ALTCHARSET* = NCURSES_BITS(1, 14)
A_INVIS* = NCURSES_BITS(1, 15)
A_PROTECT* = NCURSES_BITS(1, 16)
A_HORIZONTAL* = NCURSES_BITS(1, 17)
A_LEFT* = NCURSES_BITS(1, 18)
A_LOW* = NCURSES_BITS(1, 19)
A_RIGHT* = NCURSES_BITS(1, 20)
A_TOP* = NCURSES_BITS(1, 21)
A_VERTICAL* = NCURSES_BITS(1, 22)
#
# X/Open attributes. In the ncurses implementation, they are identical to the
# A_ attributes.
#
const
WA_ATTRIBUTES* = A_ATTRIBUTES
WA_NORMAL* = A_NORMAL
WA_STANDOUT* = A_STANDOUT
WA_UNDERLINE* = A_UNDERLINE
WA_REVERSE* = A_REVERSE
WA_BLINK* = A_BLINK
WA_DIM* = A_DIM
WA_BOLD* = A_BOLD
WA_ALTCHARSET* = A_ALTCHARSET
WA_INVIS* = A_INVIS
WA_PROTECT* = A_PROTECT
WA_HORIZONTAL* = A_HORIZONTAL
WA_LEFT* = A_LEFT
WA_LOW* = A_LOW
WA_RIGHT* = A_RIGHT
WA_TOP* = A_TOP
WA_VERTICAL* = A_VERTICAL
#
# Most of the pseudo functions are macros that either provide compatibility
# with older versions of curses, or provide inline functionality to improve
# performance.
#
#
# These pseudo functions are always implemented as macros:
#
# #define getyx(win,y,x) y = getcury(win); y = getcurx(win);
# #define getbegyx(win,y,x) y = getbegy(win); x = getbegx(win);
# #define getmaxyx(win,y,x) (y = getmaxy(win), x = getmaxx(win))
# #define getparyx(win,y,x) (y = getpary(win), x = getparx(win))
# #define getsyx(y,x) do { if (newscr) { \
# if (is_leaveok(newscr)) \
# (y) = (x) = -1; \
# else \
# getyx(newscr,(y), (x)); \
# } \
# } while(0)
# #define setsyx(y,x) do { if (newscr) { \
# if ((y) == -1 && (x) == -1) \
# leaveok(newscr, TRUE); \
# else { \
# leaveok(newscr, FALSE); \
# wmove(newscr, (y), (x)); \
# } \
# } \
# } while(0)
when not(defined(NCURSES_NOMACROS)):
#
# These miscellaneous pseudo functions are provided for compatibility:
#
template wgetstr*(w, s: expr): expr =
wgetnstr(w, s, - 1)
template getnstr*(s, n: expr): expr =
wgetnstr(stdscr, s, n)
template setterm*(term: expr): expr =
setupterm(term, 1, cast[ptr cint](0))
template fixterm*(: expr): expr =
reset_prog_mode()
template resetterm*(: expr): expr =
reset_shell_mode()
template saveterm*(: expr): expr =
def_prog_mode()
template crmode*(: expr): expr =
cbreak()
template nocrmode*(: expr): expr =
nocbreak()
template gettmode*(: expr): stmt =
nil
# It seems older SYSV curses versions define these
when not NCURSES_OPAQUE:
##define getattrs(win) NCURSES_CAST(int, (win) ? (win)->_attrs : A_NORMAL)
# #define getcurx(win) ((win) ? (win)->_curx : ERR)
# #define getcury(win) ((win) ? (win)->_cury : ERR)
# #define getbegx(win) ((win) ? (win)->_begx : ERR)
# #define getbegy(win) ((win) ? (win)->_begy : ERR)
# #define getmaxx(win) ((win) ? ((win)->_maxx + 1) : ERR)
# #define getmaxy(win) ((win) ? ((win)->_maxy + 1) : ERR)
# #define getparx(win) ((win) ? (win)->_parx : ERR)
# #define getpary(win) ((win) ? (win)->_pary : ERR)
template wstandout*(win: expr): expr =
(wattrset(win, A_STANDOUT))
template wstandend*(win: expr): expr =
(wattrset(win, A_NORMAL))
template wattron*(win, at: expr): expr =
wattr_on(win, NCURSES_CAST(attr_t, at), nil)
template wattroff*(win, at: expr): expr =
wattr_off(win, NCURSES_CAST(attr_t, at), nil)
when not NCURSES_OPAQUE:
when defined(NCURSES_WIDECHAR) and 0:
# #define wattrset(win,at) ((win) \
# ? ((win)->_color = PAIR_NUMBER(at), \
# (win)->_attrs = NCURSES_CAST(attr_t, at), \
# OK) \
# : ERR)
else:
# #define wattrset(win,at) ((win) \
# ? ((win)->_attrs = NCURSES_CAST(attr_t, at), \
# OK) \
# : ERR)
template scroll*(win: expr): expr =
wscrl(win, 1)
template touchwin*(win: expr): expr =
wtouchln((win), 0, getmaxy(win), 1)
template touchline*(win, s, c: expr): expr =
wtouchln((win), s, c, 1)
template untouchwin*(win: expr): expr =
wtouchln((win), 0, getmaxy(win), 0)
template box*(win, v, h: expr): expr =
wborder(win, v, v, h, h, 0, 0, 0, 0)
template border*(ls, rs, ts, bs, tl, tr, bl, br: expr): expr =
wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br)
template hline*(ch, n: expr): expr =
whline(stdscr, ch, n)
template vline*(ch, n: expr): expr =
wvline(stdscr, ch, n)
template winstr*(w, s: expr): expr =
winnstr(w, s, - 1)
template winchstr*(w, s: expr): expr =
winchnstr(w, s, - 1)
template winsstr*(w, s: expr): expr =
winsnstr(w, s, - 1)
when not NCURSES_OPAQUE:
##define redrawwin(win) wredrawln(win, 0, (win)->_maxy+1)
template waddstr*(win, str: expr): expr =
waddnstr(win, str, - 1)
template waddchstr*(win, str: expr): expr =
waddchnstr(win, str, - 1)
#
# These apply to the first 256 color pairs.
#
template COLOR_PAIR*(n: expr): expr =
NCURSES_BITS(n, 0)
##define PAIR_NUMBER(a) (NCURSES_CAST(int,((NCURSES_CAST(unsigned long,a) & A_COLOR) >> NCURSES_ATTR_SHIFT)))
#
# pseudo functions for standard screen
#
template addch*(ch: expr): expr =
waddch(stdscr, ch)
template addchnstr*(str, n: expr): expr =
waddchnstr(stdscr, str, n)
template addchstr*(str: expr): expr =
waddchstr(stdscr, str)
template addnstr*(str, n: expr): expr =
waddnstr(stdscr, str, n)
template addstr*(str: expr): expr =
waddnstr(stdscr, str, - 1)
template attroff*(at: expr): expr =
wattroff(stdscr, at)
template attron*(at: expr): expr =
wattron(stdscr, at)
template attrset*(at: expr): expr =
wattrset(stdscr, at)
template attr_get*(ap, cp, o: expr): expr =
wattr_get(stdscr, ap, cp, o)
template attr_off*(a, o: expr): expr =
wattr_off(stdscr, a, o)
template attr_on*(a, o: expr): expr =
wattr_on(stdscr, a, o)
template attr_set*(a, c, o: expr): expr =
wattr_set(stdscr, a, c, o)
template bkgd*(ch: expr): expr =
wbkgd(stdscr, ch)
template bkgdset*(ch: expr): expr =
wbkgdset(stdscr, ch)
template chgat*(n, a, c, o: expr): expr =
wchgat(stdscr, n, a, c, o)
template clear*(: expr): expr =
wclear(stdscr)
template clrtobot*(: expr): expr =
wclrtobot(stdscr)
template clrtoeol*(: expr): expr =
wclrtoeol(stdscr)
template color_set*(c, o: expr): expr =
wcolor_set(stdscr, c, o)
template delch*(: expr): expr =
wdelch(stdscr)
template deleteln*(: expr): expr =
winsdelln(stdscr, - 1)
template echochar*(c: expr): expr =
wechochar(stdscr, c)
template erase*(: expr): expr =
werase(stdscr)
template getch*(: expr): expr =
wgetch(stdscr)
template getstr*(str: expr): expr =
wgetstr(stdscr, str)
template inch*(: expr): expr =
winch(stdscr)
template inchnstr*(s, n: expr): expr =
winchnstr(stdscr, s, n)
template inchstr*(s: expr): expr =
winchstr(stdscr, s)
template innstr*(s, n: expr): expr =
winnstr(stdscr, s, n)
template insch*(c: expr): expr =
winsch(stdscr, c)
template insdelln*(n: expr): expr =
winsdelln(stdscr, n)
template insertln*(: expr): expr =
winsdelln(stdscr, 1)
template insnstr*(s, n: expr): expr =
winsnstr(stdscr, s, n)
template insstr*(s: expr): expr =
winsstr(stdscr, s)
template instr*(s: expr): expr =
winstr(stdscr, s)
template move*(y, x: expr): expr =
wmove(stdscr, y, x)
template refresh*(: expr): expr =
wrefresh(stdscr)
template scrl*(n: expr): expr =
wscrl(stdscr, n)
template setscrreg*(t, b: expr): expr =
wsetscrreg(stdscr, t, b)
template standend*(: expr): expr =
wstandend(stdscr)
template standout*(: expr): expr =
wstandout(stdscr)
template timeout*(delay: expr): expr =
wtimeout(stdscr, delay)
template wdeleteln*(win: expr): expr =
winsdelln(win, - 1)
template winsertln*(win: expr): expr =
winsdelln(win, 1)
#
# mv functions
#
template mvwaddch*(win, y, x, ch: expr): expr =
(if wmove(win, y, x) == ERR: ERR else: waddch(win, ch))
template mvwaddchnstr*(win, y, x, str, n: expr): expr =
(if wmove(win, y, x) == ERR: ERR else: waddchnstr(win, str, n))
template mvwaddchstr*(win, y, x, str: expr): expr =
(if wmove(win, y, x) == ERR: ERR else: waddchnstr(win, str, - 1))
template mvwaddnstr*(win, y, x, str, n: expr): expr =
(if wmove(win, y, x) == ERR: ERR else: waddnstr(win, str, n))
template mvwaddstr*(win, y, x, str: expr): expr =
(if wmove(win, y, x) == ERR: ERR else: waddnstr(win, str, - 1))
template mvwdelch*(win, y, x: expr): expr =
(if wmove(win, y, x) == ERR: ERR else: wdelch(win))
template mvwchgat*(win, y, x, n, a, c, o: expr): expr =
(if wmove(win, y, x) == ERR: ERR else: wchgat(win, n, a, c, o))
template mvwgetch*(win, y, x: expr): expr =
(if wmove(win, y, x) == ERR: ERR else: wgetch(win))
template mvwgetnstr*(win, y, x, str, n: expr): expr =
(if wmove(win, y, x) == ERR: ERR else: wgetnstr(win, str, n))
template mvwgetstr*(win, y, x, str: expr): expr =
(if wmove(win, y, x) == ERR: ERR else: wgetstr(win, str))
template mvwhline*(win, y, x, c, n: expr): expr =
(if wmove(win, y, x) == ERR: ERR else: whline(win, c, n))
template mvwinch*(win, y, x: expr): expr =
(if wmove(win, y, x) == ERR: NCURSES_CAST(chtype, ERR) else: winch(win))
template mvwinchnstr*(win, y, x, s, n: expr): expr =
(if wmove(win, y, x) == ERR: ERR else: winchnstr(win, s, n))
template mvwinchstr*(win, y, x, s: expr): expr =
(if wmove(win, y, x) == ERR: ERR else: winchstr(win, s))
template mvwinnstr*(win, y, x, s, n: expr): expr =
(if wmove(win, y, x) == ERR: ERR else: winnstr(win, s, n))
template mvwinsch*(win, y, x, c: expr): expr =
(if wmove(win, y, x) == ERR: ERR else: winsch(win, c))
template mvwinsnstr*(win, y, x, s, n: expr): expr =
(if wmove(win, y, x) == ERR: ERR else: winsnstr(win, s, n))
template mvwinsstr*(win, y, x, s: expr): expr =
(if wmove(win, y, x) == ERR: ERR else: winsstr(win, s))
template mvwinstr*(win, y, x, s: expr): expr =
(if wmove(win, y, x) == ERR: ERR else: winstr(win, s))
template mvwvline*(win, y, x, c, n: expr): expr =
(if wmove(win, y, x) == ERR: ERR else: wvline(win, c, n))
template mvaddch*(y, x, ch: expr): expr =
mvwaddch(stdscr, y, x, ch)
template mvaddchnstr*(y, x, str, n: expr): expr =
mvwaddchnstr(stdscr, y, x, str, n)
template mvaddchstr*(y, x, str: expr): expr =
mvwaddchstr(stdscr, y, x, str)
template mvaddnstr*(y, x, str, n: expr): expr =
mvwaddnstr(stdscr, y, x, str, n)
template mvaddstr*(y, x, str: expr): expr =
mvwaddstr(stdscr, y, x, str)
template mvchgat*(y, x, n, a, c, o: expr): expr =
mvwchgat(stdscr, y, x, n, a, c, o)
template mvdelch*(y, x: expr): expr =
mvwdelch(stdscr, y, x)
template mvgetch*(y, x: expr): expr =
mvwgetch(stdscr, y, x)
template mvgetnstr*(y, x, str, n: expr): expr =
mvwgetnstr(stdscr, y, x, str, n)
template mvgetstr*(y, x, str: expr): expr =
mvwgetstr(stdscr, y, x, str)
template mvhline*(y, x, c, n: expr): expr =
mvwhline(stdscr, y, x, c, n)
template mvinch*(y, x: expr): expr =
mvwinch(stdscr, y, x)
template mvinchnstr*(y, x, s, n: expr): expr =
mvwinchnstr(stdscr, y, x, s, n)
template mvinchstr*(y, x, s: expr): expr =
mvwinchstr(stdscr, y, x, s)
template mvinnstr*(y, x, s, n: expr): expr =
mvwinnstr(stdscr, y, x, s, n)
template mvinsch*(y, x, c: expr): expr =
mvwinsch(stdscr, y, x, c)
template mvinsnstr*(y, x, s, n: expr): expr =
mvwinsnstr(stdscr, y, x, s, n)
template mvinsstr*(y, x, s: expr): expr =
mvwinsstr(stdscr, y, x, s)
template mvinstr*(y, x, s: expr): expr =
mvwinstr(stdscr, y, x, s)
template mvvline*(y, x, c, n: expr): expr =
mvwvline(stdscr, y, x, c, n)
#
# Some wide-character functions can be implemented without the extensions.
#
when not NCURSES_OPAQUE:
template getbkgd*(win: expr): expr =
cast[(win)](._bkgd)
template slk_attr_off*(a, v: expr): expr =
(if (v): ERR else: slk_attroff(a))
template slk_attr_on*(a, v: expr): expr =
(if (v): ERR else: slk_attron(a))
when not NCURSES_OPAQUE:
when defined(NCURSES_WIDECHAR) and 0:
# #define wattr_set(win,a,p,opts) ((win)->_attrs = ((a) & ~A_COLOR), \
# (win)->_color = (p), OK)
# #define wattr_get(win,a,p,opts) ((void)((a) != (void *)0 && (*(a) = (win)->_attrs)), \
# (void)((p) != (void *)0 && (*(p) = (short)(win)->_color)), \
# OK)
else:
# #define wattr_set(win,a,p,opts) ((win)->_attrs = (((a) & ~A_COLOR) | (attr_t)COLOR_PAIR(p)), OK)
# #define wattr_get(win,a,p,opts) ((void)((a) != (void *)0 && (*(a) = (win)->_attrs)), \
# (void)((p) != (void *)0 && (*(p) = (short)PAIR_NUMBER((win)->_attrs))), \
# OK)
#
# X/Open curses deprecates SVr4 vwprintw/vwscanw, which are supposed to use
# varargs.h. It adds new calls vw_printw/vw_scanw, which are supposed to
# use POSIX stdarg.h. The ncurses versions of vwprintw/vwscanw already
# use stdarg.h, so...
#
const
vw_printw* = vwprintw
vw_scanw* = vwscanw
#
# Export fallback function for use in C++ binding.
#
when not 1:
template vsscanf*(a, b, c: expr): expr =
_nc_vsscanf(a, b, c)
proc vsscanf*(a2: cstring; a3: cstring; a4: va_list): cint {.cdecl.}
#
# These macros are extensions - not in X/Open Curses.
#
when 1:
when not NCURSES_OPAQUE:
# #define is_cleared(win) ((win) ? (win)->_clear : FALSE)
# #define is_idcok(win) ((win) ? (win)->_idcok : FALSE)
# #define is_idlok(win) ((win) ? (win)->_idlok : FALSE)
# #define is_immedok(win) ((win) ? (win)->_immed : FALSE)
# #define is_keypad(win) ((win) ? (win)->_use_keypad : FALSE)
# #define is_leaveok(win) ((win) ? (win)->_leaveok : FALSE)
# #define is_nodelay(win) ((win) ? ((win)->_delay == 0) : FALSE)
# #define is_notimeout(win) ((win) ? (win)->_notimeout : FALSE)
# #define is_pad(win) ((win) ? ((win)->_flags & _ISPAD) != 0 : FALSE)
# #define is_scrollok(win) ((win) ? (win)->_scroll : FALSE)
# #define is_subwin(win) ((win) ? ((win)->_flags & _SUBWIN) != 0 : FALSE)
# #define is_syncok(win) ((win) ? (win)->_sync : FALSE)
# #define wgetparent(win) ((win) ? (win)->_parent : 0)
# #define wgetscrreg(win,t,b) ((win) ? (*(t) = (win)->_regtop, *(b) = (win)->_regbottom, OK) : ERR)
#
# Public variables.
#
# Notes:
# a. ESCDELAY was an undocumented feature under AIX curses.
# It gives the ESC expire time in milliseconds.
# b. ttytype is needed for backward compatibility
#
when NCURSES_REENTRANT:
NCURSES_WRAPPED_VAR(WINDOW * , curscr)
NCURSES_WRAPPED_VAR(WINDOW * , newscr)
NCURSES_WRAPPED_VAR(WINDOW * , stdscr)
NCURSES_WRAPPED_VAR(char * , ttytype)
NCURSES_WRAPPED_VAR(int, COLORS)
NCURSES_WRAPPED_VAR(int, COLOR_PAIRS)
NCURSES_WRAPPED_VAR(int, COLS)
NCURSES_WRAPPED_VAR(int, ESCDELAY)
NCURSES_WRAPPED_VAR(int, LINES)
NCURSES_WRAPPED_VAR(int, TABSIZE)
const
curscr* = NCURSES_PUBLIC_VAR(curscr())
newscr* = NCURSES_PUBLIC_VAR(newscr())
stdscr* = NCURSES_PUBLIC_VAR(stdscr())
ttytype* = NCURSES_PUBLIC_VAR(ttytype())
COLORS* = NCURSES_PUBLIC_VAR(COLORS())
COLOR_PAIRS* = NCURSES_PUBLIC_VAR(COLOR_PAIRS())
COLS* = NCURSES_PUBLIC_VAR(COLS())
ESCDELAY* = NCURSES_PUBLIC_VAR(ESCDELAY())
LINES* = NCURSES_PUBLIC_VAR(LINES())
TABSIZE* = NCURSES_PUBLIC_VAR(TABSIZE())
else:
# IMPORTC, NODECL
var curscr*: ptr WINDOW
var newscr*: ptr WINDOW
var stdscr*: ptr WINDOW
var ttytype*: ptr char
var COLORS*: cint
var COLOR_PAIRS*: cint
var COLS*: cint
var ESCDELAY*: cint
var LINES*: cint
var TABSIZE*: cint
#
# Pseudo-character tokens outside ASCII range. The curses wgetch() function
# will return any given one of these only if the corresponding k- capability
# is defined in your terminal's terminfo entry.
#
# Some keys (KEY_A1, etc) are arranged like this:
# a1 up a3
# left b2 right
# c1 down c3
#
# A few key codes do not depend upon the terminfo entry.
#
const
KEY_CODE_YES* = 0o000000000400 # A wchar_t contains a key code
KEY_MIN* = 0o000000000401 # Minimum curses key
KEY_BREAK* = 0o000000000401 # Break key (unreliable)
KEY_SRESET* = 0o000000000530 # Soft (partial) reset (unreliable)
KEY_RESET* = 0o000000000531 # Reset or hard reset (unreliable)
#
# These definitions were generated by /build/buildd/ncurses-5.9/include/MKkey_defs.sh /build/buildd/ncurses-5.9/include/Caps
#
const
KEY_DOWN* = 0o000000000402 # down-arrow key
KEY_UP* = 0o000000000403 # up-arrow key
KEY_LEFT* = 0o000000000404 # left-arrow key
KEY_RIGHT* = 0o000000000405 # right-arrow key
KEY_HOME* = 0o000000000406 # home key
KEY_BACKSPACE* = 0o000000000407 # backspace key
KEY_F0* = 0o000000000410 # Function keys. Space for 64
template KEY_F*(n: expr): expr =
(KEY_F0 + (n)) # Value of function key n
const
KEY_DL* = 0o000000000510 # delete-line key
KEY_IL* = 0o000000000511 # insert-line key
KEY_DC* = 0o000000000512 # delete-character key
KEY_IC* = 0o000000000513 # insert-character key
KEY_EIC* = 0o000000000514 # sent by rmir or smir in insert mode
KEY_CLEAR* = 0o000000000515 # clear-screen or erase key
KEY_EOS* = 0o000000000516 # clear-to-end-of-screen key
KEY_EOL* = 0o000000000517 # clear-to-end-of-line key
KEY_SF* = 0o000000000520 # scroll-forward key
KEY_SR* = 0o000000000521 # scroll-backward key
KEY_NPAGE* = 0o000000000522 # next-page key
KEY_PPAGE* = 0o000000000523 # previous-page key
KEY_STAB* = 0o000000000524 # set-tab key
KEY_CTAB* = 0o000000000525 # clear-tab key
KEY_CATAB* = 0o000000000526 # clear-all-tabs key
KEY_ENTER* = 0o000000000527 # enter/send key
KEY_PRINT* = 0o000000000532 # print key
KEY_LL* = 0o000000000533 # lower-left key (home down)
KEY_A1* = 0o000000000534 # upper left of keypad
KEY_A3* = 0o000000000535 # upper right of keypad
KEY_B2* = 0o000000000536 # center of keypad
KEY_C1* = 0o000000000537 # lower left of keypad
KEY_C3* = 0o000000000540 # lower right of keypad
KEY_BTAB* = 0o000000000541 # back-tab key
KEY_BEG* = 0o000000000542 # begin key
KEY_CANCEL* = 0o000000000543 # cancel key
KEY_CLOSE* = 0o000000000544 # close key
KEY_COMMAND* = 0o000000000545 # command key
KEY_COPY* = 0o000000000546 # copy key
KEY_CREATE* = 0o000000000547 # create key
KEY_END* = 0o000000000550 # end key
KEY_EXIT* = 0o000000000551 # exit key
KEY_FIND* = 0o000000000552 # find key
KEY_HELP* = 0o000000000553 # help key
KEY_MARK* = 0o000000000554 # mark key
KEY_MESSAGE* = 0o000000000555 # message key
KEY_MOVE* = 0o000000000556 # move key
KEY_NEXT* = 0o000000000557 # next key
KEY_OPEN* = 0o000000000560 # open key
KEY_OPTIONS* = 0o000000000561 # options key
KEY_PREVIOUS* = 0o000000000562 # previous key
KEY_REDO* = 0o000000000563 # redo key
KEY_REFERENCE* = 0o000000000564 # reference key
KEY_REFRESH* = 0o000000000565 # refresh key
KEY_REPLACE* = 0o000000000566 # replace key
KEY_RESTART* = 0o000000000567 # restart key
KEY_RESUME* = 0o000000000570 # resume key
KEY_SAVE* = 0o000000000571 # save key
KEY_SBEG* = 0o000000000572 # shifted begin key
KEY_SCANCEL* = 0o000000000573 # shifted cancel key
KEY_SCOMMAND* = 0o000000000574 # shifted command key
KEY_SCOPY* = 0o000000000575 # shifted copy key
KEY_SCREATE* = 0o000000000576 # shifted create key
KEY_SDC* = 0o000000000577 # shifted delete-character key
KEY_SDL* = 0o000000000600 # shifted delete-line key
KEY_SELECT* = 0o000000000601 # select key
KEY_SEND* = 0o000000000602 # shifted end key
KEY_SEOL* = 0o000000000603 # shifted clear-to-end-of-line key
KEY_SEXIT* = 0o000000000604 # shifted exit key
KEY_SFIND* = 0o000000000605 # shifted find key
KEY_SHELP* = 0o000000000606 # shifted help key
KEY_SHOME* = 0o000000000607 # shifted home key
KEY_SIC* = 0o000000000610 # shifted insert-character key
KEY_SLEFT* = 0o000000000611 # shifted left-arrow key
KEY_SMESSAGE* = 0o000000000612 # shifted message key
KEY_SMOVE* = 0o000000000613 # shifted move key
KEY_SNEXT* = 0o000000000614 # shifted next key
KEY_SOPTIONS* = 0o000000000615 # shifted options key
KEY_SPREVIOUS* = 0o000000000616 # shifted previous key
KEY_SPRINT* = 0o000000000617 # shifted print key
KEY_SREDO* = 0o000000000620 # shifted redo key
KEY_SREPLACE* = 0o000000000621 # shifted replace key
KEY_SRIGHT* = 0o000000000622 # shifted right-arrow key
KEY_SRSUME* = 0o000000000623 # shifted resume key
KEY_SSAVE* = 0o000000000624 # shifted save key
KEY_SSUSPEND* = 0o000000000625 # shifted suspend key
KEY_SUNDO* = 0o000000000626 # shifted undo key
KEY_SUSPEND* = 0o000000000627 # suspend key
KEY_UNDO* = 0o000000000630 # undo key
KEY_MOUSE* = 0o000000000631 # Mouse event has occurred
KEY_RESIZE* = 0o000000000632 # Terminal resize event
KEY_EVENT* = 0o000000000633 # We were interrupted by an event
KEY_MAX* = 0o000000000777 # Maximum key value is 0633
# $Id: curses.tail,v 1.20 2010/03/28 19:10:55 tom Exp $
#
# vile:cmode:
# This file is part of ncurses, designed to be appended after curses.h.in
# (see that file for the relevant copyright).
#
# mouse interface
when NCURSES_MOUSE_VERSION > 1:
template NCURSES_MOUSE_MASK*(b, m: expr): expr =
((m) shl (((b) - 1) * 5))
else:
template NCURSES_MOUSE_MASK*(b, m: expr): expr =
((m) shl (((b) - 1) * 6))
const
NCURSES_BUTTON_RELEASED* = 1
NCURSES_BUTTON_PRESSED* = 2
NCURSES_BUTTON_CLICKED* = 4
NCURSES_DOUBLE_CLICKED* = 0o000000000010
NCURSES_TRIPLE_CLICKED* = 0o000000000020
NCURSES_RESERVED_EVENT* = 0o000000000040
# event masks
const
BUTTON1_RELEASED* = NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED)
BUTTON1_PRESSED* = NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED)
BUTTON1_CLICKED* = NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_CLICKED)
BUTTON1_DOUBLE_CLICKED* = NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED)
BUTTON1_TRIPLE_CLICKED* = NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED)
BUTTON2_RELEASED* = NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_RELEASED)
BUTTON2_PRESSED* = NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_PRESSED)
BUTTON2_CLICKED* = NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_CLICKED)
BUTTON2_DOUBLE_CLICKED* = NCURSES_MOUSE_MASK(2, NCURSES_DOUBLE_CLICKED)
BUTTON2_TRIPLE_CLICKED* = NCURSES_MOUSE_MASK(2, NCURSES_TRIPLE_CLICKED)
BUTTON3_RELEASED* = NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_RELEASED)
BUTTON3_PRESSED* = NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_PRESSED)
BUTTON3_CLICKED* = NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_CLICKED)
BUTTON3_DOUBLE_CLICKED* = NCURSES_MOUSE_MASK(3, NCURSES_DOUBLE_CLICKED)
BUTTON3_TRIPLE_CLICKED* = NCURSES_MOUSE_MASK(3, NCURSES_TRIPLE_CLICKED)
BUTTON4_RELEASED* = NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_RELEASED)
BUTTON4_PRESSED* = NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_PRESSED)
BUTTON4_CLICKED* = NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_CLICKED)
BUTTON4_DOUBLE_CLICKED* = NCURSES_MOUSE_MASK(4, NCURSES_DOUBLE_CLICKED)
BUTTON4_TRIPLE_CLICKED* = NCURSES_MOUSE_MASK(4, NCURSES_TRIPLE_CLICKED)
#
# In 32 bits the version-1 scheme does not provide enough space for a 5th
# button, unless we choose to change the ABI by omitting the reserved-events.
#
when NCURSES_MOUSE_VERSION > 1:
const
BUTTON5_RELEASED* = NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_RELEASED)
BUTTON5_PRESSED* = NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_PRESSED)
BUTTON5_CLICKED* = NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_CLICKED)
BUTTON5_DOUBLE_CLICKED* = NCURSES_MOUSE_MASK(5, NCURSES_DOUBLE_CLICKED)
BUTTON5_TRIPLE_CLICKED* = NCURSES_MOUSE_MASK(5, NCURSES_TRIPLE_CLICKED)
BUTTON_CTRL* = NCURSES_MOUSE_MASK(6, 1)
BUTTON_SHIFT* = NCURSES_MOUSE_MASK(6, 2)
BUTTON_ALT* = NCURSES_MOUSE_MASK(6, 4)
REPORT_MOUSE_POSITION* = NCURSES_MOUSE_MASK(6, 10)
else:
const
BUTTON1_RESERVED_EVENT* = NCURSES_MOUSE_MASK(1, NCURSES_RESERVED_EVENT)
BUTTON2_RESERVED_EVENT* = NCURSES_MOUSE_MASK(2, NCURSES_RESERVED_EVENT)
BUTTON3_RESERVED_EVENT* = NCURSES_MOUSE_MASK(3, NCURSES_RESERVED_EVENT)
BUTTON4_RESERVED_EVENT* = NCURSES_MOUSE_MASK(4, NCURSES_RESERVED_EVENT)
BUTTON_CTRL* = NCURSES_MOUSE_MASK(5, 1)
BUTTON_SHIFT* = NCURSES_MOUSE_MASK(5, 2)
BUTTON_ALT* = NCURSES_MOUSE_MASK(5, 4)
REPORT_MOUSE_POSITION* = NCURSES_MOUSE_MASK(5, 10)
const
ALL_MOUSE_EVENTS* = (REPORT_MOUSE_POSITION - 1)
# macros to extract single event-bits from masks
template BUTTON_RELEASE*(e, x: expr): expr =
((e) and NCURSES_MOUSE_MASK(x, 1))
template BUTTON_PRESS*(e, x: expr): expr =
((e) and NCURSES_MOUSE_MASK(x, 2))
template BUTTON_CLICK*(e, x: expr): expr =
((e) and NCURSES_MOUSE_MASK(x, 4))
template BUTTON_DOUBLE_CLICK*(e, x: expr): expr =
((e) and NCURSES_MOUSE_MASK(x, 0o000000000010))
template BUTTON_TRIPLE_CLICK*(e, x: expr): expr =
((e) and NCURSES_MOUSE_MASK(x, 0o000000000020))
template BUTTON_RESERVED_EVENT*(e, x: expr): expr =
((e) and NCURSES_MOUSE_MASK(x, 0o000000000040))
type
MEVENT* {.pure, final.} = object
id*: cshort # ID to distinguish multiple devices
x*: cint
y*: cint
z*: cint # event coordinates (character-cell)
bstate*: mmask_t # button state bits
proc has_mouse*(): bool {.cdecl.}
proc getmouse*(a2: ptr MEVENT): cint {.cdecl.}
proc ungetmouse*(a2: ptr MEVENT): cint {.cdecl.}
proc mousemask*(a2: mmask_t; a3: ptr mmask_t): mmask_t {.cdecl.}
proc wenclose*(a2: ptr WINDOW; a3: cint; a4: cint): bool {.cdecl.}
proc mouseinterval*(a2: cint): cint {.cdecl.}
proc wmouse_trafo*(a2: ptr WINDOW; a3: ptr cint; a4: ptr cint; a5: bool): bool {.
cdecl.}
proc mouse_trafo*(a2: ptr cint; a3: ptr cint; a4: bool): bool {.cdecl.}
# generated
when NCURSES_SP_FUNCS:
proc _nc_has_mouse*(a2: ptr SCREEN): bool {.cdecl.}
proc _nc_getmouse*(a2: ptr SCREEN; a3: ptr MEVENT): cint {.cdecl.}
proc _nc_ungetmouse*(a2: ptr SCREEN; a3: ptr MEVENT): cint {.cdecl.}
proc _nc_mousemask*(a2: ptr SCREEN; a3: mmask_t; a4: ptr mmask_t): mmask_t {.
cdecl.}
proc _nc_mouseinterval*(a2: ptr SCREEN; a3: cint): cint {.cdecl.}
template mouse_trafo*(y, x, to_screen: expr): expr =
wmouse_trafo(stdscr, y, x, to_screen)
# other non-XSI functions
proc mcprint*(a2: cstring; a3: cint): cint {.cdecl.}
# direct data to printer
proc has_key*(a2: cint): cint {.cdecl.}
# do we have given key?
when NCURSES_SP_FUNCS:
proc _nc_has_key*(a2: ptr SCREEN; a3: cint): cint {.cdecl.}
# do we have given key?
proc _nc_mcprint*(a2: ptr SCREEN; a3: cstring; a4: cint): cint {.cdecl.}
# direct data to printer
# Debugging : use with libncurses_g.a
proc _tracef*(a2: cstring) {.cdecl, varargs.}
proc _tracedump*(a2: cstring; a3: ptr WINDOW) {.cdecl.}
proc _traceattr*(a2: attr_t): cstring {.cdecl.}
proc _traceattr2*(a2: cint; a3: chtype): cstring {.cdecl.}
proc _nc_tracebits*(): cstring {.cdecl.}
proc _tracechar*(a2: cint): cstring {.cdecl.}
proc _tracechtype*(a2: chtype): cstring {.cdecl.}
proc _tracechtype2*(a2: cint; a3: chtype): cstring {.cdecl.}
when defined(NCURSES_WIDECHAR):
const
_tracech_t* = _tracecchar_t
proc _tracecchar_t*(a2: ptr cchar_t): cstring {.cdecl.}
const
_tracech_t2* = _tracecchar_t2
proc _tracecchar_t2*(a2: cint; a3: ptr cchar_t): cstring {.cdecl.}
else:
const
_tracech_t* = _tracechtype
_tracech_t2* = _tracechtype2
proc _tracemouse*(a2: ptr MEVENT): cstring {.cdecl.}
proc trace*(a2: cuint) {.cdecl.}
# trace masks
const
TRACE_DISABLE* = 0x00000000 # turn off tracing
TRACE_TIMES* = 0x00000001 # trace user and system times of updates
TRACE_TPUTS* = 0x00000002 # trace tputs calls
TRACE_UPDATE* = 0x00000004 # trace update actions, old & new screens
TRACE_MOVE* = 0x00000008 # trace cursor moves and scrolls
TRACE_CHARPUT* = 0x00000010 # trace all character outputs
TRACE_ORDINARY* = 0x0000001F # trace all update actions
TRACE_CALLS* = 0x00000020 # trace all curses calls
TRACE_VIRTPUT* = 0x00000040 # trace virtual character puts
TRACE_IEVENT* = 0x00000080 # trace low-level input processing
TRACE_BITS* = 0x00000100 # trace state of TTY control bits
TRACE_ICALLS* = 0x00000200 # trace internal/nested calls
TRACE_CCALLS* = 0x00000400 # trace per-character calls
TRACE_DATABASE* = 0x00000800 # trace read/write of terminfo/termcap data
TRACE_ATTRS* = 0x00001000 # trace attribute updates
TRACE_SHIFT* = 13 # number of bits in the trace masks
TRACE_MAXIMUM* = ((1 shl TRACE_SHIFT) - 1) # maximum trace level
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment