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/] [instr.c] - Blame information for rev 819

Go to most recent revision | 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: instr.c,v 1.1 2009/05/10 08:29:53 jld Exp $")
6
 
7
/*man-start**************************************************************
8
 
9
  Name:                                                         instr
10
 
11
  Synopsis:
12
        int instr(char *str);
13
        int innstr(char *str, int n);
14
        int winstr(WINDOW *win, char *str);
15
        int winnstr(WINDOW *win, char *str, int n);
16
        int mvinstr(int y, int x, char *str);
17
        int mvinnstr(int y, int x, char *str, int n);
18
        int mvwinstr(WINDOW *win, int y, int x, char *str);
19
        int mvwinnstr(WINDOW *win, int y, int x, char *str, int n);
20
 
21
        int inwstr(wchar_t *wstr);
22
        int innwstr(wchar_t *wstr, int n);
23
        int winwstr(WINDOW *win, wchar_t *wstr);
24
        int winnwstr(WINDOW *win, wchar_t *wstr, int n);
25
        int mvinwstr(int y, int x, wchar_t *wstr);
26
        int mvinnwstr(int y, int x, wchar_t *wstr, int n);
27
        int mvwinwstr(WINDOW *win, int y, int x, wchar_t *wstr);
28
        int mvwinnwstr(WINDOW *win, int y, int x, wchar_t *wstr, int n);
29
 
30
  Description:
31
        These functions take characters (or wide characters) from the
32
        current or specified position in the window, and return them as
33
        a string in str (or wstr). Attributes are ignored. The functions
34
        with n as the last argument return a string at most n characters
35
        long.
36
 
37
  Return Value:
38
        Upon successful completion, innstr(), mvinnstr(), mvwinnstr()
39
        and winnstr() return the number of characters actually read into
40
        the string; instr(), mvinstr(), mvwinstr() and winstr() return
41
        OK. Otherwise, all these functions return ERR.
42
 
43
  Portability                                X/Open    BSD    SYS V
44
        instr                                   Y       -      4.0
45
        winstr                                  Y       -      4.0
46
        mvinstr                                 Y       -      4.0
47
        mvwinstr                                Y       -      4.0
48
        innstr                                  Y       -      4.0
49
        winnstr                                 Y       -      4.0
50
        mvinnstr                                Y       -      4.0
51
        mvwinnstr                               Y       -      4.0
52
        inwstr                                  Y
53
        winwstr                                 Y
54
        mvinwstr                                Y
55
        mvwinwstr                               Y
56
        innwstr                                 Y
57
        winnwstr                                Y
58
        mvinnwstr                               Y
59
        mvwinnwstr                              Y
60
 
61
**man-end****************************************************************/
62
 
63
int winnstr(WINDOW *win, char *str, int n)
64
{
65
#ifdef PDC_WIDE
66
    wchar_t wstr[513];
67
 
68
    if (n < 0 || n > 512)
69
        n = 512;
70
 
71
    if (winnwstr(win, wstr, n) == ERR)
72
        return ERR;
73
 
74
    return PDC_wcstombs(str, wstr, n);
75
#else
76
    chtype *src;
77
    int i;
78
 
79
    PDC_LOG(("winnstr() - called: n %d \n", n));
80
 
81
    if (!win || !str)
82
        return ERR;
83
 
84
    if (n < 0 || (win->_curx + n) > win->_maxx)
85
        n = win->_maxx - win->_curx;
86
 
87
    src = win->_y[win->_cury] + win->_curx;
88
 
89
    for (i = 0; i < n; i++)
90
        str[i] = src[i] & A_CHARTEXT;
91
 
92
    str[i] = '\0';
93
 
94
    return i;
95
#endif
96
}
97
 
98
int instr(char *str)
99
{
100
    PDC_LOG(("instr() - called: string=\"%s\"\n", str));
101
 
102
    return (ERR == winnstr(stdscr, str, stdscr->_maxx)) ? ERR : OK;
103
}
104
 
105
int winstr(WINDOW *win, char *str)
106
{
107
    PDC_LOG(("winstr() - called: \n"));
108
 
109
    return (ERR == winnstr(win, str, win->_maxx)) ? ERR : OK;
110
}
111
 
112
int mvinstr(int y, int x, char *str)
113
{
114
    PDC_LOG(("mvinstr() - called: y %d x %d \n", y, x));
115
 
116
    if (move(y, x) == ERR)
117
        return ERR;
118
 
119
    return (ERR == winnstr(stdscr, str, stdscr->_maxx)) ? ERR : OK;
120
}
121
 
122
int mvwinstr(WINDOW *win, int y, int x, char *str)
123
{
124
    PDC_LOG(("mvwinstr() - called: y %d x %d \n", y, x));
125
 
126
    if (wmove(win, y, x) == ERR)
127
        return ERR;
128
 
129
    return (ERR == winnstr(win, str, win->_maxx)) ? ERR : OK;
130
}
131
 
132
int innstr(char *str, int n)
133
{
134
    PDC_LOG(("innstr() - called: n %d \n", n));
135
 
136
    return winnstr(stdscr, str, n);
137
}
138
 
139
int mvinnstr(int y, int x, char *str, int n)
140
{
141
    PDC_LOG(("mvinnstr() - called: y %d x %d n %d \n", y, x, n));
142
 
143
    if (move(y, x) == ERR)
144
        return ERR;
145
 
146
    return winnstr(stdscr, str, n);
147
}
148
 
149
int mvwinnstr(WINDOW *win, int y, int x, char *str, int n)
150
{
151
    PDC_LOG(("mvwinnstr() - called: y %d x %d n %d \n", y, x, n));
152
 
153
    if (wmove(win, y, x) == ERR)
154
        return ERR;
155
 
156
    return winnstr(win, str, n);
157
}
158
 
159
#ifdef PDC_WIDE
160
int winnwstr(WINDOW *win, wchar_t *wstr, int n)
161
{
162
    chtype *src;
163
    int i;
164
 
165
    PDC_LOG(("winnstr() - called: n %d \n", n));
166
 
167
    if (!win || !wstr)
168
        return ERR;
169
 
170
    if (n < 0 || (win->_curx + n) > win->_maxx)
171
        n = win->_maxx - win->_curx;
172
 
173
    src = win->_y[win->_cury] + win->_curx;
174
 
175
    for (i = 0; i < n; i++)
176
        wstr[i] = src[i] & A_CHARTEXT;
177
 
178
    wstr[i] = L'\0';
179
 
180
    return i;
181
}
182
 
183
int inwstr(wchar_t *wstr)
184
{
185
    PDC_LOG(("inwstr() - called\n"));
186
 
187
    return (ERR == winnwstr(stdscr, wstr, stdscr->_maxx)) ? ERR : OK;
188
}
189
 
190
int winwstr(WINDOW *win, wchar_t *wstr)
191
{
192
    PDC_LOG(("winwstr() - called\n"));
193
 
194
    return (ERR == winnwstr(win, wstr, win->_maxx)) ? ERR : OK;
195
}
196
 
197
int mvinwstr(int y, int x, wchar_t *wstr)
198
{
199
    PDC_LOG(("mvinwstr() - called\n"));
200
 
201
    if (move(y, x) == ERR)
202
        return ERR;
203
 
204
    return (ERR == winnwstr(stdscr, wstr, stdscr->_maxx)) ? ERR : OK;
205
}
206
 
207
int mvwinwstr(WINDOW *win, int y, int x, wchar_t *wstr)
208
{
209
    PDC_LOG(("mvwinstr() - called\n"));
210
 
211
    if (wmove(win, y, x) == ERR)
212
        return ERR;
213
 
214
    return (ERR == winnwstr(win, wstr, win->_maxx)) ? ERR : OK;
215
}
216
 
217
int innwstr(wchar_t *wstr, int n)
218
{
219
    PDC_LOG(("innwstr() - called\n"));
220
 
221
    return winnwstr(stdscr, wstr, n);
222
}
223
 
224
int mvinnwstr(int y, int x, wchar_t *wstr, int n)
225
{
226
    PDC_LOG(("mvinnstr() - called\n"));
227
 
228
    if (move(y, x) == ERR)
229
        return ERR;
230
 
231
    return winnwstr(stdscr, wstr, n);
232
}
233
 
234
int mvwinnwstr(WINDOW *win, int y, int x, wchar_t *wstr, int n)
235
{
236
    PDC_LOG(("mvwinnwstr() - called\n"));
237
 
238
    if (wmove(win, y, x) == ERR)
239
        return ERR;
240
 
241
    return winnwstr(win, wstr, n);
242
}
243
#endif

powered by: WebSVN 2.1.0

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