1 /* $OpenBSD: lib_slkrefr.c,v 1.2 1999/03/11 21:03:56 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.7 1999/03/03 23:44:22 juergen 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 { 59 if (i < num_labels) { 60 TPUTS_TRACE("plab_norm"); 61 putp(tparm(plab_norm, i+1, slk->win,slk->ent[i].form_text)); 62 } 63 } 64 else 65 { 66 wmove(slk->win,SLK_LINES(fmt)-1,slk->ent[i].x); 67 if (SP && SP->_slk) 68 wattrset(slk->win,SP->_slk->attr); 69 waddnstr(slk->win,slk->ent[i].form_text, 70 MAX_SKEY_LEN(fmt)); 71 /* if we simulate SLK's, it's looking much more 72 natural to use the current ATTRIBUTE also 73 for the label window */ 74 wattrset(slk->win,stdscr->_attrs); 75 } 76 } 77 slk->ent[i].dirty = FALSE; 78 } 79 } 80 slk->dirty = FALSE; 81 82 if (num_labels > 0) { 83 if (slk->hidden) 84 { 85 TPUTS_TRACE("label_off"); 86 putp(label_off); 87 } 88 else 89 { 90 TPUTS_TRACE("label_on"); 91 putp(label_on); 92 } 93 } 94 } 95 96 /* 97 * Refresh the soft labels. 98 */ 99 int 100 slk_noutrefresh(void) 101 { 102 T((T_CALLED("slk_noutrefresh()"))); 103 104 if (SP == NULL || SP->_slk == NULL) 105 returnCode(ERR); 106 if (SP->_slk->hidden) 107 returnCode(OK); 108 slk_intern_refresh(SP->_slk); 109 110 returnCode(wnoutrefresh(SP->_slk->win)); 111 } 112 113 /* 114 * Refresh the soft labels. 115 */ 116 int 117 slk_refresh(void) 118 { 119 T((T_CALLED("slk_refresh()"))); 120 121 if (SP == NULL || SP->_slk == NULL) 122 returnCode(ERR); 123 if (SP->_slk->hidden) 124 returnCode(OK); 125 slk_intern_refresh(SP->_slk); 126 127 returnCode(wrefresh(SP->_slk->win)); 128 } 129