edging.c

Go to the documentation of this file.
00001 #include <curses.h>
00002 #include "mucurses.h"
00003 #include "cursor.h"
00004 
00005 /** @file
00006  *
00007  * MuCurses edging functions
00008  *
00009  */
00010 
00011 /**
00012  * Draw borders from single-byte characters and renditions around a
00013  * window
00014  *
00015  * @v *win      window to be bordered
00016  * @v verch     vertical chtype
00017  * @v horch     horizontal chtype
00018  * @ret rc      return status code
00019  */
00020 int box ( WINDOW *win, chtype verch, chtype horch ) {
00021         chtype corner = '+' | win->attrs; /* default corner character */
00022         return wborder( win, verch, verch, horch, horch,
00023                         corner, corner, corner, corner );
00024 }
00025 
00026 /**
00027  * Draw borders from single-byte characters and renditions around a
00028  * window
00029  *
00030  * @v *win      window to be bordered
00031  * @v ls        left side
00032  * @v rs        right side
00033  * @v ts        top
00034  * @v bs        bottom
00035  * @v tl        top left corner
00036  * @v tr        top right corner
00037  * @v bl        bottom left corner
00038  * @v br        bottom right corner
00039  * @ret rc      return status code
00040  */
00041 int wborder ( WINDOW *win, chtype ls, chtype rs,
00042               chtype ts, chtype bs, chtype tl,
00043               chtype tr, chtype bl, chtype br ) {
00044         struct cursor_pos pos;
00045 
00046         _store_curs_pos( win, &pos );
00047         wmove(win,0,0);
00048 
00049         _wputch(win,tl,WRAP);
00050         while ( ( win->width - 1 ) - win->curs_x ) {
00051                 _wputch(win,ts,WRAP);
00052         }
00053         _wputch(win,tr,WRAP);
00054 
00055         while ( ( win->height - 1 ) - win->curs_y ) {
00056                 _wputch(win,ls,WRAP);
00057                 wmove(win,win->curs_y,(win->width)-1);
00058                 _wputch(win,rs,WRAP);
00059         }
00060 
00061         _wputch(win,bl,WRAP);
00062         while ( ( win->width -1 ) - win->curs_x ) {
00063                 _wputch(win,bs,WRAP);
00064         }
00065         _wputch(win,br,NOWRAP); /* do not wrap last char to leave
00066                                    cursor in last position */
00067         _restore_curs_pos( win, &pos );
00068 
00069         return OK;
00070 }
00071 
00072 /**
00073  * Create a horizontal line in a window
00074  *
00075  * @v *win      subject window
00076  * @v ch        rendition and character
00077  * @v n         max number of chars (wide) to render
00078  * @ret rc      return status code
00079  */
00080 int whline ( WINDOW *win, chtype ch, int n ) {
00081         struct cursor_pos pos;
00082 
00083         _store_curs_pos ( win, &pos );
00084         while ( ( win->curs_x - win->width ) && n-- ) {
00085                 _wputch ( win, ch, NOWRAP );
00086         }
00087         _restore_curs_pos ( win, &pos );
00088 
00089         return OK;
00090 }
00091 
00092 /**
00093  * Create a vertical line in a window
00094  *
00095  * @v *win      subject window
00096  * @v ch        rendition and character
00097  * @v n         max number of chars (high) to render
00098  * @ret rc      return status code
00099  */
00100 int wvline ( WINDOW *win, chtype ch, int n ) {
00101         struct cursor_pos pos;
00102 
00103         _store_curs_pos ( win, &pos );
00104         while ( ( win->curs_y - win->height ) && n-- ) {
00105                 _wputch ( win, ch, NOWRAP );
00106                 wmove( win, ++(win->curs_y), pos.x);
00107         }
00108         _restore_curs_pos ( win, &pos );
00109 
00110         return OK;
00111 }

Generated on Tue Apr 6 20:01:06 2010 for gPXE by  doxygen 1.5.7.1