]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/widechar/lib_pecho_wchar.c
ncurses 5.4
[ncurses.git] / ncurses / widechar / lib_pecho_wchar.c
similarity index 64%
rename from ncurses/base/lib_insstr.c
rename to ncurses/widechar/lib_pecho_wchar.c
index 347b35611c8f6e386f9a7477c30741eb9a0c0c19..e61277574311bbf7cf83918c2207ea22e09677b9 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,1999,2000,2001 Free Software Foundation, Inc.         *
+ * Copyright (c) 2004 Free Software Foundation, Inc.                        *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
  ****************************************************************************/
 
 /****************************************************************************
- *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
- *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *  Author: Thomas E. Dickey                                                *
  ****************************************************************************/
 
-/*
-**     lib_insstr.c
-**
-**     The routine winsnstr().
-**
-*/
-
 #include <curses.priv.h>
-#include <ctype.h>
 
-MODULE_ID("$Id: lib_insstr.c,v 1.20 2002/09/28 16:22:34 tom Exp $")
+MODULE_ID("$Id: lib_pecho_wchar.c,v 1.1 2004/01/03 21:42:01 tom Exp $")
 
 NCURSES_EXPORT(int)
-winsnstr(WINDOW *win, const char *s, int n)
+pecho_wchar(WINDOW *pad, const cchar_t * wch)
 {
-    int code = ERR;
-    NCURSES_SIZE_T oy;
-    NCURSES_SIZE_T ox;
-    const unsigned char *str = (const unsigned char *) s;
-    const unsigned char *cp;
+    T((T_CALLED("pecho_wchar(%p, %s)"), pad, _tracech_t(wch)));
+
+    if (pad == 0)
+       returnCode(ERR);
 
-    T((T_CALLED("winsnstr(%p,%s,%d)"), win, _nc_visbufn(s,n), n));
+    if (!(pad->_flags & _ISPAD))
+       returnCode(wecho_wchar(pad, wch));
 
-    if (win && str) {
-       oy = win->_cury;
-       ox = win->_curx;
-       for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) {
-           if (*cp == '\n' || *cp == '\r' || *cp == '\t' || *cp == '\b') {
-               NCURSES_CH_T wch;
-               SetChar2(wch, *cp);
-               _nc_waddch_nosync(win, wch);
-           } else if (is7bits(*cp) && iscntrl(*cp)) {
-               winsch(win, ' ' + (chtype) (*cp));
-               winsch(win, (chtype) '^');
-               win->_curx += 2;
-           } else {
-               winsch(win, (chtype) (*cp));
-               win->_curx++;
-           }
-           if (win->_curx > win->_maxx)
-               win->_curx = win->_maxx;
-       }
+    wadd_wch(pad, wch);
+    prefresh(pad, pad->_pad._pad_y,
+            pad->_pad._pad_x,
+            pad->_pad._pad_top,
+            pad->_pad._pad_left,
+            pad->_pad._pad_bottom,
+            pad->_pad._pad_right);
 
-       win->_curx = ox;
-       win->_cury = oy;
-       _nc_synchook(win);
-       code = OK;
-    }
-    returnCode(code);
+    returnCode(OK);
 }