home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume7 / xdm / patch1.01 / xdmconsole.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-08  |  1.0 KB  |  66 lines

  1. #include <fcntl.h>
  2. #define FONT "-adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1"
  3. #include "xdmconsole.h"
  4.  
  5. int win_err(disp, errorcode)
  6. Display *disp;
  7. XErrorEvent *errorcode;
  8. {
  9.     /*  Some obscure old event  */
  10.     exit(0);
  11. }
  12. int naughty_win_err(disp)
  13. Display *disp;
  14. {
  15.     /*  Window not currently in existance  */
  16.     exit(0);
  17. }
  18.  
  19. extern int screen;
  20. extern Display *disp;
  21.  
  22. main()
  23. {
  24.     char buf[128];
  25.     int size=0;
  26.     int inc;
  27.     char *name, stdprint[80];
  28.  
  29.     
  30.     initwin(400, 70, Place, Place, 3, Transient, "Console");
  31.     winfont(FONT);
  32.     inc = 15;
  33.     wincursor(XC_gumby);
  34.     winevents(ExposureMask);
  35.     showwin();
  36.     name = (char *) malloc(64);
  37.     if (gethostname(name, 64) != -1)
  38.     {
  39.         strcpy(stdprint, name);
  40.     }
  41.     strcat(stdprint, " console.");
  42.     winprint(2,15, stdprint);
  43.  
  44.     XSetErrorHandler(win_err);
  45.     XSetIOErrorHandler(naughty_win_err);
  46.  
  47.     
  48.     for(;;)
  49.     {
  50.         if ((size=read(0, buf, sizeof(buf))) > 0);
  51.         {
  52.             buf[size]='\0';
  53.             if (inc > 59)
  54.             {
  55.                 inc -= 15;
  56.                 scrollup(15);
  57.             }
  58.             inc += 15;
  59.             winwrapprint(2, inc, buf, 15);
  60.             buf[0]='\0';
  61.             size=0;
  62.         }
  63.     }
  64. }
  65.  
  66.