comparison lisp/hyperbole/kotl/kmenu.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children 4103f0995bd7
comparison
equal deleted inserted replaced
-1:000000000000 0:376386a54a3c
1 ;;!emacs
2 ;;
3 ;; FILE: kmenu.el
4 ;; SUMMARY: Pulldown and popup menus for kotl-mode, the Hyperbole Outliner.
5 ;; USAGE: GNU Emacs Lisp Library
6 ;; KEYWORDS: mouse, outlines, wp
7 ;;
8 ;; AUTHOR: Bob Weiner
9 ;; ORG: Motorola, Inc., PPG
10 ;;
11 ;; ORIG-DATE: 28-Mar-94 at 11:22:09
12 ;; LAST-MOD: 26-Oct-95 at 18:47:41 by Bob Weiner
13 ;;
14 ;; Copyright (C) 1994-1995 Free Software Foundation, Inc.
15 ;;
16 ;; This file is part of Hyperbole.
17 ;;
18 ;; DESCRIPTION:
19 ;; DESCRIP-END.
20
21 ;;; ************************************************************************
22 ;;; Public variables
23 ;;; ************************************************************************
24
25 ;;; This definition is used by InfoDock only.
26 (defconst id-menubar-kotl
27 '(
28 ("Koutline"
29 ["All-Cells-Attributes" (kotl-modecell-help nil -1) t]
30 ["Help" describe-mode t]
31 ["Manual" (id-info "(hyperbole.info)Outliner") t]
32 "----"
33 ["Find (Open)" find-file t]
34 ["Find-Read-Only" find-file-read-only t]
35 ["Save" save-buffer t]
36 ["Toggle-Read-Only" toggle-read-only t]
37 ["Write (Save as)" kfile:write t]
38 "----"
39 ["Quit" (id-tool-quit '(kill-buffer nil)) t]
40 )
41 ("Edit"
42 ["Set-Cell-Attribute" kotl-mode:set-cell-attribute t]
43 "----"
44 ["Add-Child" kotl-mode:add-child t]
45 ["Add-Cell" kotl-mode:add-cell t]
46 ["Add-Parent" kotl-mode:add-parent t]
47 ["Append-Cell" kotl-mode:append-cell t]
48 ["Split-Cell" kotl-mode:split-cell t]
49 "----"
50 ["Kill-to-Cell-End" kotl-mode:kill-contents t]
51 ["Kill-Tree" kotl-mode:kill-tree t]
52 ["Yank" kotl-mode:yank t]
53 "----"
54 ["Copy-After-Cell" kotl-mode:copy-after t]
55 ["Copy-Before-Cell" kotl-mode:copy-before t]
56 ["Move-After-Cell" kotl-mode:move-after t]
57 ["Move-Before-Cell" kotl-mode:move-before t]
58 "----"
59 ["Fill" kotl-mode:fill-cell t]
60 ["Fill-Paragraph" kotl-mode:fill-paragraph t]
61 ["Set-Fill-Prefix" kotl-mode:set-fill-prefix t]
62 )
63 ("Jump-to"
64 ["Cell" kotl-mode:goto-cell t]
65 "----"
66 ["Cell-Beginning" kotl-mode:beginning-of-cell t]
67 ["Cell-End" kotl-mode:end-of-cell t]
68 "----"
69 ["Child" kotl-mode:down-level t]
70 ["Parent" kotl-mode:up-level t]
71 "----"
72 ["Next-Cell" kotl-mode:next-cell t]
73 ["Prev-Cell" kotl-mode:previous-cell t]
74 "----"
75 ["Next-Same-Level" kotl-mode:forward-cell t]
76 ["Prev-Same-Level" kotl-mode:backward-cell t]
77 "----"
78 ["First-Sibling" kotl-mode:first-sibling t]
79 ["Last-Sibling" kotl-mode:last-sibling t]
80 "----"
81 ["Beginning-of-Tree" kotl-mode:beginning-of-tree t]
82 ["End-of-Tree" kotl-mode:end-of-tree t]
83 "----"
84 ["First-Cell" kotl-mode:beginning-of-buffer t]
85 ["Last-Cell" kotl-mode:end-of-buffer t]
86 )
87 ("Label-Type"
88 ["Alphanumeric (Default)" (kview:set-label-type kview 'alpha) t]
89 ["Legal" (kview:set-label-type kview 'legal) t]
90 ["None" (kview:set-label-type kview 'no) t]
91 ["Partial-Alpha" (kview:set-label-type kview 'partial-alpha) t]
92 ["Permanent-Idstamp" (kview:set-label-type kview 'id) t]
93 ["Stars" (kview:set-label-type kview 'star) t]
94 )
95 ("Link"
96 ["Add-at-Point" klink:create t]
97 )
98 ("Tree"
99 ["Copy-to-Buffer" kotl-mode:copy-to-buffer t]
100 ["Demote" kotl-mode:demote-tree t]
101 ["Kill" kotl-mode:kill-tree t]
102 ["Mail" kotl-mode:mail-tree t]
103 ["Promote" kotl-mode:promote-tree t]
104 ["Show-Attributes" (kotl-modecell-help nil 2) t]
105 "----"
106 ["Copy-After-Cell" kotl-mode:copy-after t]
107 ["Copy-Before-Cell" kotl-mode:copy-before t]
108 ["Move-After-Cell" kotl-mode:move-after t]
109 ["Move-Before-Cell" kotl-mode:move-before t]
110 )
111 ("View"
112 ["Set-View-Spec" kvspec:activate t]
113 ["Toggle-Blank-Lines" kvspec:toggle-blank-lines t]
114 "----"
115 ["Set-Cell-Attribute" kotl-mode:set-cell-attribute t]
116 ["Show-Cell-Attributes" (kotl-modecell-help) t]
117 ["All-Cells-Attributes" (kotl-modecell-help nil -1) t]
118 ["Show-Tree-Attributes" (kotl-modecell-help nil 2) t]
119 "----"
120 ["Hide (Collapse)" kotl-mode:hide-tree t]
121 ["Hide-Levels" kotl-mode:hide-sublevels t]
122 ["Hide-Subtree" kotl-mode:hide-subtree t]
123 ["Overview" kotl-mode:overview t]
124 "----"
125 ["Show (Expand)" kotl-mode:show-tree t]
126 ["Show-All" kotl-mode:show-all t]
127 ["Show-Subtree" kotl-mode:show-subtree t]
128 ["Show-Top-Level-Only" kotl-mode:top-cells t]
129 )
130 ))
131
132 ;;; This definition is used by InfoDock and XEmacs.
133 (defconst id-popup-kotl-menu
134 '("Koutline"
135 ["All-Cells-Attributes" (kotl-modecell-help nil -1) t]
136 ["Help" describe-mode t]
137 ["Manual" (id-info "(hyperbole.info)Outliner") t]
138 "----"
139 ("Edit"
140 ["Set-Cell-Attribute" kotl-mode:set-cell-attribute t]
141 "----"
142 ["Add-Child" kotl-mode:add-child t]
143 ["Add-Cell" kotl-mode:add-cell t]
144 ["Add-Parent" kotl-mode:add-parent t]
145 ["Append-Cell" kotl-mode:append-cell t]
146 ["Split-Cell" kotl-mode:split-cell t]
147 "----"
148 ["Kill-to-Cell-End" kotl-mode:kill-contents t]
149 ["Kill-Tree" kotl-mode:kill-tree t]
150 ["Yank" kotl-mode:yank t]
151 "----"
152 ["Copy-After-Cell" kotl-mode:copy-after t]
153 ["Copy-Before-Cell" kotl-mode:copy-before t]
154 ["Move-After-Cell" kotl-mode:move-after t]
155 ["Move-Before-Cell" kotl-mode:move-before t]
156 "----"
157 ["Fill" kotl-mode:fill-cell t]
158 ["Fill-Paragraph" kotl-mode:fill-paragraph t]
159 ["Set-Fill-Prefix" kotl-mode:set-fill-prefix t]
160 )
161 ("Jump-to"
162 ["Cell" kotl-mode:goto-cell t]
163 "----"
164 ["Cell-Beginning" kotl-mode:beginning-of-cell t]
165 ["Cell-End" kotl-mode:end-of-cell t]
166 "----"
167 ["Child" kotl-mode:down-level t]
168 ["Parent" kotl-mode:up-level t]
169 "----"
170 ["Next-Cell" kotl-mode:next-cell t]
171 ["Prev-Cell" kotl-mode:previous-cell t]
172 "----"
173 ["Next-Same-Level" kotl-mode:forward-cell t]
174 ["Prev-Same-Level" kotl-mode:backward-cell t]
175 "----"
176 ["First-Sibling" kotl-mode:first-sibling t]
177 ["Last-Sibling" kotl-mode:last-sibling t]
178 "----"
179 ["Beginning-of-Tree" kotl-mode:beginning-of-tree t]
180 ["End-of-Tree" kotl-mode:end-of-tree t]
181 "----"
182 ["First-Cell" kotl-mode:beginning-of-buffer t]
183 ["Last-Cell" kotl-mode:end-of-buffer t]
184 )
185 ("Label-Type"
186 ["Alphanumeric (Default)" (kview:set-label-type kview 'alpha) t]
187 ["Legal" (kview:set-label-type kview 'legal) t]
188 ["None" (kview:set-label-type kview 'no) t]
189 ["Partial-Alpha" (kview:set-label-type kview 'partial-alpha) t]
190 ["Permanent-Idstamp" (kview:set-label-type kview 'id) t]
191 ["Stars" (kview:set-label-type kview 'star) t]
192 )
193 ("Link"
194 ["Add-at-Point" klink:create t]
195 )
196 ("Tree"
197 ["Copy-to-Buffer" kotl-mode:copy-to-buffer t]
198 ["Demote" kotl-mode:demote-tree t]
199 ["Kill" kotl-mode:kill-tree t]
200 ["Mail" kotl-mode:mail-tree t]
201 ["Promote" kotl-mode:promote-tree t]
202 ["Show-Attributes" (kotl-modecell-help nil 2) t]
203 "----"
204 ["Copy-After-Cell" kotl-mode:copy-after t]
205 ["Copy-Before-Cell" kotl-mode:copy-before t]
206 ["Move-After-Cell" kotl-mode:move-after t]
207 ["Move-Before-Cell" kotl-mode:move-before t]
208 )
209 ("View"
210 ["Set-View-Spec" kvspec:activate t]
211 ["Toggle-Blank-Lines" kvspec:toggle-blank-lines t]
212 "----"
213 ["Set-Cell-Attribute" kotl-mode:set-cell-attribute t]
214 ["Show-Cell-Attributes" (kotl-modecell-help) t]
215 ["All-Cells-Attributes" (kotl-modecell-help nil -1) t]
216 ["Show-Tree-Attributes" (kotl-modecell-help nil 2) t]
217 "----"
218 ["Hide (Collapse)" kotl-mode:hide-tree t]
219 ["Hide-Levels" kotl-mode:hide-sublevels t]
220 ["Hide-Subtree" kotl-mode:hide-subtree t]
221 ["Overview" kotl-mode:overview t]
222 "----"
223 ["Show (Expand)" kotl-mode:show-tree t]
224 ["Show-All" kotl-mode:show-all t]
225 ["Show-Subtree" kotl-mode:show-subtree t]
226 ["Show-Top-Level-Only" kotl-mode:top-cells t]
227 )
228 "----"
229 ["Find (Open)" find-file t]
230 ["Find-Read-Only" find-file-read-only t]
231 ["Save" save-buffer t]
232 ["Toggle-Read-Only" toggle-read-only t]
233 ["Write (Save as)" kfile:write t]
234 "----"
235 ["Quit" (id-tool-quit '(kill-buffer nil)) t]
236 ))
237
238 ;;; ************************************************************************
239 ;;; Public functions
240 ;;; ************************************************************************
241
242 ;;; This definition is used only by XEmacs and Emacs19.
243 (defun kotl-menubar-menu ()
244 "Add a Koutline menu to the menubar for each koutline buffer."
245 (cond ((fboundp 'popup-mode-menu)
246 (setq mode-popup-menu id-popup-kotl-menu))
247 (hyperb:lemacs-p
248 (define-key kotl-mode-map 'button3 'kotl-popup-menu))
249 (t ;; hyperb:emacs19-p
250 (define-key kotl-mode-map [down-mouse-3] 'kotl-popup-menu)
251 (define-key kotl-mode-map [mouse-3] nil)))
252 (if (and (boundp 'current-menubar)
253 (or hyperb:emacs19-p current-menubar)
254 (not (car (find-menu-item current-menubar '("Koutline")))))
255 (progn
256 (set-buffer-menubar (copy-sequence current-menubar))
257 (if (fboundp 'add-submenu)
258 (add-submenu nil id-popup-kotl-menu)
259 (add-menu nil (car id-popup-kotl-menu) (cdr id-popup-kotl-menu))))))
260
261 ;;; This definition is used only by XEmacs and Emacs19.
262 (defun kotl-popup-menu (event)
263 "Popup the Koutline buffer menu."
264 (interactive "@e")
265 (mouse-set-point event)
266 (if (fboundp 'popup-mode-menu)
267 (popup-mode-menu)
268 (popup-menu id-popup-kotl-menu)))
269
270 (cond ((null hyperb:window-system))
271 ((fboundp 'id-menubar-set)
272 ;; InfoDock under a window system
273 (require 'id-menubars)
274 (id-menubar-set 'kotl-mode 'id-menubar-kotl))
275 (hyperb:lemacs-p
276 ;; XEmacs under a window system
277 (add-hook 'kotl-mode-hook 'kotl-menubar-menu))
278 (hyperb:emacs19-p
279 ;; Emacs 19 under a window system
280 (require 'lmenu)
281 (add-hook 'kotl-mode-hook 'kotl-menubar-menu)))
282
283 (provide 'kmenu)