annotate lisp/gutter-items.el @ 863:42375619fa45

[xemacs-hg @ 2002-06-04 06:03:59 by andyp] merge 21.4 windows changes, minimally tested
author andyp
date Tue, 04 Jun 2002 06:05:53 +0000
parents 943eaba38521
children 4a27df428c73
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 ;;; gutter-items.el --- Gutter content for XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 ;; Copyright (C) 1999 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 ;; Maintainer: XEmacs Development Team
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 ;; Keywords: frames, extensions, internal, dumped
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ;; any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 ;; General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 ;; along with Xmacs; see the file COPYING. If not, write to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 ;; Free Software Foundation, 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 502
diff changeset
25 ;;; Gutter-specific buffers tab code
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
27 (defvar gutter-buffers-tab nil
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
28 "A tab widget in the gutter for displaying buffers.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
29 Do not set this. Use `set-glyph-image' to change the properties of the tab.")
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
30
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
31 (defcustom gutter-buffers-tab-visible-p
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
32 (gutter-element-visible-p default-gutter-visible-p 'buffers-tab)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
33 "Whether the buffers tab is globally visible.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
34 This option should be set through the options menu."
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
35 :group 'buffers-tab
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
36 :type 'boolean
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
37 :set #'(lambda (var val)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
38 (set-gutter-element-visible-p default-gutter-visible-p
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
39 'buffers-tab val)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
40 (setq gutter-buffers-tab-visible-p val)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
41
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
42 (defcustom gutter-buffers-tab-enabled t
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
43 "*Whether to enable support for buffers tab in the gutter.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
44 This is different to `gutter-buffers-tab-visible-p' which still runs hooks
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
45 even when the gutter is invisible."
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
46 :group 'buffers-tab
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
47 :type 'boolean)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
48
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
49 (defvar gutter-buffers-tab-orientation 'top
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
50 "Where the buffers tab currently is. Do not set this.")
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
51
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 (defun add-tab-to-gutter ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 "Put a tab control in the gutter area to hold the most recent buffers."
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
54 (setq gutter-buffers-tab-orientation (default-gutter-position))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
55 (let* ((gutter-string (copy-sequence "\n"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
56 (gutter-buffers-tab-extent (make-extent 0 1 gutter-string)))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
57 (set-extent-begin-glyph gutter-buffers-tab-extent
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
58 (setq gutter-buffers-tab
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
59 (make-glyph)))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
60 ;; Nuke all existing tabs
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
61 (remove-gutter-element top-gutter 'buffers-tab)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
62 (remove-gutter-element bottom-gutter 'buffers-tab)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
63 (remove-gutter-element left-gutter 'buffers-tab)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
64 (remove-gutter-element right-gutter 'buffers-tab)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
65 ;; Put tabs into all devices that will be able to display them
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
66 (mapcar
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
67 #'(lambda (x)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
68 (when (valid-image-instantiator-format-p 'tab-control x)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
69 (cond ((eq gutter-buffers-tab-orientation 'top)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
70 ;; This looks better than a 3d border
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
71 (set-specifier top-gutter-border-width 0 'global x)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
72 (set-gutter-element top-gutter 'buffers-tab
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
73 gutter-string 'global x))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
74 ((eq gutter-buffers-tab-orientation 'bottom)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
75 (set-specifier bottom-gutter-border-width 0 'global x)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
76 (set-gutter-element bottom-gutter 'buffers-tab
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
77 gutter-string 'global x))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
78 ((eq gutter-buffers-tab-orientation 'left)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
79 (set-specifier left-gutter-border-width 0 'global x)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
80 (set-gutter-element left-gutter 'buffers-tab
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
81 gutter-string 'global x))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
82 ((eq gutter-buffers-tab-orientation 'right)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
83 (set-specifier right-gutter-border-width 0 'global x)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
84 (set-gutter-element right-gutter 'buffers-tab
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
85 gutter-string 'global x))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
86 )))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
87 (console-type-list))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
88
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
89 (defun update-tab-in-gutter (frame &optional force-selection)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 "Update the tab control in the gutter area."
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
91 ;; dedicated frames don't get tabs
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
92 (unless (or (window-dedicated-p (frame-selected-window frame))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
93 (frame-property frame 'popup))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
94 (when (specifier-instance default-gutter-visible-p frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
95 (unless (and gutter-buffers-tab
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
96 (eq (default-gutter-position)
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 430
diff changeset
97 gutter-buffers-tab-orientation))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 (add-tab-to-gutter))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
99 (when (valid-image-instantiator-format-p 'tab-control frame)
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
100 (let ((items (buffers-tab-items nil frame force-selection)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
101 (when items
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
102 (set-glyph-image
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
103 gutter-buffers-tab
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
104 (vector 'tab-control :descriptor "Buffers" :face buffers-tab-face
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
105 :orientation gutter-buffers-tab-orientation
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
106 (if (or (eq gutter-buffers-tab-orientation 'top)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
107 (eq gutter-buffers-tab-orientation 'bottom))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
108 :pixel-width :pixel-height)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
109 (if (or (eq gutter-buffers-tab-orientation 'top)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
110 (eq gutter-buffers-tab-orientation 'bottom))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
111 '(gutter-pixel-width) '(gutter-pixel-height))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
112 :items items)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
113 frame)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
114 ;; set-glyph-image will not make the gutter dirty
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
115 (set-gutter-dirty-p gutter-buffers-tab-orientation)))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
117 ;; A myriad of different update hooks all doing slightly different things
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
118 (add-one-shot-hook
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
119 'after-init-hook
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
120 #'(lambda ()
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
121 ;; don't add the hooks if the user really doesn't want them
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
122 (when gutter-buffers-tab-enabled
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
123 (add-hook 'create-frame-hook
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
124 #'(lambda (frame)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
125 (when gutter-buffers-tab (update-tab-in-gutter frame t))))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
126 (add-hook 'buffer-list-changed-hook 'update-tab-in-gutter)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
127 (add-hook 'default-gutter-position-changed-hook
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
128 #'(lambda ()
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
129 (when gutter-buffers-tab
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
130 (mapc #'update-tab-in-gutter (frame-list)))))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
131 (add-hook 'gutter-element-visibility-changed-hook
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
132 #'(lambda (prop visible-p)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
133 (when (and (eq prop 'buffers-tab) visible-p)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
134 (mapc #'update-tab-in-gutter (frame-list)))))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
135 (update-tab-in-gutter (selected-frame) t))))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
136
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 ;; progress display
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 ;; ripped off from message display
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 ;;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
141 (defcustom progress-feedback-use-echo-area nil
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
142 "*Whether progress gauge display should display in the echo area.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
143 If NIL then progress gauges will be displayed with whatever native widgets
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
144 are available on the current console. If non-NIL then progress display will be
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
145 textual and displayed in the echo area."
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
146 :type 'boolean
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
147 :group 'gutter)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
148
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
149 (defvar progress-glyph-height 24
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
150 "Height of the progress gauge glyph.")
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
151
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
152 (defvar progress-feedback-popup-period 0.5
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
153 "The time that the progress gauge should remain up after completion")
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
154
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
155 (defcustom progress-feedback-style 'large
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
156 "*Control the appearance of the progress gauge.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
157 If 'large, the default, then the progress-feedback text is displayed
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
158 above the gauge itself. If 'small then the gauge and text are arranged
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
159 side-by-side."
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
160 :group 'gutter
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
161 :type '(choice (const :tag "large" large)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
162 (const :tag "small" small)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
163
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
164 ;; private variables
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
165 (defvar progress-text-instantiator [string :data ""])
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
166 (defvar progress-layout-glyph (make-glyph))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
167 (defvar progress-layout-instantiator nil)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
168
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
169 (defvar progress-gauge-instantiator
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
170 [progress-gauge
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
171 :value 0
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
172 :pixel-height (eval progress-glyph-height)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
173 :pixel-width 250
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
174 :descriptor "Progress"])
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
175
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
176 (defun set-progress-feedback-instantiator (&optional locale)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
177 (cond
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
178 ((eq progress-feedback-style 'small)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
179 (setq progress-glyph-height 16)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
180 (setq progress-layout-instantiator
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
181 `[layout
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
182 :orientation horizontal
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
183 :margin-width 4
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
184 :items (,progress-gauge-instantiator
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
185 [button
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
186 :pixel-height (eval progress-glyph-height)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
187 ;; 'quit is special and acts "asynchronously".
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
188 :descriptor "Stop" :callback 'quit]
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
189 ,progress-text-instantiator)])
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
190 (set-glyph-image progress-layout-glyph progress-layout-instantiator
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
191 locale))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
192 (t
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
193 (setq progress-glyph-height 24)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
194 (setq progress-layout-instantiator
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
195 `[layout
863
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 771
diff changeset
196 :orientation vertical :margin-width 4
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 771
diff changeset
197 :horizontally-justify left :vertically-justify center
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
198 :items (,progress-text-instantiator
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
199 [layout
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
200 :orientation horizontal
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
201 :items (,progress-gauge-instantiator
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
202 [button
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
203 :pixel-height (eval progress-glyph-height)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
204 :descriptor " Stop "
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
205 ;; 'quit is special and acts "asynchronously".
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
206 :callback 'quit])])])
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
207 (set-glyph-image progress-layout-glyph progress-layout-instantiator
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
208 locale))))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
209
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
210 (defvar progress-abort-glyph (make-glyph))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
211
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
212 (defun set-progress-abort-instantiator (&optional locale)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
213 (set-glyph-image progress-abort-glyph
863
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 771
diff changeset
214 `[layout :orientation vertical
42375619fa45 [xemacs-hg @ 2002-06-04 06:03:59 by andyp]
andyp
parents: 771
diff changeset
215 :horizontally-justify left :vertically-justify center
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
216 :items (,progress-text-instantiator
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
217 [layout
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
218 :margin-width 4
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
219 :pixel-height progress-glyph-height
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
220 :orientation horizontal])]
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
221 locale))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
222
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 (defvar progress-stack nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 "An alist of label/string pairs representing active progress gauges.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 The first element in the list is currently displayed in the gutter area.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
226 Do not modify this directly--use the `progress-feedback' or
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
227 `display-progress-feedback'/`clear-progress-feedback' functions.")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
229 (defun progress-feedback-displayed-p (&optional return-string frame)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 "Return a non-nil value if a progress gauge is presently displayed in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 gutter area. If optional argument RETURN-STRING is non-nil,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 return a string containing the message, otherwise just return t."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 (let ((buffer (get-buffer-create " *Gutter Area*")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 (and (< (point-min buffer) (point-max buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 (if return-string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 (buffer-substring nil nil buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 t))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 ;;; Returns the string which remains in the echo area, or nil if none.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 ;;; If label is nil, the whole message stack is cleared.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
241 (defun clear-progress-feedback (&optional label frame no-restore)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
242 "Remove any progress gauge with LABEL from the progress gauge-stack,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 erasing it from the gutter area if it's currently displayed there.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 If a message remains at the head of the progress-stack and NO-RESTORE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 is nil, it will be displayed. The string which remains in the gutter
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 area will be returned, or nil if the progress-stack is now empty.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 If LABEL is nil, the entire progress-stack is cleared.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 Unless you need the return value or you need to specify a label,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 you should just use (progress nil)."
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
251 (if (or (not (valid-image-instantiator-format-p 'progress-gauge frame))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
252 progress-feedback-use-echo-area)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
253 (clear-message label frame nil no-restore)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
254 (or frame (setq frame (selected-frame)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
255 (remove-progress-feedback label frame)
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 458
diff changeset
256 (let ((inhibit-read-only t))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
257 (erase-buffer (get-buffer-create " *Gutter Area*")))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
258 (if no-restore
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
259 nil ; just preparing to put another msg up
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
260 (if progress-stack
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
261 (let ((oldmsg (cdr (car progress-stack))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
262 (raw-append-progress-feedback oldmsg nil frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
263 oldmsg)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
264 ;; nothing to display so get rid of the gauge
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
265 (set-specifier bottom-gutter-border-width 0 frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
266 (set-gutter-element-visible-p bottom-gutter-visible-p
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
267 'progress nil frame)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
269 (defun progress-feedback-clear-when-idle (&optional label)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
270 (add-one-shot-hook 'pre-idle-hook
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
271 `(lambda ()
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
272 (clear-progress-feedback ',label))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
273
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
274 (defun remove-progress-feedback (&optional label frame)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 ;; If label is nil, we want to remove all matching progress gauges.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 (while (and progress-stack
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 (or (null label) ; null label means clear whole stack
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 (eq label (car (car progress-stack)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 (setq progress-stack (cdr progress-stack)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 (let ((s progress-stack))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 (while (cdr s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 (let ((msg (car (cdr s))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 (if (eq label (car msg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 (setcdr s (cdr (cdr s))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 (setq s (cdr s)))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
288 (defun progress-feedback-dispatch-non-command-events ()
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
289 ;; don't allow errors to hose things
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
290 (condition-case t
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
291 ;; (sit-for 0) is too agressive and cause more display than we
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
292 ;; want.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
293 (dispatch-non-command-events)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
294 nil))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
295
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
296 (defun append-progress-feedback (label message &optional value frame)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 (or frame (setq frame (selected-frame)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 ;; Add a new entry to the message-stack, or modify an existing one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 (let* ((top (car progress-stack))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 (tmsg (cdr top)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 (if (eq label (car top))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 (setcdr top message)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
304 (if (equal tmsg message)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
305 (progn
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
306 (set-instantiator-property progress-gauge-instantiator :value value)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
307 (set-progress-feedback-instantiator (frame-selected-window frame)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
308 (raw-append-progress-feedback message value frame))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
309 (redisplay-gutter-area))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 (push (cons label message) progress-stack)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
311 (raw-append-progress-feedback message value frame))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
312 (progress-feedback-dispatch-non-command-events)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
313 ;; either get command events or sit waiting for them
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
314 (when (eq value 100)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
315 ; (sit-for progress-feedback-popup-period nil)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
316 (clear-progress-feedback label))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
318 (defun abort-progress-feedback (label message &optional frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
319 (if (or (not (valid-image-instantiator-format-p 'progress-gauge frame))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
320 progress-feedback-use-echo-area)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
321 (display-message label (concat message "aborted.") frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
322 (or frame (setq frame (selected-frame)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
323 ;; Add a new entry to the message-stack, or modify an existing one
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
324 (let* ((top (car progress-stack))
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 458
diff changeset
325 (inhibit-read-only t))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
326 (if (eq label (car top))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
327 (setcdr top message)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
328 (push (cons label message) progress-stack))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
329 (unless (equal message "")
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
330 (insert-string message (get-buffer-create " *Gutter Area*"))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
331 (let* ((gutter-string (copy-sequence "\n"))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
332 (ext (make-extent 0 1 gutter-string)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
333 ;; do some funky display here.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
334 (set-extent-begin-glyph ext progress-abort-glyph)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 ;; fixup the gutter specifiers
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
336 (set-gutter-element bottom-gutter 'progress gutter-string frame)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 (set-specifier bottom-gutter-border-width 2 frame)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
338 (set-instantiator-property progress-text-instantiator :data message)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
339 (set-progress-abort-instantiator (frame-selected-window frame))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 (set-specifier bottom-gutter-height 'autodetect frame)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
341 (set-gutter-element-visible-p bottom-gutter-visible-p
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
342 'progress t frame)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 ;; we have to do this so redisplay is up-to-date and so
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 ;; redisplay-gutter-area performs optimally.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 (redisplay-gutter-area)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
346 (sit-for progress-feedback-popup-period nil)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
347 (clear-progress-feedback label frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
348 (set-extent-begin-glyph ext progress-layout-glyph)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
349 (set-gutter-element bottom-gutter 'progress gutter-string frame)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 )))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
352 (defun raw-append-progress-feedback (message &optional value frame)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 (unless (equal message "")
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
354 (let* ((inhibit-read-only t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
355 (val (or value 0))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
356 (gutter-string (copy-sequence "\n"))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
357 (ext (make-extent 0 1 gutter-string)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 (insert-string message (get-buffer-create " *Gutter Area*"))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
359 ;; do some funky display here.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
360 (set-extent-begin-glyph ext progress-layout-glyph)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
361 ;; fixup the gutter specifiers
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
362 (set-gutter-element bottom-gutter 'progress gutter-string frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
363 (set-specifier bottom-gutter-border-width 2 frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
364 (set-instantiator-property progress-gauge-instantiator :value val)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
365 (set-progress-feedback-instantiator (frame-selected-window frame))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
366
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
367 (set-instantiator-property progress-text-instantiator :data message)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
368 (set-progress-feedback-instantiator (frame-selected-window frame))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
369 (if (and (eq (specifier-instance bottom-gutter-height frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
370 'autodetect)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
371 (gutter-element-visible-p bottom-gutter-visible-p
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
372 'progress frame))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
373 ;; if the gauge is already visible then just draw the gutter
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
374 ;; checking for user events
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 (progn
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
376 (redisplay-gutter-area)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
377 (progress-feedback-dispatch-non-command-events))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
378 ;; otherwise make the gutter visible and redraw the frame
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
379 (set-specifier bottom-gutter-height 'autodetect frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
380 (set-gutter-element-visible-p bottom-gutter-visible-p
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
381 'progress t frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
382 ;; we have to do this so redisplay is up-to-date and so
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
383 ;; redisplay-gutter-area performs optimally. This may also
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
384 ;; make sure the frame geometry looks ok.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
385 (progress-feedback-dispatch-non-command-events)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
386 (redisplay-frame frame)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
387 ))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
389 (defun display-progress-feedback (label message &optional value frame)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 "Display a progress gauge and message in the bottom gutter area.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 First argument LABEL is an identifier for this message. MESSAGE is
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
392 the string to display. Use `clear-progress-feedback' to remove a labelled
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 message."
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
394 (cond ((eq value 'abort)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
395 (abort-progress-feedback label message frame))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
396 ((or (not (valid-image-instantiator-format-p 'progress-gauge frame))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
397 progress-feedback-use-echo-area)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
398 (display-message label
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
399 (concat message (if (eq value 100) "done."
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
400 (make-string (/ value 5) ?.)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
401 frame))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
402 (t
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
403 (append-progress-feedback label message value frame))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
405 (defun current-progress-feedback (&optional frame)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 "Return the current progress gauge in the gutter area, or nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 The FRAME argument is currently unused."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 (cdr (car progress-stack)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 ;;; may eventually be frame-dependent
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
411 (defun current-progress-feedback-label (&optional frame)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 (car (car progress-stack)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
414 (defun progress-feedback (fmt &optional value &rest args)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 "Print a progress gauge and message in the bottom gutter area of the frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 The arguments are the same as to `format'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 If the only argument is nil, clear any existing progress gauge."
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
419 (save-excursion
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
420 (if (and (null fmt) (null args))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
421 (prog1 nil
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
422 (clear-progress-feedback nil))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
423 (let ((str (apply 'format fmt args)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
424 (display-progress-feedback 'progress str value)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
425 str))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
427 (defun progress-feedback-with-label (label fmt &optional value &rest args)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 "Print a progress gauge and message in the bottom gutter area of the frame.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 First argument LABEL is an identifier for this progress gauge. The rest of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 arguments are the same as to `format'."
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
431 ;; #### sometimes the buffer gets changed temporarily. I don't know
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
432 ;; why this is, so protect against it.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
433 (save-excursion
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
434 (if (and (null fmt) (null args))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
435 (prog1 nil
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
436 (clear-progress-feedback label nil))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
437 (let ((str (apply 'format fmt args)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
438 (display-progress-feedback label str value)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
439 str))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 (provide 'gutter-items)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 ;;; gutter-items.el ends here.