1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
#include <curses.h>
#include "mucurses.h"
#include "cursor.h"
/** @file
*
* MuCurses edging functions
*
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/**
* Draw borders from single-byte characters and renditions around a
* window
*
* @v *win window to be bordered
* @v verch vertical chtype
* @v horch horizontal chtype
* @ret rc return status code
*/
int box ( WINDOW *win, chtype verch, chtype horch ) {
chtype corner = '+' | win->attrs; /* default corner character */
return wborder( win, verch, verch, horch, horch,
corner, corner, corner, corner );
}
/**
* Draw borders from single-byte characters and renditions around a
* window
*
* @v *win window to be bordered
* @v ls left side
* @v rs right side
* @v ts top
* @v bs bottom
* @v tl top left corner
* @v tr top right corner
* @v bl bottom left corner
* @v br bottom right corner
* @ret rc return status code
*/
int wborder ( WINDOW *win, chtype ls, chtype rs,
chtype ts, chtype bs, chtype tl,
chtype tr, chtype bl, chtype br ) {
struct cursor_pos pos;
_store_curs_pos( win, &pos );
wmove(win,0,0);
_wputch(win,tl,WRAP);
while ( ( win->width - 1 ) - win->curs_x ) {
_wputch(win,ts,WRAP);
}
_wputch(win,tr,WRAP);
while ( ( win->height - 1 ) - win->curs_y ) {
_wputch(win,ls,WRAP);
wmove(win,win->curs_y,(win->width)-1);
_wputch(win,rs,WRAP);
}
_wputch(win,bl,WRAP);
while ( ( win->width -1 ) - win->curs_x ) {
_wputch(win,bs,WRAP);
}
_wputch(win,br,NOWRAP); /* do not wrap last char to leave
cursor in last position */
_restore_curs_pos( win, &pos );
return OK;
}
/**
* Create a horizontal line in a window
*
* @v *win subject window
* @v ch rendition and character
* @v n max number of chars (wide) to render
* @ret rc return status code
*/
int whline ( WINDOW *win, chtype ch, int n ) {
struct cursor_pos pos;
_store_curs_pos ( win, &pos );
while ( ( win->curs_x - win->width ) && n-- ) {
_wputch ( win, ch, NOWRAP );
}
_restore_curs_pos ( win, &pos );
return OK;
}
/**
* Create a vertical line in a window
*
* @v *win subject window
* @v ch rendition and character
* @v n max number of chars (high) to render
* @ret rc return status code
*/
int wvline ( WINDOW *win, chtype ch, int n ) {
struct cursor_pos pos;
_store_curs_pos ( win, &pos );
while ( ( win->curs_y - win->height ) && n-- ) {
_wputch ( win, ch, NOWRAP );
wmove( win, ++(win->curs_y), pos.x);
}
_restore_curs_pos ( win, &pos );
return OK;
}
|