Rewrite `inferior-containing-coordinates' to be faster. Make optional
authorChris Hanson <org/chris-hanson/cph>
Wed, 21 Jun 1989 10:37:45 +0000 (10:37 +0000)
committerChris Hanson <org/chris-hanson/cph>
Wed, 21 Jun 1989 10:37:45 +0000 (10:37 +0000)
argument be required.  Eliminate mixing of single- and multiple-value
returns, which doesn't work.

v7/src/edwin/window.scm

index 665721cab8265e9df2a59f8315fa81f207ad44dc..a483dd3ee828d39b5358b234bfa176df65d14f06 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;;    $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/window.scm,v 1.147 1989/06/19 22:36:54 markf Exp $
+;;;    $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/edwin/window.scm,v 1.148 1989/06/21 10:37:45 cph Rel $
 ;;;
 ;;;    Copyright (c) 1986, 1989 Massachusetts Institute of Technology
 ;;;
 
 (define-integrable (set-inferior-size! inferior x y)
   (=> (inferior-window inferior) :set-size! x y))
+
+(define (inferior-containing-coordinates window x y stop-search?)
+  (let search ((window window) (x x) (y y))
+    (if (stop-search? window)
+       (values window x y)
+       (let loop ((inferiors (window-inferiors window)))
+         (if (null? inferiors)
+             (values false false false)
+             (let ((inferior (car inferiors)))
+               (let ((x-start (inferior-x-start inferior))
+                     (y-start (inferior-y-start inferior)))
+                 (if (and x-start y-start)
+                     (let ((x (- x x-start))
+                           (y (- y y-start)))
+                       (if (and (not (negative? x))
+                                (<= x (inferior-x-size inferior))
+                                (not (negative? y))
+                                (<= y (inferior-y-size inferior)))                         (search (inferior-window inferior) x y)
+                           (loop (cdr inferiors))))
+                     (loop (cdr inferiors))))))))))
 \f
 (define-integrable (find-inferior? inferiors window)
   (assq window inferiors))
 
 (define-integrable (set-inferior-redisplay-flags! inferior flags)
   (vector-set! (cdr inferior) 2 flags)
-  unspecific)
-
-(define (inferior-containing-coordinates window x y #!optional stop-search?)
-  (let ((stop-search? (if (default-object? stop-search?)
-                         window-inferiors
-                         stop-search?)))
-    (let search ((window window)
-                (x x)
-                (y y))
-      (if (stop-search? window)
-         (values window x y)
-         (let loop ((inferiors (window-inferiors window)))
-           (and
-            (not (null? inferiors))
-            (let ((inferior (car inferiors)))
-              (let ((x-start (inferior-x-start inferior))
-                    (y-start (inferior-y-start inferior))
-                    (inf-window (inferior-window inferior)))
-                (cond ((or (null? x-start) (null? y-start)) false)
-                      ((and (>= x x-start)
-                            (<= x (inferior-x-end inferior))
-                            (>= y y-start)
-                            (<= y (inferior-y-end inferior)))
-                       (search inf-window
-                               (- x x-start)
-                               (- y y-start)))
-                      (else
-                       (loop (cdr inferiors))))))))))))
+  unspecific)
\ No newline at end of file