Move the cursor only when its position is changed. Previously, the
authorChris Hanson <org/chris-hanson/cph>
Tue, 14 May 1996 05:41:08 +0000 (05:41 +0000)
committerChris Hanson <org/chris-hanson/cph>
Tue, 14 May 1996 05:41:08 +0000 (05:41 +0000)
cursor was being moved many times in a row to the same location.  This
was caused by repeated screen updates being run as a result of
processing input events.  Input events can be quite common even when
there is no typing going on, as a result of window-system operations,
mouse tracking, etc.

v7/src/edwin/screen.scm

index 4d0b79ad0dcac97ea4f3bbc02d101847c90ec364..e71c6d0cabdc6f27aeb6bce4fbc9bab9f9d237b4 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;;    $Id: screen.scm,v 1.109 1996/05/14 01:49:49 cph Exp $
+;;;    $Id: screen.scm,v 1.110 1996/05/14 05:41:08 cph Exp $
 ;;;
 ;;;    Copyright (c) 1989-96 Massachusetts Institute of Technology
 ;;;
   highlight-enable
 
   ;; Cursor position.
-  cursor-x
-  cursor-y)
+  (cursor-x #f)
+  (cursor-y #f))
 
 (define (make-matrix screen)
   (let ((matrix (%make-matrix))
       (set-matrix-highlight! matrix highlight)
       (set-matrix-enable! matrix enable)
       (set-matrix-highlight-enable! matrix highlight-enable))
-    (set-matrix-cursor-x! matrix 0)
-    (set-matrix-cursor-y! matrix 0)
     matrix))
 
 (define (set-screen-size! screen x-size y-size)
           (initialize-new-line-contents screen y)
           (if highlight
               (begin
-                (boolean-vector-set! (matrix-highlight-enable new-matrix) y true)
+                (boolean-vector-set! (matrix-highlight-enable new-matrix)
+                                     y #t)
                 (initialize-new-line-highlight screen y)
-                (boolean-vector-set! (vector-ref (matrix-highlight new-matrix) y)
+                (boolean-vector-set! (vector-ref (matrix-highlight new-matrix)
+                                                 y)
                                      x highlight))))
          ((boolean-vector-ref (matrix-highlight-enable new-matrix) y)
           (boolean-vector-set! (vector-ref (matrix-highlight new-matrix) y)
         (set-screen-in-update?! screen old-flag)
         finished?)))))
 
-(define-integrable (screen-update-cursor screen)
+(define (screen-update-cursor screen)
   (let ((x (matrix-cursor-x (screen-new-matrix screen)))
        (y (matrix-cursor-y (screen-new-matrix screen))))
-    (terminal-move-cursor screen x y)
+    (if (not (and (eqv? x (matrix-cursor-x (screen-current-matrix screen)))
+                 (eqv? y (matrix-cursor-y (screen-current-matrix screen)))))
+       (terminal-move-cursor screen x y))
     (set-matrix-cursor-x! (screen-current-matrix screen) x)
     (set-matrix-cursor-y! (screen-current-matrix screen) y)))