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/] [addstr.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: addstr.c,v 1.1 2009/05/10 08:29:53 jld Exp $")
6
 
7
/*man-start**************************************************************
8
 
9
  Name:                                                         addstr
10
 
11
  Synopsis:
12
        int addstr(const char *str);
13
        int addnstr(const char *str, int n);
14
        int waddstr(WINDOW *win, const char *str);
15
        int waddnstr(WINDOW *win, const char *str, int n);
16
        int mvaddstr(int y, int x, const char *str);
17
        int mvaddnstr(int y, int x, const char *str, int n);
18
        int mvwaddstr(WINDOW *win, int y, int x, const char *str);
19
        int mvwaddnstr(WINDOW *win, int y, int x, const char *str, int n);
20
 
21
        int addwstr(const wchar_t *wstr);
22
        int addnwstr(const wchar_t *wstr, int n);
23
        int waddwstr(WINDOW *win, const wchar_t *wstr);
24
        int waddnwstr(WINDOW *win, const wchar_t *wstr, int n);
25
        int mvaddwstr(int y, int x, const wchar_t *wstr);
26
        int mvaddnwstr(int y, int x, const wchar_t *wstr, int n);
27
        int mvwaddwstr(WINDOW *win, int y, int x, const wchar_t *wstr);
28
        int mvwaddnwstr(WINDOW *win, int y, int x, const wchar_t *wstr, int n);
29
 
30
  Description:
31
        These routines write all the characters of the null-terminated
32
        string str or wide-character string wstr to the given window.
33
        The functionality is similar to calling waddch() once for each
34
        character in the string; except that, when PDCurses is built
35
        with wide-character support enabled, the narrow-character
36
        functions treat the string as a multibyte string in the current
37
        locale, and convert it. The routines with n as the last
38
        argument write at most n characters; if n is negative, then the
39
        entire string will be added.
40
 
41
  Return Value:
42
        All functions return OK or ERR.
43
 
44
  Portability                                X/Open    BSD    SYS V
45
        addstr                                  Y       Y       Y
46
        waddstr                                 Y       Y       Y
47
        mvaddstr                                Y       Y       Y
48
        mvwaddstr                               Y       Y       Y
49
        addnstr                                 Y       -      4.0
50
        waddnstr                                Y       -      4.0
51
        mvaddnstr                               Y       -      4.0
52
        mvwaddnstr                              Y       -      4.0
53
        addwstr                                 Y
54
        waddwstr                                Y
55
        mvaddwstr                               Y
56
        mvwaddwstr                              Y
57
        addnwstr                                Y
58
        waddnwstr                               Y
59
        mvaddnwstr                              Y
60
        mvwaddnwstr                             Y
61
 
62
**man-end****************************************************************/
63
 
64
int waddnstr(WINDOW *win, const char *str, int n)
65
{
66
    int i = 0;
67
 
68
    PDC_LOG(("waddnstr() - called: string=\"%s\" n %d \n", str, n));
69
 
70
    if (!win || !str)
71
        return ERR;
72
 
73
    while (str[i] && (i < n || n < 0))
74
    {
75
#ifdef PDC_WIDE
76
        wchar_t wch;
77
        int retval = PDC_mbtowc(&wch, str + i, n >= 0 ? n - i : 6);
78
 
79
        if (retval <= 0)
80
            return OK;
81
 
82
        i += retval;
83
#else
84
        chtype wch = (unsigned char)(str[i++]);
85
#endif
86
        if (waddch(win, wch) == ERR)
87
            return ERR;
88
    }
89
 
90
    return OK;
91
}
92
 
93
int addstr(const char *str)
94
{
95
    PDC_LOG(("addstr() - called: string=\"%s\"\n", str));
96
 
97
    return waddnstr(stdscr, str, -1);
98
}
99
 
100
int addnstr(const char *str, int n)
101
{
102
    PDC_LOG(("addnstr() - called: string=\"%s\" n %d \n", str, n));
103
 
104
    return waddnstr(stdscr, str, n);
105
}
106
 
107
int waddstr(WINDOW *win, const char *str)
108
{
109
    PDC_LOG(("waddstr() - called: string=\"%s\"\n", str));
110
 
111
    return waddnstr(win, str, -1);
112
}
113
 
114
int mvaddstr(int y, int x, const char *str)
115
{
116
    PDC_LOG(("mvaddstr() - called: y %d x %d string=\"%s\"\n", y, x, str));
117
 
118
    if (move(y, x) == ERR)
119
        return ERR;
120
 
121
    return waddnstr(stdscr, str, -1);
122
}
123
 
124
int mvaddnstr(int y, int x, const char *str, int n)
125
{
126
    PDC_LOG(("mvaddnstr() - called: y %d x %d string=\"%s\" n %d \n",
127
             y, x, str, n));
128
 
129
    if (move(y, x) == ERR)
130
        return ERR;
131
 
132
    return waddnstr(stdscr, str, n);
133
}
134
 
135
int mvwaddstr(WINDOW *win, int y, int x, const char *str)
136
{
137
    PDC_LOG(("mvwaddstr() - called: string=\"%s\"\n", str));
138
 
139
    if (wmove(win, y, x) == ERR)
140
        return ERR;
141
 
142
    return waddnstr(win, str, -1);
143
}
144
 
145
int mvwaddnstr(WINDOW *win, int y, int x, const char *str, int n)
146
{
147
    PDC_LOG(("mvwaddnstr() - called: y %d x %d string=\"%s\" n %d \n",
148
             y, x, str, n));
149
 
150
    if (wmove(win, y, x) == ERR)
151
        return ERR;
152
 
153
    return waddnstr(win, str, n);
154
}
155
 
156
#ifdef PDC_WIDE
157
int waddnwstr(WINDOW *win, const wchar_t *wstr, int n)
158
{
159
    int i = 0;
160
 
161
    PDC_LOG(("waddnwstr() - called\n"));
162
 
163
    if (!win || !wstr)
164
        return ERR;
165
 
166
    while (wstr[i] && (i < n || n < 0))
167
    {
168
        chtype wch = wstr[i++];
169
 
170
        if (waddch(win, wch) == ERR)
171
            return ERR;
172
    }
173
 
174
    return OK;
175
}
176
 
177
int addwstr(const wchar_t *wstr)
178
{
179
    PDC_LOG(("addwstr() - called\n"));
180
 
181
    return waddnwstr(stdscr, wstr, -1);
182
}
183
 
184
int addnwstr(const wchar_t *wstr, int n)
185
{
186
    PDC_LOG(("addnwstr() - called\n"));
187
 
188
    return waddnwstr(stdscr, wstr, n);
189
}
190
 
191
int waddwstr(WINDOW *win, const wchar_t *wstr)
192
{
193
    PDC_LOG(("waddwstr() - called\n"));
194
 
195
    return waddnwstr(win, wstr, -1);
196
}
197
 
198
int mvaddwstr(int y, int x, const wchar_t *wstr)
199
{
200
    PDC_LOG(("mvaddstr() - called\n"));
201
 
202
    if (move(y, x) == ERR)
203
        return ERR;
204
 
205
    return waddnwstr(stdscr, wstr, -1);
206
}
207
 
208
int mvaddnwstr(int y, int x, const wchar_t *wstr, int n)
209
{
210
    PDC_LOG(("mvaddnstr() - called\n"));
211
 
212
    if (move(y, x) == ERR)
213
        return ERR;
214
 
215
    return waddnwstr(stdscr, wstr, n);
216
}
217
 
218
int mvwaddwstr(WINDOW *win, int y, int x, const wchar_t *wstr)
219
{
220
    PDC_LOG(("mvwaddstr() - called\n"));
221
 
222
    if (wmove(win, y, x) == ERR)
223
        return ERR;
224
 
225
    return waddnwstr(win, wstr, -1);
226
}
227
 
228
int mvwaddnwstr(WINDOW *win, int y, int x, const wchar_t *wstr, int n)
229
{
230
    PDC_LOG(("mvwaddnstr() - called\n"));
231
 
232
    if (wmove(win, y, x) == ERR)
233
        return ERR;
234
 
235
    return waddnwstr(win, wstr, n);
236
}
237
#endif

powered by: WebSVN 2.1.0

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