This commit is contained in:
Ian Keane 2020-02-18 14:21:14 -05:00
parent 276853ba84
commit 1cb167b597
361 changed files with 77302 additions and 4 deletions

View file

@ -0,0 +1,24 @@
(in-package :de.anvi.ncurses)
;;; add_wch
;;; add a complex character and rendition to a curses window, then advance the cursor
;;; http://invisible-island.net/ncurses/man/curs_add_wch.3x.html
;;; C prototypes
;;; int add_wch(const cchar_t *wch);
;;; int wadd_wch(WINDOW *win, const cchar_t *wch);
;;; int mvadd_wch(int y, int x, const cchar_t *wch);
;;; int mvwadd_wch( WINDOW *win, int y, int x, const cchar_t *wch);
;;; int echo_wchar(const cchar_t *wch);
;;; int wecho_wchar(WINDOW *win, const cchar_t *wch);
;;; Low-level CFFI wrappers
(defcfun ("add_wch" %add-wch) :int (wch (:pointer (:struct cchar_t))))
(defcfun ("wadd_wch" %wadd-wch) :int (win window) (wch (:pointer (:struct cchar_t))))
(defcfun ("mvadd_wch" %mvadd-wch) :int (y :int) (x :int) (wch (:pointer (:struct cchar_t))))
(defcfun ("mvwadd_wch" %mvwadd-wch) :int (win window) (y :int) (x :int) (wch (:pointer (:struct cchar_t))))
(defcfun ("echo_wchar" %echo-wchar) :int (wch (:pointer (:struct cchar_t))))
(defcfun ("wecho_wchar" %wecho-wchar) :int (win window) (wch (:pointer (:struct cchar_t))))

View file

@ -0,0 +1,25 @@
(in-package :de.anvi.ncurses)
;;; addch
;;; add a character (with attributes) to a curses window, then advance the cursor
;;; http://invisible-island.net/ncurses/man/curs_addch.3x.html
;;; C prototypes
;; int addch(const chtype ch);
;; int waddch(WINDOW *win, const chtype ch);
;; int mvaddch(int y, int x, const chtype ch);
;; int mvwaddch(WINDOW *win, int y, int x, const chtype ch);
;; int echochar(const chtype ch);
;; int wechochar(WINDOW *win, const chtype ch);
;;; Low-level CFFI wrappers
(defcfun ("addch" %addch) :int (ch chtype))
(defcfun ("waddch" %waddch) :int (win window) (ch chtype))
(defcfun ("mvaddch" %mvaddch) :int (y :int) (x :int) (ch chtype))
(defcfun ("mvwaddch" %mvwaddch) :int (win window) (y :int) (x :int) (ch chtype))
(defcfun ("echochar" %echochar) :int (ch chtype))
(defcfun ("wechochar" %wechochar) :int (win window) (ch chtype))

View file

@ -0,0 +1,31 @@
(in-package :de.anvi.ncurses)
;;; addstr
;;; add a string of characters to a curses window and advance cursor
;;; http://invisible-island.net/ncurses/man/curs_addstr.3x.html
;;; http://www.manpagez.com/man/3/curs_addstr/
;;; C prototypes
;; int addstr(const char *str);
;; int addnstr(const char *str, int n);
;; int waddstr(WINDOW *win, const char *str);
;; int waddnstr(WINDOW *win, const char *str, int n);
;; int mvaddstr(int y, int x, const char *str);
;; int mvaddnstr(int y, int x, const char *str, int n);
;; int mvwaddstr(WINDOW *win, int y, int x, const char *str);
;; int mvwaddnstr(WINDOW *win, int y, int x, const char *str, int n);
;;; Low-level CFFI wrappers
(defcfun ("addstr" %addstr) :int (str :string))
(defcfun ("addnstr" %addnstr) :int (str :string) (n :int))
(defcfun ("waddstr" %waddstr) :int (win window) (str :string))
(defcfun ("waddnstr" %waddnstr) :int (win window) (str :string) (n :int))
(defcfun ("mvaddstr" %mvaddstr) :int (y :int) (x :int) (str :string))
(defcfun ("mvaddnstr" %mvaddnstr) :int (y :int) (x :int) (str :string) (n :int))
(defcfun ("mvwaddstr" %mvwaddstr) :int (win window) (y :int) (x :int) (str :string))
(defcfun ("mvwaddnstr" %mvwaddnstr) :int (win window) (y :int) (x :int) (str :string) (n :int))

View file

@ -0,0 +1,72 @@
(in-package :de.anvi.ncurses)
;;; attr
;;; curses character and window attribute control routines
;;; http://invisible-island.net/ncurses/man/curs_attr.3x.html
;;; http://publib.boulder.ibm.com/infocenter/pseries/v5r3/topic/com.ibm.aix.genprogc/doc/genprogc/manip_video_attrs.htm
;;; C prototypes
;; int attroff(int attrs);
;; int wattroff(WINDOW *win, int attrs);
;; int attron(int attrs);
;; int wattron(WINDOW *win, int attrs);
;; int attrset(int attrs);
;; int wattrset(WINDOW *win, int attrs);
;; int color_set(short color_pair_number, void* opts);
;; int wcolor_set(WINDOW *win, short color_pair_number, void* opts);
;; int standend(void);
;; int wstandend(WINDOW *win);
;; int standout(void);
;; int wstandout(WINDOW *win);
;; int attr_get(attr_t *attrs, short *pair, void *opts);
;; int wattr_get(WINDOW *win, attr_t *attrs, short *pair, void *opts);
;; int attr_off(attr_t attrs, void *opts);
;; int wattr_off(WINDOW *win, attr_t attrs, void *opts);
;; int attr_on(attr_t attrs, void *opts);
;; int wattr_on(WINDOW *win, attr_t attrs, void *opts);
;; int attr_set(attr_t attrs, short pair, void *opts);
;; int wattr_set(WINDOW *win, attr_t attrs, short pair, void *opts);
;; int chgat(int n, attr_t attr, short color, const void *opts)
;; int wchgat(WINDOW *win, int n, attr_t attr, short color, const void *opts)
;; int mvchgat(int y, int x, int n, attr_t attr, short color, const void *opts)
;; int mvwchgat(WINDOW *win, int y, int x, int n, attr_t attr, short color, const void *opts)
;;; Low-level CFFI wrappers
;; :unsigned-int should be the same size as :uint32, 4 bytes, the size of a chtype.
(defcfun ("attroff" %attroff) :int (attrs :unsigned-int))
(defcfun ("wattroff" %wattroff) :int (win window) (attrs :unsigned-int))
(defcfun ("attron" %attron) :int (attrs :unsigned-int))
(defcfun ("wattron" %wattron) :int (win window) (attrs :unsigned-int))
(defcfun ("attrset" %attrset) :int (attrs :unsigned-int))
(defcfun ("wattrset" %wattrset) :int (win window) (attrs :unsigned-int))
(defcfun ("color_set" %color-set) :int (color-pair-number :short) (opts (:pointer :void)))
(defcfun ("wcolor_set" %wcolor-set) :int (win window) (color-pair-number :short) (opts (:pointer :void)))
(defcfun ("standend" %standend) :int)
(defcfun ("wstandend" %wstandend) :int (win window))
(defcfun ("standout" %standout) :int)
(defcfun ("wstandout" %wstandout) :int (win window))
(defcfun ("attr_get" %attr-get) :int (attrs (:pointer attr)) (pair (:pointer :short)) (opts (:pointer :void)))
(defcfun ("wattr_get" %wattr-get) :int (win window) (attrs (:pointer attr)) (pair (:pointer :short)) (opts (:pointer :void)))
(defcfun ("attr_off" %attr-off) :int (attrs attr) (opts (:pointer :void)))
(defcfun ("wattr_off" %wattr-off) :int (win window) (attrs attr) (opts (:pointer :void)))
(defcfun ("attr_on" %attr-on) :int (attrs attr) (opts (:pointer :void)))
(defcfun ("wattr_on" %wattr-on) :int (win window) (attrs attr) (opts (:pointer :void)))
(defcfun ("attr_set" %attr-set) :int (attrs attr) (pair :short) (opts (:pointer :void)))
(defcfun ("wattr_set" %wattr-set) :int (win window) (attrs attr) (pair :short) (opts (:pointer :void)))
(defcfun ("chgat" %chgat) :int (n :int) (attr attr) (color :short) (opts (:pointer :void)))
(defcfun ("wchgat" %wchgat) :int (win window) (n :int) (attr attr) (color :short) (opts (:pointer :void)))
(defcfun ("mvchgat" %mvchgat) :int (y :int) (x :int) (n :int) (attr attr) (color :short) (opts (:pointer :void)))
(defcfun ("mvwchgat" %mvwchgat) :int (win window) (y :int) (x :int) (n :int) (attr attr) (color :short) (opts (:pointer :void)))

View file

@ -0,0 +1,15 @@
(in-package :de.anvi.ncurses)
;;; beep
;;; curses bell and screen flash routines
;;; http://invisible-island.net/ncurses/man/curs_beep.3x.html
;;; C prototypes
;; int beep(void);
;; int flash(void);
;;; Low-level CFFI wrappers
(defcfun ("beep" %beep) :int)
(defcfun ("flash" %flash) :int)

View file

@ -0,0 +1,21 @@
(in-package :de.anvi.ncurses)
;;; bkgd
;;; curses window background manipulation routines
;;; http://invisible-island.net/ncurses/man/curs_bkgd.3x.html
;;; C prototypes
;; void bkgdset(chtype ch);
;; void wbkgdset(WINDOW *win, chtype ch);
;; int bkgd(chtype ch);
;; int wbkgd(WINDOW *win, chtype ch);
;; chtype getbkgd(WINDOW *win);
;;; Low-level CFFI wrappers
(defcfun ("bkgdset" %bkgdset) :void (ch chtype))
(defcfun ("wbkgdset" %wbkgdset) :void (win window) (ch chtype))
(defcfun ("bkgd" %bkgd) :int (ch chtype))
(defcfun ("wbkgd" %wbkgd) :int (win window) (ch chtype))
(defcfun ("getbkgd" %getbkgd) chtype (win window))

View file

@ -0,0 +1,23 @@
(in-package :de.anvi.ncurses)
;;; bkgrnd
;;; window complex background manipulation routines
;;; http://invisible-island.net/ncurses/man/curs_bkgrnd.3x.html
;;; C prototypes
;; int bkgrnd( const cchar_t *wch);
;; int wbkgrnd( WINDOW *win, const cchar_t *wch);
;; void bkgrndset(const cchar_t *wch );
;; void wbkgrndset(WINDOW *win, const cchar_t *wch);
;; int getbkgrnd(cchar_t *wch);
;; int wgetbkgrnd(WINDOW *win, cchar_t *wch);
;;; Low-level CFFI wrappers
(defcfun ("bkgrnd" %bkgrnd) :int (wch (:pointer (:struct cchar_t))))
(defcfun ("wbkgrnd" %wbkgrnd) :int (win window) (wch (:pointer (:struct cchar_t))))
(defcfun ("bkgrndset" %bkgrndset) :void (wch (:pointer (:struct cchar_t))))
(defcfun ("wbkgrndset" %wbkgrndset) :void (win window) (wch (:pointer (:struct cchar_t))))
(defcfun ("getbkgrnd" %getbkgrnd) :int (wch (:pointer (:struct cchar_t))))
(defcfun ("wgetbkgrnd" %wgetbkgrnd) :int (win window) (wch (:pointer (:struct cchar_t))))

View file

@ -0,0 +1,57 @@
(in-package :de.anvi.ncurses)
;;; border
;;; create curses borders, horizontal and vertical lines
;;; http://invisible-island.net/ncurses/man/curs_border.3x.html
;;; http://linux.die.net/man/3/box
;;; C prototypes
;; int border(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br);
;; int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br);
;; int box(WINDOW *win, chtype verch, chtype horch);
;; int hline(chtype ch, int n);
;; int whline(WINDOW *win, chtype ch, int n);
;; int vline(chtype ch, int n);
;; int wvline(WINDOW *win, chtype ch, int n);
;; int mvhline(int y, int x, chtype ch, int n);
;; int mvwhline(WINDOW *, int y, int x, chtype ch, int n);
;; int mvvline(int y, int x, chtype ch, int n);
;; int mvwvline(WINDOW *, int y, int x, chtype ch, int n);
;;; Low-level CFFI wrappers
(defcfun ("border" %border) :int
(ls chtype)
(rs chtype)
(ts chtype)
(bs chtype)
(tl chtype)
(tr chtype)
(bl chtype)
(br chtype))
(defcfun ("wborder" %wborder) :int
(win window)
(ls chtype)
(rs chtype)
(ts chtype)
(bs chtype)
(tl chtype)
(tr chtype)
(bl chtype)
(br chtype))
(defcfun ("box" %box) :int (win window) (verch chtype) (horch chtype))
(defcfun ("hline" %hline) :int (ch chtype) (n :int))
(defcfun ("whline" %whline) :int (win window) (ch chtype) (n :int))
(defcfun ("vline" %vline) :int (ch chtype) (n :int))
(defcfun ("wvline" %wvline) :int (win window) (ch chtype) (n :int))
(defcfun ("mvhline" %mvhline) :int (y :int) (x :int) (ch chtype) (n :int))
(defcfun ("mvwhline" %mvwhline) :int (win window) (y :int) (x :int) (ch chtype) (n :int))
(defcfun ("mvvline" %mvvline) :int (y :int) (x :int) (ch chtype) (n :int))
(defcfun ("mvwvline" %mvwvline) :int (win window) (y :int) (x :int) (ch chtype) (n :int))

View file

@ -0,0 +1,60 @@
(in-package :de.anvi.ncurses)
;;; border_set
;;; create curses borders or lines using complex characters and renditions
;;; http://invisible-island.net/ncurses/man/curs_border_set.3x.html
;;; C prototypes
;; int border_set(const cchar_t *ls, const cchar_t *rs, const cchar_t *ts, const cchar_t *bs, const cchar_t *tl, const cchar_t *tr, const cchar_t *bl, const cchar_t *br);
;; int wborder_set(WINDOW *win, const cchar_t *ls, const cchar_t *rs, const cchar_t *ts, const cchar_t *bs, const cchar_t *tl, const cchar_t *tr, const cchar_t *bl, const cchar_t *br);
;; int box_set(WINDOW *win, const cchar_t *verch, const cchar_t *horch);
;; int hline_set(const cchar_t *wch, int n);
;; int whline_set(WINDOW *win, const cchar_t *wch, int n);
;; int mvhline_set(int y, int x, const cchar_t *wch, int n);
;; int mvwhline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n);
;; int vline_set(const cchar_t *wch, int n);
;; int wvline_set(WINDOW *win, const cchar_t *wch, int n);
;; int mvvline_set(int y, int x, const cchar_t *wch, int n);
;; int mvwvline_set(WINDOW *win, int y, int x, const cchar_t *wch, int n);
;;; Low-level CFFI wrappers
(defcfun ("border_set" %border-set) :int
(ls (:pointer (:struct cchar_t)))
(rs (:pointer (:struct cchar_t)))
(ts (:pointer (:struct cchar_t)))
(bs (:pointer (:struct cchar_t)))
(tl (:pointer (:struct cchar_t)))
(tr (:pointer (:struct cchar_t)))
(bl (:pointer (:struct cchar_t)))
(br (:pointer (:struct cchar_t))))
(defcfun ("wborder_set" %wborder-set) :int
(win window)
(ls (:pointer (:struct cchar_t)))
(rs (:pointer (:struct cchar_t)))
(ts (:pointer (:struct cchar_t)))
(bs (:pointer (:struct cchar_t)))
(tl (:pointer (:struct cchar_t)))
(tr (:pointer (:struct cchar_t)))
(bl (:pointer (:struct cchar_t)))
(br (:pointer (:struct cchar_t))))
(defcfun ("box_set" %box-set) :int
(win window)
(verch (:pointer (:struct cchar_t)))
(horch (:pointer (:struct cchar_t))))
(defcfun ("hline_set" %hline-set) :int (wch (:pointer (:struct cchar_t))) (n :int))
(defcfun ("whline_set" %whline-set) :int (win window) (wch (:pointer (:struct cchar_t))) (n :int))
(defcfun ("mvhline_set" %mvhline-set) :int (y :int) (x :int) (wch (:pointer (:struct cchar_t))) (n :int))
(defcfun ("mvwhline_set" %mvwhline-set) :int (win window) (y :int) (x :int) (wch (:pointer (:struct cchar_t))) (n :int))
(defcfun ("vline_set" %vline-set) :int (wch (:pointer (:struct cchar_t))) (n :int))
(defcfun ("wvline_set" %wvline-set) :int (win window) (wch (:pointer (:struct cchar_t))) (n :int))
(defcfun ("mvvline_set" %mvvline-set) :int (y :int) (x :int) (wch (:pointer (:struct cchar_t))) (n :int))
(defcfun ("mvwvline_set" %mvwvline-set) :int (win window) (y :int) (x :int) (wch (:pointer (:struct cchar_t))) (n :int))

View file

@ -0,0 +1,29 @@
(in-package :de.anvi.ncurses)
;;; clear
;;; clear all or part of a curses window
;;; http://invisible-island.net/ncurses/man/curs_clear.3x.html
;;; http://linux.die.net/man/3/erase
;;; C prototypes
;; int erase(void);
;; int werase(WINDOW *win);
;; int clear(void);
;; int wclear(WINDOW *win);
;; int clrtobot(void);
;; int wclrtobot(WINDOW *win);
;; int clrtoeol(void);
;; int wclrtoeol(WINDOW *win);
;;; Low-level CFFI wrappers
(defcfun ("erase" %erase) :int)
(defcfun ("werase" %werase) :int (win window))
(defcfun ("clear" %clear) :int)
(defcfun ("wclear" %wclear) :int (win window))
(defcfun ("clrtobot" %clrtobot) :int)
(defcfun ("wclrtobot" %wclrtobot) :int (win window))
(defcfun ("clrtoeol" %clrtoeol) :int)
(defcfun ("wclrtoeol" %wclrtoeol) :int (win window))

View file

@ -0,0 +1,56 @@
(in-package :de.anvi.ncurses)
;;; color
;;; curses color manipulation routines
;;; http://invisible-island.net/ncurses/man/curs_color.3x.html
;;; http://linux.die.net/man/3/init_color
;;; C prototypes
;; int start_color(void);
;; bool has_colors(void);
;; bool can_change_color(void);
;; int init_pair(short pair, short f, short b);
;; int init_color(short color, short r, short g, short b);
;; int pair_content(short pair, short *f, short *b);
;; int color_content(short color, short *r, short *g, short *b);
;; int init_extended_pair(int pair, int f, int b);
;; int init_extended_color(int color, int r, int g, int b);
;; int extended_pair_content(int pair, int *f, int *b);
;; int extended_color_content(int color, int *r, int *g, int *b);
;;; C macros
;; COLOR_PAIR(int n)
;; PAIR_NUMBER(attrs);
;;; Low-level CFFI wrappers
(defcfun ("start_color" %start-color) :int)
(defcfun ("has_colors" %has-colors) :boolean)
(defcfun ("can_change_color" %can-change-color) :boolean)
(defcfun ("init_pair" %init-pair) :int (pair :short) (f :short) (b :short))
(defcfun ("init_color" %init-color) :int (color :short) (r :short) (g :short) (b :short))
(defcfun ("pair_content" %pair-content) :int (pair :short) (f (:pointer :short)) (b (:pointer :short)))
(defcfun ("color_content" %color-content) :int (color :short) (r (:pointer :short)) (g (:pointer :short)) (b (:pointer :short)))
(defcfun ("init_extended_pair" %init-extended-pair) :int (pair :int) (f :int) (b :int))
(defcfun ("init_extended_color" %init-extended-color) :int (color :int) (r :int) (g :int) (b :int))
(defcfun ("extended_pair_content" %pair-extended-content) :int (pair :int) (f (:pointer :int)) (b (:pointer :int)))
(defcfun ("extended_color_content" %color-extended-content) :int (color :int) (r (:pointer :int)) (g (:pointer :int)) (b (:pointer :int)))
(defcfun ("COLOR_PAIR" %color-pair) :int (n :int))
(defcfun ("PAIR_NUMBER" %pair-number) :int (attrs :int))
(defconstant %COLOR-BLACK 0)
(defconstant %COLOR-RED 1)
(defconstant %COLOR-GREEN 2)
(defconstant %COLOR-YELLOW 3)
(defconstant %COLOR-BLUE 4)
(defconstant %COLOR-MAGENTA 5)
(defconstant %COLOR-CYAN 6)
(defconstant %COLOR-WHITE 7)

View file

@ -0,0 +1,15 @@
(in-package :de.anvi.ncurses)
;; default_colors
;; use terminal's default colors
;; http://invisible-island.net/ncurses/man/default_colors.3x.html
;;; C prototypes
;; int use_default_colors(void);
;; int assume_default_colors(int fg, int bg);
;;; Low-level CFFI wrappers
(defcfun ("use_default_colors" %use-default-colors) :int)
(defcfun ("assume_default_colors" %assume-default-colors) :int (fg :int) (bg :int))

View file

@ -0,0 +1,13 @@
(in-package :de.anvi.ncurses)
;; define_key
;; define a keycode
;; http://invisible-island.net/ncurses/man/define_key.3x.html
;;; C prototypes
;; int define_key(const char *definition, int keycode);
;;; Low-level CFFI wrappers
(defcfun ("define_key" %define-key) :int (definition :string) (keycode :int))

View file

@ -0,0 +1,19 @@
(in-package :de.anvi.ncurses)
;;; delch
;;; delete character under the cursor in a curses window
;;; http://invisible-island.net/ncurses/man/curs_delch.3x.html
;;; C prototypes
;; int delch(void);
;; int wdelch(WINDOW *win);
;; int mvdelch(int y, int x);
;; int mvwdelch(WINDOW *win, int y, int x);
;;; Low-level CFFI wrappers
(defcfun ("delch" %delch) :int)
(defcfun ("wdelch" %wdelch) :int (win window))
(defcfun ("mvdelch" %mvdelch) :int (y :int) (x :int))
(defcfun ("mvwdelch" %mvwdelch) :int (win window) (y :int) (x :int))

View file

@ -0,0 +1,23 @@
(in-package :de.anvi.ncurses)
;;; deleteln
;;; delete and insert lines in a curses window
;;; http://invisible-island.net/ncurses/man/curs_deleteln.3x.html
;;; C prototypes
;; int deleteln(void);
;; int wdeleteln(WINDOW *win);
;; int insdelln(int n);
;; int winsdelln(WINDOW *win, int n);
;; int insertln(void);
;; int winsertln(WINDOW *win);
;;; Low-level CFFI wrappers
(defcfun ("deleteln" %deleteln) :int)
(defcfun ("wdeleteln" %wdeleteln) :int (win window))
(defcfun ("insdelln" %insdelln) :int (n :int))
(defcfun ("winsdelln" %winsdelln) :int (win window) (n :int))
(defcfun ("insertln" %insertln) :int)
(defcfun ("winsertln" %winsertln) :int (win window))

View file

@ -0,0 +1,15 @@
(in-package :de.anvi.ncurses)
;;; extend
;;; miscellaneous curses extensions
;;; http://invisible-island.net/ncurses/man/curs_extend.3x.html
;;; C prototypes
;; const char * curses_version(void);
;; int use_extended_names(bool enable);
;;; Low-level CFFI wrappers
(defcfun ("curses_version" %curses-version) :string)
(defcfun ("use_extended_names" %use-extended-names) :int (enable :boolean))

View file

@ -0,0 +1,21 @@
(in-package :de.anvi.ncurses)
;;; get_wch
;;; get (or push back) a wide (multi-byte) character from curses terminal keyboard
;;; http://invisible-island.net/ncurses/man/curs_get_wch.3x.html
;;; C prototypes
;; int get_wch(wint_t *wch);
;; int wget_wch(WINDOW *win, wint_t *wch);
;; int mvget_wch(int y, int x, wint_t *wch);
;; int mvwget_wch(WINDOW *win, int y, int x, wint_t *wch);
;; int unget_wch(const wchar_t wch);
;;; Low-level CFFI wrappers
(defcfun ("get_wch" %get-wch) :int (wch (:pointer wint_t)))
(defcfun ("wget_wch" %wget-wch) :int (win window) (wch (:pointer wint_t)))
(defcfun ("mvget_wch" %mvget-wch) :int (y :int) (x :int) (wch (:pointer wint_t)))
(defcfun ("mvwget_wch" %mvwget-wch) :int (win window) (y :int) (x :int) (wch (:pointer wint_t)))
(defcfun ("unget_wch" %unget-wch) :int (wch wchar_t))

View file

@ -0,0 +1,26 @@
(in-package :de.anvi.ncurses)
;;; getcchar
;;; Get a wide character string and rendition from a cchar_t or set a cchar_t from a wide-character string
;;; http://invisible-island.net/ncurses/man/curs_getcchar.3x.html
;;; C prototypes
;; int getcchar(const cchar_t *wcval, wchar_t *wch, attr_t *attrs, short *color_pair, void *opts);
;; int setcchar(cchar_t *wcval, const wchar_t *wch, const attr_t attrs, short color_pair, void *opts);
;;; Low-level CFFI wrappers
(defcfun ("getcchar" %getcchar) :int
(wcval (:pointer (:struct cchar_t)))
(wch (:pointer wchar_t))
(attrs (:pointer attr))
(color_pair (:pointer :short))
(opts (:pointer :void)))
(defcfun ("setcchar" %setcchar) :int
(wcval (:pointer (:struct cchar_t)))
(wch (:pointer wchar_t))
(attrs attr)
(color_pair :short)
(opts (:pointer :void)))

View file

@ -0,0 +1,25 @@
(in-package :de.anvi.ncurses)
;;; getch
;;; get (or push back) characters from curses terminal keyboard
;;; http://invisible-island.net/ncurses/man/curs_getch.3x.html
;;; http://www.manpagez.com/man/3/curs_getch/
;;; C prototypes
;; int getch(void);
;; int wgetch(WINDOW *win);
;; int mvgetch(int y, int x);
;; int mvwgetch(WINDOW *win, int y, int x);
;; int ungetch(int ch);
;; int has_key(int ch);
;;; Low-level CFFI wrappers
(defcfun ("getch" %getch) :int)
(defcfun ("wgetch" %wgetch) :int (win window))
(defcfun ("mvgetch" %mvgetch) :int (y :int) (x :int))
(defcfun ("mvwgetch" %mvwgetch) :int (win window) (y :int) (x :int))
(defcfun ("ungetch" %ungetch) :int (ch :int))
(defcfun ("has_key" %has-key) :int (ch :int))

View file

@ -0,0 +1,27 @@
(in-package :de.anvi.ncurses)
;;; getstr
;;; accept character strings from curses terminal keyboard
;;; http://invisible-island.net/ncurses/man/curs_getstr.3x.html
;;; C prototypes
;; int getstr(char *str);
;; int getnstr(char *str, int n);
;; int wgetstr(WINDOW *win, char *str);
;; int wgetnstr(WINDOW *win, char *str, int n);
;; int mvgetstr(int y, int x, char *str);
;; int mvgetnstr(int y, int x, char *str, int n);
;; int mvwgetstr(WINDOW *win, int y, int x, char *str);
;; int mvwgetnstr(WINDOW *, int y, int x, char *str, int n);
;;; Low-level CFFI wrappers
(defcfun ("getstr" %getstr) :int (str :string))
(defcfun ("getnstr" %getnstr) :int (str :string) (n :int))
(defcfun ("wgetstr" %wgetstr) :int (win window) (str :string))
(defcfun ("wgetnstr" %wgetnstr) :int (win window) (str :string) (n :int))
(defcfun ("mvgetstr" %mvgetstr) :int (y :int) (x :int) (str :string))
(defcfun ("mvgetnstr" %mvgetnstr) :int (y :int) (x :int) (str :string) (n :int))
(defcfun ("mvwgetstr" %mvwgetstr) :int (win window) (y :int) (x :int) (str :string))
(defcfun ("mvwgetnstr" %mvwgetnstr) :int (win window) (y :int) (x :int) (str :string) (n :int))

View file

@ -0,0 +1,42 @@
;; (in-package :de.anvi.ncurses)
;;; getyx
;;; get curses cursor and window coordinates
;;; http://invisible-island.net/ncurses/man/curs_getyx.3x.html
;;; C prototypes
;; void getyx(WINDOW *win, int y, int x);
;; void getparyx(WINDOW *win, int y, int x);
;; void getbegyx(WINDOW *win, int y, int x);
;; void getmaxyx(WINDOW *win, int y, int x);
;;; Low-level CFFI wrappers
;; see legacy.lisp
;;; NOTES
#|
These four C macros are defined in terms of other, simpler macros:
#define getyx(win,y,x) (y = getcury(win), x = 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))
And those simpler macros are just accessing the window struct.
#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)
Those are defined as low-level functions in legacy.lisp.
|#

View file

@ -0,0 +1,19 @@
(in-package :de.anvi.ncurses)
;;; in_wch
;;; extract a wide (multi-byte) character and rendition from a window
;;; http://invisible-island.net/ncurses/man/curs_in_wch.3x.html
;;; C prototypes
;; int in_wch(cchar_t *wcval);
;; int mvin_wch(int y, int x, cchar_t *wcval);
;; int win_wch(WINDOW *win, cchar_t *wcval);
;; int mvwin_wch(WINDOW *win, int y, int x, cchar_t *wcval);
;;; Low-level CFFI wrappers
(defcfun ("in_wch" %in-wch) :int (wcval (:pointer (:struct cchar_t))))
(defcfun ("mvin_wch" %mvin-wch) :int (y :int) (x :int) (wcval (:pointer (:struct cchar_t))))
(defcfun ("win_wch" %win-wch) :int (win window) (wcval (:pointer (:struct cchar_t))))
(defcfun ("mvwin_wch" %mvwin-wch) :int (win window) (y :int) (x :int) (wcval (:pointer (:struct cchar_t))))

View file

@ -0,0 +1,19 @@
(in-package :de.anvi.ncurses)
;;; inch
;;; get a character and attributes from a curses window
;;; http://invisible-island.net/ncurses/man/curs_inch.3x.html
;;; C prototypes
;; chtype inch(void);
;; chtype winch(WINDOW *win);
;; chtype mvinch(int y, int x);
;; chtype mvwinch(WINDOW *win, int y, int x);
;;; Low-level CFFI wrappers
(defcfun ("inch" %inch) chtype)
(defcfun ("winch" %winch) chtype (win window))
(defcfun ("mvinch" %mvinch) chtype (y :int) (x :int))
(defcfun ("mvwinch" %mvwinch) chtype (win window) (y :int) (x :int))

View file

@ -0,0 +1,27 @@
(in-package :de.anvi.ncurses)
;;; inchstr
;;; get a string of characters (and attributes) from a curses window
;;; http://invisible-island.net/ncurses/man/curs_inchstr.3x.html
;;; C prototypes
;; int inchstr(chtype *chstr);
;; int inchnstr(chtype *chstr, int n);
;; int winchstr(WINDOW *win, chtype *chstr);
;; int winchnstr(WINDOW *win, chtype *chstr, int n);
;; int mvinchstr(int y, int x, chtype *chstr);
;; int mvinchnstr(int y, int x, chtype *chstr, int n);
;; int mvwinchstr(WINDOW *win, int y, int x, chtype *chstr);
;; int mvwinchnstr(WINDOW *win, int y, int x, chtype *chstr, int n);
;;; Low-level CFFI wrappers
(defcfun ("inchstr" %inchstr) :int (chstr (:pointer chtype)))
(defcfun ("inchnstr" %inchnstr) :int (chstr (:pointer chtype)) (n :int))
(defcfun ("winchstr" %winchstr) :int (win window) (chstr (:pointer chtype)))
(defcfun ("winchnstr" %winchnstr) :int (win window) (chstr (:pointer chtype)) (n :int))
(defcfun ("mvinchstr" %mvinchstr) :int (y :int) (x :int) (chstr (:pointer chtype)))
(defcfun ("mvinchnstr" %mvinchnstr) :int (y :int) (x :int) (chstr (:pointer chtype)) (n :int))
(defcfun ("mvwinchstr" %mvwinchstr) :int (win window) (y :int) (x :int) (chstr (:pointer chtype)))
(defcfun ("mvwinchnstr" %mvwinchnstr) :int (win window) (y :int) (x :int) (chstr (:pointer chtype)) (n :int))

View file

@ -0,0 +1,24 @@
(in-package :de.anvi.ncurses)
;;; initscr
;;; screen initialization and manipulation routines
;;; http://invisible-island.net/ncurses/man/curs_initscr.3x.html
;;; http://www.manpagez.com/man/3/curs_initscr/
;;; C prototypes
;; WINDOW *initscr(void);
;; int endwin(void);
;; bool isendwin(void);
;; SCREEN *newterm(char *type, FILE *outfd, FILE *infd);
;; SCREEN *set_term(SCREEN *new);
;; void delscreen(SCREEN *sp);
;;; Low-level CFFI wrappers
(defcfun ("initscr" %initscr) window)
(defcfun ("endwin" %endwin) :int)
(defcfun ("isendwin" %isendwin) :boolean)
(defcfun ("newterm" %newterm) screen (type :string) (outfd file) (infd file))
(defcfun ("set_term" %set-term) screen (new screen))
(defcfun ("delscreen" %delscreen) :void (sp screen))

View file

@ -0,0 +1,45 @@
(in-package :de.anvi.ncurses)
;;; inopts
;;; curses input options
;;; http://invisible-island.net/ncurses/man/curs_inopts.3x.html
;;; C prototypes
;; int cbreak(void);
;; int nocbreak(void);
;; int echo(void);
;; int noecho(void);
;; int halfdelay(int tenths);
;; int intrflush(WINDOW *win, bool bf);
;; int keypad(WINDOW *win, bool bf);
;; int meta(WINDOW *win, bool bf);
;; int nodelay(WINDOW *win, bool bf);
;; int raw(void);
;; int noraw(void);
;; void noqiflush(void);
;; void qiflush(void);
;; int notimeout(WINDOW *win, bool bf);
;; void timeout(int delay);
;; void wtimeout(WINDOW *win, int delay);
;; int typeahead(int fd);
;;; Low-level CFFI wrappers
(defcfun ("cbreak" %cbreak) :int)
(defcfun ("nocbreak" %nocbreak) :int)
(defcfun ("echo" %echo) :int)
(defcfun ("noecho" %noecho) :int)
(defcfun ("halfdelay" %halfdelay) :int (tenths :int))
(defcfun ("intrflush" %intrflush) :int (win window) (bf :boolean))
(defcfun ("keypad" %keypad) :int (win window) (bf :boolean))
(defcfun ("meta" %meta) :int (win window) (bf :boolean))
(defcfun ("nodelay" %nodelay) :int (win window) (bf :boolean))
(defcfun ("raw" %raw) :int)
(defcfun ("noraw" %noraw) :int)
(defcfun ("noqiflush" %noqiflush) :void)
(defcfun ("qiflush" %qiflush) :void)
(defcfun ("notimeout" %notimeout) :int (win window) (bf :boolean))
(defcfun ("timeout" %timeout) :void (delay :int))
(defcfun ("wtimeout" %wtimeout) :void (win window) (delay :int))
(defcfun ("typeahead" %typeahead) :int (fd :int))

View file

@ -0,0 +1,19 @@
(in-package :de.anvi.ncurses)
;;; ins_wch
;;; insert a complex character and rendition into a window
;;; http://invisible-island.net/ncurses/man/curs_ins_wch.3x.html
;;; C prototypes
;; int ins_wch(const cchar_t *wch);
;; int wins_wch(WINDOW *win, const cchar_t *wch);
;; int mvins_wch(int y, int x, const cchar_t *wch);
;; int mvwins_wch(WINDOW *win, int y, int x, const cchar_t *wch);
;;; Low-level CFFI wrappers
(defcfun ("ins_wch" %ins-wch) :int (wch (:pointer (:struct cchar_t))))
(defcfun ("wins_wch" %wins-wch) :int (win window) (wch (:pointer (:struct cchar_t))))
(defcfun ("mvins_wch" %mvins-wch) :int (y :int) (x :int) (wch (:pointer (:struct cchar_t))))
(defcfun ("mvwins_wch" %mvwins-wch) :int (win window) (y :int) (x :int) (wch (:pointer (:struct cchar_t))))

View file

@ -0,0 +1,19 @@
(in-package :de.anvi.ncurses)
;;; insch
;;; insert a character before cursor in a curses window
;;; http://invisible-island.net/ncurses/man/curs_insch.3x.html
;;; C prototypes
;; int insch(chtype ch);
;; int winsch(WINDOW *win, chtype ch);
;; int mvinsch(int y, int x, chtype ch);
;; int mvwinsch(WINDOW *win, int y, int x, chtype ch);
;;; Low-level CFFI wrappers
(defcfun ("insch" %insch) :int (ch chtype))
(defcfun ("winsch" %winsch) :int (win window) (ch chtype))
(defcfun ("mvinsch" %mvinsch) :int (y :int) (x :int) (ch chtype))
(defcfun ("mvwinsch" %mvwinsch) :int (win window) (y :int) (x :int) (ch chtype))

View file

@ -0,0 +1,27 @@
(in-package :de.anvi.ncurses)
;;; insstr
;;; insert string before cursor in a curses window
;;; http://invisible-island.net/ncurses/man/curs_insstr.3x.html
;;; C prototypes
;; int insstr(const char *str);
;; int insnstr(const char *str, int n);
;; int winsstr(WINDOW *win, const char *str);
;; int winsnstr(WINDOW *win, const char *str, int n);
;; int mvinsstr(int y, int x, const char *str);
;; int mvinsnstr(int y, int x, const char *str, int n);
;; int mvwinsstr(WINDOW *win, int y, int x, const char *str);
;; int mvwinsnstr(WINDOW *win, int y, int x, const char *str, int n);
;;; Low-level CFFI wrappers
(defcfun ("insstr" %insstr) :int (str :string))
(defcfun ("insnstr" %insnstr) :int (str :string) (n :int))
(defcfun ("winsstr" %winsstr) :int (win window) (str :string))
(defcfun ("winsnstr" %winsnstr) :int (win window) (str :string) (n :int))
(defcfun ("mvinsstr" %mvinsstr) :int (y :int) (x :int) (str :string))
(defcfun ("mvinsnstr" %mvinsnstr) :int (y :int) (x :int) (str :string) (n :int))
(defcfun ("mvwinsstr" %mvwinsstr) :int (win window) (y :int) (x :int) (str :string))
(defcfun ("mvwinsnstr" %mvwinsnstr) :int (win window) (y :int) (x :int) (str :string) (n :int))

View file

@ -0,0 +1,27 @@
(in-package :de.anvi.ncurses)
;;; instr
;;; get a string of characters from a curses window
;;; http://invisible-island.net/ncurses/man/curs_instr.3x.html
;;; C prototypes
;; int instr(char *str);
;; int innstr(char *str, int n);
;; int winstr(WINDOW *win, char *str);
;; int winnstr(WINDOW *win, char *str, int n);
;; int mvinstr(int y, int x, char *str);
;; int mvinnstr(int y, int x, char *str, int n);
;; int mvwinstr(WINDOW *win, int y, int x, char *str);
;; int mvwinnstr(WINDOW *win, int y, int x, char *str, int n);
;;; Low-level CFFI wrappers
(defcfun ("instr" %instr) :int (str :string))
(defcfun ("innstr" %innstr) :int (str :string) (n :int))
(defcfun ("winstr" %winstr) :int (win window) (str :string))
(defcfun ("winnstr" %winnstr) :int (win window) (str :string) (n :int))
(defcfun ("mvinstr" %mvinstr) :int (y :int) (x :int) (str :string))
(defcfun ("mvinnstr" %mvinnstr) :int (y :int) (x :int) (str :string) (n :int))
(defcfun ("mvwinstr" %mvwinstr) :int (win window) (y :int) (x :int) (str :string))
(defcfun ("mvwinnstr" %mvwinnstr) :int (win window) (y :int) (x :int) (str :string) (n :int))

View file

@ -0,0 +1,27 @@
(in-package :de.anvi.ncurses)
;;; inwstr
;;; extract a string of wchar_t characters from a curses window
;;; http://invisible-island.net/ncurses/man/curs_inwstr.3x.html
;;; C prototypes
;; int inwstr(wchar_t *str);
;; int innwstr(wchar_t *str, int n);
;; int winwstr(WINDOW *win, wchar_t *str);
;; int winnwstr(WINDOW *win, wchar_t *str, int n);
;; int mvinwstr(int y, int x, wchar_t *str);
;; int mvinnwstr(int y, int x, wchar_t *str, int n);
;; int mvwinwstr(WINDOW *win, int y, int x, wchar_t *str);
;; int mvwinnwstr(WINDOW *win, int y, int x, wchar_t *str, int n);
;;; Low-level CFFI wrappers
(defcfun ("inwstr" %inwstr) :int (str (:pointer wchar_t)))
(defcfun ("innwstr" %innwstr) :int (str (:pointer wchar_t)) (n :int))
(defcfun ("winwstr" %winwstr) :int (win window) (str (:pointer wchar_t)))
(defcfun ("winnwstr" %winnwstr) :int (win window) (str (:pointer wchar_t)) (n :int))
(defcfun ("mvinwstr" %mvinwstr) :int (y :int) (x :int) (str (:pointer wchar_t)))
(defcfun ("mvinnwstr" %mvinnwstr) :int (y :int) (x :int) (str (:pointer wchar_t)) (n :int))
(defcfun ("mvwinwstr" %mvwinwstr) :int (win window) (y :int) (x :int) (str (:pointer wchar_t)))
(defcfun ("mvwinnwstr" %mvwinnwstr) :int (win window) (y :int) (x :int) (str (:pointer wchar_t)) (n :int))

View file

@ -0,0 +1,33 @@
(in-package :de.anvi.ncurses)
;;; kernel
;;; low-level curses routines
;;; http://invisible-island.net/ncurses/man/curs_kernel.3x.html
;;; C prototypes
;; int def_prog_mode(void);
;; int def_shell_mode(void);
;; int reset_prog_mode(void);
;; int reset_shell_mode(void);
;; int resetty(void);
;; int savetty(void);
;; void getsyx(int y, int x);
;; void setsyx(int y, int x);
;; int ripoffline(int line, int (*init)(WINDOW *, int));
;; int curs_set(int visibility);
;; int napms(int ms);
;;; Low-level CFFI wrappers
(defcfun ("def_prog_mode" %def-prog-mode) :int)
(defcfun ("def_shell_mode" %def-shell-mode) :int)
(defcfun ("reset_prog_mode" %reset-prog-mode) :int)
(defcfun ("reset_shell_mode" %reset-shell-mode) :int)
(defcfun ("resetty" %resetty) :int)
(defcfun ("savetty" %savetty) :int)
(defcfun ("getsyx" %getsyx) :void (y :int) (x :int))
(defcfun ("setsyx" %setsyx) :void (y :int) (x :int))
(defcfun ("ripoffline" %ripoffline) :int (line :int) (init :pointer))
(defcfun ("curs_set" %curs-set) :int (visibility :int))
(defcfun ("napms" %napms) :int (ms :int))

View file

@ -0,0 +1,13 @@
(in-package :de.anvi.ncurses)
;; key_defined
;; check if a keycode is defined
;; http://invisible-island.net/ncurses/man/key_defined.3x.html
;;; C prototypes
;; int key_defined(const char *definition);
;;; Low-level CFFI wrappers
(defcfun ("key_defined" %key-defined) :int (definition :string))

View file

@ -0,0 +1,13 @@
(in-package :de.anvi.ncurses)
;; keybound
;; return definition of keycode
;; http://invisible-island.net/ncurses/man/keybound.3x.html
;;; C prototypes
;; char *keybound(int keycode, int count);
;;; Low-level CFFI wrappers
(defcfun ("keybound" %keybound) :string (keycode :int) (count :int))

View file

@ -0,0 +1,28 @@
(in-package :de.anvi.ncurses)
;;; legacy
;;; get curses cursor and window coordinates, attributes
;;; http://invisible-island.net/ncurses/man/curs_legacy.3x.html
;;; C prototypes
;; int getattrs(WINDOW *win);
;; int getbegx(WINDOW *win);
;; int getbegy(WINDOW *win);
;; int getcurx(WINDOW *win);
;; int getcury(WINDOW *win);
;; int getmaxx(WINDOW *win);
;; int getmaxy(WINDOW *win);
;; int getparx(WINDOW *win);
;; int getpary(WINDOW *win);
;;; Low-level CFFI wrappers
(defcfun ("getbegx" %getbegx) :int (win window))
(defcfun ("getbegy" %getbegy) :int (win window))
(defcfun ("getcurx" %getcurx) :int (win window))
(defcfun ("getcury" %getcury) :int (win window))
(defcfun ("getmaxx" %getmaxx) :int (win window))
(defcfun ("getmaxy" %getmaxy) :int (win window))
(defcfun ("getparx" %getparx) :int (win window))
(defcfun ("getpary" %getpary) :int (win window))

View file

@ -0,0 +1,12 @@
(in-package :de.anvi.ncurses)
;;; legacy coding
;;; http://invisible-island.net/ncurses/man/legacy_coding.3x.html
;;; C prototypes
;; int use_legacy_coding(int level);
;;; Low-level CFFI wrappers
(defcfun ("use_legacy_coding" %use-legacy-coding) :int (level :int))

View file

@ -0,0 +1,24 @@
(in-package :de.anvi.ncurses)
;;; mouse
;;; mouse interface through curses
;;; http://invisible-island.net/ncurses/man/curs_mouse.3x.html
;;; C prototypes
;;; bool has_mouse(void);
;;; int getmouse(MEVENT *event);
;;; int ungetmouse(MEVENT *event);
;;; mmask_t mousemask(mmask_t newmask, mmask_t *oldmask);
;;; bool wenclose(const WINDOW *win, int y, int x);
;;; bool mouse_trafo(int* pY, int* pX, bool to_screen);
;;; bool wmouse_trafo(const WINDOW* win, int* pY, int* pX, bool to_screen);
;;; int mouseinterval(int erval);
;;; Low-level CFFI wrappers
(defcfun ("getmouse" %getmouse) :int (event (:pointer (:struct mevent))))
(defcfun ("mousemask" %mousemask) mmask_t (newmask mmask_t) (oldmask (:pointer mmask_t)))
(defcfun ("has_mouse" %has-mouse) :boolean)
(defcfun ("ungetmouse" %ungetmouse) :int (event (:pointer (:struct mevent))))

View file

@ -0,0 +1,16 @@
(in-package :de.anvi.ncurses)
;;; move
;;; move curses window cursor
;;; http://invisible-island.net/ncurses/man/curs_move.3x.html
;;; http://www.manpagez.com/man/3/curs_move/
;;; C prototypes
;; int move(int y, int x);
;; int wmove(WINDOW *win, int y, int x);
;;; Low-level CFFI wrappers
(defcfun ("move" %move) :int (y :int) (x :int))
(defcfun ("wmove" %wmove) :int (win window) (y :int) (x :int))

View file

@ -0,0 +1,213 @@
(in-package :de.anvi.ncurses)
;;; ncurses
;;; CRT screen handling and optimization package
;;; http://invisible-island.net/ncurses/man/ncurses.3x.html
;; The wide multi-byte library is preferred and will be loaded when the underlying lisp system supports unicode.
#+(or sb-unicode unicode openmcl-unicode-strings)
(define-foreign-library libncursesw
(:darwin (:or "libncursesw.6.dylib" "libncursesw.5.dylib" "libncursesw.dylib" "libcurses.dylib"))
(:unix (:or "libncursesw.so.6.1" "libncursesw.so.6.0" "libncursesw.so.6" "libncursesw.so.5.9" "libncursesw.so.5" "libncursesw.so"))
(t (:default "libncursesw")))
#+(or sb-unicode unicode openmcl-unicode-strings)
(use-foreign-library libncursesw)
;; Attempt to use the legacy single-byte library only when the lisp implementation doesnt support unicode.
#-(or sb-unicode unicode openmcl-unicode-strings)
(define-foreign-library libncurses
(:darwin (:or "libncurses.6.dylib" "libncurses.5.dylib" "libncurses.dylib" "libcurses.dylib"))
(:unix (:or "libncurses.so.6.1" "libncurses.so.6.0" "libncurses.so.6" "libncurses.so.5.9" "libncurses.so.5" "libncurses.so"))
(t (:default "libncurses")))
#-(or sb-unicode unicode openmcl-unicode-strings)
(use-foreign-library libncurses)
;;; ------------------------------------------------------------------
;; Every function that can take a win, should take a win.
;; We dont want functions that implicitly operate on a global stdscr.
;; Function should return lisp-style bools, not C type int 0 or 1.
;; cffi automatically does this conversion.
;;; ------------------------------------------------------------------
;; General ncurses library implementation info:
;; data types:
;; http://pubs.opengroup.org/onlinepubs/7908799/xcurses/curses.h.html
;; http://pubs.opengroup.org/onlinepubs/7908799/xcurses/implement.html
;; http://pubs.opengroup.org/onlinepubs/7908799/cursesix.html
;; http://refspecs.linuxbase.org/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/libncurses.html
;; http://refspecs.linuxbase.org/LSB_3.0.0/LSB-Core-generic/LSB-Core-generic/libncurses-ddefs.html
;; http://h71000.www7.hp.com/doc/83final/5763/5763pro_016.html
;; http://docs.python.org/release/2.4.3/lib/curses-window-objects.html
;; http://web.ist.utl.pt/tiago.dionizio/lua/lcurses.html
;;; ------------------------------------------------------------------
;;; Types
;; Basic types as seen in the ncurses function prototypes.
;; These will only be used inside cffi wrappers.
;; not used, cffi automatically translates a boolean type
;; typedef unsigned char bool;
(defctype bool :unsigned-char)
#|
--enable-lp64
Allows an application to define _LP64 to declare chtype and mmask_t as
simply unsigned rather than the configured types
using the --with-chtype and --with-mmask_t options.
#if 1 && defined(_LP64)
typedef unsigned chtype;
typedef unsigned mmask_t;
#else
typedef uint32_t chtype;
typedef uint32_t mmask_t;
#endif
|#
;; default ubuntu build options, they build for API5.
;; --disable-lp64 --with-chtype='long' --with-mmask-t='long'
;; the default type on ubuntu isnt "unsigned int" but "long", which means signed long.
;; We will use the ABI6 default uint32_t instead of long.
;; TODO: use ABI6 values for chtype, cchar_t and mmask: --with-chtype=uint32_t
;;(defctype chtype :unsigned-int)
(defctype chtype :uint32)
;; wide character type, defined in:
;; /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h
;; it has to be able to contain the 21-bit 10FFFF, which is the max allowed unicode point.
(defctype wchar_t :int32)
;; typedef unsigned int wint_t;
;; used in get_wch.lisp
;; wint_t needs to be a signed int to represent a negative WEOF value.
(defctype wint_t :int32)
;; typedef chtype attr_t;
;; TODO: rename this to attr_t
(defctype attr :uint32
"The 32 bit integral type attr_t holds an OR-ed set of attributes.")
(defctype attr_t :uint32
"The 32 bit integral type attr_t holds an OR-ed set of attributes.")
;; winptr = *WINDOW
;; TODO: define window struct
;; (defctype ptr-window (:pointer (:struct window)))
(defctype window :pointer)
;; scrptr = *SCREEN
(defctype screen :pointer)
;; fileptr = *FILE
(defctype file :pointer)
;;; C structures
#|
Excerpt from /usr/include/ncurses.h
/*
* 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().
*/
#define CCHARW_MAX 5
typedef struct
{
attr_t attr;
wchar_t chars[CCHARW_MAX];
#if 0
#undef NCURSES_EXT_COLORS
#define NCURSES_EXT_COLORS 20110404
int ext_color; /* color pair, must be more than 16-bits */
#endif
}
cchar_t;
|#
;; For non-extended colors, the color pair is OR-ed into the attr value, like it has been done
;; with color pairs in chtypes. This is ABI5.
;;(defcstruct cchar_t
;; "A C struct containing contains a wide char and an integer containing the color pair and attributes."
;; (cchar-attr attr)
;; (cchar-chars wchar_t :count 5))
;; For extended colors, we get a new struct slot. This is ABI6, which is the default since ncurses 6.0, 20150808.
;; Intended to be used with setcchar.
;; TODO: write meaningsful docstrings here.
(defcstruct cchar_t
"C struct containing a wide char, a color pair and attributes."
(cchar-attr attr_t)
(cchar-chars wchar_t :count 5)
(cchar-colors :int))
(defctype ptr-cchar_t (:pointer (:struct cchar_t)))
;; Intended to be used with convert-to-foreign plist translation.
;; For some reasons, plists with pointers dont work, so we have to pass by value.
;; TODO: we dont need this any more, everything works now with the cchar_t struct.
(defcstruct cchar
"C struct containing a wide char, a color pair and attributes."
(cchar-attr attr_t)
(cchar-chars wchar_t)
(cchar-colors :int))
;; the default on ubuntu 12.04, 16.04 is --enable-ext-colors,
;; so is probably on debian, so we need to include "int ext_color" by default in
;; the cchar struct.
;; convert-to-foreign and convert-from-foreign do not return structs,
;; but pointers to structs.
;;; mouse.lisp
;; typedef unsigned long mmask_t;
;;
;; typedef struct {
;; short id; /* ID to distinguish multiple devices */
;; int x, y, z; /* event coordinates */
;; mmask_t bstate; /* button state bits */
;; } MEVENT;
;; TODO: ABI6: --with-mmask_t=uint32_t
;;(defctype mmask_t :unsigned-int)
(defctype mmask_t :uint32)
(defcstruct mevent
"C struct containing mouse coordinates and button state."
(id :short)
(x :int)
(y :int)
(z :int)
(bstate mmask_t))
;;; ------------------------------------------------------------------
;;; Constants
;; #defines taken from ncurses.h, should not be user visible.
;; wherever cffi defines a boolean, we can use t and nil instead of TRUE and FALSE.
;;(defconstant TRUE 1)
;;(defconstant FALSE 0)
;;(defconstant ERROR -1)
;;(defconstant OK 0)

View file

@ -0,0 +1,40 @@
(in-package :de.anvi.ncurses)
;;; opaque
;;; curses window properties
;;; http://invisible-island.net/ncurses/man/curs_opaque.3x.html
;;; C prototypes
;; bool is_cleared(const WINDOW *win);
;; bool is_idcok(const WINDOW *win);
;; bool is_idlok(const WINDOW *win);
;; bool is_immedok(const WINDOW *win);
;; bool is_keypad(const WINDOW *win);
;; bool is_leaveok(const WINDOW *win);
;; bool is_nodelay(const WINDOW *win);
;; bool is_notimeout(const WINDOW *win);
;; bool is_pad(const WINDOW *win);
;; bool is_scrollok(const WINDOW *win);
;; bool is_subwin(const WINDOW *win);
;; bool is_syncok(const WINDOW *win);
;; WINDOW *wgetparent(const WINDOW *win);
;; int wgetscrreg(const WINDOW *win, int *top, int *bottom);
;;; Low-level CFFI wrappers
(defcfun ("is_cleared" %is-cleared) :boolean (win window))
(defcfun ("is_idcok" %is-idcok) :boolean (win window))
(defcfun ("is_idlok" %is-idlok) :boolean (win window))
(defcfun ("is_immedok" %is-immedok) :boolean (win window))
(defcfun ("is_keypad" %is-keypad) :boolean (win window))
(defcfun ("is_leaveok" %is-leaveok) :boolean (win window))
(defcfun ("is_nodelay" %is-nodelay) :boolean (win window))
(defcfun ("is_notimeout" %is-notimeout) :boolean (win window))
(defcfun ("is_pad" %is-pad) :boolean (win window))
(defcfun ("is_scrollok" %is-scrollok) :boolean (win window))
(defcfun ("is_subwin" %is-subwin) :boolean (win window))
(defcfun ("is_syncok" %is-syncok) :boolean (win window))
(defcfun ("wgetparent" %wgetparent) window (win window))
(defcfun ("wgetscrreg" %wgetscrreg) :int (win window) (top (:pointer :int)) (bottom (:pointer :int)))

View file

@ -0,0 +1,35 @@
(in-package :de.anvi.ncurses)
;;; outopts
;;; curses output options
;;; http://invisible-island.net/ncurses/man/curs_outopts.3x.html
;;; C prototypes
;; int clearok(WINDOW *win, bool bf);
;; int idlok(WINDOW *win, bool bf);
;; void idcok(WINDOW *win, bool bf);
;; void immedok(WINDOW *win, bool bf);
;; int leaveok(WINDOW *win, bool bf);
;; int scrollok(WINDOW *win, bool bf);
;; int setscrreg(int top, int bot);
;; int wsetscrreg(WINDOW *win, int top, int bot);
;; int nl(void);
;; int nonl(void);
;;; Low-level CFFI wrappers
(defcfun ("clearok" %clearok) :int (win window) (bf :boolean))
(defcfun ("idlok" %idlok) :int (win window) (bf :boolean))
(defcfun ("idcok" %idcok) :void (win window) (bf :boolean))
(defcfun ("immedok" %immedok) :void (win window) (bf :boolean))
(defcfun ("leaveok" %leaveok) :int (win window) (bf :boolean))
(defcfun ("scrollok" %scrollok) :int (win window) (bf :boolean))
(defcfun ("setscrreg" %setscrreg) :int (top :int) (bot :int))
(defcfun ("wsetscrreg" %wsetscrreg) :int (win window) (top :int) (bot :int))
(defcfun ("nl" %nl) :void)
(defcfun ("nonl" %nonl) :void)

View file

@ -0,0 +1,467 @@
(defpackage #:de.anvi.ncurses
(:documentation "Low-level CFFI bindings to the Ncurses C API. Not meant to be used directly.")
(:use #:common-lisp #:cffi)
(:export
;; addch / add a character (with attributes) to a curses window, then advance the cursor
%addch
%waddch
%mvaddch
%mvwaddch
%echochar
%wechochar
;; add_wch / add a complex character and rendition to a curses window, then advance the cursor
%add-wch
%wadd-wch
%mvadd-wch
%mvwadd-wch
%echo-wchar
%wecho-wchar
;; addstr / add a string of characters to a curses window and advance cursor
%addstr
%addnstr
%waddstr
%waddnstr
%mvaddstr
%mvaddnstr
%mvwaddstr
%mvwaddnstr
;; attr / curses character and window attribute control routines
%attroff
%wattroff
%attron
%wattron
%attrset
%wattrset
%color-set
%wcolor-set
%standend
%wstandend
%standout
%wstandout
%attr-get
%wattr-get
%attr-off
%wattr-off
%attr-on
%wattr-on
%attr-set
%wattr-set
%chgat
%wchgat
%mvchgat
%mvwchgat
;; beep / curses bell and screen flash routines
%beep
%flash
;; bkgd / curses window background manipulation routines
%bkgdset
%wbkgdset
%bkgd
%wbkgd
%getbkgd
;; bkgrnd / window complex background manipulation routines
%bkgrnd
%wbkgrnd
%bkgrndset
%wbkgrndset
%getbkgrnd
%wgetbkgrnd
;; border / create curses borders, horizontal and vertical lines
%border
%wborder
%box
%hline
%whline
%vline
%wvline
%mvhline
%mvwhline
%mvvline
%mvwvline
;; border_set / create curses borders or lines using complex characters and renditions
%border-set
%wborder-set
%box-set
%hline-set
%whline-set
%mvhline-set
%mvwhline-set
%vline-set
%wvline-set
%mvvline-set
%mvwvline-set
;; clear / clear all or part of a curses window
%erase
%werase
%clear
%wclear
%clrtobot
%wclrtobot
%clrtoeol
%wclrtoeol
;; color / curses color manipulation routines
%start-color
%has-colors
%can-change-color
%init-pair
%init-color
%pair-content
%color-content
%init-extended-pair
%init-extended-color
%pair-extended-content
%color-extended-content
%color-pair
%pair-number
%COLOR-BLACK
%COLOR-RED
%COLOR-GREEN
%COLOR-YELLOW
%COLOR-BLUE
%COLOR-MAGENTA
%COLOR-CYAN
%COLOR-WHITE
;; default_colors / use terminal's default colors
%use-default-colors
%assume-default-colors
;; define_key / define a keycode
%define-key
;; delch / delete character under the cursor in a curses window
%delch
%wdelch
%mvdelch
%mvwdelch
;; deleteln / delete and insert lines in a curses window
%deleteln
%wdeleteln
%insdelln
%winsdelln
%insertln
%winsertln
;; extend / miscellaneous curses extensions
%curses-version
%use-extended-names
;; getcchar / Get a wide character string and rendition from a cchar_t or set a cchar_t from a wide-character string
%getcchar
%setcchar
;; getch / get (or push back) characters from curses terminal keyboard
%getch
%wgetch
%mvgetch
%mvwgetch
%ungetch
%has-key
;; get_wch / get (or push back) a wide (multi-byte) character from curses terminal keyboard
%get-wch
%wget-wch
%mvget-wch
%mvwget-wch
%unget-wch
wint_t
;; getstr / accept character strings from curses terminal keyboard
%getstr
%getnstr
%wgetstr
%wgetnstr
%mvgetstr
%mvgetnstr
%mvwgetstr
%mvwgetnstr
;; getyx / get curses cursor and window coordinates
;; --> legacy
;; inch / get a character and attributes from a curses window
%inch
%winch
%mvinch
%mvwinch
;; in_wch / extract a wide character and rendition from a window
%in-wch
%mvin-wch
%win-wch
%mvwin-wch
;; inchstr / get a string of characters (and attributes) from a curses window
%inchstr
%inchnstr
%winchstr
%winchnstr
%mvinchstr
%mvinchnstr
%mvwinchstr
%mvwinchnstr
;; initscr / Screen initialization and manipulation routines
%initscr
%endwin
%isendwin
%newterm
%set-term
%delscreen
;; inopts / Input options.
%cbreak
%nocbreak
%echo
%noecho
%halfdelay
%intrflush
%keypad
%meta
%nodelay
%raw
%noraw
%noqiflush
%qiflush
%notimeout
%timeout
%wtimeout
%typeahead
;; insch / insert a character before cursor in a curses window
%insch
%winsch
%mvinsch
%mvwinsch
;; ins_wch / insert a complex character and rendition into a window
%ins-wch
%wins-wch
%mvins-wch
%mvwins-wch
;; insstr / insert string before cursor in a curses window
%insstr
%insnstr
%winsstr
%winsnstr
%mvinsstr
%mvinsnstr
%mvwinsstr
%mvwinsnstr
;; instr / get a string of characters from a curses window
%instr
%innstr
%winstr
%winnstr
%mvinstr
%mvinnstr
%mvwinstr
%mvwinnstr
;; inwstr / extract a string of wchar_t characters from a curses window
%inwstr
%innwstr
%winwstr
%winnwstr
%mvinwstr
%mvinnwstr
%mvwinwstr
%mvwinnwstr
;; kernel / low-level curses routines
%def-prog-mode
%def-shell-mode
%reset-prog-mode
%reset-shell-mode
%resetty
%savetty
%getsyx
%setsyx
%ripoffline
%curs-set
%napms
;; keybound / return definition of keycode
%keybound
;; key_defined / check if a keycode is defined
%key-defined
;; legacy / get curses cursor and window coordinates, attributes
%getbegx
%getbegy
%getcurx
%getcury
%getmaxx
%getmaxy
%getparx
%getpary
;; legacy_coding
%use-legacy-coding
;; mouse interface through curses
%getmouse
%mousemask
;; move / move curses window cursor
%move
%wmove
;; ncurses / CRT screen handling and optimization package
chtype
wchar_t
wint_t
attr_t
cchar
cchar_t
ptr-cchar_t
cchar-attr
cchar-chars
cchar-colors
mmask_t
mevent
%ERROR
%OK
;; opaque / curses window properties
%is-cleared
%is-idcok
%is-idlok
%is-immedok
%is-keypad
%is-leaveok
%is-nodelay
%is-notimeout
%is-pad
%is-scrollok
%is-subwin
%is-syncok
%wgetparent
%wgetscrreg
;; outopts / curses output options
%clearok
%idlok
%idcok
%immedok
%leaveok
%scrollok
%setscrreg
%wsetscrreg
%nl
%nonl
;; pad / create and display curses pads
%newpad
%subpad
%prefresh
%pnoutrefresh
%pechochar
%pecho-wchar
;; refresh / refresh curses windows and lines
%refresh
%wrefresh
%wnoutrefresh
%doupdate
%redrawwin
%wredrawln
;; resizeterm / change the curses terminal size
%is-term-resized
%resize-term
%resizeterm
;; scroll / scroll a curses window
%scroll
%scrl
%wscrl
;; slk / curses soft label routines
%slk-init
%slk-set
%slk-refresh
%slk-noutrefresh
%slk-label
%slk-clear
%slk-restore
%slk-touch
%slk-attron
%slk-attroff
%slk-attrset
%slk-attr-on
%slk-attr-off
%slk-attr-set
%slk-attr
%slk-color
;; termattrs / environment query routines
%baudrate
%erasechar
%has-ic
%has-il
%killchar
%longname
%term-attrs
%termattrs
%termname
;; touch / curses refresh control routines
%touchwin
%touchline
%untouchwin
%wtouchln
%is-linetouched
%is-wintouched
;; util / miscellaneous curses utility routines
%unctrl
%keyname
%filter
%nofilter
%use-env
%putwin
%getwin
%delay-output
%flushinp
;; variables / curses global variables
%COLOR-PAIRS
%COLORS
%COLS
%ESCDELAY
%LINES
%TABSIZE
;; window / create curses windows
%newwin
%delwin
%mvwin
%subwin
%derwin
%mvderwin
%dupwin
%wsyncup
%syncok
%wcursyncup
%wsyncdown
;; wresize / resize a curses window
%wresize
))

View file

@ -0,0 +1,45 @@
(in-package :de.anvi.ncurses)
;;; pad
;;; create and display curses pads
;;; http://invisible-island.net/ncurses/man/curs_pad.3x.html
;;; http://pic.dhe.ibm.com/infocenter/aix/v7r1/topic/com.ibm.aix.basetechref/doc/basetrf2/newpad.htm
;;; http://www.gnu.org/software/guile-ncurses/manual/html_node/Create-and-display-pads.html
;;; C prototypes
;; WINDOW *newpad(int nlines, int ncols);
;; WINDOW *subpad(WINDOW *orig, int nlines, int ncols, int begin_y, int begin_x);
;; int prefresh(WINDOW *pad, int pminrow, int pmincol, int sminrow, int smincol, int smaxrow, int smaxcol);
;; int pnoutrefresh(WINDOW *pad, int pminrow, int pmincol, int sminrow, int smincol, int smaxrow, int smaxcol);
;; int pechochar(WINDOW *pad, chtype ch);
;; int pecho_wchar(WINDOW *pad, const cchar_t *wch);
;;; Low-level CFFI wrappers
(defcfun ("newpad" %newpad) window (nlines :int) (ncols :int))
(defcfun ("subpad" %subpad) window (orig window) (nlines :int) (ncols :int) (begin_y :int) (begin_x :int))
(defcfun ("prefresh" %prefresh) :int
(pad window)
(pminrow :int)
(pmincol :int)
(sminrow :int)
(smincol :int)
(smaxrow :int)
(smaxcol :int))
(defcfun ("pnoutrefresh" %pnoutrefresh) :int
(pad window)
(pminrow :int)
(pmincol :int)
(sminrow :int)
(smincol :int)
(smaxrow :int)
(smaxcol :int))
(defcfun ("pechochar" %pechochar) :int (pad window) (ch chtype))
(defcfun ("pecho_wchar" %pecho-wchar) :int (pad window) (wch (:pointer (:struct cchar_t))))

View file

@ -0,0 +1,23 @@
(in-package :de.anvi.ncurses)
;;; refresh
;;; refresh curses windows and lines
;;; http://www.manpagez.com/man/3/curs_refresh/
;;; C prototypes
;; int refresh(void);
;; int wrefresh(WINDOW *win);
;; int wnoutrefresh(WINDOW *win);
;; int doupdate(void);
;; int redrawwin(WINDOW *win);
;; int wredrawln(WINDOW *win, int beg_line, int num_lines);
;;; Low-level CFFI wrappers
(defcfun ("refresh" %refresh) :int)
(defcfun ("wrefresh" %wrefresh) :int (win window))
(defcfun ("wnoutrefresh" %wnoutrefresh) :int (win window))
(defcfun ("doupdate" %doupdate) :int)
(defcfun ("redrawwin" %redrawwin) :int (win window))
(defcfun ("wredrawln" %wredrawln) :int (win window) (beg-line :int) (num-lines :int))

View file

@ -0,0 +1,17 @@
(in-package :de.anvi.ncurses)
;;; resizeterm
;;; change the curses terminal size
;;; http://invisible-island.net/ncurses/man/resizeterm.3x.html
;;; C prototypes
;; bool is_term_resized(int lines, int columns);
;; int resize_term(int lines, int columns);
;; int resizeterm(int lines, int columns);
;;; Low-level CFFI wrappers
(defcfun ("is_term_resized" %is-term-resized) :boolean (lines :int) (columns :int))
(defcfun ("resize_term" %resize-term) :int (lines :int) (columns :int))
(defcfun ("resizeterm" %resizeterm) :int (lines :int) (columns :int))

View file

@ -0,0 +1,17 @@
(in-package :de.anvi.ncurses)
;;; scroll
;;; scroll a curses window
;;; http://invisible-island.net/ncurses/man/curs_scroll.3x.html
;;; C prototypes
;; int scroll(WINDOW *win);
;; int scrl(int n);
;; int wscrl(WINDOW *win, int n);
;;; Low-level CFFI wrappers
(defcfun ("scroll" %scroll) :int (win window))
(defcfun ("scrl" %scrl) :int (n :int))
(defcfun ("wscrl" %wscrl) :int (win window) (n :int))

View file

@ -0,0 +1,47 @@
(in-package :de.anvi.ncurses)
;;; slk
;;; curses soft label routines
;;; http://invisible-island.net/ncurses/man/curs_slk.3x.html
;;; C prototypes
;; int slk_init(int fmt);
;; int slk_set(int labnum, const char *label, int fmt);
;; int slk_refresh(void);
;; int slk_noutrefresh(void);
;; char *slk_label(int labnum);
;; int slk_clear(void);
;; int slk_restore(void);
;; int slk_touch(void);
;; int slk_attron(const chtype attrs);
;; int slk_attroff(const chtype attrs);
;; int slk_attrset(const chtype attrs);
;; int slk_attr_on(attr_t attrs, void *opts);
;; int slk_attr_off(const attr_t attrs, void *opts);
;; int slk_attr_set(const attr_t attrs, short color_pair, void *opts);
;; attr_t slk_attr(void);
;; int slk_color(short color_pair);
;; int slk_wset(int labnum, const wchar_t *label, int fmt);
;;; Low-level CFFI wrappers
(defcfun ("slk_init" %slk-init) :int (fmt :int))
(defcfun ("slk_set" %slk-set) :int (labnum :int) (label :string) (fmt :int))
(defcfun ("slk_refresh" %slk-refresh) :int)
(defcfun ("slk_noutrefresh" %slk-noutrefresh) :int)
(defcfun ("slk_label" %slk-label) :string (labnum :int))
(defcfun ("slk_clear" %slk-clear) :int)
(defcfun ("slk_restore" %slk-restore) :int)
(defcfun ("slk_touch" %slk-touch) :int)
(defcfun ("slk_attron" %slk-attron) :int (attrs chtype))
(defcfun ("slk_attroff" %slk-attroff) :int (attrs chtype))
(defcfun ("slk_attrset" %slk-attrset) :int (attrs chtype))
(defcfun ("slk_attr_on" %slk-attr-on) :int (attrs attr) (opts (:pointer :void)))
(defcfun ("slk_attr_off" %slk-attr-off) :int (attrs attr) (opts (:pointer :void)))
(defcfun ("slk_attr_set" %slk-attr-set) :int (attrs attr) (color-pair :short) (opts (:pointer :void)))
(defcfun ("slk_attr" %slk-attr) attr)
(defcfun ("slk_color" %slk-color) :int (color-pair :short))

View file

@ -0,0 +1,31 @@
(in-package :de.anvi.ncurses)
;;; termattrs
;;; environment query routines
;;; http://invisible-island.net/ncurses/man/curs_termattrs.3x.html
;;; C prototypes
;; int baudrate(void);
;; char erasechar(void);
;; int erasewchar(wchar_t *ch);
;; bool has_ic(void);
;; bool has_il(void);
;; char killchar(void);
;; int killwchar(wchar_t *ch);
;; char *longname(void);
;; attr_t term_attrs(void);
;; chtype termattrs(void);
;; char *termname(void);
;;; Low-level CFFI wrappers
(defcfun ("baudrate" %baudrate) :int)
(defcfun ("erasechar" %erasechar) :char)
(defcfun ("has_ic" %has-ic) :boolean)
(defcfun ("has_il" %has-il) :boolean)
(defcfun ("killchar" %killchar) :char)
(defcfun ("longname" %longname) :string)
(defcfun ("term_attrs" %term-attrs) attr)
(defcfun ("termattrs" %termattrs) chtype)
(defcfun ("termname" %termname) :string)

View file

@ -0,0 +1,25 @@
(in-package :de.anvi.ncurses)
;;; touch
;;; curses refresh control routines
;;; http://invisible-island.net/ncurses/man/curs_touch.3x.html
;;; http://www-01.ibm.com/support/knowledgecenter/ssw_aix_61/com.ibm.aix.basetrf2/touchwin.htm
;;; C prototypes
;; int touchwin(WINDOW *win);
;; int touchline(WINDOW *win, int start, int count);
;; int untouchwin(WINDOW *win);
;; int wtouchln(WINDOW *win, int y, int n, int changed);
;; bool is_linetouched(WINDOW *win, int line);
;; bool is_wintouched(WINDOW *win);
;;; Low-level CFFI wrappers
(defcfun ("touchwin" %touchwin) :int (win window))
(defcfun ("touchline" %touchline) :int (win window) (start :int) (count :int))
(defcfun ("untouchwin" %untouchwin) :int (win window))
(defcfun ("wtouchln" %wtouchln) :int (win window) (y :int) (n :int) (changed :int))
(defcfun ("is_linetouched" %is-linetouched) :boolean (win window) (line :int))
(defcfun ("is_wintouched" %is-wintouched) :boolean (win window))

View file

@ -0,0 +1,33 @@
(in-package :de.anvi.ncurses)
;;; util
;;; miscellaneous curses utility routines
;;; http://invisible-island.net/ncurses/man/curs_util.3x.html
;;; C prototypes
;; char *unctrl(chtype c);
;; wchar_t *wunctrl(cchar_t *c);
;; char *keyname(int c);
;; char *key_name(wchar_t w);
;; void filter(void);
;; void nofilter(void);
;; void use_env(bool f);
;; int putwin(WINDOW *win, FILE *filep);
;; WINDOW *getwin(FILE *filep);
;; int delay_output(int ms);
;; int flushinp(void);
;;; Low-level CFFI wrappers
(defcfun ("unctrl" %unctrl) :string (c chtype))
(defcfun ("wunctrl" %wunctrl) :string (c (:pointer (:struct cchar_t))))
(defcfun ("keyname" %keyname) :string (c :int))
(defcfun ("key_name" %key_name) :string (w wchar_t))
(defcfun ("filter" %filter) :void)
(defcfun ("nofilter" %nofilter) :void)
(defcfun ("use_env" %use-env) :void (f :boolean))
(defcfun ("putwin" %putwin) :int (win window) (filep :pointer))
(defcfun ("getwin" %getwin) window (filep :pointer))
(defcfun ("delay_output" %delay-output) :int (ms :int))
(defcfun ("flushinp" %flushinp) :int)

View file

@ -0,0 +1,27 @@
(in-package :de.anvi.ncurses)
;;; variables
;;; curses global variables
;;; http://invisible-island.net/ncurses/man/curs_variables.3x.html
;;; http://h71000.www7.hp.com/doc/83final/5763/5763pro_016.html
;;; Low-level C global variables
;; int COLOR_PAIRS;
;; int COLORS;
;; int COLS;
;; int ESCDELAY;
;; int LINES;
;; int TABSIZE;
;; WINDOW * curscr;
;; WINDOW * newscr;
;; WINDOW * stdscr;
;;; Lisp read-only global constants.
(defcvar ("COLOR_PAIRS" %COLOR-PAIRS :read-only t) :int)
(defcvar ("COLORS" %COLORS :read-only t) :int)
(defcvar ("COLS" %COLS :read-only t) :int)
(defcvar ("ESCDELAY" %ESCDELAY :read-only t) :int)
(defcvar ("LINES" %LINES :read-only t) :int)
(defcvar ("TABSIZE" %TABSIZE :read-only t) :int)

View file

@ -0,0 +1,36 @@
(in-package :de.anvi.ncurses)
;;; window
;;; create curses windows
;;; http://invisible-island.net/ncurses/man/curs_window.3x.html
;;; http://www.manpagez.com/man/3/newwin/
;;; C prototypes
;; WINDOW *newwin(int nlines, int ncols, int begin_y, int begin_x);
;; int delwin(WINDOW *win);
;; int mvwin(WINDOW *win, int y, int x);
;; WINDOW *subwin(WINDOW *orig, int nlines, int ncols, int begin_y, int begin_x);
;; WINDOW *derwin(WINDOW *orig, int nlines, int ncols, int begin_y, int begin_x);
;; int mvderwin(WINDOW *win, int par_y, int par_x);
;; WINDOW *dupwin(WINDOW *win);
;; void wsyncup(WINDOW *win);
;; int syncok(WINDOW *win, bool bf);
;; void wcursyncup(WINDOW *win);
;; void wsyncdown(WINDOW *win);
;;; Low-level CFFI wrappers
(defcfun ("newwin" %newwin) window (nlines :int) (ncols :int) (begin_y :int) (begin_x :int))
(defcfun ("delwin" %delwin) :int (win window))
(defcfun ("mvwin" %mvwin) :int (win window) (y :int) (x :int))
(defcfun ("subwin" %subwin) window (orig window) (nlines :int) (ncols :int) (begin_y :int) (begin_x :int))
(defcfun ("derwin" %derwin) window (orig window) (nlines :int) (ncols :int) (begin_y :int) (begin_x :int))
(defcfun ("mvderwin" %mvderwin) :int (win window) (par_y :int) (par_x :int))
(defcfun ("dupwin" %dupwin) window (win window))
(defcfun ("wsyncup" %wsyncup) :void (win window))
(defcfun ("syncok" %syncok) :int (win window) (bf :boolean))
(defcfun ("wcursyncup" %wcursyncup) :void (win window))
(defcfun ("wsyncdown" %wsyncdown) :void (win window))

View file

@ -0,0 +1,13 @@
(in-package :de.anvi.ncurses)
;;; wresize
;;; resize a curses window
;;; http://invisible-island.net/ncurses/man/wresize.3x.html
;;; C prototypes
;; int wresize(WINDOW *win, int lines, int columns);
;;; Low-level CFFI wrappers
(defcfun ("wresize" %wresize) :int (win window) (lines :int) (columns :int))