mirror of
https://github.com/VARCem/PDCurses.git
synced 2026-09-24 15:55:14 +00:00
Implementation of get_wch() family.
This commit is contained in:
12
curses.h
12
curses.h
@@ -11,7 +11,7 @@
|
||||
* See the file maintain.er for details of the current maintainer. *
|
||||
************************************************************************/
|
||||
|
||||
/* $Id: curses.h,v 1.239 2006/10/28 13:22:02 wmcbrine Exp $ */
|
||||
/* $Id: curses.h,v 1.240 2006/10/29 12:05:13 wmcbrine Exp $ */
|
||||
|
||||
/*----------------------------------------------------------------------*
|
||||
* PDCurses *
|
||||
@@ -1348,6 +1348,7 @@ int echo_wchar(const cchar_t *);
|
||||
int erasewchar(wchar_t *);
|
||||
int getbkgrnd(cchar_t *);
|
||||
int getcchar(const cchar_t *, wchar_t *, attr_t *, short *, void *);
|
||||
int get_wch(wint_t *);
|
||||
int hline_set(const cchar_t *, int);
|
||||
int innwstr(wchar_t *, int);
|
||||
int ins_nwstr(const wchar_t *, int);
|
||||
@@ -1364,6 +1365,7 @@ int mvaddwstr(int, int, const wchar_t *);
|
||||
int mvadd_wch(int, int, const cchar_t *);
|
||||
int mvadd_wchnstr(int, int, const cchar_t *, int);
|
||||
int mvadd_wchstr(int, int, const cchar_t *);
|
||||
int mvget_wch(int, int, wint_t *);
|
||||
int mvhline_set(int, int, const cchar_t *, int);
|
||||
int mvinnwstr(int, int, wchar_t *, int);
|
||||
int mvins_nwstr(int, int, const wchar_t *, int);
|
||||
@@ -1379,6 +1381,7 @@ int mvwaddwstr(WINDOW *, int, int, const wchar_t *);
|
||||
int mvwadd_wch(WINDOW *, int, int, const cchar_t *);
|
||||
int mvwadd_wchnstr(WINDOW *, int, int, const cchar_t *, int);
|
||||
int mvwadd_wchstr(WINDOW *, int, int, const cchar_t *);
|
||||
int mvwget_wch(WINDOW *, int, int, wint_t *);
|
||||
int mvwhline_set(WINDOW *, int, int, const cchar_t *, int);
|
||||
int mvwinnwstr(WINDOW *, int, int, wchar_t *, int);
|
||||
int mvwins_nwstr(WINDOW *, int, int, const wchar_t *, int);
|
||||
@@ -1391,6 +1394,7 @@ int mvwinwstr(WINDOW *, int, int, wchar_t *);
|
||||
int mvwvline_set(WINDOW *, int, int, const cchar_t *, int);
|
||||
int pecho_wchar(WINDOW *, const cchar_t*);
|
||||
int setcchar(cchar_t*, const wchar_t*, const attr_t, short, const void*);
|
||||
int unget_wch(const wchar_t);
|
||||
int vline_set(const cchar_t *, int);
|
||||
int waddnwstr(WINDOW *, const wchar_t *, int);
|
||||
int waddwstr(WINDOW *, const wchar_t *);
|
||||
@@ -1404,6 +1408,7 @@ int wborder_set(WINDOW *, const cchar_t *, const cchar_t *,
|
||||
const cchar_t *, const cchar_t *, const cchar_t *);
|
||||
int wecho_wchar(WINDOW *, const cchar_t *);
|
||||
int wgetbkgrnd(WINDOW *, cchar_t *);
|
||||
int wget_wch(WINDOW *, wint_t *);
|
||||
int whline_set(WINDOW *, const cchar_t *, int);
|
||||
int winnwstr(WINDOW *, wchar_t *, int);
|
||||
int wins_nwstr(WINDOW *, const wchar_t *, int);
|
||||
@@ -1419,20 +1424,15 @@ int wvline_set(WINDOW *, const cchar_t *, int);
|
||||
/* Not implemented yet */
|
||||
|
||||
int getn_wstr(wint_t *, int);
|
||||
int get_wch(wint_t *);
|
||||
int get_wstr(wint_t *);
|
||||
int mvgetn_wstr(int, int, wint_t *, int);
|
||||
int mvget_wch(int, int, wint_t *);
|
||||
int mvget_wstr(int, int, wint_t *);
|
||||
int mvwgetn_wstr(WINDOW *, int, int, wint_t *, int);
|
||||
int mvwget_wch(WINDOW *, int, int, wint_t *);
|
||||
int mvwget_wstr(WINDOW *, int, int, wint_t *);
|
||||
int wgetn_wstr(WINDOW *, wint_t *, int);
|
||||
int wget_wch(WINDOW *, wint_t *);
|
||||
int wget_wstr(WINDOW *, wint_t *);
|
||||
|
||||
int slk_wset(int, const wchar_t *, int);
|
||||
int unget_wch(const wchar_t);
|
||||
#endif
|
||||
|
||||
/* Quasi-standard */
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#define _INBUFSIZ 512 /* size of terminal input buffer */
|
||||
#define NUNGETCH 256 /* max # chars to ungetch() */
|
||||
|
||||
RCSID("$Id: getch.c,v 1.48 2006/10/28 13:22:02 wmcbrine Exp $");
|
||||
RCSID("$Id: getch.c,v 1.49 2006/10/29 12:05:13 wmcbrine Exp $");
|
||||
|
||||
static int c_pindex = 0; /* putter index */
|
||||
static int c_gindex = 1; /* getter index */
|
||||
@@ -35,6 +35,12 @@ static int c_ungch[NUNGETCH]; /* array of ungotten chars */
|
||||
int ungetch(int ch);
|
||||
int flushinp(void);
|
||||
|
||||
int get_wch(wint_t *wch);
|
||||
int wget_wch(WINDOW *win, wint_t *wch);
|
||||
int mvget_wch(int y, int x, wint_t *wch);
|
||||
int mvwget_wch(WINDOW *win, int y, int x, wint_t *wch);
|
||||
int unget_wch(const wchar_t wch);
|
||||
|
||||
int PDC_get_key_modifiers(void);
|
||||
|
||||
X/Open Description:
|
||||
@@ -96,6 +102,11 @@ static int c_ungch[NUNGETCH]; /* array of ungotten chars */
|
||||
mvwgetch Y Y Y
|
||||
ungetch Y Y Y
|
||||
flushinp Y Y Y
|
||||
get_wch Y
|
||||
wget_wch Y
|
||||
mvget_wch Y
|
||||
mvwget_wch Y
|
||||
unget_wch Y
|
||||
PDC_get_key_modifiers - - -
|
||||
|
||||
**man-end****************************************************************/
|
||||
@@ -103,14 +114,13 @@ static int c_ungch[NUNGETCH]; /* array of ungotten chars */
|
||||
int wgetch(WINDOW *win)
|
||||
{
|
||||
static int buffer[_INBUFSIZ]; /* character buffer */
|
||||
int key, display_key, waitcount;
|
||||
int key, waitcount;
|
||||
|
||||
PDC_LOG(("wgetch() - called\n"));
|
||||
|
||||
if (win == (WINDOW *)NULL)
|
||||
return ERR;
|
||||
|
||||
display_key = 0x100;
|
||||
waitcount = 0;
|
||||
|
||||
/* set the number of 1/20th second napms() calls */
|
||||
@@ -188,12 +198,12 @@ int wgetch(WINDOW *win)
|
||||
|
||||
/* translate CR */
|
||||
|
||||
if ((key == '\r') && (SP->autocr) && (!SP->raw_inp))
|
||||
if (key == '\r' && SP->autocr && !SP->raw_inp)
|
||||
key = '\n';
|
||||
|
||||
/* if echo is enabled */
|
||||
|
||||
if (SP->echo && (key < display_key))
|
||||
if (SP->echo && !SP->key_code)
|
||||
{
|
||||
waddch(win, key);
|
||||
wrefresh(win);
|
||||
@@ -201,7 +211,7 @@ int wgetch(WINDOW *win)
|
||||
|
||||
/* if no buffering */
|
||||
|
||||
if ((SP->raw_inp || SP->cbreak))
|
||||
if (SP->raw_inp || SP->cbreak)
|
||||
return key;
|
||||
|
||||
/* if no overflow, put data in buffer */
|
||||
@@ -217,7 +227,7 @@ int wgetch(WINDOW *win)
|
||||
|
||||
/* if we got a line */
|
||||
|
||||
if ((key == '\n') || (key == '\r'))
|
||||
if (key == '\n' || key == '\r')
|
||||
return buffer[c_gindex++];
|
||||
}
|
||||
}
|
||||
@@ -273,3 +283,56 @@ unsigned long PDC_get_key_modifiers(void)
|
||||
|
||||
return pdc_key_modifiers;
|
||||
}
|
||||
|
||||
#ifdef PDC_WIDE
|
||||
int wget_wch(WINDOW *win, wint_t *wch)
|
||||
{
|
||||
int key;
|
||||
|
||||
PDC_LOG(("wget_wch() - called\n"));
|
||||
|
||||
if (!wch)
|
||||
return ERR;
|
||||
|
||||
key = wgetch(win);
|
||||
|
||||
if (key == ERR)
|
||||
return ERR;
|
||||
|
||||
*wch = key;
|
||||
|
||||
return SP->key_code ? KEY_CODE_YES : OK;
|
||||
}
|
||||
|
||||
int get_wch(wint_t *wch)
|
||||
{
|
||||
PDC_LOG(("get_wch() - called\n"));
|
||||
|
||||
return wget_wch(stdscr, wch);
|
||||
}
|
||||
|
||||
int mvget_wch(int y, int x, wint_t *wch)
|
||||
{
|
||||
PDC_LOG(("mvget_wch() - called\n"));
|
||||
|
||||
if (move(y, x) == ERR)
|
||||
return ERR;
|
||||
|
||||
return wget_wch(stdscr, wch);
|
||||
}
|
||||
|
||||
int mvwget_wch(WINDOW *win, int y, int x, wint_t *wch)
|
||||
{
|
||||
PDC_LOG(("mvwget_wch() - called\n"));
|
||||
|
||||
if (wmove(win, y, x) == ERR)
|
||||
return ERR;
|
||||
|
||||
return wget_wch(win, wch);
|
||||
}
|
||||
|
||||
int unget_wch(const wchar_t wch)
|
||||
{
|
||||
return PDC_ungetch(wch);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user