]> granicus.if.org Git - php/commitdiff
activated ncurses_instr
authorGeorg Richter <georg@php.net>
Tue, 25 Dec 2001 23:30:55 +0000 (23:30 +0000)
committerGeorg Richter <georg@php.net>
Tue, 25 Dec 2001 23:30:55 +0000 (23:30 +0000)
New functions: ncurses_longname, ncurses_termname, ncurses_mousemask

ext/ncurses/ncurses.c
ext/ncurses/ncurses_fe.c
ext/ncurses/ncurses_functions.c
ext/ncurses/php_ncurses_fe.h

index 370c1b45bdaa4a1539e15392103dc35a75466cbb..775dc9787ddaed622732fb49b9d6531e4fbcadfa 100644 (file)
@@ -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;
index aea1995785c96a3aceb0758597f8c4a9f02506c4..a21641b26012ed4de1a481e65efd276f7d369ad8 100644 (file)
@@ -13,7 +13,7 @@
    | license@php.net so we can mail you a copy immediately.               |
    +----------------------------------------------------------------------+
    | Authors: Hartmut Holzgraefe <hartmut@six.de>                         |
-   |                                                                      |
+   |          Georg Richter <georg.richter@php-ev.de                      |
    +----------------------------------------------------------------------+
  */
 
@@ -25,6 +25,8 @@
 #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[].
@@ -132,11 +134,7 @@ function_entry 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)
@@ -146,6 +144,9 @@ function_entry ncurses_functions[] = {
   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[] */
 };
 
index 5039296cbec45d879ab90ecf29548e89329c851a..bbf7755e81206d6b56d936b700f9ed4708ee6be2 100644 (file)
@@ -13,7 +13,7 @@
   | license@php.net so we can mail you a copy immediately.               |
   +----------------------------------------------------------------------+
   | Authors: Hartmut Holzgraefe <hartmut@six.de>                         |
-  |                                                                      |
+  |          Georg Richter <georg.richter@php-ev.de>                     |
   +----------------------------------------------------------------------+
 */
 
@@ -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, &param) == 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, &param) == 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
index aa979c539c3a5783ba3be7db11338e0fbe79643c..3572938f65b64c6348b8028ca216c87b72564daf 100644 (file)
@@ -13,7 +13,7 @@
    | license@php.net so we can mail you a copy immediately.               |
    +----------------------------------------------------------------------+
    | Authors: Hartmut Holzgraefe <hartmut@six.de>                         |
-   |                                                                      |
+   |          Georg Richter <georg.richter@php-ev.de>                     |
    +----------------------------------------------------------------------+
  */
 
@@ -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
 
 /*