buffer-position.sl 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %
  3. % BUFFER-POSITION.SL - EMODE Buffer Position Objects
  4. %
  5. % Author: Alan Snyder
  6. % Hewlett-Packard/CRC
  7. % Date: 6 July 1982
  8. %
  9. % This file implements objects that store buffer positions.
  10. %
  11. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  12. (CompileTime (load common))
  13. (fluid '(CurrentLineIndex point))
  14. (de buffer-position-create (line-number column-number)
  15. (cons line-number column-number))
  16. (de buffer-position-line (bp)
  17. (car bp))
  18. (de buffer-position-column (bp)
  19. (cdr bp))
  20. (de buffer-position-compare (bp1 bp2)
  21. (cond ((< (buffer-position-line bp1) (buffer-position-line bp2)) -1)
  22. ((> (buffer-position-line bp1) (buffer-position-line bp2)) 1)
  23. ((< (buffer-position-column bp1) (buffer-position-column bp2)) -1)
  24. ((> (buffer-position-column bp1) (buffer-position-column bp2)) 1)
  25. (t 0)))
  26. (de buffer-get-position ()
  27. (buffer-position-create CurrentLineIndex point))
  28. (de buffer-set-position (bp)
  29. (if bp (progn
  30. (PutLine)
  31. (setf CurrentLineIndex (buffer-position-line bp))
  32. (setf point (buffer-position-column bp))
  33. (GetLine CurrentLineIndex)
  34. )))