1  /* wprint.c -- agit comme printf sur une Text Widget
 2   */
 3  #include <Xm/Text.h>
 4  #include <Xm/MainW.h>
 5  #include <Xm/PushBG.h>
 6  #include <Xm/RowColumn.h>
 7  #include <stdio.h>
 8  #include <varargs.h>
 9
10  extern Widget top_scrolledText1;
11
12
13  /*VARARGS*/
14  void
15  wprint(va_alist)
16  va_dcl
17  {
18      char msgbuf[256];
19      char *fmt;
20      static XmTextPosition wpr_position;
21      va_list args;
22
23      va_start (args);
24      fmt = va_arg (args, char *);
25  #ifndef NO_VPRINTF
26      (void) vsprintf (msgbuf, fmt, args);
27  #else /* !NO_VPRINTF */
28      {
29          FILE foo;
30          foo._cnt = 256;
31          foo._base = foo._ptr = msgbuf; /* (unsigned char *) ?? */
32          foo._flag = _IOWRT+_IOSTRG;
33          (void) _doprnt (fmt, args, &foo);
34          *foo._ptr = '\0'; /* plant terminating null character */
35      }
36  #endif /* NO_VPRINTF */
37      va_end (args);
38
39      XmTextInsert (top_scrolledText1, wpr_position, msgbuf);
40      wpr_position = wpr_position + strlen (msgbuf);
41      XtVaSetValues (top_scrolledText1, XmNcursorPosition, wpr_position, NULL);
42      XmTextShowPosition (top_scrolledText1, wpr_position);
43  }