[mcclim-cvs] CVS mcclim/Drei

thenriksen thenriksen at common-lisp.net
Fri Jan 18 11:00:23 UTC 2008


Update of /project/mcclim/cvsroot/mcclim/Drei
In directory clnet:/tmp/cvs-serv8387/Drei

Modified Files:
	basic-commands.lisp views.lisp 
Log Message:
Added line motion with goal columns.


--- /project/mcclim/cvsroot/mcclim/Drei/basic-commands.lisp	2007/12/21 14:22:07	1.10
+++ /project/mcclim/cvsroot/mcclim/Drei/basic-commands.lisp	2008/01/18 11:00:22	1.11
@@ -137,11 +137,36 @@
 
 ;;; Autogenerate commands
 (define-motion-commands word movement-table)
-(define-motion-commands line movement-table)
 (define-motion-commands page movement-table)
 (define-motion-commands paragraph movement-table)
 (define-motion-commands sentence movement-table)
 
+;;; Lines have goal-columns, so we have to define the commands
+;;; manually.
+(define-command (com-forward-line :name t :command-table movement-table)
+    ((count 'integer :prompt "number of lines" :default 1))
+  "move point forward by one line.
+with a numeric argument n, move point forward by n lines.
+with a negative argument -n, move point backward by n lines."
+  (handling-motion-limit-errors ("lines")
+    (unless (member (unlisted (previous-command (drei-instance)))
+                    '(com-forward-line com-backward-line))
+      (setf (goal-column (current-view)) (column-number (point))))
+    (forward-line (point) (current-syntax) count)
+    (setf (column-number (point)) (goal-column (current-view)))))
+
+(define-command (com-backward-line :name t :command-table movement-table)
+    ((count 'integer :prompt "number of lines" :default 1))
+  "move point backward by one line.
+with a numeric argument n, move point backward by n lines.
+with a negative argument -n, move point forward by n lines."
+  (handling-motion-limit-errors ("lines")
+    (unless (member (unlisted (previous-command (drei-instance)))
+                    '(com-forward-line com-backward-line))
+      (setf (goal-column (current-view)) (column-number (point))))
+    (backward-line (point) (current-syntax) count)
+    (setf (column-number (point)) (goal-column (current-view)))))
+
 ;;; Bind gestures to commands
 (set-key `(com-forward-object ,*numeric-argument-marker*)
 	 'movement-table
--- /project/mcclim/cvsroot/mcclim/Drei/views.lisp	2008/01/16 09:03:26	1.22
+++ /project/mcclim/cvsroot/mcclim/Drei/views.lisp	2008/01/18 11:00:23	1.23
@@ -734,7 +734,10 @@
 
 (defclass point-mark-view (drei-buffer-view)
   ((%point :initform nil :initarg :point :accessor point-of)
-   (%mark :initform nil :initarg :mark :accessor mark-of))
+   (%mark :initform nil :initarg :mark :accessor mark-of)
+   (%goal-column :initform nil :accessor goal-column
+                 :documentation "The column that point will be
+attempted to be positioned in when moving by line."))
   (:metaclass modual-class)
   (:documentation "A view class containing a point and a mark
 into its buffer."))
@@ -762,8 +765,6 @@
   ((%auto-fill-mode :initform nil :accessor auto-fill-mode)
    (%auto-fill-column :initform 70 :accessor auto-fill-column)
    (%region-visible-p :initform nil :accessor region-visible-p)
-   ;; for next-line and previous-line commands
-   (%goal-column :initform nil :accessor goal-column)
    ;; for dynamic abbrev expansion
    (%original-prefix :initform nil :accessor original-prefix)
    (%prefix-start-offset :initform nil :accessor prefix-start-offset)




More information about the Mcclim-cvs mailing list