]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/lib_options.c
ncurses 5.6 - patch 20070106
[ncurses.git] / ncurses / tinfo / lib_options.c
index 0edf9d5a9a0191094e9a5c235c54896887fe61ad..5cdd1d468077887f9d7130dc3f610f9dac091bb2 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -29,7 +29,7 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
- *     and: Thomas E. Dickey                        1996-2003               *
+ *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
 /*
@@ -43,7 +43,7 @@
 
 #include <term.h>
 
-MODULE_ID("$Id: lib_options.c,v 1.47 2003/10/25 19:51:38 tom Exp $")
+MODULE_ID("$Id: lib_options.c,v 1.50 2006/12/30 16:03:27 tom Exp $")
 
 NCURSES_EXPORT(int)
 idlok(WINDOW *win, bool flag)
@@ -99,7 +99,7 @@ nodelay(WINDOW *win, bool flag)
 NCURSES_EXPORT(int)
 notimeout(WINDOW *win, bool f)
 {
-    T((T_CALLED("notimout(%p,%d)"), win, f));
+    T((T_CALLED("notimeout(%p,%d)"), win, f));
 
     if (win) {
        win->_notimeout = f;
@@ -159,43 +159,44 @@ meta(WINDOW *win GCC_UNUSED, bool flag)
 NCURSES_EXPORT(int)
 curs_set(int vis)
 {
-    int cursor = SP->_cursor;
+    int result = ERR;
 
     T((T_CALLED("curs_set(%d)"), vis));
-
-    if (vis < 0 || vis > 2)
-       returnCode(ERR);
-
-    if (vis == cursor)
-       returnCode(cursor);
-
-    switch (vis) {
-    case 2:
-       if (cursor_visible) {
-           TPUTS_TRACE("cursor_visible");
-           putp(cursor_visible);
-       } else
-           returnCode(ERR);
-       break;
-    case 1:
-       if (cursor_normal) {
-           TPUTS_TRACE("cursor_normal");
-           putp(cursor_normal);
-       } else
-           returnCode(ERR);
-       break;
-    case 0:
-       if (cursor_invisible) {
-           TPUTS_TRACE("cursor_invisible");
-           putp(cursor_invisible);
-       } else
-           returnCode(ERR);
-       break;
+    if (SP != 0 && vis >= 0 && vis <= 2) {
+       int cursor = SP->_cursor;
+
+       if (vis == cursor) {
+           result = cursor;
+       } else {
+           result = (cursor == -1 ? 1 : cursor);
+           switch (vis) {
+           case 2:
+               if (cursor_visible) {
+                   TPUTS_TRACE("cursor_visible");
+                   putp(cursor_visible);
+               } else
+                   result = ERR;
+               break;
+           case 1:
+               if (cursor_normal) {
+                   TPUTS_TRACE("cursor_normal");
+                   putp(cursor_normal);
+               } else
+                   result = ERR;
+               break;
+           case 0:
+               if (cursor_invisible) {
+                   TPUTS_TRACE("cursor_invisible");
+                   putp(cursor_invisible);
+               } else
+                   result = ERR;
+               break;
+           }
+           SP->_cursor = vis;
+           _nc_flush();
+       }
     }
-    SP->_cursor = vis;
-    _nc_flush();
-
-    returnCode(cursor == -1 ? 1 : cursor);
+    returnCode(result);
 }
 
 NCURSES_EXPORT(int)
@@ -219,7 +220,7 @@ typeahead(int fd)
 
 #if NCURSES_EXT_FUNCS
 static int
-has_key_internal(int keycode, struct tries *tp)
+has_key_internal(int keycode, TRIES *tp)
 {
     if (tp == 0)
        return (FALSE);
@@ -258,10 +259,12 @@ _nc_keypad(bool flag)
        _nc_flush();
     }
 
-    if (flag && SP != 0 && !SP->_tried) {
-       _nc_init_keytry();
-       SP->_tried = TRUE;
+    if (SP != 0) {
+       if (flag && !SP->_tried) {
+           _nc_init_keytry();
+           SP->_tried = TRUE;
+       }
+       SP->_keypad_on = flag;
     }
-    SP->_keypad_on = flag;
     return (OK);
 }