Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Utilities/cmpdcurses/pdcurses/inchstr.c
3153 views
1
/* PDCurses */
2
3
#include <curspriv.h>
4
5
/*man-start**************************************************************
6
7
inchstr
8
-------
9
10
### Synopsis
11
12
int inchstr(chtype *ch);
13
int inchnstr(chtype *ch, int n);
14
int winchstr(WINDOW *win, chtype *ch);
15
int winchnstr(WINDOW *win, chtype *ch, int n);
16
int mvinchstr(int y, int x, chtype *ch);
17
int mvinchnstr(int y, int x, chtype *ch, int n);
18
int mvwinchstr(WINDOW *, int y, int x, chtype *ch);
19
int mvwinchnstr(WINDOW *, int y, int x, chtype *ch, int n);
20
21
int in_wchstr(cchar_t *wch);
22
int in_wchnstr(cchar_t *wch, int n);
23
int win_wchstr(WINDOW *win, cchar_t *wch);
24
int win_wchnstr(WINDOW *win, cchar_t *wch, int n);
25
int mvin_wchstr(int y, int x, cchar_t *wch);
26
int mvin_wchnstr(int y, int x, cchar_t *wch, int n);
27
int mvwin_wchstr(WINDOW *win, int y, int x, cchar_t *wch);
28
int mvwin_wchnstr(WINDOW *win, int y, int x, cchar_t *wch, int n);
29
30
### Description
31
32
These routines read a chtype or cchar_t string from the window,
33
starting at the current or specified position, and ending at the
34
right margin, or after n elements, whichever is less.
35
36
### Return Value
37
38
All functions return the number of elements read, or ERR on error.
39
40
### Portability
41
X/Open ncurses NetBSD
42
inchstr Y Y Y
43
winchstr Y Y Y
44
mvinchstr Y Y Y
45
mvwinchstr Y Y Y
46
inchnstr Y Y Y
47
winchnstr Y Y Y
48
mvinchnstr Y Y Y
49
mvwinchnstr Y Y Y
50
in_wchstr Y Y Y
51
win_wchstr Y Y Y
52
mvin_wchstr Y Y Y
53
mvwin_wchstr Y Y Y
54
in_wchnstr Y Y Y
55
win_wchnstr Y Y Y
56
mvin_wchnstr Y Y Y
57
mvwin_wchnstr Y Y Y
58
59
**man-end****************************************************************/
60
61
int winchnstr(WINDOW *win, chtype *ch, int n)
62
{
63
chtype *src;
64
int i;
65
66
PDC_LOG(("winchnstr() - called\n"));
67
68
if (!win || !ch || n < 0)
69
return ERR;
70
71
if ((win->_curx + n) > win->_maxx)
72
n = win->_maxx - win->_curx;
73
74
src = win->_y[win->_cury] + win->_curx;
75
76
for (i = 0; i < n; i++)
77
*ch++ = *src++;
78
79
*ch = (chtype)0;
80
81
return OK;
82
}
83
84
int inchstr(chtype *ch)
85
{
86
PDC_LOG(("inchstr() - called\n"));
87
88
return winchnstr(stdscr, ch, stdscr->_maxx - stdscr->_curx);
89
}
90
91
int winchstr(WINDOW *win, chtype *ch)
92
{
93
PDC_LOG(("winchstr() - called\n"));
94
95
return winchnstr(win, ch, win->_maxx - win->_curx);
96
}
97
98
int mvinchstr(int y, int x, chtype *ch)
99
{
100
PDC_LOG(("mvinchstr() - called: y %d x %d\n", y, x));
101
102
if (move(y, x) == ERR)
103
return ERR;
104
105
return winchnstr(stdscr, ch, stdscr->_maxx - stdscr->_curx);
106
}
107
108
int mvwinchstr(WINDOW *win, int y, int x, chtype *ch)
109
{
110
PDC_LOG(("mvwinchstr() - called:\n"));
111
112
if (wmove(win, y, x) == ERR)
113
return ERR;
114
115
return winchnstr(win, ch, win->_maxx - win->_curx);
116
}
117
118
int inchnstr(chtype *ch, int n)
119
{
120
PDC_LOG(("inchnstr() - called\n"));
121
122
return winchnstr(stdscr, ch, n);
123
}
124
125
int mvinchnstr(int y, int x, chtype *ch, int n)
126
{
127
PDC_LOG(("mvinchnstr() - called: y %d x %d n %d\n", y, x, n));
128
129
if (move(y, x) == ERR)
130
return ERR;
131
132
return winchnstr(stdscr, ch, n);
133
}
134
135
int mvwinchnstr(WINDOW *win, int y, int x, chtype *ch, int n)
136
{
137
PDC_LOG(("mvwinchnstr() - called: y %d x %d n %d \n", y, x, n));
138
139
if (wmove(win, y, x) == ERR)
140
return ERR;
141
142
return winchnstr(win, ch, n);
143
}
144
145
#ifdef PDC_WIDE
146
int win_wchnstr(WINDOW *win, cchar_t *wch, int n)
147
{
148
PDC_LOG(("win_wchnstr() - called\n"));
149
150
return winchnstr(win, wch, n);
151
}
152
153
int in_wchstr(cchar_t *wch)
154
{
155
PDC_LOG(("in_wchstr() - called\n"));
156
157
return win_wchnstr(stdscr, wch, stdscr->_maxx - stdscr->_curx);
158
}
159
160
int win_wchstr(WINDOW *win, cchar_t *wch)
161
{
162
PDC_LOG(("win_wchstr() - called\n"));
163
164
return win_wchnstr(win, wch, win->_maxx - win->_curx);
165
}
166
167
int mvin_wchstr(int y, int x, cchar_t *wch)
168
{
169
PDC_LOG(("mvin_wchstr() - called: y %d x %d\n", y, x));
170
171
if (move(y, x) == ERR)
172
return ERR;
173
174
return win_wchnstr(stdscr, wch, stdscr->_maxx - stdscr->_curx);
175
}
176
177
int mvwin_wchstr(WINDOW *win, int y, int x, cchar_t *wch)
178
{
179
PDC_LOG(("mvwin_wchstr() - called:\n"));
180
181
if (wmove(win, y, x) == ERR)
182
return ERR;
183
184
return win_wchnstr(win, wch, win->_maxx - win->_curx);
185
}
186
187
int in_wchnstr(cchar_t *wch, int n)
188
{
189
PDC_LOG(("in_wchnstr() - called\n"));
190
191
return win_wchnstr(stdscr, wch, n);
192
}
193
194
int mvin_wchnstr(int y, int x, cchar_t *wch, int n)
195
{
196
PDC_LOG(("mvin_wchnstr() - called: y %d x %d n %d\n", y, x, n));
197
198
if (move(y, x) == ERR)
199
return ERR;
200
201
return win_wchnstr(stdscr, wch, n);
202
}
203
204
int mvwin_wchnstr(WINDOW *win, int y, int x, cchar_t *wch, int n)
205
{
206
PDC_LOG(("mvwinchnstr() - called: y %d x %d n %d \n", y, x, n));
207
208
if (wmove(win, y, x) == ERR)
209
return ERR;
210
211
return win_wchnstr(win, wch, n);
212
}
213
#endif
214
215