comparison lisp/strokes.el @ 90203:187d6a1f84f7

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-71 Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 485-492) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 92-94) - Merge from emacs--cvs-trunk--0 - Update from CVS
author Miles Bader <miles@gnu.org>
date Fri, 22 Jul 2005 08:27:27 +0000
parents f9a65d7ebd29 dc55ec2be671
children 2d92f5c9d6ae
comparison
equal deleted inserted replaced
90202:7597b4a23c3b 90203:187d6a1f84f7
241 :type 'integer 241 :type 'integer
242 :group 'strokes) 242 :group 'strokes)
243 243
244 (defcustom strokes-grid-resolution 9 244 (defcustom strokes-grid-resolution 9
245 "*Integer defining dimensions of the stroke grid. 245 "*Integer defining dimensions of the stroke grid.
246 The grid is a square grid, where STROKES-GRID-RESOLUTION defaults to 246 The grid is a square grid, where `strokes-grid-resolution' defaults to
247 `9', making a 9x9 grid whose coordinates go from (0 . 0) on the top 247 `9', making a 9x9 grid whose coordinates go from (0 . 0) on the top
248 left to ((STROKES-GRID-RESOLUTION - 1) . (STROKES-GRID-RESOLUTION - 1)) 248 left to ((strokes-grid-resolution - 1) . (strokes-grid-resolution - 1))
249 on the bottom right. The greater the resolution, the more intricate 249 on the bottom right. The greater the resolution, the more intricate
250 your strokes can be. 250 your strokes can be.
251 NOTE: This variable should be odd and MUST NOT be less than 3 and need 251 NOTE: This variable should be odd and MUST NOT be less than 3 and need
252 not be greater than 33, which is the resolution of the pixmaps. 252 not be greater than 33, which is the resolution of the pixmaps.
253 WARNING: Changing the value of this variable will gravely affect the 253 WARNING: Changing the value of this variable will gravely affect the
257 only then start programming in your custom strokes." 257 only then start programming in your custom strokes."
258 :type 'integer 258 :type 'integer
259 :group 'strokes) 259 :group 'strokes)
260 260
261 (defcustom strokes-file (convert-standard-filename "~/.strokes") 261 (defcustom strokes-file (convert-standard-filename "~/.strokes")
262 "*File containing saved strokes for stroke-mode (default is ~/.strokes)." 262 "*File containing saved strokes for Strokes mode (default is ~/.strokes)."
263 :type 'file 263 :type 'file
264 :group 'strokes) 264 :group 'strokes)
265 265
266 (defvar strokes-buffer-name " *strokes*" 266 (defvar strokes-buffer-name " *strokes*"
267 "The name of the buffer that the strokes take place in.") 267 "The name of the buffer that the strokes take place in.")
282 282
283 (defvar strokes-last-stroke nil 283 (defvar strokes-last-stroke nil
284 "Last stroke entered by the user. 284 "Last stroke entered by the user.
285 Its value gets set every time the function 285 Its value gets set every time the function
286 `strokes-fill-stroke' gets called, 286 `strokes-fill-stroke' gets called,
287 since that is the best time to set the variable") 287 since that is the best time to set the variable.")
288 288
289 (defvar strokes-global-map '() 289 (defvar strokes-global-map '()
290 "Association list of strokes and their definitions. 290 "Association list of strokes and their definitions.
291 Each entry is (STROKE . COMMAND) where STROKE is itself a list of 291 Each entry is (STROKE . COMMAND) where STROKE is itself a list of
292 coordinates (X . Y) where X and Y are lists of positions on the 292 coordinates (X . Y) where X and Y are lists of positions on the
293 normalized stroke grid, with the top left at (0 . 0). COMMAND is the 293 normalized stroke grid, with the top left at (0 . 0). COMMAND is the
294 corresponding interactive function") 294 corresponding interactive function.")
295 295
296 (defvar strokes-load-hook nil 296 (defvar strokes-load-hook nil
297 "Function or functions to be called when `strokes' is loaded.") 297 "Functions to be called when Strokes is loaded.")
298 298
299 ;;; ### NOT IMPLEMENTED YET ### 299 ;;; ### NOT IMPLEMENTED YET ###
300 ;;(defvar edit-strokes-menu 300 ;;(defvar edit-strokes-menu
301 ;; '("Edit-Strokes" 301 ;; '("Edit-Strokes"
302 ;; ["Add stroke..." strokes-global-set-stroke t] 302 ;; ["Add stroke..." strokes-global-set-stroke t]
471 ;; (strokes-read-stroke "Enter the stroke you want to delete..."))) 471 ;; (strokes-read-stroke "Enter the stroke you want to delete...")))
472 ;; (strokes-define-stroke 'strokes-global-map stroke command)) 472 ;; (strokes-define-stroke 'strokes-global-map stroke command))
473 473
474 (defun strokes-get-grid-position (stroke-extent position &optional grid-resolution) 474 (defun strokes-get-grid-position (stroke-extent position &optional grid-resolution)
475 "Map POSITION to a new grid position. 475 "Map POSITION to a new grid position.
476 Do so based on its STROKE-EXTENT and GRID-RESOLUTION. 476 Do so based on its STROKE-EXTENT and GRID-RESOLUTION.
477 STROKE-EXTENT as a list \(\(XMIN . YMIN\) \(XMAX . YMAX\)\). 477 STROKE-EXTENT as a list \(\(XMIN . YMIN\) \(XMAX . YMAX\)\).
478 If POSITION is a `strokes-lift', then it is itself returned. 478 If POSITION is a `strokes-lift', then it is itself returned.
479 Optional GRID-RESOLUTION may be used in place of STROKES-GRID-RESOLUTION. 479 Optional GRID-RESOLUTION may be used in place of `strokes-grid-resolution'.
480 The grid is a square whose dimension is [0,GRID-RESOLUTION)." 480 The grid is a square whose dimension is [0,GRID-RESOLUTION)."
481 (cond ((consp position) ; actual pixel location 481 (cond ((consp position) ; actual pixel location
482 (let ((grid-resolution (or grid-resolution strokes-grid-resolution)) 482 (let ((grid-resolution (or grid-resolution strokes-grid-resolution))
483 (x (car position)) 483 (x (car position))
484 (y (cdr position)) 484 (y (cdr position))
564 ;; nil)) 564 ;; nil))
565 565
566 (defun strokes-renormalize-to-grid (positions &optional grid-resolution) 566 (defun strokes-renormalize-to-grid (positions &optional grid-resolution)
567 "Map POSITIONS to a new grid whose dimensions are based on GRID-RESOLUTION. 567 "Map POSITIONS to a new grid whose dimensions are based on GRID-RESOLUTION.
568 POSITIONS is a list of positions and stroke-lifts. 568 POSITIONS is a list of positions and stroke-lifts.
569 Optional GRID-RESOLUTION may be used in place of STROKES-GRID-RESOLUTION. 569 Optional GRID-RESOLUTION may be used in place of `strokes-grid-resolution'.
570 The grid is a square whose dimension is [0,GRID-RESOLUTION)." 570 The grid is a square whose dimension is [0,GRID-RESOLUTION)."
571 (or grid-resolution (setq grid-resolution strokes-grid-resolution)) 571 (or grid-resolution (setq grid-resolution strokes-grid-resolution))
572 (let ((stroke-extent (strokes-get-stroke-extent positions))) 572 (let ((stroke-extent (strokes-get-stroke-extent positions)))
573 (mapcar (function 573 (mapcar (function
574 (lambda (pos) 574 (lambda (pos)
724 "Read a simple stroke (interactively) and return the stroke. 724 "Read a simple stroke (interactively) and return the stroke.
725 Optional PROMPT in minibuffer displays before and during stroke reading. 725 Optional PROMPT in minibuffer displays before and during stroke reading.
726 This function will display the stroke interactively as it is being 726 This function will display the stroke interactively as it is being
727 entered in the strokes buffer if the variable 727 entered in the strokes buffer if the variable
728 `strokes-use-strokes-buffer' is non-nil. 728 `strokes-use-strokes-buffer' is non-nil.
729 Optional EVENT is acceptable as the starting event of the stroke" 729 Optional EVENT is acceptable as the starting event of the stroke."
730 (save-excursion 730 (save-excursion
731 (let ((pix-locs nil) 731 (let ((pix-locs nil)
732 (grid-locs nil) 732 (grid-locs nil)
733 (safe-to-draw-p nil)) 733 (safe-to-draw-p nil))
734 (if strokes-use-strokes-buffer 734 (if strokes-use-strokes-buffer
788 "Read a complex stroke (interactively) and return the stroke. 788 "Read a complex stroke (interactively) and return the stroke.
789 Optional PROMPT in minibuffer displays before and during stroke reading. 789 Optional PROMPT in minibuffer displays before and during stroke reading.
790 Note that a complex stroke allows the user to pen-up and pen-down. This 790 Note that a complex stroke allows the user to pen-up and pen-down. This
791 is implemented by allowing the user to paint with button 1 or button 2 and 791 is implemented by allowing the user to paint with button 1 or button 2 and
792 then complete the stroke with button 3. 792 then complete the stroke with button 3.
793 Optional EVENT is acceptable as the starting event of the stroke" 793 Optional EVENT is acceptable as the starting event of the stroke."
794 (save-excursion 794 (save-excursion
795 (save-window-excursion 795 (save-window-excursion
796 (set-window-configuration strokes-window-configuration) 796 (set-window-configuration strokes-window-configuration)
797 (let ((pix-locs nil) 797 (let ((pix-locs nil)
798 (grid-locs nil)) 798 (grid-locs nil))
890 (message "That stroke is undefined")) 890 (message "That stroke is undefined"))
891 (sleep-for 1))) ; helpful for recursive edits 891 (sleep-for 1))) ; helpful for recursive edits
892 892
893 ;;;###autoload 893 ;;;###autoload
894 (defun strokes-help () 894 (defun strokes-help ()
895 "Get instruction on using the `strokes' package." 895 "Get instruction on using the Strokes package."
896 (interactive) 896 (interactive)
897 (with-output-to-temp-buffer "*Help with Strokes*" 897 (with-output-to-temp-buffer "*Help with Strokes*"
898 (princ 898 (princ
899 "This is help for the strokes package. 899 (substitute-command-keys
900 "This is help for the strokes package.
900 901
901 ------------------------------------------------------------ 902 ------------------------------------------------------------
902 903
903 ** Strokes... 904 ** Strokes...
904 905
984 called ~/.strokes, along with other strokes configuration variables. 985 called ~/.strokes, along with other strokes configuration variables.
985 You can change this location by setting the variable `strokes-file'. 986 You can change this location by setting the variable `strokes-file'.
986 You will be prompted to save them when you exit Emacs, or you can save 987 You will be prompted to save them when you exit Emacs, or you can save
987 them with 988 them with
988 989
989 > M-x strokes-save-strokes 990 > M-x strokes-prompt-user-save-strokes
990 991
991 Your strokes get loaded automatically when you enable `strokes-mode'. 992 Your strokes get loaded automatically when you enable `strokes-mode'.
992 You can also load in your user-defined strokes with 993 You can also load in your user-defined strokes with
993 994
994 > M-x strokes-load-user-strokes 995 > M-x strokes-load-user-strokes
1022 commentary of `strokes.el'. Better to just use \\[apropos] and read their 1023 commentary of `strokes.el'. Better to just use \\[apropos] and read their
1023 docstrings. All variables/functions start with `strokes'. The one 1024 docstrings. All variables/functions start with `strokes'. The one
1024 variable which many people wanted to see was 1025 variable which many people wanted to see was
1025 `strokes-use-strokes-buffer' which allows the user to use strokes 1026 `strokes-use-strokes-buffer' which allows the user to use strokes
1026 silently--without displaying the strokes. All variables can be set 1027 silently--without displaying the strokes. All variables can be set
1027 by customizing the group `strokes' via \[customize-group].") 1028 by customizing the group `strokes' via \\[customize-group]."))
1028 (set-buffer standard-output) 1029 (set-buffer standard-output)
1029 (help-mode) 1030 (help-mode)
1030 (print-help-return-message))) 1031 (print-help-return-message)))
1031 1032
1032 (defalias 'strokes-report-bug 'report-emacs-bug) 1033 (defalias 'strokes-report-bug 'report-emacs-bug)