prntscan.c

Go to the documentation of this file.
00001 #include <string.h>
00002 #include <curses.h>
00003 #include "curspriv.h"
00004 
00005 static char printscanbuf[513];  /* buffer used during I/O */
00006 
00007 /****************************************************************/
00008 /* Wprintw(win,fmt,args) does a printf() in window 'win'.       */
00009 /****************************************************************/
00010 int wprintw(WINDOW *win, const char *fmt, ...)
00011 {
00012   va_list args;
00013 
00014   va_start(args, fmt);
00015   vsprintf(printscanbuf, fmt, args);
00016   if (waddstr(win, printscanbuf) == ERR) return(ERR);
00017   return(strlen(printscanbuf));
00018 }
00019 
00020 /****************************************************************/
00021 /* Printw(fmt,args) does a printf() in stdscr.                  */
00022 /****************************************************************/
00023 int printw(const char *fmt, ...)
00024 {
00025   va_list args;
00026 
00027   va_start(args, fmt);
00028   vsprintf(printscanbuf, fmt, args);
00029   if (waddstr(stdscr, printscanbuf) == ERR) return(ERR);
00030   return(strlen(printscanbuf));
00031 }                               /* printw */
00032 
00033 /****************************************************************/
00034 /* Mvprintw(fmt,args) moves the stdscr cursor to a new posi-    */
00035 /* tion, then does a printf() in stdscr.                        */
00036 /****************************************************************/
00037 int mvprintw(int y, int x, const char *fmt, ...)
00038 {
00039   va_list args;
00040 
00041   va_start(args, fmt);
00042   if (wmove(stdscr, y, x) == ERR) return(ERR);
00043   vsprintf(printscanbuf, fmt, args);
00044   if (waddstr(stdscr, printscanbuf) == ERR) return(ERR);
00045   return(strlen(printscanbuf));
00046 }
00047 
00048 /****************************************************************/
00049 /* Mvwprintw(win,fmt,args) moves the window 'win's cursor to    */
00050 /* A new position, then does a printf() in window 'win'.        */
00051 /****************************************************************/
00052 int mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...)
00053 {
00054   va_list args;
00055 
00056   va_start(args, fmt);
00057   if (wmove(win, y, x) == ERR) return(ERR);
00058   vsprintf(printscanbuf, fmt, args);
00059   if (waddstr(win, printscanbuf) == ERR) return(ERR);
00060   return(strlen(printscanbuf));
00061 }                               /* mvwprintw */
00062 
00063 /****************************************************************/
00064 /* Wscanw(win,fmt,args) gets a string via window 'win', then    */
00065 /* Scans the string using format 'fmt' to extract the values    */
00066 /* And put them in the variables pointed to the arguments.      */
00067 /****************************************************************/
00068 int wscanw(WINDOW *win, const char *fmt, ...)
00069 {
00070   va_list args;
00071 
00072   va_start(args, fmt);
00073   wrefresh(win);                /* set cursor */
00074   if (wgetstr(win, printscanbuf) == ERR)        /* get string */
00075         return(ERR);
00076   return(vsscanf(printscanbuf, fmt, args));
00077 }                               /* wscanw */
00078 
00079 /****************************************************************/
00080 /* Scanw(fmt,args) gets a string via stdscr, then scans the     */
00081 /* String using format 'fmt' to extract the values and put them */
00082 /* In the variables pointed to the arguments.                   */
00083 /****************************************************************/
00084 int scanw(const char *fmt, ...)
00085 {
00086   va_list args;
00087 
00088   va_start(args, fmt);
00089   wrefresh(stdscr);             /* set cursor */
00090   if (wgetstr(stdscr, printscanbuf) == ERR)     /* get string */
00091         return(ERR);
00092   return(vsscanf(printscanbuf, fmt, args));
00093 }                               /* scanw */
00094 
00095 /****************************************************************/
00096 /* Mvscanw(y,x,fmt,args) moves stdscr's cursor to a new posi-   */
00097 /* Tion, then gets a string via stdscr and scans the string     */
00098 /* Using format 'fmt' to extract the values and put them in the */
00099 /* Variables pointed to the arguments.                          */
00100 /****************************************************************/
00101 int mvscanw(int y, int x, const char *fmt, ...)
00102 {
00103   va_list args;
00104 
00105   va_start(args, fmt);
00106   if (wmove(stdscr, y, x) == ERR) return(ERR);
00107   wrefresh(stdscr);             /* set cursor */
00108   if (wgetstr(stdscr, printscanbuf) == ERR)     /* get string */
00109         return(ERR);
00110   return(vsscanf(printscanbuf, fmt, args));
00111 }                               /* mvscanw */
00112 
00113 /****************************************************************/
00114 /* Mvwscanw(win,y,x,fmt,args) moves window 'win's cursor to a   */
00115 /* New position, then gets a string via 'win' and scans the     */
00116 /* String using format 'fmt' to extract the values and put them */
00117 /* In the variables pointed to the arguments.                   */
00118 /****************************************************************/
00119 int mvwscanw(WINDOW *win, int y, int x, const char *fmt, ...)
00120 {
00121   va_list args;
00122 
00123   va_start(args, fmt);
00124   if (wmove(win, y, x) == ERR) return(ERR);
00125   wrefresh(win);                /* set cursor */
00126   if (wgetstr(win, printscanbuf) == ERR)        /* get string */
00127         return(ERR);
00128   return(vsscanf(printscanbuf, fmt, args));
00129 }                               /* mvwscanw */

Generated on Fri Apr 14 22:57:26 2006 for minix by  doxygen 1.4.6