1 /* $OpenBSD: lib_slkrefr.c,v 1.1 1999/01/18 19:10:03 millert Exp $ */ 2 3 /**************************************************************************** 4 * Copyright (c) 1998 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.6 1999/01/02 22:56:59 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 for (i = 0; i < slk->labcnt; i++) { 53 if (slk->dirty || slk->ent[i].dirty) { 54 if (slk->ent[i].visible) { 55 if (num_labels > 0 && SLK_STDFMT) 56 { 57 if (i < num_labels) { 58 TPUTS_TRACE("plab_norm"); 59 putp(tparm(plab_norm, i, slk->win,slk->ent[i].form_text)); 60 } 61 } 62 else 63 { 64 wmove(slk->win,SLK_LINES-1,slk->ent[i].x); 65 if (SP && SP->_slk) 66 wattrset(slk->win,SP->_slk->attr); 67 waddnstr(slk->win,slk->ent[i].form_text, MAX_SKEY_LEN); 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 { 82 TPUTS_TRACE("label_off"); 83 putp(label_off); 84 } 85 else 86 { 87 TPUTS_TRACE("label_on"); 88 putp(label_on); 89 } 90 } 91 } 92 93 /* 94 * Refresh the soft labels. 95 */ 96 int 97 slk_noutrefresh(void) 98 { 99 T((T_CALLED("slk_noutrefresh()"))); 100 101 if (SP == NULL || SP->_slk == NULL) 102 returnCode(ERR); 103 if (SP->_slk->hidden) 104 returnCode(OK); 105 slk_intern_refresh(SP->_slk); 106 107 returnCode(wnoutrefresh(SP->_slk->win)); 108 } 109 110 /* 111 * Refresh the soft labels. 112 */ 113 int 114 slk_refresh(void) 115 { 116 T((T_CALLED("slk_refresh()"))); 117 118 if (SP == NULL || SP->_slk == NULL) 119 returnCode(ERR); 120 if (SP->_slk->hidden) 121 returnCode(OK); 122 slk_intern_refresh(SP->_slk); 123 124 returnCode(wrefresh(SP->_slk->win)); 125 } 126