libpayload: remove trailing whitespace and run dos2unix
[coreboot.git] / payloads / libpayload / curses / PDCurses-3.4 / os2 / pdcsetsc.c
1 /* Public Domain Curses */
2
3 #include "pdcos2.h"
4
5 RCSID("$Id: pdcsetsc.c,v 1.44 2008/07/14 04:24:51 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9   Name:                                                         pdcsetsc
10
11   Synopsis:
12         int PDC_set_blink(bool blinkon);
13         void PDC_set_title(const char *title);
14
15   Description:
16         PDC_set_blink() toggles whether the A_BLINK attribute sets an
17         actual blink mode (TRUE), or sets the background color to high
18         intensity (FALSE). The default is platform-dependent (FALSE in
19         most cases). It returns OK if it could set the state to match
20         the given parameter, ERR otherwise. Current platforms also
21         adjust the value of COLORS according to this function -- 16 for
22         FALSE, and 8 for TRUE.
23
24         PDC_set_title() sets the title of the window in which the curses
25         program is running. This function may not do anything on some
26         platforms. (Currently it only works in Win32 and X11.)
27
28   Portability                                X/Open    BSD    SYS V
29         PDC_set_blink                           -       -       -
30         PDC_set_title                           -       -       -
31
32 **man-end****************************************************************/
33
34 int PDC_curs_set(int visibility)
35 {
36 #ifndef EMXVIDEO
37     VIOCURSORINFO pvioCursorInfo;
38 #endif
39     int ret_vis, hidden = 0, start = 0, end = 0;
40
41     PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));
42
43     ret_vis = SP->visibility;
44     SP->visibility = visibility;
45
46     switch(visibility)
47     {
48     case 0:     /* invisible */
49 #ifdef EMXVIDEO
50         start = end = 0;
51 #else
52         start = pdc_font / 4;
53         end = pdc_font;
54         hidden = -1;
55 #endif
56         break;
57
58     case 2:     /* highly visible */
59         start = 2;      /* almost full-height block */
60         end = pdc_font - 1;
61         break;
62
63     default:    /* normal visibility */
64         start = (SP->orig_cursor >> 8) & 0xff;
65         end = SP->orig_cursor & 0xff;
66     }
67
68 #ifdef EMXVIDEO
69     if (!visibility)
70         v_hidecursor();
71     else
72         v_ctype(start, end);
73 #else
74     pvioCursorInfo.yStart = (USHORT)start;
75     pvioCursorInfo.cEnd = (USHORT)end;
76     pvioCursorInfo.cx = (USHORT)1;
77     pvioCursorInfo.attr = hidden;
78     VioSetCurType((PVIOCURSORINFO)&pvioCursorInfo, 0);
79 #endif
80     return ret_vis;
81 }
82
83 void PDC_set_title(const char *title)
84 {
85     PDC_LOG(("PDC_set_title() - called:<%s>\n", title));
86 }
87
88 int PDC_set_blink(bool blinkon)
89 {
90 #ifndef EMXVIDEO
91     USHORT statebuf[3], result;
92
93     statebuf[0] = 6;    /* length */
94     statebuf[1] = 2;    /* blink/intensity */
95     statebuf[2] = !blinkon;
96
97     result = VioSetState(&statebuf, 0);
98     VioGetState(&statebuf, 0);  /* needed? */
99
100     if (pdc_color_started)
101         COLORS = statebuf[2] ? 16 : 8;
102
103     return (result == 0) ? OK : ERR;
104 #else
105     if (pdc_color_started)
106         COLORS = 16;
107
108     return blinkon ? ERR : OK;
109 #endif
110 }