2006-06-08 19:23:37 +02:00
|
|
|
#include <curses.h>
|
2006-12-18 17:52:21 +01:00
|
|
|
#include "mucurses.h"
|
2006-06-08 19:23:37 +02:00
|
|
|
#include "cursor.h"
|
|
|
|
|
2006-06-21 12:27:52 +02:00
|
|
|
/** @file
|
|
|
|
*
|
|
|
|
* MuCurses clearing functions
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-03-02 13:04:57 +01:00
|
|
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
2009-05-01 16:41:06 +02:00
|
|
|
|
2006-06-08 19:23:37 +02:00
|
|
|
/**
|
|
|
|
* Clear a window to the bottom from current cursor position
|
|
|
|
*
|
|
|
|
* @v *win subject window
|
|
|
|
* @ret rc return status code
|
|
|
|
*/
|
|
|
|
int wclrtobot ( WINDOW *win ) {
|
|
|
|
struct cursor_pos pos;
|
|
|
|
|
|
|
|
_store_curs_pos( win, &pos );
|
|
|
|
do {
|
2006-12-19 02:17:10 +01:00
|
|
|
_wputc( win, ' ', WRAP );
|
2006-06-08 19:23:37 +02:00
|
|
|
} while ( win->curs_y + win->curs_x );
|
|
|
|
_restore_curs_pos( win, &pos );
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear a window to the end of the current line
|
|
|
|
*
|
|
|
|
* @v *win subject window
|
|
|
|
* @ret rc return status code
|
|
|
|
*/
|
|
|
|
int wclrtoeol ( WINDOW *win ) {
|
|
|
|
struct cursor_pos pos;
|
|
|
|
|
|
|
|
_store_curs_pos( win, &pos );
|
|
|
|
while ( ( win->curs_y - pos.y ) == 0 ) {
|
2006-12-19 02:17:10 +01:00
|
|
|
_wputc( win, ' ', WRAP );
|
2006-06-08 19:23:37 +02:00
|
|
|
}
|
|
|
|
_restore_curs_pos( win, &pos );
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2006-06-21 12:27:52 +02:00
|
|
|
/**
|
|
|
|
* Delete character under the cursor in a window
|
|
|
|
*
|
|
|
|
* @v *win subject window
|
|
|
|
* @ret rc return status code
|
|
|
|
*/
|
|
|
|
int wdelch ( WINDOW *win ) {
|
2006-12-19 02:17:10 +01:00
|
|
|
_wputc( win, ' ', NOWRAP );
|
2006-06-28 13:48:40 +02:00
|
|
|
_wcursback( win );
|
2006-06-21 12:27:52 +02:00
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete line under a window's cursor
|
|
|
|
*
|
|
|
|
* @v *win subject window
|
|
|
|
* @ret rc return status code
|
|
|
|
*/
|
|
|
|
int wdeleteln ( WINDOW *win ) {
|
|
|
|
struct cursor_pos pos;
|
|
|
|
|
|
|
|
_store_curs_pos( win, &pos );
|
|
|
|
/* let's just set the cursor to the beginning of the line and
|
|
|
|
let wclrtoeol do the work :) */
|
|
|
|
wmove( win, win->curs_y, 0 );
|
|
|
|
wclrtoeol( win );
|
|
|
|
_restore_curs_pos( win, &pos );
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2006-06-08 19:23:37 +02:00
|
|
|
/**
|
|
|
|
* Completely clear a window
|
|
|
|
*
|
|
|
|
* @v *win subject window
|
|
|
|
* @ret rc return status code
|
|
|
|
*/
|
|
|
|
int werase ( WINDOW *win ) {
|
|
|
|
wmove( win, 0, 0 );
|
|
|
|
wclrtobot( win );
|
|
|
|
return OK;
|
|
|
|
}
|
2013-11-28 06:01:29 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Completely clear the screen
|
|
|
|
*
|
|
|
|
* @ret rc return status code
|
|
|
|
*/
|
|
|
|
int erase ( void ) {
|
|
|
|
stdscr->scr->erase( stdscr->scr, stdscr->attrs );
|
|
|
|
return OK;
|
|
|
|
}
|