libpayload: Add PDCurses and ncurses' libform/libmenu
[coreboot.git] / payloads / libpayload / curses / PDCurses-3.4 / pdcurses / delch.c
1 /* Public Domain Curses */
2
3 #include <curspriv.h>
4
5 RCSID("$Id: delch.c,v 1.33 2008/07/13 16:08:18 wmcbrine Exp $")
6
7 /*man-start**************************************************************
8
9   Name:                                                         delch
10
11   Synopsis:
12         int delch(void);
13         int wdelch(WINDOW *win);
14         int mvdelch(int y, int x);
15         int mvwdelch(WINDOW *win, int y, int x);
16
17   Description:
18         The character under the cursor in the window is deleted.  All
19         characters to the right on the same line are moved to the left
20         one position and the last character on the line is filled with
21         a blank.  The cursor position does not change (after moving to
22         y, x if coordinates are specified).
23
24   Return Value:
25         All functions return OK on success and ERR on error.
26
27   Portability                                X/Open    BSD    SYS V
28         delch                                   Y       Y       Y
29         wdelch                                  Y       Y       Y
30         mvdelch                                 Y       Y       Y
31         mvwdelch                                Y       Y       Y
32
33 **man-end****************************************************************/
34
35 #include <string.h>
36
37 int wdelch(WINDOW *win)
38 {
39     int y, x, maxx;
40     chtype *temp1;
41
42     PDC_LOG(("wdelch() - called\n"));
43
44     if (!win)
45         return ERR;
46
47     y = win->_cury;
48     x = win->_curx;
49     maxx = win->_maxx - 1;
50     temp1 = &win->_y[y][x];
51
52     memmove(temp1, temp1 + 1, (maxx - x) * sizeof(chtype));
53
54     /* wrs (4/10/93) account for window background */
55
56     win->_y[y][maxx] = win->_bkgd;
57
58     win->_lastch[y] = maxx;
59
60     if ((win->_firstch[y] == _NO_CHANGE) || (win->_firstch[y] > x))
61         win->_firstch[y] = x;
62
63     PDC_sync(win);
64
65     return OK;
66 }
67
68 int delch(void)
69 {
70     PDC_LOG(("delch() - called\n"));
71
72     return wdelch(stdscr);
73 }
74
75 int mvdelch(int y, int x)
76 {
77     PDC_LOG(("mvdelch() - called\n"));
78
79     if (move(y, x) == ERR)
80         return ERR;
81
82     return wdelch(stdscr);
83 }
84
85 int mvwdelch(WINDOW *win, int y, int x)
86 {
87     PDC_LOG(("mvwdelch() - called\n"));
88
89     if (wmove(win, y, x) == ERR)
90         return ERR;
91
92     return wdelch(win);
93 }