Path: blob/master/Utilities/cmpdcurses/pdcurses/inchstr.c
3153 views
/* PDCurses */12#include <curspriv.h>34/*man-start**************************************************************56inchstr7-------89### Synopsis1011int inchstr(chtype *ch);12int inchnstr(chtype *ch, int n);13int winchstr(WINDOW *win, chtype *ch);14int winchnstr(WINDOW *win, chtype *ch, int n);15int mvinchstr(int y, int x, chtype *ch);16int mvinchnstr(int y, int x, chtype *ch, int n);17int mvwinchstr(WINDOW *, int y, int x, chtype *ch);18int mvwinchnstr(WINDOW *, int y, int x, chtype *ch, int n);1920int in_wchstr(cchar_t *wch);21int in_wchnstr(cchar_t *wch, int n);22int win_wchstr(WINDOW *win, cchar_t *wch);23int win_wchnstr(WINDOW *win, cchar_t *wch, int n);24int mvin_wchstr(int y, int x, cchar_t *wch);25int mvin_wchnstr(int y, int x, cchar_t *wch, int n);26int mvwin_wchstr(WINDOW *win, int y, int x, cchar_t *wch);27int mvwin_wchnstr(WINDOW *win, int y, int x, cchar_t *wch, int n);2829### Description3031These routines read a chtype or cchar_t string from the window,32starting at the current or specified position, and ending at the33right margin, or after n elements, whichever is less.3435### Return Value3637All functions return the number of elements read, or ERR on error.3839### Portability40X/Open ncurses NetBSD41inchstr Y Y Y42winchstr Y Y Y43mvinchstr Y Y Y44mvwinchstr Y Y Y45inchnstr Y Y Y46winchnstr Y Y Y47mvinchnstr Y Y Y48mvwinchnstr Y Y Y49in_wchstr Y Y Y50win_wchstr Y Y Y51mvin_wchstr Y Y Y52mvwin_wchstr Y Y Y53in_wchnstr Y Y Y54win_wchnstr Y Y Y55mvin_wchnstr Y Y Y56mvwin_wchnstr Y Y Y5758**man-end****************************************************************/5960int winchnstr(WINDOW *win, chtype *ch, int n)61{62chtype *src;63int i;6465PDC_LOG(("winchnstr() - called\n"));6667if (!win || !ch || n < 0)68return ERR;6970if ((win->_curx + n) > win->_maxx)71n = win->_maxx - win->_curx;7273src = win->_y[win->_cury] + win->_curx;7475for (i = 0; i < n; i++)76*ch++ = *src++;7778*ch = (chtype)0;7980return OK;81}8283int inchstr(chtype *ch)84{85PDC_LOG(("inchstr() - called\n"));8687return winchnstr(stdscr, ch, stdscr->_maxx - stdscr->_curx);88}8990int winchstr(WINDOW *win, chtype *ch)91{92PDC_LOG(("winchstr() - called\n"));9394return winchnstr(win, ch, win->_maxx - win->_curx);95}9697int mvinchstr(int y, int x, chtype *ch)98{99PDC_LOG(("mvinchstr() - called: y %d x %d\n", y, x));100101if (move(y, x) == ERR)102return ERR;103104return winchnstr(stdscr, ch, stdscr->_maxx - stdscr->_curx);105}106107int mvwinchstr(WINDOW *win, int y, int x, chtype *ch)108{109PDC_LOG(("mvwinchstr() - called:\n"));110111if (wmove(win, y, x) == ERR)112return ERR;113114return winchnstr(win, ch, win->_maxx - win->_curx);115}116117int inchnstr(chtype *ch, int n)118{119PDC_LOG(("inchnstr() - called\n"));120121return winchnstr(stdscr, ch, n);122}123124int mvinchnstr(int y, int x, chtype *ch, int n)125{126PDC_LOG(("mvinchnstr() - called: y %d x %d n %d\n", y, x, n));127128if (move(y, x) == ERR)129return ERR;130131return winchnstr(stdscr, ch, n);132}133134int mvwinchnstr(WINDOW *win, int y, int x, chtype *ch, int n)135{136PDC_LOG(("mvwinchnstr() - called: y %d x %d n %d \n", y, x, n));137138if (wmove(win, y, x) == ERR)139return ERR;140141return winchnstr(win, ch, n);142}143144#ifdef PDC_WIDE145int win_wchnstr(WINDOW *win, cchar_t *wch, int n)146{147PDC_LOG(("win_wchnstr() - called\n"));148149return winchnstr(win, wch, n);150}151152int in_wchstr(cchar_t *wch)153{154PDC_LOG(("in_wchstr() - called\n"));155156return win_wchnstr(stdscr, wch, stdscr->_maxx - stdscr->_curx);157}158159int win_wchstr(WINDOW *win, cchar_t *wch)160{161PDC_LOG(("win_wchstr() - called\n"));162163return win_wchnstr(win, wch, win->_maxx - win->_curx);164}165166int mvin_wchstr(int y, int x, cchar_t *wch)167{168PDC_LOG(("mvin_wchstr() - called: y %d x %d\n", y, x));169170if (move(y, x) == ERR)171return ERR;172173return win_wchnstr(stdscr, wch, stdscr->_maxx - stdscr->_curx);174}175176int mvwin_wchstr(WINDOW *win, int y, int x, cchar_t *wch)177{178PDC_LOG(("mvwin_wchstr() - called:\n"));179180if (wmove(win, y, x) == ERR)181return ERR;182183return win_wchnstr(win, wch, win->_maxx - win->_curx);184}185186int in_wchnstr(cchar_t *wch, int n)187{188PDC_LOG(("in_wchnstr() - called\n"));189190return win_wchnstr(stdscr, wch, n);191}192193int mvin_wchnstr(int y, int x, cchar_t *wch, int n)194{195PDC_LOG(("mvin_wchnstr() - called: y %d x %d n %d\n", y, x, n));196197if (move(y, x) == ERR)198return ERR;199200return win_wchnstr(stdscr, wch, n);201}202203int mvwin_wchnstr(WINDOW *win, int y, int x, cchar_t *wch, int n)204{205PDC_LOG(("mvwinchnstr() - called: y %d x %d n %d \n", y, x, n));206207if (wmove(win, y, x) == ERR)208return ERR;209210return win_wchnstr(win, wch, n);211}212#endif213214215