📄 ncurses_functions.c
字号:
int str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",&str,&str_len)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(scr_init(str));}/* }}} *//* {{{ proto int ncurses_scr_restore(string filename) Restores screen from file dump */PHP_FUNCTION(ncurses_scr_restore){ char *str; int str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",&str,&str_len)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(scr_restore(str));}/* }}} *//* {{{ proto int ncurses_scr_set(string filename) Inherits screen from file dump */PHP_FUNCTION(ncurses_scr_set){ char *str; int str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",&str,&str_len)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(scr_set(str));}/* }}} *//* {{{ proto int ncurses_mvaddch(int y, int x, int c) Moves current position and add character */PHP_FUNCTION(ncurses_mvaddch){ long y,x,c; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",&y,&x,&c)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(mvaddch(y,x,c));}/* }}} *//* {{{ proto int ncurses_mvaddchnstr(int y, int x, string s, int n) Moves position and add attrributed string with specified length */PHP_FUNCTION(ncurses_mvaddchnstr){ long y,x,n; char *str; int str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llsl",&y,&x,&str,&str_len,&n)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(mvaddchnstr(y,x,(chtype *)str,n));}/* }}} *//* {{{ proto int ncurses_addchnstr(string s, int n) Adds attributed string with specified length at current position */PHP_FUNCTION(ncurses_addchnstr){ long n; char *str; int str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl",&str,&str_len,&n)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(addchnstr((chtype *)str,n));}/* }}} *//* {{{ proto int ncurses_mvaddchstr(int y, int x, string s) Moves position and add attributed string */PHP_FUNCTION(ncurses_mvaddchstr){ long y,x; char *str; int str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lls",&y,&x,&str,&str_len)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(mvaddchstr(y,x,(chtype *)str));}/* }}} *//* {{{ proto int ncurses_addchstr(string s) Adds attributed string at current position */PHP_FUNCTION(ncurses_addchstr){ char *str; int str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",&str,&str_len)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(addchstr((chtype *)str));}/* }}} *//* {{{ proto int ncurses_mvaddnstr(int y, int x, string s, int n) Moves position and add string with specified length */PHP_FUNCTION(ncurses_mvaddnstr){ long y,x,n; char *str; int str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llsl",&y,&x,&str,&str_len,&n)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(mvaddnstr(y,x,str,n));}/* }}} *//* {{{ proto int ncurses_addnstr(string s, int n) Adds string with specified length at current position */PHP_FUNCTION(ncurses_addnstr){ long n; char *str; int str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl",&str,&str_len,&n)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(addnstr(str,n));}/* }}} *//* {{{ proto int ncurses_mvaddstr(int y, int x, string s) Moves position and add string */PHP_FUNCTION(ncurses_mvaddstr){ long y,x; char *str; int str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lls",&y,&x,&str,&str_len)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(mvaddstr(y,x,str));}/* }}} *//* {{{ proto int ncurses_mvdelch(int y, int x) Moves position and delete character, shift rest of line left */PHP_FUNCTION(ncurses_mvdelch){ long y,x; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",&y,&x)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(mvdelch(y,x));}/* }}} *//* {{{ proto int ncurses_mvgetch(int y, int x) Moves position and get character at new position */PHP_FUNCTION(ncurses_mvgetch){ long y,x; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",&y,&x)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(mvgetch(y,x));}/* }}} *//* {{{ proto int ncurses_mvinch(int y, int x) Moves position and get attributed character at new position */PHP_FUNCTION(ncurses_mvinch){ long y,x; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",&y,&x)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(mvinch(y,x));}/* }}} *//* {{{ proto int ncurses_insstr(string text) Inserts string at current position, moving rest of line right */PHP_FUNCTION(ncurses_insstr){ char *str; int str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",&str,&str_len)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(insstr(str));}/* }}} *//* {{{ proto int ncurses_instr(string buffer) Reads string from terminal screen */PHP_FUNCTION(ncurses_instr){ ulong retval; zval **param; char *str; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, ¶m) == FAILURE ){ WRONG_PARAM_COUNT; } IS_NCURSES_INITIALIZED(); convert_to_string_ex(param); str = (char *)emalloc(COLS + 1); retval = instr(str); ZVAL_STRING(*param, str, 1); efree(str); RETURN_LONG(retval);}/* }}} *//* {{{ proto int ncurses_mvhline(int y, int x, int attrchar, int n) Sets new position and draw a horizontal line using an attributed character and max. n characters long */PHP_FUNCTION(ncurses_mvhline){ long i1,i2,i3,i4; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll",&i1,&i2,&i3,&i4)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(mvhline(i1,i2,i3,i4));}/* }}} *//* {{{ proto int ncurses_mvvline(int y, int x, int attrchar, int n) Sets new position and draw a vertical line using an attributed character and max. n characters long */PHP_FUNCTION(ncurses_mvvline){ long i1,i2,i3,i4; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll",&i1,&i2,&i3,&i4)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(mvvline(i1,i2,i3,i4));}/* }}} *//* {{{ proto int ncurses_mvcur(int old_y,int old_x, int new_y, int new_x) Moves cursor immediately */PHP_FUNCTION(ncurses_mvcur){ long i1,i2,i3,i4; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll",&i1,&i2,&i3,&i4)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(mvcur(i1,i2,i3,i4));}/* }}} *//* {{{ proto int ncurses_init_color(int color, int r, int g, int b) Sets new RGB value for color */PHP_FUNCTION(ncurses_init_color){ long i1,i2,i3,i4; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll",&i1,&i2,&i3,&i4)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(init_color(i1,i2,i3,i4));}/* }}} *//* {{{ proto int ncurses_color_content(int color, int &r, int &g, int &b) Gets the RGB value for color */PHP_FUNCTION(ncurses_color_content){ zval **c, **r, **g, **b; short rv, gv, bv; int retval; if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &c, &r, &g, &b) == FAILURE) { WRONG_PARAM_COUNT; } IS_NCURSES_INITIALIZED(); convert_to_long_ex(c); convert_to_long_ex(r); convert_to_long_ex(g); convert_to_long_ex(b); rv = Z_LVAL_PP(r); gv = Z_LVAL_PP(g); bv = Z_LVAL_PP(b); retval = color_content(Z_LVAL_PP(c), &rv, &gv, &bv); Z_LVAL_PP(r) = rv; Z_LVAL_PP(g) = gv; Z_LVAL_PP(b) = bv; RETURN_LONG(retval);}/* }}} *//* {{{ proto int ncurses_pair_content(int pair, int &f, int &b) Gets the RGB value for color */PHP_FUNCTION(ncurses_pair_content){ zval **p, **f, **b; short fv, bv; int retval; if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &p, &f, &b) == FAILURE) { WRONG_PARAM_COUNT; } IS_NCURSES_INITIALIZED(); convert_to_long_ex(p); convert_to_long_ex(f); convert_to_long_ex(b); fv = Z_LVAL_PP(f); bv = Z_LVAL_PP(b); retval = pair_content(Z_LVAL_PP(f), &fv, &bv); Z_LVAL_PP(f) = fv; Z_LVAL_PP(b) = bv; RETURN_LONG(retval);}/* }}} *//* {{{ proto int ncurses_border(int left, int right, int top, int bottom, int tl_corner, int tr_corner, int bl_corner, int br_corner) Draws a border around the screen using attributed characters */PHP_FUNCTION(ncurses_border){ long i1,i2,i3,i4,i5,i6,i7,i8; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llllllll",&i1,&i2,&i3,&i4,&i5,&i6,&i7,&i8)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(border(i1,i2,i3,i4,i5,i6,i7,i8));}/* }}} *//* {{{ proto int ncurses_wborder(resource window, int left, int right, int top, int bottom, int tl_corner, int tr_corner, int bl_corner, int br_corner) Draws a border around the window using attributed characters */PHP_FUNCTION(ncurses_wborder){ long i1,i2,i3,i4,i5,i6,i7,i8; zval *handle; WINDOW **win; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllllllll",&handle,&i1,&i2,&i3,&i4,&i5,&i6,&i7,&i8)==FAILURE) { return; } FETCH_WINRES(win,&handle); RETURN_LONG(wborder(*win,i1,i2,i3,i4,i5,i6,i7,i8));}/* }}} *//* {{{ proto int ncurses_assume_default_colors(int fg, int bg) Defines default colors for color 0 */PHP_FUNCTION(ncurses_assume_default_colors){#ifdef HAVE_NCURSES_ASSUME_DEFAULT_COLORS long i1,i2; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",&i1,&i2)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(assume_default_colors(i1,i2));#else php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not supported in this build"); RETURN_FALSE;#endif }/* }}} *//* {{{ proto int ncurses_define_key(string definition, int keycode) Defines a keycode */PHP_FUNCTION(ncurses_define_key){ long n; char *str; int str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl",&str,&str_len,&n)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(define_key(str,n));}/* }}} *//* {{{ proto int ncurses_hline(int charattr, int n) Draws a horizontal line at current position using an attributed character and max. n characters long */PHP_FUNCTION(ncurses_hline){ long i1,i2; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",&i1,&i2)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(hline(i1,i2));}/* }}} *//* {{{ proto int ncurses_vline(int charattr, int n) Draws a vertical line at current position using an attributed character and max. n characters long */PHP_FUNCTION(ncurses_vline){ long i1,i2; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",&i1,&i2)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(vline(i1,i2));}/* }}} *//* {{{ proto int ncurses_whline(resource window, int charattr, int n) Draws a horizontal line in a window at current position using an attributed character and max. n characters long */PHP_FUNCTION(ncurses_whline){ long i1,i2; zval *handle; WINDOW **win; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll",&handle,&i1,&i2)==FAILURE) { return; } FETCH_WINRES(win,&handle); RETURN_LONG(whline(*win,i1,i2));}/* }}} *//* {{{ proto int ncurses_wvline(resource window, int charattr, int n) Draws a vertical line in a window at current position using an attributed character and max. n characters long */PHP_FUNCTION(ncurses_wvline){ long i1,i2; zval *handle; WINDOW **win; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll",&handle,&i1,&i2)==FAILURE) { return; } FETCH_WINRES(win,&handle); RETURN_LONG(wvline(*win,i1,i2));}/* }}} *//* {{{ proto int ncurses_keyok(int keycode, bool enable) Enables or disable a keycode */PHP_FUNCTION(ncurses_keyok){ long i,b; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",&i,&b)==FAILURE) { return; } IS_NCURSES_INITIALIZED(); RETURN_LONG(hline(i,b));}/* }}} *//* {{{ proto int ncurses_mvwaddstr(resource window, int y, int x, string text) Adds string at new position in window */PHP_FUNCTION(ncurses_mvwaddstr){ zval **handle, **x, **y, **text; WINDOW **w; if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &handle, &y, &x, &text) == FAILURE){ WRONG_PARAM_COUNT; } FETCH_WINRES(w,handle); convert_to_long_ex(y); convert_to_long_ex(x); convert_to_string_ex(text); RETURN_LONG(mvwaddstr(*w,Z_LVAL_PP(y),Z_LVAL_PP(x),Z_STRVAL_PP(text)));}/* }}} *//* {{{ proto int ncurses_wrefresh(resource window) Refreshes window on terminal screen */PHP_FUNCTION(ncurses_wrefresh){ zval **handle; WINDOW **w; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &handle) == FAILURE){ WRONG_PARAM_COUNT; } FETCH_WINRES(w,handle); RETURN_LONG(wrefresh(*w));}/* }}} *//* {{{ proto string ncurses_termname(void) Returns terminal name */PHP_FUNCTION(ncurses_termname){ char temp[15]; IS_NCURSES_INITIALIZED(); strcpy (temp, termname()); RETURN_STRINGL (temp, strlen(temp), 1);}/* }}} *//* {{{ proto string ncurses_longname(void) Returns terminal description */PHP_FUNCTION(ncurses_longname){ char temp[128]; IS_NCURSES_INITIALIZED(); strcpy (temp, longname()); RETURN_STRINGL (temp, strlen(temp), 1);}/* }}} *//* {{{ proto int ncurses_mousemask(int newmask, int &oldmask) Returns and sets mouse options */PHP_FUNCTION(ncurses_mousemask){ ulong oldmask; ulong retval; zval **param, **newmask; if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &newmask, ¶m) == FAILURE ){ WRONG_PARAM_COUNT; } IS_NCURSES_INITIALIZED(); convert_to_long_ex(newmask); retval = mousemask(Z_LVAL_PP(newmask), &oldmask); Z_TYPE_PP(param) = IS_LONG; Z_LVAL_PP(param) = oldmask; RETURN_LONG(retval);}/* }}} *//* {{{ proto bool ncurses_getmouse(array mevent) Reads mouse event from queue */PHP_FUNCTION(ncurses_getmouse){ zval **arg; MEVENT mevent; ulong retval; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE){ WRONG_PARAM_COUNT; } IS_NCURSES_INITIALIZED(); pval_destructor(*arg); array_init(*arg); retval = getmouse(&mevent); add_assoc_long(*arg, "id", mevent.id); add_assoc_long(*arg, "x", mevent.x); add_assoc_long(*arg, "y", mevent.y); add_assoc_long(*arg, "z", mevent.z); add_assoc_long(*arg, "mmask", mevent.bstate); RETURN_BOOL(retval == 0);}/* }}} *//* {{{ proto int ncurses_ungetmouse(array mevent)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -