[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'recenter' in fred?



   From: slh@digitool.com (Steve Hain)
   Date: 14 May 1995 17:44:57 -0400

   At 1:25 PM 5/13/95, Paul Shannon wrote:
   >What's the equivalent to the emacs 'recenter' function -- usually
   >bound to control-L?

   Slightly modifying ed-scroll-cursor-to-top (from the file
   "Examples:assorted-fred-commands.lisp") yields:
   [...]

We might as well make it work with a numeric arg while we're at it.
With no arg center the cursor.  With arg put cursor arg lines from top.

;;; -*- Package: CCL -*-

(defmethod ed-scroll-cursor-to-middle ((w fred-mixin))
  (let* ((frec (frec w))
         (bpos (buffer-position (fred-buffer w)))
         (lines (frec-full-lines frec))
         (arg (fred-prefix-argument w))
         (context (or (if (consp arg) (car arg) arg)
                      (round lines 2))))
    (set-mark (fred-display-start-mark w)
              (frec-screen-line-start frec bpos (- context)))
    (with-focused-view w
      (frec-draw-contents frec t))))

(comtab-set-key *comtab* '(:control #\l) 'ed-scroll-cursor-to-middle)

-Carl
cgay@cs.uoregon.edu
http://www.cs.uoregon.edu/~cgay/