1 /* Public Domain Curses */
5 RCSID("$Id: inchstr.c,v 1.34 2008/07/13 16:08:18 wmcbrine Exp $")
7 /*man-start**************************************************************
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);
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);
31 These routines read a chtype or cchar_t string from the window,
32 starting at the current or specified position, and ending at the
33 right margin, or after n elements, whichever is less.
36 All functions return the number of elements read, or ERR on
39 Portability X/Open BSD SYS V
57 **man-end****************************************************************/
59 int winchnstr(WINDOW
*win
, chtype
*ch
, int n
)
64 PDC_LOG(("winchnstr() - called\n"));
66 if (!win
|| !ch
|| n
< 0)
69 if ((win
->_curx
+ n
) > win
->_maxx
)
70 n
= win
->_maxx
- win
->_curx
;
72 src
= win
->_y
[win
->_cury
] + win
->_curx
;
74 for (i
= 0; i
< n
; i
++)
82 int inchstr(chtype
*ch
)
84 PDC_LOG(("inchstr() - called\n"));
86 return winchnstr(stdscr
, ch
, stdscr
->_maxx
- stdscr
->_curx
);
89 int winchstr(WINDOW
*win
, chtype
*ch
)
91 PDC_LOG(("winchstr() - called\n"));
93 return winchnstr(win
, ch
, win
->_maxx
- win
->_curx
);
96 int mvinchstr(int y
, int x
, chtype
*ch
)
98 PDC_LOG(("mvinchstr() - called: y %d x %d\n", y
, x
));
100 if (move(y
, x
) == ERR
)
103 return winchnstr(stdscr
, ch
, stdscr
->_maxx
- stdscr
->_curx
);
106 int mvwinchstr(WINDOW
*win
, int y
, int x
, chtype
*ch
)
108 PDC_LOG(("mvwinchstr() - called:\n"));
110 if (wmove(win
, y
, x
) == ERR
)
113 return winchnstr(win
, ch
, win
->_maxx
- win
->_curx
);
116 int inchnstr(chtype
*ch
, int n
)
118 PDC_LOG(("inchnstr() - called\n"));
120 return winchnstr(stdscr
, ch
, n
);
123 int mvinchnstr(int y
, int x
, chtype
*ch
, int n
)
125 PDC_LOG(("mvinchnstr() - called: y %d x %d n %d\n", y
, x
, n
));
127 if (move(y
, x
) == ERR
)
130 return winchnstr(stdscr
, ch
, n
);
133 int mvwinchnstr(WINDOW
*win
, int y
, int x
, chtype
*ch
, int n
)
135 PDC_LOG(("mvwinchnstr() - called: y %d x %d n %d \n", y
, x
, n
));
137 if (wmove(win
, y
, x
) == ERR
)
140 return winchnstr(win
, ch
, n
);
144 int win_wchnstr(WINDOW
*win
, cchar_t
*wch
, int n
)
146 PDC_LOG(("win_wchnstr() - called\n"));
148 return winchnstr(win
, wch
, n
);
151 int in_wchstr(cchar_t
*wch
)
153 PDC_LOG(("in_wchstr() - called\n"));
155 return win_wchnstr(stdscr
, wch
, stdscr
->_maxx
- stdscr
->_curx
);
158 int win_wchstr(WINDOW
*win
, cchar_t
*wch
)
160 PDC_LOG(("win_wchstr() - called\n"));
162 return win_wchnstr(win
, wch
, win
->_maxx
- win
->_curx
);
165 int mvin_wchstr(int y
, int x
, cchar_t
*wch
)
167 PDC_LOG(("mvin_wchstr() - called: y %d x %d\n", y
, x
));
169 if (move(y
, x
) == ERR
)
172 return win_wchnstr(stdscr
, wch
, stdscr
->_maxx
- stdscr
->_curx
);
175 int mvwin_wchstr(WINDOW
*win
, int y
, int x
, cchar_t
*wch
)
177 PDC_LOG(("mvwin_wchstr() - called:\n"));
179 if (wmove(win
, y
, x
) == ERR
)
182 return win_wchnstr(win
, wch
, win
->_maxx
- win
->_curx
);
185 int in_wchnstr(cchar_t
*wch
, int n
)
187 PDC_LOG(("in_wchnstr() - called\n"));
189 return win_wchnstr(stdscr
, wch
, n
);
192 int mvin_wchnstr(int y
, int x
, cchar_t
*wch
, int n
)
194 PDC_LOG(("mvin_wchnstr() - called: y %d x %d n %d\n", y
, x
, n
));
196 if (move(y
, x
) == ERR
)
199 return win_wchnstr(stdscr
, wch
, n
);
202 int mvwin_wchnstr(WINDOW
*win
, int y
, int x
, cchar_t
*wch
, int n
)
204 PDC_LOG(("mvwinchnstr() - called: y %d x %d n %d \n", y
, x
, n
));
206 if (wmove(win
, y
, x
) == ERR
)
209 return win_wchnstr(win
, wch
, n
);