iPXE
clear.c File Reference

MuCurses clearing functions. More...

#include <curses.h>
#include "mucurses.h"
#include "cursor.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
int wclrtobot (WINDOW *win)
 Clear a window to the bottom from current cursor position.
int wclrtoeol (WINDOW *win)
 Clear a window to the end of the current line.
int wdelch (WINDOW *win)
 Delete character under the cursor in a window.
int wdeleteln (WINDOW *win)
 Delete line under a window's cursor.
int werase (WINDOW *win)
 Completely clear a window.
int erase (void)
 Completely clear the screen.

Detailed Description

MuCurses clearing functions.

Definition in file clear.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ wclrtobot()

int wclrtobot ( WINDOW * win)

Clear a window to the bottom from current cursor position.

Parameters
*winsubject window
Return values
rcreturn status code

Definition at line 20 of file clear.c.

20 {
21 struct cursor_pos pos;
22
23 _store_curs_pos( win, &pos );
24 do {
25 _wputc( win, ' ', WRAP );
26 } while ( win->curs_y + win->curs_x );
27 _restore_curs_pos( win, &pos );
28
29 return OK;
30}
#define OK
Definition curses.h:25
static void _store_curs_pos(WINDOW *win, struct cursor_pos *pos)
Store cursor position for later restoration.
Definition cursor.h:33
static void _restore_curs_pos(WINDOW *win, struct cursor_pos *pos)
Restore cursor position from encoded backup variable.
Definition cursor.h:23
void _wputc(WINDOW *win, char c, int wrap) __nonnull
Write a single character to a window.
Definition mucurses.c:78
#define WRAP
Definition mucurses.h:13
unsigned int curs_x
window cursor position
Definition curses.h:98
unsigned int curs_y
Definition curses.h:98

References _restore_curs_pos(), _store_curs_pos(), _wputc(), _curses_window::curs_x, _curses_window::curs_y, OK, and WRAP.

Referenced by clrtobot(), and werase().

◆ wclrtoeol()

int wclrtoeol ( WINDOW * win)

Clear a window to the end of the current line.

Parameters
*winsubject window
Return values
rcreturn status code

Definition at line 38 of file clear.c.

38 {
39 struct cursor_pos pos;
40
41 _store_curs_pos( win, &pos );
42 while ( ( win->curs_y - pos.y ) == 0 ) {
43 _wputc( win, ' ', WRAP );
44 }
45 _restore_curs_pos( win, &pos );
46
47 return OK;
48}

References _restore_curs_pos(), _store_curs_pos(), _wputc(), _curses_window::curs_y, OK, WRAP, and cursor_pos::y.

Referenced by clrtoeol(), slk_clear(), and wdeleteln().

◆ wdelch()

int wdelch ( WINDOW * win)

Delete character under the cursor in a window.

Parameters
*winsubject window
Return values
rcreturn status code

Definition at line 56 of file clear.c.

56 {
57 _wputc( win, ' ', NOWRAP );
58 _wcursback( win );
59
60 return OK;
61}
void _wcursback(WINDOW *win) __nonnull
Retreat the cursor back one position (useful for a whole host of ops)
Definition mucurses.c:88
#define NOWRAP
Definition mucurses.h:14

References _wcursback(), _wputc(), NOWRAP, and OK.

Referenced by delch(), mvdelch(), mvwdelch(), wgetch(), and wgetnstr().

◆ wdeleteln()

int wdeleteln ( WINDOW * win)

Delete line under a window's cursor.

Parameters
*winsubject window
Return values
rcreturn status code

Definition at line 69 of file clear.c.

69 {
70 struct cursor_pos pos;
71
72 _store_curs_pos( win, &pos );
73 /* let's just set the cursor to the beginning of the line and
74 let wclrtoeol do the work :) */
75 wmove( win, win->curs_y, 0 );
76 wclrtoeol( win );
77 _restore_curs_pos( win, &pos );
78 return OK;
79}
int wclrtoeol(WINDOW *win)
Clear a window to the end of the current line.
Definition clear.c:38
int wmove(WINDOW *win, int y, int x) __nonnull
Move a window's cursor to the specified position.
Definition mucurses.c:136

References _restore_curs_pos(), _store_curs_pos(), _curses_window::curs_y, OK, wclrtoeol(), and wmove().

Referenced by deleteln().

◆ werase()

int werase ( WINDOW * win)

Completely clear a window.

Parameters
*winsubject window
Return values
rcreturn status code

Definition at line 87 of file clear.c.

87 {
88 wmove( win, 0, 0 );
89 wclrtobot( win );
90 return OK;
91}
int wclrtobot(WINDOW *win)
Clear a window to the bottom from current cursor position.
Definition clear.c:20

References OK, wclrtobot(), and wmove().

◆ erase()

int erase ( void )

Completely clear the screen.

Return values
rcreturn status code

Definition at line 98 of file clear.c.

98 {
99 stdscr->scr->erase( stdscr->scr, stdscr->attrs );
100 return OK;
101}
#define stdscr
Definition curses.h:111

References OK, and stdscr.

Referenced by draw_form(), fdt_set(), settings_ui(), and show_menu().