]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_slkrefr.c
ncurses 5.8 - patch 20110307
[ncurses.git] / ncurses / base / lib_slkrefr.c
index ee3c91dbee6710d6faeeee0bbdedbe88e46d35d4..b06bf8d7f802af3bd1953de3ce2468cb742aff24 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -29,6 +29,8 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Juergen Pfeifer                         1996-on                 *
+ *     and: Thomas E. Dickey                                                *
  ****************************************************************************/
 
 /*
  ****************************************************************************/
 
 /*
  *     Write SLK window to the (virtual) screen.
  */
 #include <curses.priv.h>
  *     Write SLK window to the (virtual) screen.
  */
 #include <curses.priv.h>
-#include <term.h>        /* num_labels, label_*, plab_norm */
 
 
-MODULE_ID("$Id: lib_slkrefr.c,v 1.8 1999/03/14 00:10:27 Alexander.V.Lukyanov Exp $")
+#ifndef CUR
+#define CUR SP_TERMTYPE
+#endif
+
+MODULE_ID("$Id: lib_slkrefr.c,v 1.26 2010/05/01 19:17:28 tom Exp $")
+
+#ifdef USE_TERM_DRIVER
+#define NumLabels    InfoOf(SP_PARM).numlabels
+#else
+#define NumLabels    num_labels
+#endif
+
+/*
+ * Paint the info line for the PC style SLK emulation.
+ */
+static void
+slk_paint_info(WINDOW *win)
+{
+    SCREEN *sp = _nc_screen_of(win);
+
+    if (win && sp && (sp->slk_format == 4)) {
+       int i;
+
+       (void) mvwhline(win, 0, 0, 0, getmaxx(win));
+       wmove(win, 0, 0);
+
+       for (i = 0; i < sp->_slk->maxlab; i++) {
+           mvwprintw(win, 0, sp->_slk->ent[i].ent_x, "F%d", i + 1);
+       }
+    }
+}
 
 /*
  * Write the soft labels to the soft-key window.
  */
 static void
 
 /*
  * Write the soft labels to the soft-key window.
  */
 static void
-slk_intern_refresh(SLK *slk)
+slk_intern_refresh(SCREEN *sp)
 {
 {
-int i;
-int fmt = SP->slk_format;
-
-       for (i = 0; i < slk->labcnt; i++) {
-               if (slk->dirty || slk->ent[i].dirty) {
-                       if (slk->ent[i].visible) {
-                               if (num_labels > 0 && SLK_STDFMT(fmt))
-                               {
-                                 if (i < num_labels) {
-                                   TPUTS_TRACE("plab_norm");
-                                   putp(tparm(plab_norm, i+1, slk->ent[i].form_text));
-                                 }
-                               }
-                               else
-                               {
-                                       wmove(slk->win,SLK_LINES(fmt)-1,slk->ent[i].x);
-                                       if (SP && SP->_slk)
-                                         wattrset(slk->win,SP->_slk->attr);
-                                       waddnstr(slk->win,slk->ent[i].form_text,
-                                                MAX_SKEY_LEN(fmt));
-                                       /* if we simulate SLK's, it's looking much more
-                                          natural to use the current ATTRIBUTE also
-                                          for the label window */
-                                       wattrset(slk->win,stdscr->_attrs);
-                               }
-                       }
-                       slk->ent[i].dirty = FALSE;
+    int i;
+    int fmt;
+    SLK *slk;
+    int numlab;
+
+    if (sp == 0)
+       return;
+
+    slk = sp->_slk;
+    fmt = sp->slk_format;
+    numlab = NumLabels;
+
+    if (slk->hidden)
+       return;
+
+    for (i = 0; i < slk->labcnt; i++) {
+       if (slk->dirty || slk->ent[i].dirty) {
+           if (slk->ent[i].visible) {
+               if (numlab > 0 && SLK_STDFMT(fmt)) {
+#ifdef USE_TERM_DRIVER
+                   CallDriver_2(sp, hwlabel, i + 1, slk->ent[i].form_text);
+#else
+                   if (i < num_labels) {
+                       TPUTS_TRACE("plab_norm");
+                       putp(TPARM_2(plab_norm, i + 1, slk->ent[i].form_text));
+                   }
+#endif
+               } else {
+                   if (fmt == 4)
+                       slk_paint_info(slk->win);
+                   wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x);
+                   if (sp->_slk) {
+                       (void) wattrset(slk->win, AttrOf(sp->_slk->attr));
+                   }
+                   waddstr(slk->win, slk->ent[i].form_text);
+                   /* if we simulate SLK's, it's looking much more
+                      natural to use the current ATTRIBUTE also
+                      for the label window */
+                   (void) wattrset(slk->win, WINDOW_ATTRS(StdScreen(sp)));
                }
                }
+           }
+           slk->ent[i].dirty = FALSE;
        }
        }
-       slk->dirty = FALSE;
+    }
+    slk->dirty = FALSE;
 
 
-       if (num_labels > 0) {
-           if (slk->hidden)
-           {
-               TPUTS_TRACE("label_off");
-               putp(label_off);
-           }
-           else
-           {
-               TPUTS_TRACE("label_on");
-               putp(label_on);
-           }
+    if (numlab > 0) {
+#ifdef USE_TERM_DRIVER
+       CallDriver_1(sp, hwlabelOnOff, slk->hidden ? FALSE : TRUE);
+#else
+       if (slk->hidden) {
+           TPUTS_TRACE("label_off");
+           putp(label_off);
+       } else {
+           TPUTS_TRACE("label_on");
+           putp(label_on);
        }
        }
+#endif
+    }
 }
 
 /*
  * Refresh the soft labels.
  */
 }
 
 /*
  * Refresh the soft labels.
  */
-int
-slk_noutrefresh(void)
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(slk_noutrefresh) (NCURSES_SP_DCL0)
 {
 {
-       T((T_CALLED("slk_noutrefresh()")));
+    T((T_CALLED("slk_noutrefresh(%p)"), (void *) SP_PARM));
+
+    if (SP_PARM == 0 || SP_PARM->_slk == 0)
+       returnCode(ERR);
+    if (SP_PARM->_slk->hidden)
+       returnCode(OK);
+    slk_intern_refresh(SP_PARM);
 
 
-       if (SP == NULL || SP->_slk == NULL)
-               returnCode(ERR);
-       if (SP->_slk->hidden)
-               returnCode(OK);
-       slk_intern_refresh(SP->_slk);
+    returnCode(wnoutrefresh(SP_PARM->_slk->win));
+}
 
 
-       returnCode(wnoutrefresh(SP->_slk->win));
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+slk_noutrefresh(void)
+{
+    return NCURSES_SP_NAME(slk_noutrefresh) (CURRENT_SCREEN);
 }
 }
+#endif
 
 /*
  * Refresh the soft labels.
  */
 
 /*
  * Refresh the soft labels.
  */
-int
-slk_refresh(void)
+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(slk_refresh) (NCURSES_SP_DCL0)
 {
 {
-       T((T_CALLED("slk_refresh()")));
+    T((T_CALLED("slk_refresh(%p)"), (void *) SP_PARM));
 
 
-       if (SP == NULL || SP->_slk == NULL)
-               returnCode(ERR);
-       if (SP->_slk->hidden)
-               returnCode(OK);
-       slk_intern_refresh(SP->_slk);
+    if (SP_PARM == 0 || SP_PARM->_slk == 0)
+       returnCode(ERR);
+    if (SP_PARM->_slk->hidden)
+       returnCode(OK);
+    slk_intern_refresh(SP_PARM);
 
 
-       returnCode(wrefresh(SP->_slk->win));
+    returnCode(wrefresh(SP_PARM->_slk->win));
+}
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+slk_refresh(void)
+{
+    return NCURSES_SP_NAME(slk_refresh) (CURRENT_SCREEN);
 }
 }
+#endif