add curses bindings, patch by Ed Schouten
authorJuerg Billeter <j@bitron.ch>
Mon, 27 Aug 2007 14:53:16 +0000 (14:53 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Mon, 27 Aug 2007 14:53:16 +0000 (14:53 +0000)
2007-08-27  Juerg Billeter  <j@bitron.ch>

* vapi/Makefile.am, vapi/curses.vala: add curses bindings,
  patch by Ed Schouten

svn path=/trunk/; revision=505

ChangeLog
vapi/Makefile.am
vapi/curses.vala [new file with mode: 0644]

index 2d44420..46c4a06 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2007-08-27  Jürg Billeter  <j@bitron.ch>
 
+       * vapi/Makefile.am, vapi/curses.vala: add curses bindings,
+         patch by Ed Schouten
+
+2007-08-27  Jürg Billeter  <j@bitron.ch>
+
        * gobject/valaclassregisterfunction.vala,
          gobject/valacodegeneratorinterface.vala,
          gobject/valainterfaceregisterfunction.vala,
index 0d16c91..43c073c 100644 (file)
@@ -13,6 +13,7 @@ dist_vapi_DATA = \
        cairo.vala \
        clutter-0.3.vala \
        clutter-0.3.deps \
+       curses.vala \
        dbus-glib-1.vala \
        enchant.vala \
        glib-2.0.vala \
diff --git a/vapi/curses.vala b/vapi/curses.vala
new file mode 100644 (file)
index 0000000..7712d59
--- /dev/null
@@ -0,0 +1,453 @@
+/* curses.vala
+ *
+ * Copyright (c) 2007 Ed Schouten <ed@fxq.nl>
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+using GLib;
+
+[CCode (lower_case_cprefix = "", cheader_filename = "curses.h")]
+namespace Curses {
+       public const int COLORS;
+       public const int COLOR_PAIRS;
+
+       public enum Color {
+               BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE
+       }
+
+       public enum Acs {
+               ULCORNER, LLCORNER, URCORNER, LRCORNER, LTEE, RTEE,
+               BTEE, TTEE, HLINE, VLINE, PLUS, S1, S9, DIAMOND,
+               CKBOARD, DEGREE, PLMINUS, BULLET, LARROW, RARROW,
+               DARROW, UARROW, BOARD, LANTERN, BLOCK, S3, S7, LEQUAL,
+               GEQUAL, PI, NEQUAL, STERLING, BSSB, SSBB, BBSS, SBBS,
+               SBSS, SSSB, SSBS, BSSS, BSBS, SBSB, SSSS
+       }
+
+       public const Window stdscr;
+       public const Window curscr;
+       public const Window newscr;
+
+       public const int LINES;
+       public const int COLS;
+       public const int TABSIZE;
+
+       public const int ESCDELAY;
+
+       [ReferenceType (free_function = "delwin", dup_function = "dupwin")]
+       [CCode (cname = "WINDOW", cprefix = "")]
+       public struct Window {
+               public int box(ulong verch, ulong horch);
+               public int clearok(bool bf);
+               public int copywin(Window dstwin, int sminrow, int smincol, int dminrow, int dmincol, int dmaxrow, int dmaxcol, int overlay);
+               public int delwin();
+               public Window derwin(int nlines, int ncols, int begin_y, int begin_x);
+               public Window dupwin();
+               public ulong getbkgd();
+               public static Window getwin(FileStream filep);
+               public void idcok(bool bf);
+               public int idlok(bool bf);
+               public void immedok(bool bf);
+               public int intrflush(bool bf);
+               public bool is_linetouched(int line);
+               public bool is_wintouched();
+               public int keypad(bool bf);
+               public int leaveok(bool bf);
+               public int meta(bool bf);
+               public int mvderwin(int par_y, int par_x);
+               [CCode (cname = "mvwaddch")]
+               public int mvaddch(int y, int x, ulong ch);
+               [CCode (cname = "mvwaddchnstr")]
+               [NoArrayLength]
+               public int mvaddchnstr(int y, int x, ulong[] chstr, int n);
+               [CCode (cname = "mvwaddchstr")]
+               [NoArrayLength]
+               public int mvaddchstr(int y, int x, ulong[] chstr);
+               [CCode (cname = "mvwaddnstr")]
+               public int mvaddnstr(int y, int x, string str, int n);
+               [CCode (cname = "mvwaddstr")]
+               public int mvaddstr(int y, int x, string str);
+               [CCode (cname = "mvwchgat")]
+               public int mvchgat(int y, int x, int n, ulong attr, short color);
+               [CCode (cname = "mvwdelch")]
+               public int mvdelch(int y, int x);
+               [CCode (cname = "mvwgetch")]
+               public int mvgetch(int y, int x);
+               [CCode (cname = "mvwgetnstr")]
+               public int mvgetnstr(int y, int x, string str, int n);
+               [CCode (cname = "mvwgetstr")]
+               public int mvgetstr(int y, int x, string str);
+               [CCode (cname = "mvwhline")]
+               public int mvhline(int y, int x, ulong ch, int n);
+               public int mvwin(int y, int x);
+               [CCode (cname = "mvwinch")]
+               public ulong mvinch(int y, int x);
+               [CCode (cname = "mvwinchnstr")]
+               [NoArrayLength]
+               public int mvinchnstr(int y, int x, ulong[] chstr, int n);
+               [CCode (cname = "mvwinchstr")]
+               [NoArrayLength]
+               public int mvinchstr(int y, int x, ulong[] chstr);
+               [CCode (cname = "mvwinnstr")]
+               public int mvinnstr(int y, int x, string str, int n);
+               [CCode (cname = "mvwinsch")]
+               public int mvinsch(int y, int x, ulong ch);
+               [CCode (cname = "mvwinsnstr")]
+               public int mvinsnstr(int y, int x, string str, int n);
+               [CCode (cname = "mvwinsstr")]
+               public int mvinsstr(int y, int x, string str);
+               [CCode (cname = "mvwinstr")]
+               public int mvinstr(int y, int x, string str);
+               [CCode (cname = "mvwprintw")]
+               [PrintfLike]
+               public int mvprintw(int y, int x, string str, ...);
+               [CCode (cname = "mvwscanw")]
+               [PrintfLike]
+               public int mvscanw(int y, int x, string str, ...);
+               [CCode (cname = "mvwvline")]
+               public int mvvline(int y, int x, ulong ch, int n);
+               public static Window newpad(int nlines, int ncols);
+               public static Window newwin(int nlines, int ncols, int begin_y, int begin_x);
+               public int nodelay(bool bf);
+               public int notimeout(bool bf);
+               public int overlay(Window win);
+               public int overwrite(Window win);
+               public int pechochar(ulong ch);
+               public int pnoutrefresh(int pminrow, int pmincol, int sminrow, int smincol, int smaxrow, int smaxcol);
+               public int prefresh(int pminrow, int pmincol, int sminrow, int smincol, int smaxrow, int smaxcol);
+               public int putwin(FileStream filep);
+               public int redrawwin();
+               public int scroll();
+               public int scrollok(bool bf);
+               public Window subpad(int nlines, int ncols, int begin_y, int begin_x);
+               public Window subwin(int nlines, int ncols, int begin_y, int begin_x);
+               public int syncok(bool bf);
+               public int touchline(int start, int count);
+               public int touchwin();
+               public int untouchwin();
+               [CCode (cname = "waddch")]
+               public int addch(ulong ch);
+               [NoArrayLength]
+               public int waddchnstr(ulong[] chstr, int n);
+               [NoArrayLength]
+               public int waddchstr(ulong[] chstr);
+               public int waddnstr(string str, int n);
+               [CCode (cname = "waddstr")]
+               public int addstr(string str);
+               [CCode (cname = "wattron")]
+               public int attron(ulong attrs);
+               [CCode (cname = "wattroff")]
+               public int attroff(ulong attrs);
+               [CCode (cname = "wattrset")]
+               public int attrset(ulong attrs);
+               [CCode (cname = "wattr_get")]
+               public int attr_get(ref ulong attrs, ref ulong pair);
+               [CCode (cname = "wattr_on")]
+               public int attr_on(ulong attrs);
+               [CCode (cname = "wattr_off")]
+               public int attr_off(ulong attrs);
+               [CCode (cname = "wattr_set")]
+               public int attr_set(ulong attrs, short pair);
+               [CCode (cname = "wbkgd")]
+               public int bkgd(ulong ch);
+               [CCode (cname = "wbkgdset")]
+               public void bkgdset(ulong ch);
+               [CCode (cname = "wborder")]
+               public int border(ulong ls, ulong rs, ulong ts, ulong bs, ulong tl, ulong tr, ulong bl, ulong br);
+               [CCode (cname = "wchgat")]
+               public int chgat(int n, ulong attr, short color);
+               [CCode (cname = "wclear")]
+               public int clear();
+               [CCode (cname = "wclrtobot")]
+               public int clrtobot();
+               [CCode (cname = "wclrtoeol")]
+               public int clrtoeol();
+               [CCode (cname = "wcolor_set")]
+               public int color_set(short color_pair_number);
+               [CCode (cname = "wcursyncup")]
+               public void cursyncup();
+               [CCode (cname = "wdelch")]
+               public int delch();
+               [CCode (cname = "wdeleteln")]
+               public int deleteln();
+               [CCode (cname = "wechochar")]
+               public int echochar(ulong ch);
+               [CCode (cname = "werase")]
+               public int erase();
+               [CCode (cname = "wgetch")]
+               public int getch();
+               [CCode (cname = "wgetnstr")]
+               public int getnstr(string str, int n);
+               [CCode (cname = "wgetstr")]
+               public int getstr(string str);
+               [CCode (cname = "whline")]
+               public int hline(ulong ch, int n);
+               [CCode (cname = "winch")]
+               public ulong inch();
+               [CCode (cname = "winchnstr")]
+               [NoArrayLength]
+               public int inchnstr(ulong[] chstr, int n);
+               [CCode (cname = "winchstr")]
+               [NoArrayLength]
+               public int inchstr(ulong[] chstr);
+               [CCode (cname = "winnstr")]
+               public int innstr(string str, int n);
+               [CCode (cname = "winsch")]
+               public int insch(ulong ch);
+               [CCode (cname = "winsdelln")]
+               public int insdelln(int n);
+               [CCode (cname = "winsertln")]
+               public int insertln();
+               [CCode (cname = "winsnstr")]
+               public int insnstr(string str, int n);
+               [CCode (cname = "winsstr")]
+               public int insstr(string str);
+               [CCode (cname = "winstr")]
+               public int instr(string str);
+               [CCode (cname = "wmove")]
+               public int move(int y, int x);
+               [CCode (cname = "wnoutrefresh")]
+               public int noutrefresh();
+               [CCode (cname = "wprintw")]
+               [PrintfLike]
+               public int printw(string str, ...);
+               [CCode (cname = "wredrawln")]
+               public int redrawln(int beg_line, int num_lines);
+               [CCode (cname = "wrefresh")]
+               public int refresh();
+               [CCode (cname = "wscanw")]
+               [PrintfLike]
+               public int scanw(string str, ...);
+               [CCode (cname = "wscrl")]
+               public int scrl(int n);
+               [CCode (cname = "wsetscrreg")]
+               public int setscrreg(int top, int bot);
+               [CCode (cname = "wstandout")]
+               public int standout();
+               [CCode (cname = "wstandend")]
+               public int standend();
+               [CCode (cname = "wsyncdown")]
+               public void syncdown();
+               [CCode (cname = "wsyncup")]
+               public void syncup();
+               [CCode (cname = "wtimeout")]
+               public void timeout(int delay);
+               [CCode (cname = "wtouchln")]
+               public int touchln(int y, int n, int changed);
+               [CCode (cname = "wvline")]
+               public int vline(ulong ch, int n);
+       }
+
+       [ReferenceType (free_function = "delscreen")]
+       [CCode (cname = "SCREEN", cprefix = "")]
+       public struct Screen {
+               public void delscreen();
+               public static Screen newterm(string str, FileStream outfd, FileStream infd);
+               public weak Screen set_term();
+       }
+
+       public int addch(ulong ch);
+       [NoArrayLength]
+       public int addchnstr(ulong[] chstr, int n);
+       [NoArrayLength]
+       public int addchstr(ulong[] chstr);
+       public int addnstr(string str, int n);
+       public int addstr(string str);
+       public int attroff(ulong attr);
+       public int attron(ulong attr);
+       public int attrset(ulong attr);
+       public int attr_get(ref ulong attrs, ref short pair);
+       public int attr_off(ulong attrs);
+       public int attr_on(ulong attrs);
+       public int attr_set(ulong attrs, short pair);
+       public int baudrate();
+       public int beep();
+       public int bkgd(ulong ch);
+       public void bkgdset(ulong ch);
+       public int border(ulong ls, ulong rs, ulong ts, ulong bs, ulong tl, ulong tr, ulong bl, ulong br);
+       public bool can_change_color();
+       public int cbreak();
+       public int chgat(int n, ulong attr, short color);
+       public int clear();
+       public int clrtobot();
+       public int clrtoeol();
+       public int color_content(short color, ref short r, ref short g, ref short b);
+       public int color_set(short color_pair_number);
+       public int COLOR_PAIR(int n);
+       public int curs_set(int visibility);
+       public int def_prog_mode();
+       public int def_shell_mode();
+       public int delay_output(int ms);
+       public int delch();
+       public int deleteln();
+       public int doupdate();
+       public int echo();
+       public int echochar(ulong ch);
+       public int erase();
+       public int endwin();
+       public char erasechar();
+       public void filter();
+       public int flash();
+       public int flushinp();
+       public int getch();
+       public int getnstr(string str, int n);
+       public int getstr(string str);
+       public int halfdelay(int tenths);
+       public bool has_colors();
+       public bool has_ic();
+       public bool has_il();
+       public int hline(ulong ch, int n);
+       public ulong inch();
+       [NoArrayLength]
+       public int inchnstr(ulong[] chstr, int n);
+       [NoArrayLength]
+       public int inchstr(ulong[] chstr);
+       public weak Window initscr();
+       public int init_color(short color, short r, short g, short b);
+       public int init_pair(short pair, Color f, Color b);
+       public int innstr(string str, int n);
+       public int insch(ulong ch);
+       public int insdelln(int n);
+       public int insertln();
+       public int insnstr(string str, int n);
+       public int insstr(string str);
+       public int instr(string str);
+       public bool isendwin();
+       public string keyname(int c);
+       public char killchar();
+       public string ulongname();
+       public int move(int y, int x);
+       public int mvaddch(int y, int x, ulong ch);
+       [NoArrayLength]
+       public int mvaddchnstr(int y, int x, ulong[] chstr, int n);
+       [NoArrayLength]
+       public int mvaddchstr(int y, int x, ulong[] chstr);
+       public int mvaddnstr(int y, int x, string str, int n);
+       public int mvaddstr(int y, int x, string str);
+       public int mvchgat(int y, int x, int n, ulong attr, short color);
+       public int mvcur(int oldrow, int oldcol, int newrow, int newcol);
+       public int mvdelch(int y, int x);
+       public int mvgetch(int y, int x);
+       public int mvgetnstr(int y, int x, string str, int n);
+       public int mvgetstr(int y, int x, string str);
+       public int mvhline(int y, int x, ulong ch, int n);
+       public ulong mvinch(int y, int x);
+       [NoArrayLength]
+       public int mvinchnstr(int y, int x, ulong[] chstr, int n);
+       [NoArrayLength]
+       public int mvinchstr(int y, int x, ulong[] chstr);
+       public int mvinnstr(int y, int x, string str, int n);
+       public int mvinsch(int y, int x, ulong ch);
+       public int mvinsnstr(int y, int x, string str, int n);
+       public int mvinsstr(int y, int x, string str);
+       public int mvinstr(int y, int x, string str);
+       [PrintfLike]
+       public int mvprintw(int y, int x, string str, ...);
+       [PrintfLike]
+       public int mvscanw(int y, int x, string str, ...);
+       public int mvvline(int y, int x, ulong ch, int n);
+       public int napms(int ms);
+       public int nl();
+       public int nocbreak();
+       public int noecho();
+       public int nonl();
+       public void noqiflush();
+       public int noraw();
+       public int pair_content(short pair, ref Color f, ref Color b);
+       public int PAIR_NUMBER(int attrs);
+       [PrintfLike]
+       public int printw(string str, ...);
+       public void qiflush();
+       public int raw();
+       public int refresh();
+       public int resetty();
+       public int reset_prog_mode();
+       public int reset_shell_mode();
+       public delegate int RipofflineInitFunc(Window win, int n);
+       public int ripoffline(int line, RipofflineInitFunc init);
+       public int savetty();
+       [PrintfLike]
+       public int scanw(string str, ...);
+       public int scr_dump(string str);
+       public int scr_init(string str);
+       public int scrl(int n);
+       public int scr_restore(string str);
+       public int scr_set(string str);
+       public int setscrreg(int top, int bot);
+       public int slk_attroff(ulong attrs);
+       public int slk_attr_off(ulong attrs);
+       public int slk_attron(ulong attrs);
+       public int slk_attr_on(ulong attrs);
+       public int slk_attrset(ulong attrs);
+       public ulong slk_attr();
+       public int slk_attr_set(ulong attrs, short pair);
+       public int slk_clear();
+       public int slk_color(short color_pair_number);
+       public int slk_init(int fmt);
+       public string slk_label(int labnum);
+       public int slk_noutrefresh();
+       public int slk_refresh();
+       public int slk_restore();
+       public int slk_set(int labnum, string label, int fmt);
+       public int slk_touch();
+       public int standout();
+       public int standend();
+       public int start_color();
+       public ulong termattrs();
+       public string termname();
+       public void timeout(int delay);
+       public int typeahead(int fd);
+       public int ungetch(int ch);
+       public void use_env(bool bf);
+       public int vidattr(ulong attrs);
+       public delegate int VidputsPutcFunc(char ch);
+       public int vidputs(ulong attrs, VidputsPutcFunc putc);
+       public int vline(ulong ch, int n);
+       /* no vwprintw, vw_printw, vwscanw, vw_scanw - va_list */
+
+       [CCode (cprefix = "A_")]
+       public enum Attribute {
+               NORMAL, ATTRIBUTES, CHARTEXT, COLOR, STANDOUT,
+               UNDERLINE, REVERSE, BLINK, DIM, BOLD, ALTCHARSET, INVIS,
+               PROTECT, HORIZONTAL, LEFT, LOW, RIGHT, TOP, VERTICAL
+       }
+
+       public enum Key {
+               CODE_YES, MIN, BREAK, SRESET, RESET, DOWN, UP, LEFT,
+               RIGHT, HOME, BACKSPACE, F0, /* XXX F(n), */ DL, IL, DC,
+               IC, EIC, CLEAR, EOS, EOL, SF, SR, NPAGE, PPAGE, STAB,
+               CTAB, CATAB, ENTER, PRINT, LL, A1, A3, B2, C1, C3, BTAB,
+               BEG, CANCEL, CLOSE, COMMAND, COPY, CREATE, END, EXIT,
+               FIND, HELP, MARK, MESSAGE, MOVE, NEXT, OPEN, OPTIONS,
+               PREVIOUS, REDO, REFERENCE, REFRESH, REPLACE, RESTART,
+               RESUME, SAVE, SBEG, SCANCEL, SCOMMAND, SCOPY, SCREATE,
+               SDC, SDL, SELECT, SEND, SEOL, SEXIT, SFIND, SHELP,
+               SHOME, SIC, SLEFT, SMESSAGE, SMOVE, SNEXT, SOPTIONS,
+               SPREVIOUS, SPRINT, SREDO, SREPLACE, SRIGHT, SRSUME,
+               SSAVE, SSUSPEND, SUNDO, SUSPEND, UNDO, MOUSE, RESIZE,
+               EVENT, MAX
+       }
+       
+       /* TODO: mouse + wide char support */
+}