iPXE
clear.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 clearing functions
00008  *
00009  */
00010 
00011 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00012 
00013 /**
00014  * Clear a window to the bottom from current cursor position
00015  *
00016  * @v *win      subject window
00017  * @ret rc      return status code
00018  */
00019 int wclrtobot ( WINDOW *win ) {
00020         struct cursor_pos pos;
00021 
00022         _store_curs_pos( win, &pos );
00023         do {
00024                 _wputc( win, ' ', WRAP );
00025         } while ( win->curs_y + win->curs_x );
00026         _restore_curs_pos( win, &pos );
00027 
00028         return OK;
00029 }
00030 
00031 /**
00032  * Clear a window to the end of the current line
00033  *
00034  * @v *win      subject window
00035  * @ret rc      return status code
00036  */
00037 int wclrtoeol ( WINDOW *win ) {
00038         struct cursor_pos pos;
00039 
00040         _store_curs_pos( win, &pos );
00041         while ( ( win->curs_y - pos.y ) == 0 ) {
00042                 _wputc( win, ' ', WRAP );
00043         }
00044         _restore_curs_pos( win, &pos );
00045 
00046         return OK;
00047 }
00048 
00049 /**
00050  * Delete character under the cursor in a window
00051  *
00052  * @v *win      subject window
00053  * @ret rc      return status code
00054  */
00055 int wdelch ( WINDOW *win ) {
00056         _wputc( win, ' ', NOWRAP );
00057         _wcursback( win );
00058 
00059         return OK;
00060 }
00061 
00062 /**
00063  * Delete line under a window's cursor
00064  *
00065  * @v *win      subject window
00066  * @ret rc      return status code
00067  */
00068 int wdeleteln ( WINDOW *win ) {
00069         struct cursor_pos pos;
00070 
00071         _store_curs_pos( win, &pos );
00072         /* let's just set the cursor to the beginning of the line and
00073            let wclrtoeol do the work :) */
00074         wmove( win, win->curs_y, 0 );
00075         wclrtoeol( win );
00076         _restore_curs_pos( win, &pos );
00077         return OK;
00078 }
00079 
00080 /**
00081  * Completely clear a window
00082  *
00083  * @v *win      subject window
00084  * @ret rc      return status code
00085  */
00086 int werase ( WINDOW *win ) {
00087         wmove( win, 0, 0 );
00088         wclrtobot( win );
00089         return OK;
00090 }
00091 
00092 /**
00093  * Completely clear the screen
00094  *
00095  * @ret rc      return status code
00096  */
00097 int erase ( void ) {
00098         stdscr->scr->erase( stdscr->scr, stdscr->attrs );
00099         return OK;
00100 }