;ELC   
;;; compiled by cadet@mit.edu on Sun Mar 23 13:20:18 1997
;;; from file /afs/athena.mit.edu/user/c/a/cadet/elisp/strokes.el
;;; emacs version 20.0 XEmacs Lucid (beta90).
;;; bytecomp version 2.25 XEmacs; 22-Mar-96.
;;; optimization is on.
;;; this file uses opcodes which do not exist in Emacs 19.

(if (and (boundp 'emacs-version)
	 (or (and (boundp 'epoch::version) epoch::version)
	     (string-lessp emacs-version "20")))
    (error "`strokes.el' was compiled for Emacs 20"))

(or (boundp 'current-load-list) (setq current-load-list nil))


(byte-code "ÀÁ\nBÁ‡" ["1.0" strokes-version current-load-list] 2)
#@123 *Minimum score for a stroke to be considered as a possible match.
Requiring a perfect match would set this variable to 0.
(defvar minimum-stroke-match-score 150 (#$ . -628))
#@249 *Integer defining stroke grid resolution such that the grid is
STROKE-GRID-RES square grid defaults to `6', making a 6x6
grid whose coordinates go from (0 . 0) on the top left to
((STROKE-GRID-RES - 1) . (STROKE-GRID-RES - 1)) on the bottom
right.
(defvar stroke-grid-res 6 (#$ . -809))
#@71 *File containing saved strokes for stroke-mode (default is ~/.strokes
(defvar strokes-file "~/.strokes" (#$ . -1102))
#@68 The buffer that the strokes take place in (default is `*strokes*')
(defvar stroke-buffer-name "*strokes*" (#$ . 1226))
#@246 *Command to execute when stroke is too short to be considered a
real stroke and is more likely meant to be a `click' event.  If set
to 'mouse-yank (the default), then the variable
`mouse-yank-at-point' is set to t, so that mouse-yank will work.
(defvar stroke-click-command 'mouse-yank (#$ . -1352))
#@59 Variable determining whether strokes are globally enabled
(defvar strokes-enabled t (#$ . 1658))
#@126 The special window configuration used when entering strokes.  This
will be set properly in the function `make-window-buffer'
(defconst stroke-window-configuration nil (#$ . 1762))
#@221 This is the stroke (string) representing the last stroke entered by
the user.  Its value gets set every time the function
`eliminate-consecutive-redundancies' gets called, since that is the
best time to set the variable
(defvar last-stroke nil (#$ . 1949))
#@137 This is the symbol which denotes a stroke lift event for complex
strokes which contain two or more strokes, such as a Chinese character
(defconst LIFT 'LIFT (#$ . 2213))
#@283 Association list of stroke definitions where each entry is 
(STROKE . COMMAND) where STROKE is itself a list of coordinates 
(X . Y) where X and Y are lists of positions on the normalized
stroke grid, with the top left at (0 . 0).  COMMAND is the
corresponding interactive function
(defvar global-stroke-map nil (#$ . 2390))
(defalias 'stroke-lift-p #[(object) "Á=‡" [object LIFT] 2])
(defalias 'xor #[(a b) "«„	?®…	­‚?‡" [a b] 1])
#@55 add STROKE to STROKE-MAP alist with given command DEF
(defalias 'define-stroke '(macro . #[(stroke-map stroke def) "À	Â‰EÅ	EEE‡" [setq stroke-map cons stroke def remassoc] 7 (#$ . 2831)]))
#@39 Undo the last stroke definition done.
(defalias 'unset-last-stroke #[nil "@AÂÃÄ	\"!«ˆAÅÆ!ªƒÅÇ!)‡" [global-stroke-map command y-or-n-p-minibuf format "really delete last stroke definition, defined to `%s'? " message "that stroke has been deleted" "nothing done."] 4 (#$ . 3029) nil])
#@106 add STROKE to `global-stroke-map' alist with given DEF, letting the
user input the stroke with the mouse
(defalias 'global-set-stroke #[(stroke command) "	BÂ\"B‰‡" [stroke command remassoc global-stroke-map] 4 (#$ . 3323) (list (read-complex-stroke "define a new stroke (with the mouse).  end by pressing button3") (read-command "command to map stroke to: "))])
#@36 returns the square of the number X
(defalias 'square #[(x) "‰_‡" [x] 2 (#$ . 3695)])
(byte-code "ÀÁNÂ>¬…ÃÄÀ\"ˆÅÀÁÆ#‡" [square byte-optimizer (nil byte-compile-inline-expand) error "%s already has a byte-optimizer, can't make it inline" put byte-compile-inline-expand] 4)
#@100 Gets the distance (squared) between to points P1 and P2,
where the points are cons cells \(X . Y\)
(defalias 'distance-squared #[(p1 p2) "@A	@	AZ‰‰_)\nZ‰‰_)\\,‡" [p1 p2 y2 x2 y1 x1 x] 5 (#$ . 3974)])
(byte-code "ÀÁNÂ>¬…ÃÄÀ\"ˆÅÀÁÆ#‡" [distance-squared byte-optimizer (nil byte-compile-inline-expand) error "%s already has a byte-optimizer, can't make it inline" put byte-compile-inline-expand] 4)
#@86 Wait for the user to enter in a stroke.  Optional PROMPT in
minibuffer while waiting
(defalias 'read-stroke #[(&optional prompt) "ŠÀ‹)‡" [((byte-code "ÀÀÃ!ˆ«™ÆÀ\"È!¬�É!ˆÆ!ªmÊŽÆ Ë!¬¨Ì!«šÍ!bˆÎÏ!ˆÐÑ!ˆÒ!Ó!B	BÆ!ªRÔ	Ÿ!Ö!‰)‡" [nil pix-locs stroke set-window-configuration stroke-window-configuration prompt next-event event button-press-event-p dispatch-event ((byte-code "ebˆÀÁÂÃ#«ˆÄÅÂÃ#ˆªqebˆÆ ‡" [search-forward "o" nil t replace-match " " bury-buffer] 4)) button-release-event-p mouse-event-p event-closest-point delete-char 1 insert-char 111 event-x-pixel event-y-pixel reduce-stroke-pixels-to-grid grid-locs eliminate-consecutive-redundancies] 3))] 1 (#$ . 4389)])
#@86 Wait for the user to enter in a stroke.  Optional PROMPT in
minibuffer while waiting
(defalias 'read-complex-stroke #[(&optional prompt) "ŠÀ‹)‡" [((byte-code "ÀÀÃ!ˆÅÀ\"«•È!¬�É!ˆÅ\"ªkÊŽÈ!«ˆË!Ì=¬ÊÍ!¬ªÎ!«šÏ!bˆÐÑ!ˆÒÓ!ˆÔ!Õ!B	BÅ\"ªP	BÈ!¬7É!ˆÅ\"ªk	AŸA×	!Ù!‰)‡" [nil pix-locs stroke set-window-configuration stroke-window-configuration next-event prompt event button-press-event-p dispatch-event ((byte-code "ebˆÀÁÂÃ#«ˆÄÅÂÃ#ˆªqebˆÆ ‡" [search-forward "o" nil t replace-match " " bury-buffer] 4)) event-button 3 button-release-event-p mouse-event-p event-closest-point delete-char 1 insert-char 111 event-x-pixel event-y-pixel LIFT reduce-stroke-pixels-to-grid grid-locs eliminate-consecutive-redundancies] 3))] 1 (#$ . 5096)])
#@60 let user interactively enter a stroke and then describe it
(defalias 'describe-stroke #[(stroke) "À	\n\"‰@A«ŒX«†ÇÈ\"ªƒÇÉ!+‡" [match-stroke stroke global-stroke-map match command score minimum-stroke-match-score message "that stroke maps to `%s'" "that stroke is undefined."] 4 (#$ . 5880) (list (read-complex-stroke "enter stroke to describe.  end with button3..."))])
#@126 Changes the pixel positions of the trajectory of the stroke into
positions on a grid defined by the variable STROKE-GRID-RES
(defalias 'reduce-stroke-pixels-to-grid #[(pixel-positions) "À	!ÃÄ	\")‡" [get-stroke-extent pixel-positions stroke-extent mapcar #[(pix-pos) "À	\n\"‡" [get-grid-position stroke-extent pix-pos] 3]] 3 (#$ . 6265)])
#@197 Given STROKE-EXTENT as a list \(\(xmin . ymin\) \(xmax . ymax\)\)
and a particular pixel position \(or LIFT\), find the corresponding
grid position \(based on `stroke-grid-res'\) for the PIX-POS.
(defalias 'get-grid-position #[(stroke-extent pix-pos) ":«Â@A	@@	@A	A@@T	A@ATÈ	ÊZ!ÊZ!¥_!È	ÊZ!Ê\nZ!¥_!.B‡Ë!­‚‡" [pix-pos stroke-extent ymax xmax ymin xmin y x floor stroke-grid-res float stroke-lift-p LIFT] 7 (#$ . 6611)])
#@119 From a list of PIXEL-POSITIONS, return the spatial pixel extent of
the stroke as a list ((xmin . ymin) (xmax . ymax))
(defalias 'get-stroke-extent #[(pixel-positions) "…– @@@@@A@AA	«¹	@:«®	@@	@A‰W«ƒV«ƒW«ƒ\nV«ƒ*	A‰¬GZ\nZ‰	V«–	ZÊ¥Z\n	ZÊ¥\\ª”	ZÊ¥Z	ZÊ¥\\B\n.BD‡" [pixel-positions rest ymax ymin xmax xmin y x delta-y delta-x 2] 6 (#$ . 7062)])
#@55 Returns a list with no consecutive redundant entries.
(defalias 'eliminate-consecutive-redundancies #[(entries) "­«@A‰C	«š	@\nš«†	A‰ªpB	A‰¬fŸ‰*‡" [entries rest current non-redundant-list next last-stroke] 3 (#$ . 7476)])
#@121 Read a simple stroke from the user and then exectute the
corresponding command.  This should be bound to a mouse event.
(defalias 'do-stroke #[(event) "ÀÁ !‡" [execute-stroke read-stroke] 2 (#$ . 7721) "e"])
#@122 Read a complex stroke from the user and then exectute the
corresponding command.  This should be bound to a mouse event.
(defalias 'do-complex-stroke #[(event) "ÀÁ !‡" [execute-stroke read-complex-stroke] 2 (#$ . 7936) "e"])
#@110 Given STROKE, execute the command which corresponds to it, provided
that one exists.  Returns nil otherwise.
(defalias 'execute-stroke #[(stroke) "À	\n\"‰@A	GÆW«†Ç!ªš«�	X«ŠÊË\"ˆÇ!ª‡ÌÍ	\"ˆÎ+‡" [match-stroke stroke global-stroke-map match command score 2 call-interactively stroke-click-command minimum-stroke-match-score message "%s" cerror "No stroke matches. see variable `minimum-stroke-match-score'" nil] 4 (#$ . 8168)])
#@104 Finds the best match of STROKE in STROKE-MAP and returns the
corresponding match as (COMMAND . SCORE).
(defalias 'match-stroke #[(stroke stroke-map) "­Ã	­ÀÂ	@@\"	@A	A«¨Â@@\"‰«‰«†W¬‡«Š¬‡@AA)ªU­ƒB+‡" [stroke stroke-map rate-stroke map command score newscore] 4 (#$ . 8611)])
#@300 Computes the distances between corresponding grid points of strokes
and then rates the strokes accordingly.  Note: the rating is an error
rating, and therefore, a return of 0 represents a perfect match.  Also
note that the order of stroke arguments is order-independent for the
algorithm used here.
(defalias 'rate-stroke #[(stroke1 stroke2) "…Ú	…ÚA	A@	@‰@A\n@\nAZ‰‰_)Z‰‰_)\\.	\nƒ=\nƒ=@:«È\n@:«Â	@\n@‰@A\n@\nAZ‰‰_)Z‰‰_)\\.\\	\nA	A\nª2Ì@!«“Ì\n@!«ŒA\nA\nªÌ\n@!«¿@:«	@	@‰@A\n@\nAZ‰‰_)Z‰‰_)\\.\\	A‰ªCÌ@!ƒ= \n@:ƒ= 	@\n@‰@A\n@\nAZ‰‰_)Z‰‰_)\\.\\	\nA‰\nªB\n¬¿@:«¹	@	@‰@A\n@\nAZ‰‰_)Z‰‰_)\\.\\	A‰ªC¬¿\n@:«¹	@\n@‰@A\n@\nAZ‰‰_)Z‰‰_)\\.\\	\nA‰\nªCÌ@!¬‡Ì\n@!«†Í‰	ª‚	+‡" [stroke1 stroke2 p2 p1 y2 x2 y1 x1 x err rest2 rest1 stroke-lift-p nil] 8 (#$ . 8918)])
#@68 Prepare the window and buffer in which the strokes will take place
(defalias 'make-stroke-window-configuration #[nil "ŠÀ‹)‡" [((byte-code "ÀÁ\n\"ˆÃ\n!ˆÄ ˆÅ ˆÆ ˆÇÈ!ˆÉÈ!ˆÊp!ˆËÍ Ï Ï _ÈW«ŒÒÓ!ˆT‰ªoebˆÔp!ˆÀÕ!*‡" [message "buffer `%s' being created..." stroke-buffer-name switch-to-buffer delete-other-windows fundamental-mode erase-buffer auto-save-mode 0 font-lock-mode buffer-disable-undo nil truncate-lines current-window-configuration stroke-window-configuration frame-width count max insert-string " " bury-buffer "done"] 4))] 1 (#$ . 9875) nil])
#@53 Update stroke window when other frames are selected
(defalias 'update-stroke-window-configuration #[nil "ŠÀ‹)‡" [((byte-code "À	!ˆÂ ˆÃ Å ‡" [switch-to-buffer stroke-buffer-name delete-other-windows current-window-configuration stroke-window-configuration bury-buffer] 2))] 1 (#$ . 10443)])
(byte-code "ÀÁÂ\"ˆÀÃÄ\"‡" [add-hook select-frame-hook update-stroke-window-configuration kill-emacs-hook prompt-user-save-strokes] 3)
#@59 save user-defined strokes to file named by `strokes-file'
(defalias 'prompt-user-save-strokes #[nil "Št¬†ÀÁ!…¥ ÂÃ!ˆÄÅ!ˆÆÇ!ˆÇqˆÈ ˆÉ ˆebˆÊË!ˆÌ ˆÊÍÎÏ ÐÑÒ\"#!ˆÌ ˆÓ ˆÊÍÔ\"!ˆÓ ˆÊÍÖ\"!ˆÓ ˆØ=«ŽÊÙ!ˆÚ ˆÊÛ!ˆÓ ˆÊÍÜ\"!ˆÓ ˆÊÍÞ\"!ˆÓ ˆÊÍÜ\"!ˆÓ ˆÄÅ!ˆÊÍàÃ!!\"!ˆÄÅ!ˆâedÒ#ˆã$!ˆå )‡" [y-or-n-p-minibuf "save your strokes?" require pp message "saving strokes..." get-buffer-create "*saved-strokes*" erase-buffer emacs-lisp-mode insert-string ";;   -*- Syntax: Emacs-Lisp; Mode: emacs-lisp -*-" newline format ";;; saved strokes for %s, as of %s" user-full-name format-time-string "%B %e, %Y" nil newline-and-indent "(setq stroke-buffer-name %S" stroke-buffer-name "stroke-click-command '%s" stroke-click-command mouse-yank "mouse-yank-at-point t" lisp-indent-for-comment " make 'mouse-yank work with strokes" "minimum-stroke-match-score %s" minimum-stroke-match-score "stroke-grid-res %s" stroke-grid-res "global-stroke-map '%s)" global-stroke-map indent-region write-file strokes-file kill-this-buffer] 7 (#$ . 10874) nil])
(defalias 'save-strokes 'prompt-user-save-strokes)
#@61 Load user-defined strokes from file named by `strokes-file'
(defalias 'load-strokes #[nil "À	!«‰Â	!«„Ã	!‡t«„ÄÅ!‡ÆÇ!‡" [file-exists-p strokes-file file-readable-p load-file error "trouble loading user-defined strokes. nothing done." message "no user-defined strokes, sorry"] 2 (#$ . 11948) nil])
#@17 Turn on strokes
(defalias 'enable-strokes #[nil "À ˆÁ ˆÂÃÄ\"ˆÂÅÄ\"ˆÆÈÉ#ˆÆÊË#ˆÌ‰‡" [load-strokes make-stroke-window-configuration global-set-key [(button2)] do-stroke [(control button2)] define-key global-map [(shift button2)] do-complex-stroke [(control h) S] describe-stroke t strokes-enabled] 4 (#$ . 12249) nil])
#@18 Turn off strokes
(defalias 'disable-strokes #[nil "À	!«†ÂÀ	!!ˆÃÄ!ˆÃÅ!ˆÃÆ!ˆÃÇ!ˆÈ‰	‡" [get-buffer stroke-buffer-name kill-buffer global-unset-key [(button2)] [(control button2)] [(shift button2)] [(control h) S] nil strokes-enabled] 3 (#$ . 12577) nil])
(byte-code "À ˆÁÂ!‡" [enable-strokes provide strokes] 2)
