]> granicus.if.org Git - php/commitdiff
1) fixed bugs in soft label key functions
authorGeorg Richter <georg@php.net>
Sat, 29 Dec 2001 11:48:30 +0000 (11:48 +0000)
committerGeorg Richter <georg@php.net>
Sat, 29 Dec 2001 11:48:30 +0000 (11:48 +0000)
2) insert new slk-functions
3) defined new key-constants

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

index 775dc9787ddaed622732fb49b9d6531e4fbcadfa..6e79507b56e7fea37ebac24d7807f7bb6de84426 100644 (file)
@@ -74,6 +74,8 @@ PHP_INI_END()
 /* }}} */
 
 #define PHP_NCURSES_CONST(x)  REGISTER_LONG_CONSTANT("NCURSES_"#x, x, CONST_CS | CONST_PERSISTENT)
+#define PHP_NCURSES_FKEY_CONST(x)  REGISTER_LONG_CONSTANT("NCURSES_KEY_F"#x, KEY_F0 + x, CONST_CS | CONST_PERSISTENT)
+
 
 /* {{{ PHP_MINIT_FUNCTION
  */
@@ -88,13 +90,128 @@ PHP_MINIT_FUNCTION(ncurses)
     PHP_NCURSES_CONST(COLOR_MAGENTA);
     PHP_NCURSES_CONST(COLOR_CYAN);
     PHP_NCURSES_CONST(COLOR_WHITE);
-    
+
     /* keyboard constants */
     PHP_NCURSES_CONST(KEY_DOWN);
     PHP_NCURSES_CONST(KEY_UP);
     PHP_NCURSES_CONST(KEY_LEFT);
     PHP_NCURSES_CONST(KEY_RIGHT);
     PHP_NCURSES_CONST(KEY_BACKSPACE);
+    PHP_NCURSES_CONST(KEY_MOUSE);
+    PHP_NCURSES_CONST(KEY_F0);
+
+
+    /* TODO:this macro sux, we have 65 function key,
+       so we need a little loop */
+    PHP_NCURSES_FKEY_CONST(1);
+    PHP_NCURSES_FKEY_CONST(2);
+    PHP_NCURSES_FKEY_CONST(3);
+    PHP_NCURSES_FKEY_CONST(4);
+    PHP_NCURSES_FKEY_CONST(5);
+    PHP_NCURSES_FKEY_CONST(6);
+    PHP_NCURSES_FKEY_CONST(7);
+    PHP_NCURSES_FKEY_CONST(8);
+    PHP_NCURSES_FKEY_CONST(9);
+    PHP_NCURSES_FKEY_CONST(10);
+    PHP_NCURSES_FKEY_CONST(11);
+    PHP_NCURSES_FKEY_CONST(12);
+
+    PHP_NCURSES_CONST(KEY_DL);
+    PHP_NCURSES_CONST(KEY_IL);
+    PHP_NCURSES_CONST(KEY_DC);
+    PHP_NCURSES_CONST(KEY_IC);
+    PHP_NCURSES_CONST(KEY_EIC);
+    PHP_NCURSES_CONST(KEY_CLEAR);
+    PHP_NCURSES_CONST(KEY_EOS);
+    PHP_NCURSES_CONST(KEY_EOL);
+    PHP_NCURSES_CONST(KEY_SF);
+    PHP_NCURSES_CONST(KEY_SR);
+    PHP_NCURSES_CONST(KEY_NPAGE);
+    PHP_NCURSES_CONST(KEY_PPAGE);
+    PHP_NCURSES_CONST(KEY_STAB);
+    PHP_NCURSES_CONST(KEY_CTAB);
+    PHP_NCURSES_CONST(KEY_CATAB);
+    PHP_NCURSES_CONST(KEY_ENTER);
+    PHP_NCURSES_CONST(KEY_SRESET);
+    PHP_NCURSES_CONST(KEY_RESET);
+    PHP_NCURSES_CONST(KEY_PRINT);
+    PHP_NCURSES_CONST(KEY_LL);
+    PHP_NCURSES_CONST(KEY_A1);
+    PHP_NCURSES_CONST(KEY_A3);
+    PHP_NCURSES_CONST(KEY_B2);
+    PHP_NCURSES_CONST(KEY_C1);
+    PHP_NCURSES_CONST(KEY_C3);
+    PHP_NCURSES_CONST(KEY_BTAB);
+    PHP_NCURSES_CONST(KEY_BEG);
+    PHP_NCURSES_CONST(KEY_CANCEL);
+    PHP_NCURSES_CONST(KEY_CLOSE);
+    PHP_NCURSES_CONST(KEY_COMMAND);
+    PHP_NCURSES_CONST(KEY_COPY);
+    PHP_NCURSES_CONST(KEY_CREATE);
+    PHP_NCURSES_CONST(KEY_END);
+    PHP_NCURSES_CONST(KEY_EXIT);
+    PHP_NCURSES_CONST(KEY_FIND);
+    PHP_NCURSES_CONST(KEY_HELP);
+    PHP_NCURSES_CONST(KEY_MARK);
+    PHP_NCURSES_CONST(KEY_MESSAGE);
+    PHP_NCURSES_CONST(KEY_MOVE);
+    PHP_NCURSES_CONST(KEY_NEXT);
+    PHP_NCURSES_CONST(KEY_OPEN);
+    PHP_NCURSES_CONST(KEY_OPTIONS);
+    PHP_NCURSES_CONST(KEY_PREVIOUS);
+    PHP_NCURSES_CONST(KEY_REDO);
+    PHP_NCURSES_CONST(KEY_REFERENCE);
+    PHP_NCURSES_CONST(KEY_REFRESH);
+    PHP_NCURSES_CONST(KEY_REPLACE);
+    PHP_NCURSES_CONST(KEY_RESTART);
+    PHP_NCURSES_CONST(KEY_RESUME);
+    PHP_NCURSES_CONST(KEY_SAVE);
+    PHP_NCURSES_CONST(KEY_SBEG);
+    PHP_NCURSES_CONST(KEY_SCANCEL);
+    PHP_NCURSES_CONST(KEY_SCOMMAND);
+    PHP_NCURSES_CONST(KEY_SCOPY);
+    PHP_NCURSES_CONST(KEY_SCREATE);
+    PHP_NCURSES_CONST(KEY_SDC);
+    PHP_NCURSES_CONST(KEY_SDL);
+    PHP_NCURSES_CONST(KEY_SELECT);
+    PHP_NCURSES_CONST(KEY_SEND);
+    PHP_NCURSES_CONST(KEY_SEOL);
+    PHP_NCURSES_CONST(KEY_SEXIT);
+    PHP_NCURSES_CONST(KEY_SFIND);
+    PHP_NCURSES_CONST(KEY_SHELP);
+    PHP_NCURSES_CONST(KEY_SHOME);
+    PHP_NCURSES_CONST(KEY_SIC);
+    PHP_NCURSES_CONST(KEY_SLEFT);
+    PHP_NCURSES_CONST(KEY_SMESSAGE);
+    PHP_NCURSES_CONST(KEY_SMOVE);
+    PHP_NCURSES_CONST(KEY_SNEXT);
+    PHP_NCURSES_CONST(KEY_SOPTIONS);
+    PHP_NCURSES_CONST(KEY_SPREVIOUS);
+    PHP_NCURSES_CONST(KEY_SPRINT);
+    PHP_NCURSES_CONST(KEY_SREDO);
+    PHP_NCURSES_CONST(KEY_SREPLACE);
+    PHP_NCURSES_CONST(KEY_SRIGHT);
+    PHP_NCURSES_CONST(KEY_SRSUME);
+    PHP_NCURSES_CONST(KEY_SSAVE);
+    PHP_NCURSES_CONST(KEY_SSUSPEND);
+    PHP_NCURSES_CONST(KEY_SUNDO);
+    PHP_NCURSES_CONST(KEY_SUSPEND);
+    PHP_NCURSES_CONST(KEY_UNDO);
+    PHP_NCURSES_CONST(KEY_MOUSE);
+    PHP_NCURSES_CONST(KEY_RESIZE);
+
+    /* screen attribute constants */
+    PHP_NCURSES_CONST(A_NORMAL);
+    PHP_NCURSES_CONST(A_STANDOUT);
+    PHP_NCURSES_CONST(A_UNDERLINE);
+    PHP_NCURSES_CONST(A_REVERSE);
+    PHP_NCURSES_CONST(A_BLINK);
+    PHP_NCURSES_CONST(A_DIM);
+    PHP_NCURSES_CONST(A_BOLD);
+    PHP_NCURSES_CONST(A_PROTECT);
+    PHP_NCURSES_CONST(A_INVIS);
+    PHP_NCURSES_CONST(A_ALTCHARSET);
+    PHP_NCURSES_CONST(A_CHARTEXT);
 
     /* mouse constants */
     PHP_NCURSES_CONST(BUTTON1_PRESSED);
@@ -123,8 +240,7 @@ PHP_MINIT_FUNCTION(ncurses)
     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);    
+    le_ncurses = zend_register_list_destructors_ex(ncurses_destruct, NULL, "ncurses_handle", module_number);
 
     return SUCCESS;
 }
@@ -162,6 +278,12 @@ PHP_MINFO_FUNCTION(ncurses)
 {
     php_info_print_table_start();
     php_info_print_table_header(2, "ncurses support", "enabled");
+    php_info_print_table_row(2, "ncurses library version", NCURSES_VERSION);
+#ifdef HAVE_NCURSES_COLOR_SET
+               php_info_print_table_row(2, "color support", "yes");
+#else
+               php_info_print_table_row(2, "color support", "no");
+#endif
     php_info_print_table_end();
 
     /* Remove comments if you have entries in php.ini
index 7cf3583bdee6d19e27cd34c8e2c06de1fe7cfa51..f6499b46d44699662fd178a5b9fd27aa4be83da2 100644 (file)
@@ -107,6 +107,7 @@ function_entry ncurses_functions[] = {
   PHP_FE(ncurses_slk_attrset, NULL)
   PHP_FE(ncurses_slk_color, NULL)
   PHP_FE(ncurses_slk_init, NULL)
+       PHP_FE(ncurses_slk_set, NULL)
   PHP_FE(ncurses_typeahead, NULL)
   PHP_FE(ncurses_ungetch, NULL)
   PHP_FE(ncurses_vidattr, NULL)
index aa59a7328c7b76783dfa74b2a27aff6d5b5d85ce..3be74f6ba0fb4aa484d3261e0f8e4b8ab20d953e 100644 (file)
@@ -471,6 +471,9 @@ PHP_FUNCTION(ncurses_use_default_colors)
 }
 /* }}} */
 
+/* {{{ proto bool ncurses_slk_clear(void)
+ */
+
 /* {{{ proto bool ncurses_slk_attr(void)
  */
 PHP_FUNCTION(ncurses_slk_attr)
@@ -519,6 +522,23 @@ PHP_FUNCTION(ncurses_slk_touch)
 }
 /* }}} */
 
+/* {{{ proto bool ncurses_slk_init(int labelnr, string label, int format)
+  sets function key labels */
+PHP_FUNCTION(ncurses_slk_set)
+{
+       char *str;
+       int  len;
+       long labelnr;
+       long format;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lsl",&labelnr, &str, &len, &format)==FAILURE) {
+               return;
+       }
+       RETURN_BOOL(slk_set(labelnr, str, format));
+}
+/* }}} */
+
+
 /* {{{ proto int ncurses_attroff(int attributes)
    Turn off the given attributes */
 PHP_FUNCTION(ncurses_attroff)
@@ -626,7 +646,7 @@ PHP_FUNCTION(ncurses_halfdelay)
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",&intarg)==FAILURE) {
                return;
        }
-       
+
        RETURN_LONG(halfdelay(intarg));
 }
 /* }}} */
@@ -763,7 +783,7 @@ PHP_FUNCTION(ncurses_slk_color)
 {
 #ifdef HAVE_NCURSES_SLK_COLOR
        long intarg;
-       
+
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",&intarg)==FAILURE) {
                return;
        }
@@ -772,7 +792,7 @@ PHP_FUNCTION(ncurses_slk_color)
 #else
        php_error(E_WARNING,"%s not supported in this build");
        RETURN_FALSE;
-#endif  
+#endif
 }
 /* }}} */
 
@@ -781,7 +801,7 @@ PHP_FUNCTION(ncurses_slk_color)
 PHP_FUNCTION(ncurses_slk_init)
 {
        long intarg;
-       
+
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",&intarg)==FAILURE) {
                return;
        }
@@ -795,7 +815,7 @@ PHP_FUNCTION(ncurses_slk_init)
 PHP_FUNCTION(ncurses_typeahead)
 {
        long intarg;
-       
+
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",&intarg)==FAILURE) {
                return;
        }
@@ -809,7 +829,7 @@ PHP_FUNCTION(ncurses_typeahead)
 PHP_FUNCTION(ncurses_ungetch)
 {
        long intarg;
-       
+
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",&intarg)==FAILURE) {
                return;
        }
@@ -908,7 +928,7 @@ PHP_FUNCTION(ncurses_timeout)
 PHP_FUNCTION(ncurses_use_env)
 {
        long intarg;
-       
+
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",&intarg)==FAILURE) {
                return;
        }
@@ -1447,7 +1467,7 @@ PHP_FUNCTION(ncurses_mousemask)
 }
 /* }}} */
 
-/* {{{ proto int ncurses_getmouse(array mevent)
+/* {{{ proto bool ncurses_getmouse(array mevent)
    Reads mouse event from queue */
 PHP_FUNCTION(ncurses_getmouse)
 {
@@ -1470,12 +1490,12 @@ PHP_FUNCTION(ncurses_getmouse)
        add_assoc_long(*arg, "z", mevent.z);
        add_assoc_long(*arg, "mmask", mevent.bstate);
 
-       RETURN_LONG(retval);
+       RETURN_BOOL(retval);
 }
 /* }}} */
 
 /* {{{ proto int ncurses_ungetmouse(array mevent)
-   push mouse event to queue */
+   pushes mouse event to queue */
 PHP_FUNCTION(ncurses_ungetmouse)
 {
   zval **arg, **pvalue;
index 0b595f06db02bdfb869d2ecd0181407be61c7462..cefbdbc5162ed1ac80588f0dae70c9e492043d09 100644 (file)
@@ -92,6 +92,7 @@ PHP_FUNCTION(ncurses_slk_attron);
 PHP_FUNCTION(ncurses_slk_attrset);
 PHP_FUNCTION(ncurses_slk_color);
 PHP_FUNCTION(ncurses_slk_init);
+PHP_FUNCTION(ncurses_slk_set);
 PHP_FUNCTION(ncurses_typeahead);
 PHP_FUNCTION(ncurses_ungetch);
 PHP_FUNCTION(ncurses_vidattr);