package curses

  1. Overview
  2. Docs

Module CursesSource

* Bindings to the ncurses library. * * Beware, all coordinates are passed y first, then x. * * Functions whose name start with a "w" take as first argument the window the * function applies to. * Functions whose name start with "mv" take as first two arguments the * coordinates y and x of the point to move the cursor to. For example * mvaddch y x ch is the same as move y x; addch ch.

Sourcetype window

Windows.

Sourcetype screen

Screens.

Sourcetype terminal

Terminals.

Sourcetype chtype = int

Characters. Usual characters can be converted from/to chtype using * char_of_int and int_of_char. See also get_acs_codes for characters * useful for drawing and the Key module for special input characters.

Sourcetype attr_t = int

Attributes are lorings of flags which are defined in the A module.

Sourcetype err = bool

A return value. false means that an error occured.

Initialization functions

Sourceval initscr : unit -> window

Initialize the curses library.

Sourceval endwin : unit -> unit

Restore the terminal (should be called before exiting).

Sourceval isendwin : unit -> bool

Has endwin been called without any subsequent call to werefresh?

Sourceval newterm : string -> Unix.file_descr -> Unix.file_descr -> screen

Create a new terminal.

Sourceval set_term : screen -> unit

Switch terminal.

Sourceval delscreen : screen -> unit

Delete a screen.

Sourceval stdscr : unit -> window
Sourceval getyx : window -> int * int

Get the current cursor position.

Sourceval getparyx : window -> int * int
Sourceval getbegyx : window -> int * int
Sourceval getmaxyx : window -> int * int
Sourceval move : int -> int -> err

Move the cursor.

Sourceval wmove : window -> int -> int -> err

Operations on characters

Sourcemodule Acs : sig ... end

Predefined characters.

Sourceval get_acs_codes : unit -> Acs.acs

Get the predefined characters.

Sourceval addch : chtype -> err

Add a character at the current position, then advance the cursor.

Sourceval waddch : window -> chtype -> err
Sourceval mvaddch : int -> int -> chtype -> err
Sourceval mvwaddch : window -> int -> int -> chtype -> err
Sourceval echochar : chtype -> err

echochar ch is equivalent to addch ch followed by refresh ().

Sourceval wechochar : window -> chtype -> err
Sourceval addchstr : chtype array -> err

Add a sequence of characters at the current position. See also addstr.

Sourceval waddchstr : window -> chtype array -> err
Sourceval mvaddchstr : int -> int -> chtype array -> err
Sourceval mvwaddchstr : window -> int -> int -> chtype array -> err
Sourceval addchnstr : chtype array -> int -> int -> err
Sourceval waddchnstr : window -> chtype array -> int -> int -> err
Sourceval mvaddchnstr : int -> int -> chtype array -> int -> int -> err
Sourceval mvwaddchnstr : window -> int -> int -> chtype array -> int -> int -> err
Sourceval addstr : string -> err

Add a string at the current position.

Sourceval waddstr : window -> string -> err
Sourceval mvaddstr : int -> int -> string -> err
Sourceval mvwaddstr : window -> int -> int -> string -> err
Sourceval addnstr : string -> int -> int -> err
Sourceval waddnstr : window -> string -> int -> int -> err
Sourceval mvaddnstr : int -> int -> string -> int -> int -> err
Sourceval mvwaddnstr : window -> int -> int -> string -> int -> int -> err
Sourceval insch : chtype -> err

Insert a character before cursor.

Sourceval winsch : window -> chtype -> err
Sourceval mvinsch : int -> int -> chtype -> err
Sourceval mvwinsch : window -> int -> int -> chtype -> err
Sourceval insstr : string -> err

Insert a string before cursor.

Sourceval winsstr : window -> string -> err
Sourceval mvinsstr : int -> int -> string -> err
Sourceval mvwinsstr : window -> int -> int -> string -> err
Sourceval insnstr : string -> int -> int -> err
Sourceval winsnstr : window -> string -> int -> int -> err
Sourceval mvinsnstr : int -> int -> string -> int -> int -> err
Sourceval mvwinsnstr : window -> int -> int -> string -> int -> int -> err
Sourceval delch : unit -> err

Delete a character.

Sourceval wdelch : window -> err
Sourceval mvdelch : int -> int -> err
Sourceval mvwdelch : window -> int -> int -> err
Sourcemodule A : sig ... end

Attributes.

Sourcemodule WA : sig ... end

New series of highlight attributes.

Sourceval attroff : int -> unit

Turn off the attributes given in argument (see the A module).

Sourceval wattroff : window -> int -> unit
Sourceval attron : int -> unit

Turn on the attributes given in argument.

Sourceval wattron : window -> int -> unit
Sourceval attrset : int -> unit

Set the attributes.

Sourceval wattrset : window -> int -> unit
Sourceval standend : unit -> unit
Sourceval wstandend : window -> unit
Sourceval standout : unit -> unit
Sourceval wstandout : window -> unit
Sourceval attr_off : attr_t -> unit

Turn off the attributes given in argument (see the WA module).

Sourceval wattr_off : window -> attr_t -> unit
Sourceval attr_on : attr_t -> unit
Sourceval wattr_on : window -> attr_t -> unit
Sourceval attr_set : attr_t -> int -> unit
Sourceval wattr_set : window -> attr_t -> int -> unit
Sourceval chgat : int -> attr_t -> int -> unit

chgat n attr color changes the attributes of n characters.

Sourceval wchgat : window -> int -> attr_t -> int -> unit
Sourceval mvchgat : int -> int -> int -> attr_t -> int -> unit
Sourceval mvwchgat : window -> int -> int -> int -> attr_t -> int -> unit
Sourceval inch : unit -> chtype

Get the attributes of the caracter at current position.

Sourceval winch : window -> chtype
Sourceval mvinch : int -> int -> chtype
Sourceval mvwinch : window -> int -> int -> chtype
Sourceval inchstr : chtype array -> err

Get the attributes of a sequence of characters.

Sourceval winchstr : window -> chtype array -> err
Sourceval mvinchstr : int -> int -> chtype array -> err
Sourceval mvwinchstr : window -> int -> int -> chtype array -> err
Sourceval inchnstr : chtype array -> int -> int -> err
Sourceval winchnstr : window -> chtype array -> int -> int -> err
Sourceval mvinchnstr : int -> int -> chtype array -> int -> int -> err
Sourceval mvwinchnstr : window -> int -> int -> chtype array -> int -> int -> err
Sourceval instr : string -> err

Get the attributes of a string.

Sourceval winstr : window -> string -> err
Sourceval mvinstr : int -> int -> string -> err
Sourceval mvwinstr : window -> int -> int -> string -> err
Sourceval innstr : string -> int -> int -> err
Sourceval winnstr : window -> string -> int -> int -> err
Sourceval mvinnstr : int -> int -> string -> int -> int -> err
Sourceval mvwinnstr : window -> int -> int -> string -> int -> int -> err

Background

Sourceval bkgdset : chtype -> unit

Set the background of the current character.

Sourceval wbkgdset : window -> chtype -> unit
Sourceval bkgd : chtype -> unit

Set the background of every character.

Sourceval wbkgd : window -> chtype -> unit
Sourceval getbkgd : window -> chtype

Get the current background.

Operations on lines

Sourceval deleteln : unit -> err

Delete a line.

Sourceval wdeleteln : window -> err
Sourceval insdelln : int -> err

insdelln n inserts n lines above the current line if n is positive or * deletes -n lines if n is negative.

Sourceval winsdelln : window -> int -> err
Sourceval insertln : unit -> err

Insert a blank line above the current line.

Sourceval winsertln : window -> err
Sourcemodule Key : sig ... end

Special keys.

Sourceval getch : unit -> int

Read a character in a window.

Sourceval wgetch : window -> int
Sourceval mvgetch : int -> int -> int
Sourceval mvwgetch : window -> int -> int -> int
Sourceval ungetch : int -> err
Sourceval getstr : string -> err

Read a string in a window.

Sourceval wgetstr : window -> string -> err
Sourceval mvgetstr : int -> int -> string -> err
Sourceval mvwgetstr : window -> int -> int -> string -> err
Sourceval getnstr : string -> int -> int -> err
Sourceval wgetnstr : window -> string -> int -> int -> err
Sourceval mvgetnstr : int -> int -> string -> int -> int -> err
Sourceval mvwgetnstr : window -> int -> int -> string -> int -> int -> err

Windows

Window manipulations

Sourceval newwin : int -> int -> int -> int -> window

newwin l c y x create a new window with l lines, c columns. The upper * left-hand corner is at (x,y).

Sourceval delwin : window -> err

Delete a window.

Sourceval mvwin : window -> int -> int -> err

Move a window.

Sourceval subwin : window -> int -> int -> int -> int -> window

subwin l c y x create a subwindow with l lines and c columns at * screen-relative position (x,y).

Sourceval derwin : window -> int -> int -> int -> int -> window

Same as subwin excepting that the position (x,y) is relative to the * parent window.

Sourceval mvderwin : window -> int -> int -> err

Move a derived windw.

Sourceval dupwin : window -> window

Duplicate a window.

Sourceval wsyncup : window -> unit
Sourceval syncok : window -> bool -> err

If syncok is called with true as second argument, wsyncup is called * automatically whenever there is a change in the window.

Sourceval wcursyncup : window -> unit
Sourceval wsyncdown : window -> unit
Sourceval winch_handler_on : unit -> unit
Sourceval winch_handler_off : unit -> unit
Sourceval get_size : unit -> int * int
Sourceval get_size_fd : Unix.file_descr -> int * int
Sourceval null_window : window
Sourceval refresh : unit -> err

Refresh windows.

Sourceval wrefresh : window -> err
Sourceval wnoutrefresh : window -> err
Sourceval doupdate : unit -> err
Sourceval redrawwin : window -> err
Sourceval wredrawln : window -> int -> int -> err
Sourceval wresize : window -> int -> int -> err
Sourceval resizeterm : int -> int -> err
Sourceval scroll : window -> err
Sourceval scrl : int -> err
Sourceval wscrl : window -> int -> err
Sourceval touchwin : window -> err
Sourceval touchline : window -> int -> int -> err
Sourceval untouchwin : window -> err
Sourceval wtouchln : window -> int -> int -> bool -> err
Sourceval is_linetouched : window -> int -> int
Sourceval is_wintouched : window -> bool
Sourceval erase : unit -> unit

Clear a window.

Sourceval werase : window -> unit
Sourceval clear : unit -> unit
Sourceval wclear : window -> unit
Sourceval clrtobot : unit -> unit
Sourceval wclrtobot : window -> unit
Sourceval clrtoeol : unit -> unit
Sourceval wclrtoeol : window -> unit
Sourceval overlay : window -> window -> err

overlay srcwin dstwin overlays srcwin on top of dstwin.

Sourceval overwrite : window -> window -> err
Sourceval copywin : window -> window -> int -> int -> int -> int -> int -> int -> bool -> err

Decorations

Sourceval border : chtype -> chtype -> chtype -> chtype -> chtype -> chtype -> chtype -> chtype -> unit

Draw a box around the edges of a window.

Sourceval wborder : window -> chtype -> chtype -> chtype -> chtype -> chtype -> chtype -> chtype -> chtype -> unit
Sourceval box : window -> chtype -> chtype -> unit

Draw a box.

Sourceval hline : chtype -> int -> unit

Draw an horizontal line.

Sourceval whline : window -> chtype -> int -> unit
Sourceval mvhline : int -> int -> chtype -> int -> unit
Sourceval mvwhline : window -> int -> int -> chtype -> int -> unit
Sourceval vline : chtype -> int -> unit

Draw a vertical line.

Sourceval wvline : window -> chtype -> int -> unit
Sourceval mvvline : int -> int -> chtype -> int -> unit
Sourceval mvwvline : window -> int -> int -> chtype -> int -> unit

Pads

A pad is like a window except that it is not restricted by the screen size, * and is not necessarily associated with a particular part of the screen.

Sourceval newpad : int -> int -> window

Create a new pad.

Sourceval subpad : window -> int -> int -> int -> int -> window
Sourceval prefresh : window -> int -> int -> int -> int -> int -> int -> err
Sourceval pnoutrefresh : window -> int -> int -> int -> int -> int -> int -> err
Sourceval pechochar : window -> chtype -> err

Colors

Sourcemodule Color : sig ... end

Colors.

Sourceval start_color : unit -> err
Sourceval use_default_colors : unit -> err
Sourceval init_pair : int -> int -> int -> err
Sourceval init_color : int -> int -> int -> int -> err
Sourceval has_colors : unit -> bool
Sourceval can_change_color : unit -> bool
Sourceval color_content : int -> int * int * int
Sourceval pair_content : int -> int * int
Sourceval colors : unit -> int
Sourceval color_pairs : unit -> int

Input/output options

Sourceval cbreak : unit -> err

Disable line buffering.

Sourceval halfdelay : int -> err

Similar to cbreak but with delay.

Sourceval nocbreak : unit -> err

Enable line buffering (waits for characters until newline is typed).

Sourceval echo : unit -> err

Don't echo typed characters.

Sourceval noecho : unit -> err

Echo typed characters.

Sourceval intrflush : window -> bool -> err
Sourceval keypad : window -> bool -> err
Sourceval meta : window -> bool -> err
Sourceval nodelay : window -> bool -> err
Sourceval raw : unit -> err
Sourceval noraw : unit -> err
Sourceval noqiflush : unit -> unit
Sourceval qiflush : unit -> unit
Sourceval notimeout : window -> bool -> err
Sourceval timeout : int -> unit
Sourceval wtimeout : window -> int -> unit
Sourceval typeahead : Unix.file_descr -> err
Sourceval notypeahead : unit -> err
Sourceval clearok : window -> bool -> unit

If called with true as second argument, the next call to wrefresh with * this window will clear the streen completely and redraw the entire screen * from scratch.

Sourceval idlok : window -> bool -> unit
Sourceval idcok : window -> bool -> unit
Sourceval immedok : window -> bool -> unit
Sourceval leaveok : window -> bool -> unit
Sourceval setscrreg : int -> int -> err
Sourceval wsetscrreg : window -> int -> int -> err
Sourceval scrollok : window -> bool -> unit
Sourceval nl : unit -> unit
Sourceval nonl : unit -> unit

Soft-label keys

Sourceval slk_init : int -> err

Initialize soft labels.

Sourceval slk_set : int -> string -> int -> err
Sourceval slk_refresh : unit -> err
Sourceval slk_noutrefresh : unit -> err
Sourceval slk_label : int -> string
Sourceval slk_clear : unit -> err
Sourceval slk_restore : unit -> err
Sourceval slk_touch : unit -> err
Sourceval slk_attron : attr_t -> err
Sourceval slk_attroff : attr_t -> err
Sourceval slk_attrset : attr_t -> err
Sourceval mousemask : int -> int * int

Sets the mouse mask.

Misc

Sourceval beep : unit -> err

Ring a bell.

Sourceval flash : unit -> err

Flash the screen.

Sourceval unctrl : chtype -> string
Sourceval keyname : int -> string
Sourceval filter : unit -> unit
Sourceval use_env : bool -> unit
Sourceval putwin : window -> Unix.file_descr -> err
Sourceval getwin : Unix.file_descr -> window
Sourceval delay_output : int -> err
Sourceval flushinp : unit -> unit
Sourceval scr_dump : string -> err

Dump the current screen to a file.

Sourceval scr_restore : string -> err
Sourceval scr_init : string -> err
Sourceval scr_set : string -> err

Terminal

Sourceval baudrate : unit -> int

Get the speed of a terminal (in bits per second).

Sourceval erasechar : unit -> char

Get user's current erase character.

Sourceval has_ic : unit -> bool

Has the terminal insert- and delete-character capabilites?

Sourceval has_il : unit -> bool

Has the terminal insert- and delete-line capabilites?

Sourceval killchar : unit -> char

Get user's current line kill character.

Sourceval longname : unit -> string

Get a description of the terminal.

Sourceval termattrs : unit -> attr_t
Sourceval termname : unit -> string
Sourceval tgetent : string -> bool
Sourceval tgetflag : string -> bool
Sourceval tgetnum : string -> int
Sourceval tgetstr : string -> bool
Sourceval tgoto : string -> int -> int -> string
Sourceval setupterm : string -> Unix.file_descr -> err
Sourceval setterm : string -> err
Sourceval cur_term : unit -> terminal
Sourceval set_curterm : terminal -> terminal
Sourceval del_curterm : terminal -> err
Sourceval restartterm : string -> Unix.file_descr -> err
Sourceval putp : string -> err
Sourceval vidattr : chtype -> err
Sourceval mvcur : int -> int -> int -> int -> err
Sourceval tigetflag : string -> bool
Sourceval tigetnum : string -> int
Sourceval tigetstr : string -> string
Sourceval tputs : string -> int -> (char -> unit) -> err
Sourceval vidputs : chtype -> (char -> unit) -> err
Sourceval tparm : string -> int array -> string
Sourceval bool_terminfo_variable : int -> string * string * string
Sourceval num_terminfo_variable : int -> string * string * string
Sourceval str_terminfo_variable : int -> string * string * string
Sourceval bool_terminfo_variables : (string, string * string) Hashtbl.t
Sourceval num_terminfo_variables : (string, string * string) Hashtbl.t
Sourceval str_terminfo_variables : (string, string * string) Hashtbl.t
Sourceval def_prog_mode : unit -> unit

Save the current terminal modes as the "program" state for use by the * reser_prog_mod and reset_shell_mode functions.

Sourceval def_shell_mode : unit -> unit
Sourceval reset_prog_mode : unit -> unit
Sourceval reset_shell_mode : unit -> unit
Sourceval resetty : unit -> unit
Sourceval savetty : unit -> unit
Sourceval getsyx : unit -> int * int
Sourceval setsyx : int -> int -> unit
Sourceval curs_set : int -> err
Sourceval napms : int -> unit
Sourceval ripoffline : bool -> unit
Sourceval get_ripoff : unit -> window * int

Configuration

Sourcemodule Curses_config : sig ... end
OCaml

Innovation. Community. Security.