source: trunk/minix/lib/curses/wbox.c@ 10

Last change on this file since 10 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 1.8 KB
Line 
1#include <curses.h>
2#include "curspriv.h"
3
4/****************************************************************/
5/* Wbox(win,ymin,xmin,ymax,xmax,v,h) draws a box in window */
6/* 'win', enclosing the area xmin-xmax and ymin-xmax. If */
7/* Xmax and/or ymax is 0, the window max value is used. 'v' and */
8/* 'h' are the vertical and horizontal characters to use. If */
9/* 'v' and 'h' are 0, wbox will use the alternate character set */
10/* In a pretty way. */
11/****************************************************************/
12
13int wbox(win, ymin, xmin, ymax, xmax, v, h)
14WINDOW *win;
15int ymin, xmin, ymax, xmax;
16unsigned int v;
17unsigned int h;
18{
19 unsigned int vc, hc, ulc, urc, llc, lrc; /* corner chars */
20 int i;
21
22 if (ymax == 0) ymax = win->_maxy;
23 if (xmax == 0) xmax = win->_maxx;
24
25 if (ymin >= win->_maxy || ymax > win->_maxy ||
26 xmin >= win->_maxx || xmax > win->_maxx ||
27 ymin >= ymax || xmin >= xmax)
28 return(ERR);
29
30 vc = v;
31 hc = h;
32 ulc = urc = llc = lrc = vc; /* default same as vertical */
33
34 if (v == 0 && h == 0) {
35 ulc = ACS_ULCORNER;
36 urc = ACS_URCORNER;
37 llc = ACS_LLCORNER;
38 lrc = ACS_LRCORNER;
39 hc = ACS_HLINE;
40 vc = ACS_VLINE;
41 }
42 for (i = xmin + 1; i <= xmax - 1; i++) {
43 win->_line[ymin][i] = hc | win->_attrs;
44 win->_line[ymax][i] = hc | win->_attrs;
45 }
46 for (i = ymin + 1; i <= ymax - 1; i++) {
47 win->_line[i][xmin] = vc | win->_attrs;
48 win->_line[i][xmax] = vc | win->_attrs;
49 }
50 win->_line[ymin][xmin] = ulc | win->_attrs;
51 win->_line[ymin][xmax] = urc | win->_attrs;
52 win->_line[ymax][xmin] = llc | win->_attrs;
53 win->_line[ymax][xmax] = lrc | win->_attrs;
54
55 for (i = ymin; i <= ymax; i++) {
56 if (win->_minchng[i] == _NO_CHANGE) {
57 win->_minchng[i] = xmin;
58 win->_maxchng[i] = xmax;
59 } else {
60 win->_minchng[i] = min(win->_minchng[i], xmin);
61 win->_maxchng[i] = max(win->_maxchng[i], xmax);
62 }
63 }
64 return(OK);
65}
Note: See TracBrowser for help on using the repository browser.