home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / pcscheme / geneva / sources.exe / SOURCES / EDWIN / INSERT80.S < prev    next >
Encoding:
Text File  |  1993-06-15  |  4.9 KB  |  146 lines

  1. ;;;
  2. ;;;    Copyright (c) 1985 Massachusetts Institute of Technology
  3. ;;;
  4. ;;;    This material was developed by the Scheme project at the
  5. ;;;    Massachusetts Institute of Technology, Department of
  6. ;;;    Electrical Engineering and Computer Science.  Permission to
  7. ;;;    copy this software, to redistribute it, and to use it for any
  8. ;;;    purpose is granted, subject to the following restrictions and
  9. ;;;    understandings.
  10. ;;;
  11. ;;;    1. Any copy made of this software must include this copyright
  12. ;;;    notice in full.
  13. ;;;
  14. ;;;    2. Users of this software agree to make their best efforts (a)
  15. ;;;    to return to the MIT Scheme project any improvements or
  16. ;;;    extensions that they make, so that these may be included in
  17. ;;;    future releases; and (b) to inform MIT of noteworthy uses of
  18. ;;;    this software.
  19. ;;;
  20. ;;;    3.  All materials developed as a consequence of the use of
  21. ;;;    this software shall duly acknowledge such use, in accordance
  22. ;;;    with the usual standards of acknowledging credit in academic
  23. ;;;    research.
  24. ;;;
  25. ;;;    4. MIT has made no warrantee or representation that the
  26. ;;;    operation of this software will be error-free, and MIT is
  27. ;;;    under no obligation to provide any services, by way of
  28. ;;;    maintenance, update, or otherwise.
  29. ;;;
  30. ;;;    5.  In conjunction with products arising from the use of this
  31. ;;;    material, there shall be no use of the name of the
  32. ;;;    Massachusetts Institute of Technology nor of any adaptation
  33. ;;;    thereof in any advertising, promotional, or sales literature
  34. ;;;    without prior written consent from MIT in each case.
  35. ;;;
  36. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  37. ;;;
  38. ;;;    Modified by Texas Instruments Inc 8/15/85
  39. ;;;
  40. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  41.  
  42. ;;;; These routines are implemented to get speed in character
  43. ;;;; insertion and deletions. They are written so as not to effect
  44. ;;;; the code too much.
  45. ;;;; Changes arise in the command for delete character and delete backward
  46. ;;;; character in allcoms.scm. Also, redisplay contains an statement for the
  47. ;;;; creation of the daemons.
  48. ;;;; These should be faster and should create less garbage.
  49.  
  50. (define region-insert-char!
  51.   (lambda (mark char)
  52.     (if (eq? char #\newline)
  53.     (region-insert-newline! mark)
  54.     (begin
  55.       (if (group-read-only? (mark-group mark))
  56.           (editor-error "Trying to modify read only text"))
  57.       ((lambda (line pos)
  58.          (%region-insert-char! line pos char))
  59.        (mark-line mark) (mark-position mark))
  60.       (%recompute-for-insert-del-char!  mark)))))
  61.  
  62. (define %region-insert-char!
  63.   (letrec
  64.     ((%receiver
  65.     (lambda (mark cursor?)
  66.       (if (or (> (mark-position mark) %pos)
  67.           (and (= (mark-position mark) %pos)
  68.                (mark-left-inserting? mark)))
  69.           (set-mark-position! mark (1+ (mark-position mark))))))
  70.      (%pos '()))
  71.  
  72.     (lambda (line pos char)
  73.       (set! %pos pos)
  74.       (for-each-mark! line %receiver)
  75.       (line-insert-char! line pos char))))
  76.  
  77.  
  78. (define %recompute-for-insert-del-char! '())
  79.  
  80. (define %create-char-daemon
  81.   (lambda (window)
  82.     (set! %recompute-for-insert-del-char!
  83.       (%char-daemon window))))
  84.  
  85. (define (%char-daemon window)
  86.   (lambda (mark)
  87.     (let ((buffer (vector-ref window window:buffer))
  88.       (table  (vector-ref window window:lines))
  89.       (line   (mark-line mark))
  90.       (y (line->y window (mark-line mark)))
  91.       (y-size (vector-ref window window:y-size)))
  92.       (let ((inferior (vector-ref table y)))
  93.     (let ((old-ys (inferior:y-size inferior))
  94.           (new-ys (find-y-size line)))
  95.       (buffer-modified! buffer)
  96.       (if (= old-ys new-ys)
  97.           (begin
  98.            (maybe-marks-changed window y)
  99.            (set-start-end! window y y)
  100.            (cursor-moved! window))
  101.           (begin
  102.            (if (< old-ys new-ys)
  103.            (scroll-lines-down! window (- new-ys old-ys) y-size
  104.                            table (+ (inferior:y-start inferior) old-ys))
  105.            (scroll-lines-up! window (- old-ys new-ys) y-size
  106.               table (+ (inferior:y-start inferior) old-ys)))
  107.            (set-inferior:y-size! inferior new-ys)
  108.            (fill-entries (1+ y) 
  109.                  (+ (inferior:y-start inferior) new-ys)
  110.                  y table y-size)
  111.            (set-start-end! window y (-1+ y-size))
  112.            (everything-changed! window window-redraw!))))))))
  113.  
  114.  
  115. (define %region-delete-char!
  116.   (letrec
  117.     ((%receiver
  118.     (lambda (mark cursor?)
  119.       (cond ((> (mark-position mark) end-pos)
  120.          (set-mark-position! mark (- (mark-position mark)
  121.                          offset)))
  122.         ((> (mark-position mark) %pos)
  123.          (set-mark-position! mark %pos)))))
  124.      (%pos '())
  125.      (end-pos '())
  126.      (offset 1))
  127.  
  128.   (lambda (mark)
  129.     (letrec
  130.       ((%%region-delete-char!
  131.      (lambda (line pos)
  132.        (set! %pos pos)
  133.        (set! end-pos (1+ pos))
  134.        (for-each-mark! line %receiver)
  135.        (subline-extract! line pos (1+ pos)))))
  136.  
  137.     (if (group-read-only? (mark-group mark))
  138.     (editor-error "Trying to modify read only text"))
  139.     (%%region-delete-char! (mark-line mark) (mark-position mark))
  140.     (%recompute-for-insert-del-char! mark)))))
  141.  
  142.  
  143.  
  144.  
  145.  
  146.