OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [services/] [curses/] [pdcurses/] [current/] [src/] [pdcurses/] [clear.c] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
/* Public Domain Curses */
2
 
3
#include <curspriv.h>
4
 
5
RCSID("$Id: clear.c,v 1.1 2009/05/10 08:29:53 jld Exp $")
6
 
7
/*man-start**************************************************************
8
 
9
  Name:                                                         clear
10
 
11
  Synopsis:
12
        int clear(void);
13
        int wclear(WINDOW *win);
14
        int erase(void);
15
        int werase(WINDOW *win);
16
        int clrtobot(void);
17
        int wclrtobot(WINDOW *win);
18
        int clrtoeol(void);
19
        int wclrtoeol(WINDOW *win);
20
 
21
  Description:
22
        erase() and werase() copy blanks (i.e. the background chtype) to
23
        every cell of the window.
24
 
25
        clear() and wclear() are similar to erase() and werase(), but
26
        they also call clearok() to ensure that the the window is
27
        cleared on the next wrefresh().
28
 
29
        clrtobot() and wclrtobot() clear the window from the current
30
        cursor position to the end of the window.
31
 
32
        clrtoeol() and wclrtoeol() clear the window from the current
33
        cursor position to the end of the current line.
34
 
35
  Return Value:
36
        All functions return OK on success and ERR on error.
37
 
38
  Portability                                X/Open    BSD    SYS V
39
        clear                                   Y       Y       Y
40
        wclear                                  Y       Y       Y
41
        erase                                   Y       Y       Y
42
        werase                                  Y       Y       Y
43
        clrtobot                                Y       Y       Y
44
        wclrtobot                               Y       Y       Y
45
        clrtoeol                                Y       Y       Y
46
        wclrtoeol                               Y       Y       Y
47
 
48
**man-end****************************************************************/
49
 
50
int wclrtoeol(WINDOW *win)
51
{
52
    int x, y, minx;
53
    chtype blank, *ptr;
54
 
55
    PDC_LOG(("wclrtoeol() - called: Row: %d Col: %d\n",
56
             win->_cury, win->_curx));
57
 
58
    if (!win)
59
        return ERR;
60
 
61
    y = win->_cury;
62
    x = win->_curx;
63
 
64
    /* wrs (4/10/93) account for window background */
65
 
66
    blank = win->_bkgd;
67
 
68
    for (minx = x, ptr = &win->_y[y][x]; minx < win->_maxx; minx++, ptr++)
69
        *ptr = blank;
70
 
71
    if (x < win->_firstch[y] || win->_firstch[y] == _NO_CHANGE)
72
        win->_firstch[y] = x;
73
 
74
    win->_lastch[y] = win->_maxx - 1;
75
 
76
    PDC_sync(win);
77
    return OK;
78
}
79
 
80
int clrtoeol(void)
81
{
82
    PDC_LOG(("clrtoeol() - called\n"));
83
 
84
    return wclrtoeol(stdscr);
85
}
86
 
87
int wclrtobot(WINDOW *win)
88
{
89
    int savey = win->_cury;
90
    int savex = win->_curx;
91
 
92
    PDC_LOG(("wclrtobot() - called\n"));
93
 
94
    if (!win)
95
        return ERR;
96
 
97
    /* should this involve scrolling region somehow ? */
98
 
99
    if (win->_cury + 1 < win->_maxy)
100
    {
101
        win->_curx = 0;
102
        win->_cury++;
103
        for (; win->_maxy > win->_cury; win->_cury++)
104
            wclrtoeol(win);
105
        win->_cury = savey;
106
        win->_curx = savex;
107
    }
108
    wclrtoeol(win);
109
 
110
    PDC_sync(win);
111
    return OK;
112
}
113
 
114
int clrtobot(void)
115
{
116
    PDC_LOG(("clrtobot() - called\n"));
117
 
118
    return wclrtobot(stdscr);
119
}
120
 
121
int werase(WINDOW *win)
122
{
123
    PDC_LOG(("werase() - called\n"));
124
 
125
    if (wmove(win, 0, 0) == ERR)
126
        return ERR;
127
 
128
    return wclrtobot(win);
129
}
130
 
131
int erase(void)
132
{
133
    PDC_LOG(("erase() - called\n"));
134
 
135
    return werase(stdscr);
136
}
137
 
138
int wclear(WINDOW *win)
139
{
140
    PDC_LOG(("wclear() - called\n"));
141
 
142
    if (!win)
143
        return ERR;
144
 
145
    win->_clear = TRUE;
146
    return werase(win);
147
}
148
 
149
int clear(void)
150
{
151
    PDC_LOG(("clear() - called\n"));
152
 
153
    return wclear(stdscr);
154
}

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.