Update of /project/mcclim/cvsroot/mcclim/Drei
In directory clnet:/tmp/cvs-serv29065/Drei
Modified Files:
drei-clim.lisp drei-redisplay.lisp drei.lisp input-editor.lisp
Log Message:
Changed a bit in how cursors work, they are now always part of the
output history, and aren't arbitrarily added and removed as their state changes.
Also restores the blue inactive-cursors in Climacs.
--- /project/mcclim/cvsroot/mcclim/Drei/drei-clim.lisp 2008/01/17 23:11:06 1.32
+++ /project/mcclim/cvsroot/mcclim/Drei/drei-clim.lisp 2008/01/27 09:36:07 1.33
@@ -55,6 +55,12 @@
;;; CLIM cursors, though perhaps this facility should be built on top
;;; of what CLIM already provides. That seemed a bit (=a lot) hairy,
;;; though.
+
+;;; Cursors are output records. When a cursor is created, it adds
+;;; itself to its output stream. The owner of the cursor (a Drei
+;;; instance) is responsible for removing the cursor once it is done
+;;; with it. Cursors can be active/inactive and enabled/disabled and
+;;; have the same activity-status as their associated view.
(defclass drei-cursor (standard-sequence-output-record)
((%view :reader view
:initarg :view
@@ -90,6 +96,10 @@
Drei buffer. The most important role for instances of subclasses
of this class is to visually represent the position of point."))
+(defmethod initialize-instance :after ((object drei-cursor) &rest initargs)
+ (declare (ignore initargs))
+ (stream-add-output-record (output-stream object) object))
+
(defmethod active ((cursor drei-cursor))
"Whether the cursor is active or
not. An active cursor is drawn using the active ink, and an
@@ -106,9 +116,6 @@
(active-ink cursor)
(inactive-ink cursor)))
-(defmethod (setf enabled) ((new-value null) (cursor drei-cursor))
- (erase-output-record cursor (output-stream cursor) nil))
-
(defclass point-cursor (drei-cursor)
()
(:default-initargs
@@ -136,7 +143,7 @@
(defmethod enabled ((cursor mark-cursor))
*show-mark*)
-(defgeneric visible (cursor view)
+(defgeneric visible-1 (cursor view)
(:documentation "Is `cursor', associated with `view', visible?
If this function returns true, it is assumed that it is safe to
display `cursor' to the editor stream. If just one of the
@@ -146,6 +153,12 @@
(:method and (cursor view)
(enabled cursor)))
+(defun visible-p (cursor)
+ "Return true if `cursor' is visible. This is a trampoline
+function that calls `visible-1' with `cursor' and the view of
+`cursor'."
+ (visible-1 cursor (view cursor)))
+
;;; Drei instances.
(defclass drei-pane (drei application-pane)
@@ -174,7 +187,7 @@
;; display surface.
drei)
-(defmethod visible and (cursor (view drei-view))
+(defmethod visible-1 and (cursor (view drei-buffer-view))
;; We should only redisplay when the cursor is on display, or
;; `offset-to-screen-position' will return a non-number.
(<= (offset (top view))
--- /project/mcclim/cvsroot/mcclim/Drei/drei-redisplay.lisp 2008/01/22 22:35:38 1.49
+++ /project/mcclim/cvsroot/mcclim/Drei/drei-redisplay.lisp 2008/01/27 09:36:07 1.50
@@ -83,7 +83,7 @@
is *guaranteed* to not return NIL or T.")
(:method :around ((stream extended-output-stream) (view drei-view)
(cursor drei-cursor))
- (when (visible cursor view)
+ (when (visible-p cursor)
(letf (((stream-default-view stream) view))
(call-next-method)))))
@@ -1003,7 +1003,7 @@
(dolist (cursor (cursors drei))
(apply #'erase-output-record cursor stream
(when errorp-supplied
- errorp))))
+ (list errorp)))))
;; XXX: Full redraw for every replay, should probably use the `region'
;; parameter to only invalidate some strokes.
@@ -1021,7 +1021,7 @@
(declare (ignore x-offset y-offset region))
(clear-output-record cursor)
(with-output-recording-options (stream :record t :draw t)
- (when (active cursor)
+ (when (visible-p cursor)
(display-drei-view-cursor stream (view cursor) cursor))))
(defun display-drei-area (drei)
--- /project/mcclim/cvsroot/mcclim/Drei/drei.lisp 2008/01/21 17:08:28 1.30
+++ /project/mcclim/cvsroot/mcclim/Drei/drei.lisp 2008/01/27 09:36:07 1.31
@@ -281,6 +281,11 @@
considered the primary user-oriented cursor, most probably the
cursor for the editor point. Note that this cursor is also in the
cursors-list.")
+ (%cursors-visible :accessor cursors-visible
+ :initform t
+ :initarg :cursors-visible
+ :documentation "If true, the cursors of this
+Drei instance will be visible. If false, they will not.")
(%isearch-mode :initform nil :accessor isearch-mode)
(%isearch-states :initform '() :accessor isearch-states)
(%isearch-previous-string :initform nil :accessor isearch-previous-string)
@@ -301,6 +306,10 @@
(defmethod (setf active) (new-val (drei drei))
(setf (active (view drei)) new-val))
+(defmethod (setf cursors-visible) :after (new-val (drei drei))
+ (dolist (cursor (cursors drei))
+ (setf (enabled cursor) new-val)))
+
(defmethod available-modes append ((modual drei))
(available-modes (view modual)))
@@ -325,7 +334,7 @@
the Drei instance."
(setf (cursors drei) (nreverse (create-view-cursors (editor-pane drei) (view drei))))
(dolist (cursor (cursors drei))
- (stream-add-output-record (editor-pane drei) cursor))
+ (setf (enabled cursor) (cursors-visible drei)))
;; We define the point cursor to be the first point-cursor object
;; in the list of cursors.
(setf (point-cursor drei)
@@ -346,7 +355,10 @@
(add-view-cursors drei)))
(defmethod (setf view) :after (new-val (drei drei))
- ;; We have some new cursors.
+ ;; Delete the old cursors, then add the new ones, provided the
+ ;; setting of the view is successful.
+ (dolist (cursor (cursors drei))
+ (delete-output-record cursor (output-record-parent cursor) nil))
(add-view-cursors drei))
(defmethod esa-current-buffer ((drei drei))
--- /project/mcclim/cvsroot/mcclim/Drei/input-editor.lisp 2008/01/23 10:16:25 1.24
+++ /project/mcclim/cvsroot/mcclim/Drei/input-editor.lisp 2008/01/27 09:36:07 1.25
@@ -97,7 +97,8 @@
(defmethod (setf cursor-visibility)
(visibility (stream drei-input-editing-mixin))
- (setf (active (drei-instance stream)) visibility))
+ (setf (active (drei-instance stream)) visibility
+ (cursors-visible (drei-instance stream)) visibility))
(defclass drei-unselectable-presentation (presentation)
()