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;
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Hartmut Holzgraefe <hartmut@six.de> |
- | |
+ | Georg Richter <georg.richter@php-ev.de |
+----------------------------------------------------------------------+
*/
#include "php_ini.h"
#include "php_ncurses.h"
+static unsigned char second_args_force_ref[] = {2, BYREF_NONE, BYREF_FORCE};
+static unsigned char first_args_force_ref[] = {1, BYREF_FORCE};
/* ncurses_functions[]
*
* Every user visible function must have an entry in ncurses_functions[].
PHP_FE(ncurses_mvinch, NULL)
PHP_FE(ncurses_mvwaddstr, NULL)
PHP_FE(ncurses_insstr, NULL)
-
-#if 0
- PHP_FE(ncurses_instr, NULL)
-#endif
-
+ PHP_FE(ncurses_instr, first_args_force_ref)
PHP_FE(ncurses_mvhline, NULL)
PHP_FE(ncurses_mvcur, NULL)
PHP_FE(ncurses_init_color, NULL)
PHP_FE(ncurses_hline, NULL)
PHP_FE(ncurses_vline, NULL)
PHP_FE(ncurses_keyok, NULL)
+ PHP_FE(ncurses_termname, NULL)
+ PHP_FE(ncurses_longname, NULL)
+ PHP_FE(ncurses_mousemask, second_args_force_ref)
{NULL, NULL, NULL} /* Must be the last line in ncurses_functions[] */
};
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Hartmut Holzgraefe <hartmut@six.de> |
- | |
+ | Georg Richter <georg.richter@php-ev.de> |
+----------------------------------------------------------------------+
*/
/* }}} */
/* {{{ proto int ncurses_baudrate()
- Return baudrate of terminal */
+ Returns baudrate of terminal */
PHP_FUNCTION(ncurses_baudrate)
{
RETURN_LONG(baudrate());
/* }}} */
/* {{{ proto string ncurses_erasechar()
- Return current erase character */
+ Returns current erase character */
PHP_FUNCTION(ncurses_erasechar)
{
char temp[2];
/* }}} */
/* {{{ proto string ncurses_killchar()
- Return current line kill character */
+ Returns current line kill character */
PHP_FUNCTION(ncurses_killchar)
{
char temp[2];
/* }}} */
/* {{{ 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());
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lls",&y,&x)==FAILURE) {
return;
}
-
+
RETURN_LONG(mvinch(y,x));
}
/* }}} */
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 */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll",&i1,&i2,&i3,&i4)==FAILURE) {
return;
}
-
+
RETURN_LONG(mvhline(i1,i2,i3,i4));
}
/* }}} */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",&i1,&i2)==FAILURE) {
return;
}
-
+
RETURN_LONG(vline(i1,i2));
}
/* }}} */
}
/* }}} */
+/* {{{ 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
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Hartmut Holzgraefe <hartmut@six.de> |
- | |
+ | Georg Richter <georg.richter@php-ev.de> |
+----------------------------------------------------------------------+
*/
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);
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
/*