libpayload: Add PDCurses and ncurses' libform/libmenu
[coreboot.git] / payloads / libpayload / curses / PDCurses-3.4 / pdcurses / outopts.c
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: outopts.c,v 1.39 2008/07/14 12:22:13 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9   Name:                                                         outopts
10
11   Synopsis:
12         int clearok(WINDOW *win, bool bf);
13         int idlok(WINDOW *win, bool bf);
14         void idcok(WINDOW *win, bool bf);
15         void immedok(WINDOW *win, bool bf);
16         int leaveok(WINDOW *win, bool bf);
17         int setscrreg(int top, int bot);
18         int wsetscrreg(WINDOW *win, int top, int bot);
19         int scrollok(WINDOW *win, bool bf);
20
21         int raw_output(bool bf);
22
23   Description:
24         With clearok(), if bf is TRUE, the next call to wrefresh() with 
25         this window will clear the screen completely and redraw the 
26         entire screen.
27
28         immedok(), called with a second argument of TRUE, causes an 
29         automatic wrefresh() every time a change is made to the 
30         specified window.
31
32         Normally, the hardware cursor is left at the location of the
33         window being refreshed.  leaveok() allows the cursor to be
34         left wherever the update happens to leave it.  It's useful
35         for applications where the cursor is not used, since it reduces
36         the need for cursor motions.  If possible, the cursor is made
37         invisible when this option is enabled.
38
39         wsetscrreg() sets a scrolling region in a window; "top" and 
40         "bot" are the line numbers for the top and bottom margins. If 
41         this option and scrollok() are enabled, any attempt to move off 
42         the bottom margin will cause all lines in the scrolling region 
43         to scroll up one line. setscrreg() is the stdscr version.
44
45         idlok() and idcok() do nothing in PDCurses, but are provided for 
46         compatibility with other curses implementations.
47
48         raw_output() enables the output of raw characters using the 
49         standard *add* and *ins* curses functions (that is, it disables 
50         translation of control characters).
51
52   Return Value:
53         All functions return OK on success and ERR on error.
54
55   Portability                                X/Open    BSD    SYS V
56         clearok                                 Y       Y       Y
57         idlok                                   Y       Y       Y
58         idcok                                   Y       -      4.0
59         immedok                                 Y       -      4.0
60         leaveok                                 Y       Y       Y
61         setscrreg                               Y       Y       Y
62         wsetscrreg                              Y       Y       Y
63         scrollok                                Y       Y       Y
64         raw_output                              -       -       -
65
66 **man-end****************************************************************/
67
68 int clearok(WINDOW *win, bool bf)
69 {
70     PDC_LOG(("clearok() - called\n"));
71
72     if (!win)
73         return ERR;
74
75     win->_clear = bf;
76
77     return OK;
78 }
79
80 int idlok(WINDOW *win, bool bf)
81 {
82     PDC_LOG(("idlok() - called\n"));
83
84     return OK;
85 }
86
87 void idcok(WINDOW *win, bool bf)
88 {
89     PDC_LOG(("idcok() - called\n"));
90 }
91
92 void immedok(WINDOW *win, bool bf)
93 {
94     PDC_LOG(("immedok() - called\n"));
95
96     if (win)
97         win->_immed = bf;
98 }
99
100 int leaveok(WINDOW *win, bool bf)
101 {
102     PDC_LOG(("leaveok() - called\n"));
103
104     if (!win)
105         return ERR;
106
107     win->_leaveit = bf;
108
109     curs_set(!bf);
110
111     return OK;
112 }
113
114 int setscrreg(int top, int bottom)
115 {
116     PDC_LOG(("setscrreg() - called: top %d bottom %d\n", top, bottom));
117
118     return wsetscrreg(stdscr, top, bottom);
119 }
120
121 int wsetscrreg(WINDOW *win, int top, int bottom)
122 {
123     PDC_LOG(("wsetscrreg() - called: top %d bottom %d\n", top, bottom));
124
125     if (win && 0 <= top && top <= win->_cury &&
126         win->_cury <= bottom && bottom < win->_maxy)
127     {
128         win->_tmarg = top;
129         win->_bmarg = bottom;
130
131         return OK;
132     }
133     else
134         return ERR;
135 }
136
137 int scrollok(WINDOW *win, bool bf)
138 {
139     PDC_LOG(("scrollok() - called\n"));
140
141     if (!win)
142         return ERR;
143
144     win->_scroll = bf;
145
146     return OK;
147 }
148
149 int raw_output(bool bf)
150 {
151     PDC_LOG(("raw_output() - called\n"));
152
153     SP->raw_out = bf;
154
155     return OK;
156 }