vs-support.sl 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %
  3. % VS-SUPPORT.SL - "Fast" routines to support the "virtual-screen" package.
  4. %
  5. % Author: Alan Snyder
  6. % Hewlett-Packard/CRC
  7. % Date: 6 August 1982
  8. %
  9. % This revised version takes advantage of TerminalClearEOL.
  10. %
  11. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  12. (BothTimes (load fast-vector))
  13. (de RewriteChangedCharacters (oldline newline RowLocation LeftCol RightCol)
  14. % A rather specialized routine to look for characters that differ between
  15. % oldline and newline, and to write those out to the screen. The search is
  16. % limited to run from LeftCol to RightCol. RowLocation is simply passed on
  17. % to WritePhysicalCharacter.
  18. (prog (last-nonblank-column)
  19. % Check to see whether a Clear-EOL is appropriate. It is appropriate if
  20. % the rightmost changed character has been changed to a BLANK, and the
  21. % remainder of the line is blank. If this is the case, we determine the
  22. % column to clear from, clear out the old line, and (after outputting prior
  23. % changed characters), do the Clear-EOL.
  24. % Find out where the rightmost changed character actually is:
  25. (while (and (WLEQ LeftCol RightCol)
  26. (WEQ (igets newline RightCol) (igets oldline RightCol)))
  27. (setf RightCol (WDifference RightCol 1))
  28. )
  29. (if (WGreaterP LeftCol RightCol) (return NIL)) % No change at all!
  30. % If the rightmost changed character is being changed to a space, then find
  31. % out if the rest of the line is blank. If it is, then set the variable
  32. % LAST-NONBLANK-COLUMN to the appropriate value and clear out OLDLINE in
  33. % preparation for a later ClearEOL. Otherwise, LAST-NONBLANK-COLUMN
  34. % remains NIL.
  35. (if (WEQ (igets newline RightCol) (char space))
  36. (progn
  37. (setf last-nonblank-column (size newline))
  38. (while (and (WGEQ last-nonblank-column 0)
  39. (WEQ (igets newline last-nonblank-column) (char space))
  40. )
  41. (setf last-nonblank-column (WDifference last-nonblank-column 1))
  42. )
  43. (if (WLessP last-nonblank-column RightCol)
  44. (while (> RightCol last-nonblank-column)
  45. (iputs oldline RightCol (char space))
  46. (setf RightCol (WDifference RightCol 1))
  47. )
  48. )))
  49. % Output all changed characters (other than those that will be taken care
  50. % of by ClearEOL):
  51. (while (WLEQ LeftCol RightCol)
  52. (let ((ch (igets newline LeftCol)))
  53. (if (WNEQ ch (igets oldline LeftCol))
  54. (WritePhysicalCharacter ch RowLocation LeftCol)
  55. ))
  56. (setf LeftCol (wplus2 LeftCol 1))
  57. )
  58. % Do the ClearEOL, if that's what we decided to do.
  59. (if last-nonblank-column
  60. (progn
  61. (MoveToPhysicalLocation RowLocation (WPlus2 last-nonblank-column 1))
  62. (TerminalClearEOL)
  63. ))
  64. ))