1 /* $OpenBSD: lib_slkrefr.c,v 1.4 2001/01/22 18:01:46 millert Exp $ */ 2 3 /**************************************************************************** 4 * Copyright (c) 1998,2000 Free Software Foundation, Inc. * 5 * * 6 * Permission is hereby granted, free of charge, to any person obtaining a * 7 * copy of this software and associated documentation files (the * 8 * "Software"), to deal in the Software without restriction, including * 9 * without limitation the rights to use, copy, modify, merge, publish, * 10 * distribute, distribute with modifications, sublicense, and/or sell * 11 * copies of the Software, and to permit persons to whom the Software is * 12 * furnished to do so, subject to the following conditions: * 13 * * 14 * The above copyright notice and this permission notice shall be included * 15 * in all copies or substantial portions of the Software. * 16 * * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 24 * * 25 * Except as contained in this notice, the name(s) of the above copyright * 26 * holders shall not be used in advertising or otherwise to promote the * 27 * sale, use or other dealings in this Software without prior written * 28 * authorization. * 29 ****************************************************************************/ 30 31 /**************************************************************************** 32 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * 33 * and: Eric S. Raymond <esr@snark.thyrsus.com> * 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 43 MODULE_ID("$From: lib_slkrefr.c,v 1.10 2000/12/10 02:43:27 tom Exp $") 44 45 /* 46 * Write the soft labels to the soft-key window. 47 */ 48 static void 49 slk_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(plab_norm, i + 1, slk->ent[i].form_text)); 61 } 62 } else { 63 wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].x); 64 if (SP && SP->_slk) 65 wattrset(slk->win, SP->_slk->attr); 66 waddnstr(slk->win, slk->ent[i].form_text, 67 MAX_SKEY_LEN(fmt)); 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, stdscr->_attrs); 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 */ 93 NCURSES_EXPORT(int) 94 slk_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 */ 110 NCURSES_EXPORT(int) 111 slk_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