lib_slkrefr.c revision 166124
1/**************************************************************************** 2 * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. * 3 * * 4 * Permission is hereby granted, free of charge, to any person obtaining a * 5 * copy of this software and associated documentation files (the * 6 * "Software"), to deal in the Software without restriction, including * 7 * without limitation the rights to use, copy, modify, merge, publish, * 8 * distribute, distribute with modifications, sublicense, and/or sell * 9 * copies of the Software, and to permit persons to whom the Software is * 10 * furnished to do so, subject to the following conditions: * 11 * * 12 * The above copyright notice and this permission notice shall be included * 13 * in all copies or substantial portions of the Software. * 14 * * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 22 * * 23 * Except as contained in this notice, the name(s) of the above copyright * 24 * holders shall not be used in advertising or otherwise to promote the * 25 * sale, use or other dealings in this Software without prior written * 26 * authorization. * 27 ****************************************************************************/ 28 29/**************************************************************************** 30 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * 31 * and: Eric S. Raymond <esr@snark.thyrsus.com> * 32 * and: Juergen Pfeifer 1996-on * 33 * and: Thomas E. Dickey * 34 ****************************************************************************/ 35 36/* 37 * lib_slkrefr.c 38 * Write SLK window to the (virtual) screen. 39 */ 40#include <curses.priv.h> 41#include <term.h> /* num_labels, label_*, plab_norm */ 42 43MODULE_ID("$Id: lib_slkrefr.c,v 1.15 2006/11/25 22:32:15 tom Exp $") 44 45/* 46 * Write the soft labels to the soft-key window. 47 */ 48static void 49slk_intern_refresh(SLK * slk) 50{ 51 int i; 52 int fmt = SP->slk_format; 53 54 for (i = 0; i < slk->labcnt; i++) { 55 if (slk->dirty || slk->ent[i].dirty) { 56 if (slk->ent[i].visible) { 57 if (num_labels > 0 && SLK_STDFMT(fmt)) { 58 if (i < num_labels) { 59 TPUTS_TRACE("plab_norm"); 60 putp(TPARM_2(plab_norm, i + 1, slk->ent[i].form_text)); 61 } 62 } else { 63 wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x); 64 if (SP && SP->_slk) { 65 wattrset(slk->win, AttrOf(SP->_slk->attr)); 66 } 67 waddstr(slk->win, slk->ent[i].form_text); 68 /* if we simulate SLK's, it's looking much more 69 natural to use the current ATTRIBUTE also 70 for the label window */ 71 wattrset(slk->win, WINDOW_ATTRS(stdscr)); 72 } 73 } 74 slk->ent[i].dirty = FALSE; 75 } 76 } 77 slk->dirty = FALSE; 78 79 if (num_labels > 0) { 80 if (slk->hidden) { 81 TPUTS_TRACE("label_off"); 82 putp(label_off); 83 } else { 84 TPUTS_TRACE("label_on"); 85 putp(label_on); 86 } 87 } 88} 89 90/* 91 * Refresh the soft labels. 92 */ 93NCURSES_EXPORT(int) 94slk_noutrefresh(void) 95{ 96 T((T_CALLED("slk_noutrefresh()"))); 97 98 if (SP == NULL || SP->_slk == NULL) 99 returnCode(ERR); 100 if (SP->_slk->hidden) 101 returnCode(OK); 102 slk_intern_refresh(SP->_slk); 103 104 returnCode(wnoutrefresh(SP->_slk->win)); 105} 106 107/* 108 * Refresh the soft labels. 109 */ 110NCURSES_EXPORT(int) 111slk_refresh(void) 112{ 113 T((T_CALLED("slk_refresh()"))); 114 115 if (SP == NULL || SP->_slk == NULL) 116 returnCode(ERR); 117 if (SP->_slk->hidden) 118 returnCode(OK); 119 slk_intern_refresh(SP->_slk); 120 121 returnCode(wrefresh(SP->_slk->win)); 122} 123