Back to index

tetex-bin  3.0
lib_printw.c
Go to the documentation of this file.
00001 /****************************************************************************
00002  * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
00003  *                                                                          *
00004  * Permission is hereby granted, free of charge, to any person obtaining a  *
00005  * copy of this software and associated documentation files (the            *
00006  * "Software"), to deal in the Software without restriction, including      *
00007  * without limitation the rights to use, copy, modify, merge, publish,      *
00008  * distribute, distribute with modifications, sublicense, and/or sell       *
00009  * copies of the Software, and to permit persons to whom the Software is    *
00010  * furnished to do so, subject to the following conditions:                 *
00011  *                                                                          *
00012  * The above copyright notice and this permission notice shall be included  *
00013  * in all copies or substantial portions of the Software.                   *
00014  *                                                                          *
00015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
00016  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
00017  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
00018  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
00019  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
00020  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
00021  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
00022  *                                                                          *
00023  * Except as contained in this notice, the name(s) of the above copyright   *
00024  * holders shall not be used in advertising or otherwise to promote the     *
00025  * sale, use or other dealings in this Software without prior written       *
00026  * authorization.                                                           *
00027  ****************************************************************************/
00028 
00029 /****************************************************************************
00030  *  Author: Thomas E. Dickey <dickey@clark.net> 1997                        *
00031  ****************************************************************************/
00032 
00033 /*
00034 **     lib_printw.c
00035 **
00036 **     The routines printw(), wprintw() and friends.
00037 **
00038 */
00039 
00040 #include <curses.priv.h>
00041 
00042 MODULE_ID("$Id: lib_printw.c,v 1.15 2003/02/08 20:50:13 tom Exp $")
00043 
00044 NCURSES_EXPORT(int)
00045 printw(const char *fmt,...)
00046 {
00047     va_list argp;
00048     int code;
00049 
00050 #ifdef TRACE
00051     va_start(argp, fmt);
00052     T((T_CALLED("printw(%s%s)"),
00053        _nc_visbuf(fmt), _nc_varargs(fmt, argp)));
00054     va_end(argp);
00055 #endif
00056 
00057     va_start(argp, fmt);
00058     code = vwprintw(stdscr, fmt, argp);
00059     va_end(argp);
00060 
00061     returnCode(code);
00062 }
00063 
00064 NCURSES_EXPORT(int)
00065 wprintw(WINDOW *win, const char *fmt,...)
00066 {
00067     va_list argp;
00068     int code;
00069 
00070 #ifdef TRACE
00071     va_start(argp, fmt);
00072     T((T_CALLED("wprintw(%p,%s%s)"),
00073        win, _nc_visbuf(fmt), _nc_varargs(fmt, argp)));
00074     va_end(argp);
00075 #endif
00076 
00077     va_start(argp, fmt);
00078     code = vwprintw(win, fmt, argp);
00079     va_end(argp);
00080 
00081     returnCode(code);
00082 }
00083 
00084 NCURSES_EXPORT(int)
00085 mvprintw(int y, int x, const char *fmt,...)
00086 {
00087     va_list argp;
00088     int code;
00089 
00090 #ifdef TRACE
00091     va_start(argp, fmt);
00092     T((T_CALLED("mvprintw(%d,%d,%s%s)"),
00093        y, x, _nc_visbuf(fmt), _nc_varargs(fmt, argp)));
00094     va_end(argp);
00095 #endif
00096 
00097     if ((code = move(y, x)) != ERR) {
00098        va_start(argp, fmt);
00099        code = vwprintw(stdscr, fmt, argp);
00100        va_end(argp);
00101     }
00102     returnCode(code);
00103 }
00104 
00105 NCURSES_EXPORT(int)
00106 mvwprintw(WINDOW *win, int y, int x, const char *fmt,...)
00107 {
00108     va_list argp;
00109     int code;
00110 
00111 #ifdef TRACE
00112     va_start(argp, fmt);
00113     T((T_CALLED("mvwprintw(%d,%d,%p,%s%s)"),
00114        y, x, win, _nc_visbuf(fmt), _nc_varargs(fmt, argp)));
00115     va_end(argp);
00116 #endif
00117 
00118     if ((code = wmove(win, y, x)) != ERR) {
00119        va_start(argp, fmt);
00120        code = vwprintw(win, fmt, argp);
00121        va_end(argp);
00122     }
00123     returnCode(code);
00124 }
00125 
00126 NCURSES_EXPORT(int)
00127 vwprintw(WINDOW *win, const char *fmt, va_list argp)
00128 {
00129     char *buf;
00130     int code = ERR;
00131 
00132     T((T_CALLED("vwprintw(%p,%s,%p)"),
00133        win, _nc_visbuf(fmt), argp));
00134 
00135     if ((buf = _nc_printf_string(fmt, argp)) != 0) {
00136        code = waddstr(win, buf);
00137     }
00138     returnCode(code);
00139 }