From: Georg Richter Date: Tue, 25 Dec 2001 23:30:55 +0000 (+0000) Subject: activated ncurses_instr X-Git-Tag: PRE_ISSET_PATCH~417 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1ca88c9276c314119018c2931d90fae918b259c5;p=php activated ncurses_instr New functions: ncurses_longname, ncurses_termname, ncurses_mousemask --- diff --git a/ext/ncurses/ncurses.c b/ext/ncurses/ncurses.c index 370c1b45bd..775dc9787d 100644 --- a/ext/ncurses/ncurses.c +++ b/ext/ncurses/ncurses.c @@ -96,6 +96,34 @@ PHP_MINIT_FUNCTION(ncurses) PHP_NCURSES_CONST(KEY_RIGHT); PHP_NCURSES_CONST(KEY_BACKSPACE); + /* mouse constants */ + PHP_NCURSES_CONST(BUTTON1_PRESSED); + PHP_NCURSES_CONST(BUTTON1_RELEASED); + PHP_NCURSES_CONST(BUTTON1_CLICKED); + PHP_NCURSES_CONST(BUTTON1_DOUBLE_CLICKED); + PHP_NCURSES_CONST(BUTTON1_TRIPLE_CLICKED); + PHP_NCURSES_CONST(BUTTON2_PRESSED); + PHP_NCURSES_CONST(BUTTON2_RELEASED); + PHP_NCURSES_CONST(BUTTON2_CLICKED); + PHP_NCURSES_CONST(BUTTON2_DOUBLE_CLICKED); + PHP_NCURSES_CONST(BUTTON2_TRIPLE_CLICKED); + PHP_NCURSES_CONST(BUTTON3_PRESSED); + PHP_NCURSES_CONST(BUTTON3_RELEASED); + PHP_NCURSES_CONST(BUTTON3_CLICKED); + PHP_NCURSES_CONST(BUTTON3_DOUBLE_CLICKED); + PHP_NCURSES_CONST(BUTTON3_TRIPLE_CLICKED); + PHP_NCURSES_CONST(BUTTON4_PRESSED); + PHP_NCURSES_CONST(BUTTON4_RELEASED); + PHP_NCURSES_CONST(BUTTON4_CLICKED); + PHP_NCURSES_CONST(BUTTON4_DOUBLE_CLICKED); + PHP_NCURSES_CONST(BUTTON4_TRIPLE_CLICKED); + PHP_NCURSES_CONST(BUTTON_SHIFT); + PHP_NCURSES_CONST(BUTTON_CTRL); + PHP_NCURSES_CONST(BUTTON_ALT); + PHP_NCURSES_CONST(ALL_MOUSE_EVENTS); + PHP_NCURSES_CONST(REPORT_MOUSE_POSITION); + + le_ncurses = zend_register_list_destructors_ex(ncurses_destruct, NULL, "ncurses_handle", module_number); return SUCCESS; diff --git a/ext/ncurses/ncurses_fe.c b/ext/ncurses/ncurses_fe.c index aea1995785..a21641b260 100644 --- a/ext/ncurses/ncurses_fe.c +++ b/ext/ncurses/ncurses_fe.c @@ -13,7 +13,7 @@ | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Hartmut Holzgraefe | - | | + | Georg Richter | - | | + | Georg Richter | +----------------------------------------------------------------------+ */ @@ -193,7 +193,7 @@ PHP_FUNCTION(ncurses_standend) /* }}} */ /* {{{ proto int ncurses_baudrate() - Return baudrate of terminal */ + Returns baudrate of terminal */ PHP_FUNCTION(ncurses_baudrate) { RETURN_LONG(baudrate()); @@ -305,7 +305,7 @@ PHP_FUNCTION(ncurses_erase) /* }}} */ /* {{{ proto string ncurses_erasechar() - Return current erase character */ + Returns current erase character */ PHP_FUNCTION(ncurses_erasechar) { char temp[2]; @@ -379,7 +379,7 @@ PHP_FUNCTION(ncurses_isendwin) /* }}} */ /* {{{ proto string ncurses_killchar() - Return current line kill character */ + Returns current line kill character */ PHP_FUNCTION(ncurses_killchar) { char temp[2]; @@ -456,7 +456,7 @@ PHP_FUNCTION(ncurses_savetty) /* }}} */ /* {{{ proto bool ncurses_termattrs() - Return a logical OR of all attribute flags supported by terminal */ + Returns a logical OR of all attribute flags supported by terminal */ PHP_FUNCTION(ncurses_termattrs) { RETURN_LONG(termattrs()); @@ -1170,7 +1170,7 @@ PHP_FUNCTION(ncurses_mvinch) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lls",&y,&x)==FAILURE) { return; } - + RETURN_LONG(mvinch(y,x)); } /* }}} */ @@ -1185,28 +1185,36 @@ PHP_FUNCTION(ncurses_insstr) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",&str,&str_len)==FAILURE) { return; } - + RETURN_LONG(insstr(str)); } /* }}} */ -#if 0 -/* TODO return by reference */ + /* {{{ proto int ncurses_instr(string buffer) - Read string from terminal screen */ + Reads string from terminal screen */ PHP_FUNCTION(ncurses_instr) { + ulong retval; + zval **param; char *str; - int str_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",&str,&str_len)==FAILURE) { - return; + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, ¶m) == FAILURE ){ + WRONG_PARAM_COUNT; } - - RETURN_LONG(instr(str)); + + convert_to_string_ex(param); + + str = (char *)emalloc(COLS + 1); + retval = instr(str); + + ZVAL_STRING(*param, str, strlen(str)); + efree(str); + + RETURN_LONG(retval); } /* }}} */ -#endif + /* {{{ proto int ncurses_mvhline(int y, int x, int attrchar, int n) Set new position and draw a horizontal line using an attributed character and max. n characters long */ @@ -1217,7 +1225,7 @@ PHP_FUNCTION(ncurses_mvhline) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll",&i1,&i2,&i3,&i4)==FAILURE) { return; } - + RETURN_LONG(mvhline(i1,i2,i3,i4)); } /* }}} */ @@ -1336,7 +1344,7 @@ PHP_FUNCTION(ncurses_vline) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",&i1,&i2)==FAILURE) { return; } - + RETURN_LONG(vline(i1,i2)); } /* }}} */ @@ -1394,6 +1402,51 @@ PHP_FUNCTION(ncurses_wrefresh) } /* }}} */ +/* {{{ proto string ncurses_termname() + returns terminal name */ +PHP_FUNCTION(ncurses_termname) +{ + char temp[15]; + + strcpy (temp, termname()); + RETURN_STRINGL (temp, strlen(temp), 1); +} +/* }}} */ + +/* {{{ proto string ncurses_longname() + returns terminal description */ +PHP_FUNCTION(ncurses_longname) +{ + char temp[128]; + + strcpy (temp, longname()); + RETURN_STRINGL (temp, strlen(temp), 1); +} +/* }}} */ + +/* {{{ proto int ncurses_mousemask() + 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; + } + + 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); +} +/* }}} */ + /* * Local variables: * tab-width: 4 diff --git a/ext/ncurses/php_ncurses_fe.h b/ext/ncurses/php_ncurses_fe.h index aa979c539c..3572938f65 100644 --- a/ext/ncurses/php_ncurses_fe.h +++ b/ext/ncurses/php_ncurses_fe.h @@ -13,7 +13,7 @@ | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Hartmut Holzgraefe | - | | + | Georg Richter | +----------------------------------------------------------------------+ */ @@ -122,11 +122,7 @@ PHP_FUNCTION(ncurses_mvgetch); PHP_FUNCTION(ncurses_mvinch); PHP_FUNCTION(ncurses_mvwaddstr); PHP_FUNCTION(ncurses_insstr); - -#if 0 PHP_FUNCTION(ncurses_instr); -#endif - PHP_FUNCTION(ncurses_mvhline); PHP_FUNCTION(ncurses_mvcur); PHP_FUNCTION(ncurses_init_color); @@ -136,6 +132,9 @@ PHP_FUNCTION(ncurses_define_key); PHP_FUNCTION(ncurses_hline); PHP_FUNCTION(ncurses_vline); PHP_FUNCTION(ncurses_keyok); +PHP_FUNCTION(ncurses_termname); +PHP_FUNCTION(ncurses_longname); +PHP_FUNCTION(ncurses_mousemask); #endif /*