ncurses 5.7 - patch 20100501
[ncurses.git] / ncurses / base / lib_slk.c
index a1dea62660ebd75ba2ea9cd87cf5363da3505821..8fafdbca83832530aa11f347106bd107e58f6aaf 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2009,2010 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            *
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: lib_slk.c,v 1.40 2009/07/19 00:34:07 tom Exp $")
+MODULE_ID("$Id: lib_slk.c,v 1.45 2010/05/01 20:44:34 tom Exp $")
+
+#ifdef USE_TERM_DRIVER
+#define NumLabels    InfoOf(SP_PARM).numlabels
+#define NoColorVideo InfoOf(SP_PARM).nocolorvideo
+#define LabelWidth   InfoOf(SP_PARM).labelwidth
+#define LabelHeight  InfoOf(SP_PARM).labelheight
+#else
+#define NumLabels    num_labels
+#define NoColorVideo no_color_video
+#define LabelWidth   label_width
+#define LabelHeight  label_height
+#endif
 
 /*
  * Free any memory related to soft labels, return an error.
@@ -107,8 +119,9 @@ _nc_format_slks(NCURSES_SP_DCLx int cols)
                    x += max_length;
                    x += (i == 2 || i == 4) ? gap : 1;
                }
-           } else
-               returnCode(slk_failed(NCURSES_SP_ARG));
+           } else {
+               return slk_failed(NCURSES_SP_ARG);
+           }
        }
     }
     SP_PARM->_slk->dirty = TRUE;
@@ -127,7 +140,6 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
     int res = OK;
     unsigned max_length;
     SCREEN *sp;
-    TERMINAL *term;
     int numlab;
 
     T((T_CALLED("_nc_slk_initialize()")));
@@ -138,18 +150,15 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
     if (0 == sp)
        returnCode(ERR);
 
-    term = TerminalOf(SP_PARM);
-    assert(term);
+    assert(TerminalOf(SP_PARM));
 
-    numlab = InfoOf(SP_PARM).numlabels;
+    numlab = NumLabels;
 
     if (SP_PARM->_slk) {       /* we did this already, so simply return */
        returnCode(OK);
     } else if ((SP_PARM->_slk = typeCalloc(SLK, 1)) == 0)
        returnCode(ERR);
 
-    SP_PARM->_slk->hidden = TRUE;
-    SP_PARM->_slk->ent = NULL;
     if (!SP_PARM->slk_format)
        SP_PARM->slk_format = _nc_globals.slk_format;
 
@@ -158,7 +167,7 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
      * with colors.  In that case, we're still guaranteed that "reverse" would
      * work.
      */
-    if ((InfoOf(SP_PARM).nocolorvideo & 1) == 0)
+    if ((NoColorVideo & 1) == 0)
        SetAttr(SP_PARM->_slk->attr, A_STANDOUT);
     else
        SetAttr(SP_PARM->_slk->attr, A_REVERSE);
@@ -167,7 +176,7 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
                             ? numlab
                             : MAX_SKEY(SP_PARM->slk_format));
     SP_PARM->_slk->maxlen = ((numlab > 0)
-                            ? InfoOf(SP_PARM).labelwidth * InfoOf(SP_PARM).labelheight
+                            ? LabelWidth * LabelHeight
                             : MAX_SKEY_LEN(SP_PARM->slk_format));
     SP_PARM->_slk->labcnt = ((SP_PARM->_slk->maxlab < MAX_SKEY(SP_PARM->slk_format))
                             ? MAX_SKEY(SP_PARM->slk_format)
@@ -218,7 +227,7 @@ _nc_slk_initialize(WINDOW *stwin, int cols)
 NCURSES_EXPORT(int)
 NCURSES_SP_NAME(slk_restore) (NCURSES_SP_DCL0)
 {
-    T((T_CALLED("slk_restore(%p)"), SP_PARM));
+    T((T_CALLED("slk_restore(%p)"), (void *) SP_PARM));
 
     if (0 == SP_PARM)
        returnCode(ERR);