Back to index

tetex-bin  3.0
lib_slkrefr.c
Go to the documentation of this file.
00001 /****************************************************************************
00002  * Copyright (c) 1998-2000,2003 Free Software Foundation, Inc.              *
00003  *                                                                          *
00004  * Permission is hereby granted, free of charge, to any person obtaining a  *
00005  * copy of this software and associated documentation files (the            *
00006  * "Software"), to deal in the Software without restriction, including      *
00007  * without limitation the rights to use, copy, modify, merge, publish,      *
00008  * distribute, distribute with modifications, sublicense, and/or sell       *
00009  * copies of the Software, and to permit persons to whom the Software is    *
00010  * furnished to do so, subject to the following conditions:                 *
00011  *                                                                          *
00012  * The above copyright notice and this permission notice shall be included  *
00013  * in all copies or substantial portions of the Software.                   *
00014  *                                                                          *
00015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
00016  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
00017  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
00018  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
00019  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
00020  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
00021  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
00022  *                                                                          *
00023  * Except as contained in this notice, the name(s) of the above copyright   *
00024  * holders shall not be used in advertising or otherwise to promote the     *
00025  * sale, use or other dealings in this Software without prior written       *
00026  * authorization.                                                           *
00027  ****************************************************************************/
00028 
00029 /****************************************************************************
00030  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
00031  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
00032  ****************************************************************************/
00033 
00034 /*
00035  *     lib_slkrefr.c
00036  *     Write SLK window to the (virtual) screen.
00037  */
00038 #include <curses.priv.h>
00039 #include <term.h>           /* num_labels, label_*, plab_norm */
00040 
00041 MODULE_ID("$Id: lib_slkrefr.c,v 1.11 2003/03/29 22:53:48 tom Exp $")
00042 
00043 /*
00044  * Write the soft labels to the soft-key window.
00045  */
00046 static void
00047 slk_intern_refresh(SLK * slk)
00048 {
00049     int i;
00050     int fmt = SP->slk_format;
00051 
00052     for (i = 0; i < slk->labcnt; i++) {
00053        if (slk->dirty || slk->ent[i].dirty) {
00054            if (slk->ent[i].visible) {
00055               if (num_labels > 0 && SLK_STDFMT(fmt)) {
00056                   if (i < num_labels) {
00057                      TPUTS_TRACE("plab_norm");
00058                      putp(tparm(plab_norm, i + 1, slk->ent[i].form_text));
00059                   }
00060               } else {
00061                   wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x);
00062                   if (SP && SP->_slk)
00063                      wattrset(slk->win, SP->_slk->attr);
00064                   waddnstr(slk->win, slk->ent[i].form_text,
00065                           MAX_SKEY_LEN(fmt));
00066                   /* if we simulate SLK's, it's looking much more
00067                      natural to use the current ATTRIBUTE also
00068                      for the label window */
00069                   wattrset(slk->win, stdscr->_attrs);
00070               }
00071            }
00072            slk->ent[i].dirty = FALSE;
00073        }
00074     }
00075     slk->dirty = FALSE;
00076 
00077     if (num_labels > 0) {
00078        if (slk->hidden) {
00079            TPUTS_TRACE("label_off");
00080            putp(label_off);
00081        } else {
00082            TPUTS_TRACE("label_on");
00083            putp(label_on);
00084        }
00085     }
00086 }
00087 
00088 /*
00089  * Refresh the soft labels.
00090  */
00091 NCURSES_EXPORT(int)
00092 slk_noutrefresh(void)
00093 {
00094     T((T_CALLED("slk_noutrefresh()")));
00095 
00096     if (SP == NULL || SP->_slk == NULL)
00097        returnCode(ERR);
00098     if (SP->_slk->hidden)
00099        returnCode(OK);
00100     slk_intern_refresh(SP->_slk);
00101 
00102     returnCode(wnoutrefresh(SP->_slk->win));
00103 }
00104 
00105 /*
00106  * Refresh the soft labels.
00107  */
00108 NCURSES_EXPORT(int)
00109 slk_refresh(void)
00110 {
00111     T((T_CALLED("slk_refresh()")));
00112 
00113     if (SP == NULL || SP->_slk == NULL)
00114        returnCode(ERR);
00115     if (SP->_slk->hidden)
00116        returnCode(OK);
00117     slk_intern_refresh(SP->_slk);
00118 
00119     returnCode(wrefresh(SP->_slk->win));
00120 }