7 * MuCurses edging functions
11 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
14 * Draw borders from single-byte characters and renditions around a
17 * @v *win window to be bordered
18 * @v verch vertical chtype
19 * @v horch horizontal chtype
20 * @ret rc return status code
22 int box ( WINDOW *win, chtype verch, chtype horch ) {
23 chtype corner = '+' | win->attrs; /* default corner character */
24 return wborder( win, verch, verch, horch, horch,
25 corner, corner, corner, corner );
29 * Draw borders from single-byte characters and renditions around a
32 * @v *win window to be bordered
37 * @v tl top left corner
38 * @v tr top right corner
39 * @v bl bottom left corner
40 * @v br bottom right corner
41 * @ret rc return status code
43 int wborder ( WINDOW *win, chtype ls, chtype rs,
44 chtype ts, chtype bs, chtype tl,
45 chtype tr, chtype bl, chtype br ) {
46 struct cursor_pos pos;
48 _store_curs_pos( win, &pos );
52 while ( ( win->width - 1 ) - win->curs_x ) {
57 while ( ( win->height - 1 ) - win->curs_y ) {
59 wmove(win,win->curs_y,(win->width)-1);
64 while ( ( win->width -1 ) - win->curs_x ) {
67 _wputch(win,br,NOWRAP); /* do not wrap last char to leave
68 cursor in last position */
69 _restore_curs_pos( win, &pos );
75 * Create a horizontal line in a window
77 * @v *win subject window
78 * @v ch rendition and character
79 * @v n max number of chars (wide) to render
80 * @ret rc return status code
82 int whline ( WINDOW *win, chtype ch, int n ) {
83 struct cursor_pos pos;
85 _store_curs_pos ( win, &pos );
86 while ( ( win->curs_x - win->width ) && n-- ) {
87 _wputch ( win, ch, NOWRAP );
89 _restore_curs_pos ( win, &pos );
95 * Create a vertical line in a window
97 * @v *win subject window
98 * @v ch rendition and character
99 * @v n max number of chars (high) to render
100 * @ret rc return status code
102 int wvline ( WINDOW *win, chtype ch, int n ) {
103 struct cursor_pos pos;
105 _store_curs_pos ( win, &pos );
106 while ( ( win->curs_y - win->height ) && n-- ) {
107 _wputch ( win, ch, NOWRAP );
108 wmove( win, ++(win->curs_y), pos.x);
110 _restore_curs_pos ( win, &pos );