lib_slkrefr.c revision 166124
150276Speter/**************************************************************************** 2166124Srafan * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. * 350276Speter * * 450276Speter * Permission is hereby granted, free of charge, to any person obtaining a * 550276Speter * copy of this software and associated documentation files (the * 650276Speter * "Software"), to deal in the Software without restriction, including * 750276Speter * without limitation the rights to use, copy, modify, merge, publish, * 850276Speter * distribute, distribute with modifications, sublicense, and/or sell * 950276Speter * copies of the Software, and to permit persons to whom the Software is * 1050276Speter * furnished to do so, subject to the following conditions: * 1150276Speter * * 1250276Speter * The above copyright notice and this permission notice shall be included * 1350276Speter * in all copies or substantial portions of the Software. * 1450276Speter * * 1550276Speter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 1650276Speter * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 1750276Speter * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 1850276Speter * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 1950276Speter * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 2050276Speter * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 2150276Speter * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 2250276Speter * * 2350276Speter * Except as contained in this notice, the name(s) of the above copyright * 2450276Speter * holders shall not be used in advertising or otherwise to promote the * 2550276Speter * sale, use or other dealings in this Software without prior written * 2650276Speter * authorization. * 2750276Speter ****************************************************************************/ 2850276Speter 2950276Speter/**************************************************************************** 3050276Speter * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * 3150276Speter * and: Eric S. Raymond <esr@snark.thyrsus.com> * 32166124Srafan * and: Juergen Pfeifer 1996-on * 33166124Srafan * and: Thomas E. Dickey * 3450276Speter ****************************************************************************/ 3550276Speter 3650276Speter/* 3750276Speter * lib_slkrefr.c 3850276Speter * Write SLK window to the (virtual) screen. 3950276Speter */ 4050276Speter#include <curses.priv.h> 4176726Speter#include <term.h> /* num_labels, label_*, plab_norm */ 4250276Speter 43166124SrafanMODULE_ID("$Id: lib_slkrefr.c,v 1.15 2006/11/25 22:32:15 tom Exp $") 4450276Speter 4550276Speter/* 4650276Speter * Write the soft labels to the soft-key window. 4750276Speter */ 4850276Speterstatic void 4976726Speterslk_intern_refresh(SLK * slk) 5050276Speter{ 5176726Speter int i; 5276726Speter int fmt = SP->slk_format; 5350276Speter 5476726Speter for (i = 0; i < slk->labcnt; i++) { 5576726Speter if (slk->dirty || slk->ent[i].dirty) { 5676726Speter if (slk->ent[i].visible) { 5776726Speter if (num_labels > 0 && SLK_STDFMT(fmt)) { 5876726Speter if (i < num_labels) { 5976726Speter TPUTS_TRACE("plab_norm"); 60166124Srafan putp(TPARM_2(plab_norm, i + 1, slk->ent[i].form_text)); 6176726Speter } 6276726Speter } else { 63166124Srafan wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x); 64166124Srafan if (SP && SP->_slk) { 65166124Srafan wattrset(slk->win, AttrOf(SP->_slk->attr)); 66166124Srafan } 67166124Srafan waddstr(slk->win, slk->ent[i].form_text); 6876726Speter /* if we simulate SLK's, it's looking much more 6976726Speter natural to use the current ATTRIBUTE also 7076726Speter for the label window */ 71166124Srafan wattrset(slk->win, WINDOW_ATTRS(stdscr)); 7250276Speter } 7376726Speter } 7476726Speter slk->ent[i].dirty = FALSE; 7550276Speter } 7676726Speter } 7776726Speter slk->dirty = FALSE; 7850276Speter 7976726Speter if (num_labels > 0) { 8076726Speter if (slk->hidden) { 8176726Speter TPUTS_TRACE("label_off"); 8276726Speter putp(label_off); 8376726Speter } else { 8476726Speter TPUTS_TRACE("label_on"); 8576726Speter putp(label_on); 8650276Speter } 8776726Speter } 8850276Speter} 8950276Speter 9050276Speter/* 9150276Speter * Refresh the soft labels. 9250276Speter */ 9376726SpeterNCURSES_EXPORT(int) 9450276Speterslk_noutrefresh(void) 9550276Speter{ 9676726Speter T((T_CALLED("slk_noutrefresh()"))); 9750276Speter 9876726Speter if (SP == NULL || SP->_slk == NULL) 9976726Speter returnCode(ERR); 10076726Speter if (SP->_slk->hidden) 10176726Speter returnCode(OK); 10276726Speter slk_intern_refresh(SP->_slk); 10350276Speter 10476726Speter returnCode(wnoutrefresh(SP->_slk->win)); 10550276Speter} 10650276Speter 10750276Speter/* 10850276Speter * Refresh the soft labels. 10950276Speter */ 11076726SpeterNCURSES_EXPORT(int) 11150276Speterslk_refresh(void) 11250276Speter{ 11376726Speter T((T_CALLED("slk_refresh()"))); 11450276Speter 11576726Speter if (SP == NULL || SP->_slk == NULL) 11676726Speter returnCode(ERR); 11776726Speter if (SP->_slk->hidden) 11876726Speter returnCode(OK); 11976726Speter slk_intern_refresh(SP->_slk); 12050276Speter 12176726Speter returnCode(wrefresh(SP->_slk->win)); 12250276Speter} 123