-int _nc_slk_format; /* one more than format specified in slk_init() */
-
-static chtype _slk_attr = A_STANDOUT; /* soft label attribute */
-static SLK *_slk;
-static void slk_paint_info(WINDOW *win);
-
-/*
- * Fetch the label text.
- */
-
-char *
-slk_label(int n)
-{
- T(("slk_label(%d)", n));
-
- if (SP->_slk == NULL || n < 1 || n > SP->_slk->labcnt)
- return NULL;
- return(SP->_slk->ent[n-1].text);
-}
-
-/*
- * Write the soft labels to the soft-key window.
- */
-
-static void
-slk_intern_refresh(SLK *slk)
-{
-int i;
- for (i = 0; i < slk->labcnt; i++) {
- if (slk->dirty || slk->ent[i].dirty) {
- if (slk->ent[i].visible) {
-#ifdef num_labels
- if (num_labels > 0 && SLK_STDFMT)
- {
- if (i < num_labels) {
- TPUTS_TRACE("plab_norm");
- putp(tparm(plab_norm, i, slk->win,slk->ent[i].form_text));
- }
- }
- else
-#endif /* num_labels */
- {
- wmove(slk->win,SLK_LINES-1,slk->ent[i].x);
- wattrset(slk->win,_slk_attr);
- waddnstr(slk->win,slk->ent[i].form_text, MAX_SKEY_LEN);
- /* if we simulate SLK's, it's looking much more
- natural to use the current ATTRIBUTE also
- for the label window */
- wattrset(slk->win,stdscr->_attrs);
- }
- }
- slk->ent[i].dirty = FALSE;
- }
- }
- slk->dirty = FALSE;
-
-#ifdef num_labels
- if (num_labels > 0)
- if (slk->hidden)
- {
- TPUTS_TRACE("label_off");
- putp(label_off);
- }
- else
- {
- TPUTS_TRACE("label_on");
- putp(label_on);
- }
-#endif /* num_labels */
-}
-
-/*
- * Refresh the soft labels.
- */
-
-int
-slk_noutrefresh(void)
-{
- T(("slk_noutrefresh()"));
-
- if (SP->_slk == NULL)
- return(ERR);
- if (SP->_slk->hidden)
- return(OK);
- slk_intern_refresh(SP->_slk);
- return(wnoutrefresh(SP->_slk->win));
-}
-
-/*
- * Refresh the soft labels.
- */
-
-int
-slk_refresh(void)
-{
- T(("slk_refresh()"));
-
- if (SP->_slk == NULL)
- return(ERR);
- if (SP->_slk->hidden)
- return(OK);
- slk_intern_refresh(SP->_slk);
- return(wrefresh(SP->_slk->win));
-}
-
-/*
- * Restore the soft labels on the screen.
- */
-
-int
-slk_restore(void)
-{
- T(("slk_restore()"));
-
- if (SP->_slk == NULL)
- return(ERR);
- SP->_slk->hidden = FALSE;
- SP->_slk->dirty = TRUE;
- /* we have to repaint info line eventually */
- slk_paint_info(SP->_slk->win);
- return slk_refresh();
-}
-
-/*
- * Set soft label text.
- */
-
-int
-slk_set(int i, const char *astr, int format)
-{
-SLK *slk = SP->_slk;
-size_t len;
-const char *str = astr;
-const char *p;
-
- T(("slk_set(%d, \"%s\", %d)", i, str, format));
-
- if (slk == NULL || i < 1 || i > slk->labcnt || format < 0 || format > 2)
- return(ERR);
- if (str == NULL)
- str = "";
-
- while (isspace(*str)) str++; /* skip over leading spaces */
- p = str;
- while (isprint(*p)) p++; /* The first non-print stops */
-
- --i; /* Adjust numbering of labels */
-
- len = (size_t)(p - str);
- if (len > (unsigned)slk->maxlen)
- len = slk->maxlen;
- if (len==0)
- slk->ent[i].text[0] = 0;
- else
- (void) strncpy(slk->ent[i].text, str, len);
- memset(slk->ent[i].form_text,' ', (unsigned)slk->maxlen);
- slk->ent[i].text[slk->maxlen] = 0;
- /* len = strlen(slk->ent[i].text); */
-
- switch(format) {
- case 0: /* left-justified */
- memcpy(slk->ent[i].form_text,
- slk->ent[i].text,
- len);
- break;
- case 1: /* centered */
- memcpy(slk->ent[i].form_text+(slk->maxlen - len)/2,
- slk->ent[i].text,
- len);
- break;
- case 2: /* right-justified */
- memcpy(slk->ent[i].form_text+ slk->maxlen - len,
- slk->ent[i].text,
- len);
- break;
- }
- slk->ent[i].form_text[slk->maxlen] = 0;
- slk->ent[i].dirty = TRUE;
- return(OK);
-}
-
-/*
- * Force the code to believe that the soft keys have been changed.
- */
-
-int
-slk_touch(void)
-{
- T(("slk_touch()"));
-
- if (SP->_slk == NULL)
- return(ERR);
- SP->_slk->dirty = TRUE;
- return(OK);
-}
-
-/*
- * Remove soft labels from the screen.
- */
-
-int
-slk_clear(void)
-{
- T(("slk_clear()"));
-
- if (SP->_slk == NULL)
- return(ERR);
- SP->_slk->hidden = TRUE;
- /* For simulated SLK's it's looks much more natural to
- inherit those attributes from the standard screen */
- SP->_slk->win->_bkgd = stdscr->_bkgd;
- SP->_slk->win->_attrs = stdscr->_attrs;
- werase(SP->_slk->win);
- return wrefresh(SP->_slk->win);
-}