home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / cug / softt-7.lbr / OS.RQT / OS.RAT
Encoding:
Text File  |  1984-07-05  |  1.6 KB  |  75 lines

  1. #-h-  os.r                       1322  local   01/05/81  23:23:52
  2.  ## definitions for overstrike tool
  3.  # put on a file named 'oversym'
  4.  # Used only by overstrike
  5.  
  6.  define(NOSKIP,PLUS)        #suppress carriage-return/line feed
  7.  define(SKIP,BLANK)
  8.  #---------------------------------------------------------------------
  9.  ## os - convert backspaces into multiple lines
  10.  DRIVER(os)
  11.  
  12.  character buf(MAXLINE)
  13.  integer getarg, open
  14.  integer i, fd
  15.  
  16.  call query ("usage:  os [file].")
  17.  for (i=1; getarg(i, buf, MAXLINE) != EOF; i=i+1)
  18.     {
  19.     if (buf(1) == MINUS & buf(2) == EOS)
  20.         fd = STDIN
  21.     else
  22.         {
  23.         fd = open(buf,READ)
  24.         if (fd == ERR)
  25.             call cant(buf)
  26.         }
  27.     call overs (fd)
  28.     if (fd != STDIN)
  29.         call close(fd)
  30.     }
  31.  if (i == 1)
  32.     call overs (STDIN)
  33.  
  34.  DRETURN
  35.  end
  36.  ## overs - convert backspaces into multiple lines from file -int-
  37.  subroutine overs(int)
  38.  character getch
  39.  character c
  40.  integer col, newcol, int
  41.  
  42.  col = 1
  43.  repeat
  44.     {
  45.     newcol = col
  46.     while (getch(c,int) == BACKSPACE)    #eat up backspaces
  47.         newcol = max(newcol-1, 1)
  48.     if (newcol < col)            #start overstrike line
  49.         {
  50.         call putc(NEWLINE)
  51.         call putc(NOSKIP)
  52.         for (col=1; col<newcol; col=col+1)
  53.             call putc(BLANK)
  54.         }
  55.     else if (col == 1 & c != EOF)        #start normal line
  56.         call putc(SKIP)
  57.                         #else middle of line
  58.     if (c == EOF)
  59.         break
  60.     call putc(c)                #normal character
  61.     if (c == NEWLINE)
  62.         col = 1
  63.     else
  64.         col = col + 1
  65.     }
  66.  return
  67.  end
  68. #-t-  os.r                       1322  local   01/05/81  23:23:52
  69. #-t-  os                         2496  local   01/07/81  00:30:07
  70. S & buf(2) == EOS)
  71.         fd = STDIN
  72.     else
  73.         {
  74.         fd = open(buf,READ)
  75.         if (fd =