home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / C / WPUTCHAR.ZIP / WPUTCHAR.C
Encoding:
Text File  |  1988-06-15  |  1.8 KB  |  50 lines

  1. /*
  2.         This function replaces the similar function of the same name in the
  3.         file TWINDOW.C, function name wputchar() in the book Memory Resident
  4.         Utilities, Screen I/O, and Programming Techniques by Al Stevens for
  5.         TURBO C by Borland.  This fixes a problem where a TAB (0x09) character
  6.         will corrupt the screen memory contents if it positions the cursor
  7.         outside of the specified window.  On occasions, this has caused by
  8.         PC to completely hang, requiring a HARD RESET to recover !  The
  9.         problem was due to the TAB character ALWAYS being sent to the screen,
  10.         irrespective as to whether or not, it was outside the windows
  11.         dimensions.
  12.  
  13.         Uploaded by Chris Cox  G4JEC-W0.
  14.  
  15.         NOTE. It seems impossible to define FASTWINDOWS in TWINDOW.H.
  16.         This is because two functions/macros ? are missing from the book.
  17.         These are vins & vget.  Does anybody have the source for these two
  18.         functions, or a definition of what they are supposed to do ?
  19.         Please leave me a message on The C Station, Terrapin Station, or
  20.         CompuServe (73027,1576) re above.  Alternatively, give me a call
  21.         at (612) 727-1971.
  22. */
  23.  
  24. /* ----- write a character to the window ----- */
  25. void wputchar(WINDOW *wnd, int c)
  26. {
  27.     if(!verify_wnd(&wnd))
  28.         return;
  29.     switch(c){
  30.         case '\n':
  31.             if(SCROLL == HEIGHT-3)
  32.                 scroll(wnd, UP);
  33.             else
  34.                 SCROLL++;
  35.             WCURS = 0;
  36.             break;
  37.         case '\t':
  38.             if ((WCURS+1+TABS) <= (WIDTH - 1 - TABS)){
  39.                 do    displ(wnd, (WCURS++)+3, SCROLL+1, ' ', WNORMAL);
  40.                 while((WCURS%TABS) && (WCURS+1) < WIDTH-1);
  41.             }
  42.             break;
  43.         default:
  44.             if((WCURS+1) < WIDTH-1){
  45.                 displ(wnd, WCURS+1, SCROLL+1, c, WNORMAL);
  46.                 WCURS++;
  47.             }
  48.             break;
  49.     }
  50. }