libpayload: Add PDCurses and ncurses' libform/libmenu
[coreboot.git] / payloads / libpayload / curses / PDCurses-3.4 / x11 / pdcsetsc.c
1 /* Public Domain Curses */
2
3 #include "pdcx11.h"
4
5 RCSID("$Id: pdcsetsc.c,v 1.33 2008/07/14 04:24:52 wmcbrine Exp $")
6
7 #include <string.h>
8
9 /*man-start**************************************************************
10
11   Name:                                                         pdcsetsc
12
13   Synopsis:
14         int PDC_set_blink(bool blinkon);
15         void PDC_set_title(const char *title);
16
17   Description:
18         PDC_set_blink() toggles whether the A_BLINK attribute sets an
19         actual blink mode (TRUE), or sets the background color to high
20         intensity (FALSE). The default is platform-dependent (FALSE in
21         most cases). It returns OK if it could set the state to match 
22         the given parameter, ERR otherwise. Current platforms also 
23         adjust the value of COLORS according to this function -- 16 for 
24         FALSE, and 8 for TRUE.
25
26         PDC_set_title() sets the title of the window in which the curses
27         program is running. This function may not do anything on some
28         platforms. (Currently it only works in Win32 and X11.)
29
30   Portability                                X/Open    BSD    SYS V
31         PDC_set_blink                           -       -       -
32         PDC_set_title                           -       -       -
33
34 **man-end****************************************************************/
35
36 int PDC_curs_set(int visibility)
37 {
38     int ret_vis = SP->visibility;
39
40     PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
41
42     if (visibility != -1)
43         SP->visibility = visibility;
44
45     PDC_display_cursor(SP->cursrow, SP->curscol, SP->cursrow,
46                        SP->curscol, visibility);
47
48     return ret_vis;
49 }
50
51 void PDC_set_title(const char *title)
52 {
53     int len;
54
55     PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
56
57     len = strlen(title) + 1;        /* write nul character */
58
59     XCursesInstruct(CURSES_TITLE);
60
61     if (XC_write_display_socket_int(len) >= 0)
62         if (XC_write_socket(xc_display_sock, title, len) >= 0)
63             return;
64
65     XCursesExitCursesProcess(1, "exiting from PDC_set_title");
66 }
67
68 int PDC_set_blink(bool blinkon)
69 {
70     if (pdc_color_started)
71         COLORS = 16;
72
73     return blinkon ? ERR : OK;
74 }