Permalink
Browse files

Generic popup-menu-titles and popup-menu for the methods-buffer

  • Loading branch information...
1 parent 08a9fc8 commit 7c82858dc4bb1befdba9b9fb627a1d0a71abcb67 berndl committed Mar 27, 2003
Showing with 124 additions and 21 deletions.
  1. +12 −8 NEWS
  2. +89 −4 ecb.el
  3. +23 −9 tree-buffer.el
View
20 NEWS
@@ -29,18 +29,22 @@
*** `ecb-toggle-compile-window' now has a default key-binding: [C-c . \]
+*** Now also layouts with user-defined special ecb-windows can be created
+ interactively. See the online-manual for further details.
+
+** Enhancements to the tree-buffers:
+
+*** Now user-extensions can be added to the popup-menues of the tree-buffers.
+ See new options `ecb-directories-menu-user-extension',
+ `ecb-sources-menu-user-extension', `ecb-methods-menu-user-extension',
+ `ecb-history-menu-user-extension'.
+
+*** The methods-buffer now has a popup-menu with senseful actions
+
** New option `ecb-sources-exclude-cvsignore' which allows to exclude files from
being displayed in the sources-buffer if they are contained in a .cvsignore
file.
-** Now also layouts with user-defined special ecb-windows can be created
- interactively. See the online-manual for further details.
-
-** Now user-extensions can be added to the popup-menues of the tree-buffers.
- See new options `ecb-directories-menu-user-extension',
- `ecb-sources-menu-user-extension', `ecb-methods-menu-user-extension',
- `ecb-history-menu-user-extension'.
-
** ECB now also works with buffers "online" extracted from archives.
Buffers extracted from an archive in `tar-mode' or `archive-mode' are now
correct handled as if they were normal file-buffers. This feature doesn't
View
93 ecb.el
@@ -3621,6 +3621,7 @@ combination is invalid \(see `ecb-interpret-mouse-click'."
(ecb-goto-window tree-buffer-name)
(tree-buffer-remove-highlight))))
+
(defun ecb-tree-buffer-node-expand-callback (node
mouse-button
shift-pressed
@@ -3941,8 +3942,9 @@ can last a long time - depending of machine- and disk-performance."
;; let us set the mark so the user can easily jump back.
(if ecb-token-jump-sets-mark
(push-mark nil t))
- (when ecb-token-jump-narrow
- (widen))
+;; (when ecb-token-jump-narrow
+;; (widen))
+ (widen)
(goto-char (ecb-semantic-token-start token))
(if ecb-token-jump-narrow
(narrow-to-region (ecb-line-beginning-pos)
@@ -4756,6 +4758,9 @@ always the ECB-frame if called from another frame."
'identity)
(append ecb-directories-menu-user-extension
ecb-source-path-menu))))
+ (list (cons 0 ecb-directories-menu-title-creator)
+ (cons 1 ecb-directories-menu-title-creator)
+ (cons 2 ecb-directories-menu-title-creator))
(nth 0 ecb-truncate-lines)
t
ecb-tree-indent
@@ -4791,6 +4796,7 @@ always the ECB-frame if called from another frame."
'identity)
(append ecb-sources-menu-user-extension
ecb-sources-menu))))
+ (list (cons 0 ecb-sources-menu-title-creator))
(nth 1 ecb-truncate-lines)
t
ecb-tree-indent
@@ -4834,7 +4840,18 @@ always the ECB-frame if called from another frame."
(list (cons 0 (funcall (or ecb-methods-menu-sorter
'identity)
(append ecb-methods-menu-user-extension
- ecb-methods-menu))))
+ ecb-methods-token-menu)))
+ (cons 1 (funcall (or ecb-methods-menu-sorter
+ 'identity)
+ (append ecb-methods-menu-user-extension
+ ecb-common-methods-menu)))
+ (cons 2 (funcall (or ecb-methods-menu-sorter
+ 'identity)
+ (append ecb-methods-menu-user-extension
+ ecb-common-methods-menu))))
+ (list (cons 0 ecb-methods-menu-title-creator)
+ (cons 1 ecb-methods-menu-title-creator)
+ (cons 2 ecb-methods-menu-title-creator))
(nth 2 ecb-truncate-lines)
t
ecb-tree-indent
@@ -4866,6 +4883,7 @@ always the ECB-frame if called from another frame."
'identity)
(append ecb-history-menu-user-extension
ecb-history-menu))))
+ (list (cons 0 ecb-history-menu-title-creator))
(nth 3 ecb-truncate-lines)
t
ecb-tree-indent
@@ -5143,6 +5161,12 @@ source-path of `ecb-source-path'.")
ecb-common-directories-menu
'(("Make This a Source Path" ecb-node-to-source-path))))
+(defvar ecb-directories-menu-title-creator
+ (function (lambda (node)
+ (tree-node-get-data node)))
+ "The menu-title for the directories menu. Has to be either a string or a
+function which is called with current node and has to return a string.")
+
(defvar ecb-source-path-menu nil
"Builtin menu for the directories-buffer for directories which are elements of
`ecb-source-path'.")
@@ -5161,8 +5185,63 @@ source-path of `ecb-source-path'.")
("Create File" ecb-create-file-2)
("Create Source" ecb-create-source)))
-(defvar ecb-methods-menu nil
+(defvar ecb-sources-menu-title-creator
+ (function (lambda (node)
+ (file-name-nondirectory (tree-node-get-data node))))
+ "The menu-title for the sources menu. See
+`ecb-directories-menu-title-creator'.")
+
+(defun ecb-methods-menu-jump-and-narrow (node)
+ (ecb-method-clicked node 1 t))
+
+(defun ecb-methods-menu-widen (node)
+ (ecb-select-edit-window)
+ (widen))
+
+(defun ecb-methods-menu-collapse-all (node)
+ (ecb-expand-methods-nodes-internal -1 nil t))
+
+(defun ecb-methods-menu-expand-0 (node)
+ (ecb-expand-methods-nodes-internal 0 nil t))
+
+(defun ecb-methods-menu-expand-1 (node)
+ (ecb-expand-methods-nodes-internal 1 nil t))
+
+(defun ecb-methods-menu-expand-2 (node)
+ (ecb-expand-methods-nodes-internal 2 nil t))
+
+(defun ecb-methods-menu-expand-all (node)
+ (ecb-expand-methods-nodes-internal 100 nil t))
+
+(defvar ecb-common-methods-menu nil
"Builtin menu for the methods-buffer.")
+(setq ecb-common-methods-menu
+ '(("Undo narrowing of edit-window" ecb-methods-menu-widen)
+ ("---")
+ ("Collapse all" ecb-methods-menu-collapse-all)
+ ("Expand level 0" ecb-methods-menu-expand-0)
+ ("Expand level 1" ecb-methods-menu-expand-1)
+ ("Expand level 2" ecb-methods-menu-expand-2)
+ ("Expand all" ecb-methods-menu-expand-all)))
+
+(defvar ecb-methods-token-menu nil)
+(setq ecb-methods-token-menu
+ (append '(("Jump to token and narrow" ecb-methods-menu-jump-and-narrow))
+ ecb-common-methods-menu))
+
+(defvar ecb-methods-menu-title-creator
+ (function (lambda (node)
+ (let ((data (tree-node-get-data node)))
+ (if data
+ (cond ((semantic-token-p data)
+ (semantic-token-name data))
+ ((stringp data)
+ data)
+ (t (tree-node-get-name node)))
+ (tree-node-get-name node)))))
+ "The menu-title for the methods menu. See
+`ecb-directories-menu-title-creator'.")
+
;; three easy-entry functions for the history menu for conveniance
;; Note: The node argument in the first two functions is not used.
@@ -5212,6 +5291,12 @@ buffers does not exist anymore."
("Remove All Entries" ecb-clear-history-all)
("Remove Non Existing Buffer Entries" ecb-clear-history-only-not-existing)))
+(defvar ecb-history-menu-title-creator
+ (function (lambda (node)
+ (tree-node-get-data node)))
+ "The menu-title for the history menu. See
+`ecb-directories-menu-title-creator'.")
+
;; ECB byte-compilation
View
@@ -123,6 +123,7 @@ node name.")
(defvar tree-buffer-indent nil)
(defvar tree-buffer-highlighted-node-data nil)
(defvar tree-buffer-menus nil)
+(defvar tree-buffer-menu-titles nil)
(defvar tree-buffer-type-facer nil)
(defvar tree-buffer-expand-symbol-before nil)
(defvar tree-buffer-is-click-valid-fn nil)
@@ -670,13 +671,19 @@ see `tree-buffer-expand-nodes'."
(when tree-buffer-menus
(let ((node (tree-buffer-get-node-at-point)))
(when node
- (let ((menu (cdr (assoc (tree-node-get-type node) tree-buffer-menus))))
- (when menu
+ (let* ((menu (cdr (assoc (tree-node-get-type node) tree-buffer-menus)))
+ (menu-title-creator
+ (cdr (assoc (tree-node-get-type node) tree-buffer-menu-titles)))
+ (menu-title (cond ((stringp menu-title-creator)
+ menu-title-creator)
+ ((functionp menu-title-creator)
+ (funcall menu-title-creator node))
+ (t "ECB-tree-buffer-menu"))))
+ (when menu
(if tree-buffer-running-xemacs
- (popup-menu (cons (tree-node-get-data node) menu))
+ (popup-menu (cons menu-title menu))
(let ((fn (x-popup-menu
- event (cons 'keymap
- (cons (tree-node-get-data node) menu)))))
+ event (cons 'keymap (cons menu-title menu)))))
(when fn
(funcall (car fn) node)))))))))))
@@ -1000,7 +1007,7 @@ functionality is done with the `help-echo'-property and the function
(defun tree-buffer-create (name frame is-click-valid-fn node-selected-fn
node-expanded-fn node-mouse-over-fn
node-data-equal-fn
- menus tr-lines read-only tree-indent
+ menus menu-titles tr-lines read-only tree-indent
incr-search arrow-navigation hor-scroll
&optional type-facer expand-symbol-before
highlight-node-face general-face
@@ -1067,9 +1074,14 @@ NODE-MOUSE-OVER-FN: Function to call when the mouse is moved over a node. This
NODE-DATA-EQUAL-FN: Function used by the tree-buffer to test if the data of
two tree-nodes are equal. The data of node can be set/get
with `tree-node-set-data'/`tree-node-get-data'.
-MENUS: Nil or a list of one or two conses, each cons for a node-type \(0 or 1)
- Example: \(\(0 . menu-for-type-0) \(1 . menu-for-type-1)). The cdr of a
- cons must be a menu.
+MENUS: Nil or a list of one to three conses, each cons for a node-type \(0, 1
+ or 2) Example: \(\(0 . menu-for-type-0) \(1 . menu-for-type-1)). The
+ cdr of a cons must be a menu.
+MENU-TITLES: Nil or a list of one to three conses, each cons for a node-type
+ \(0, 1 or 2). See MENUES. The cdr of a cons must be either a
+ string or a function which will be called with current node
+ under point and must return a string which is displayed as the
+ menu-title.
TR-LINES: Should lines in this tree buffer be truncated \(not nil)
READ-ONLY: Should the treebuffer be read-only \(not nil)
TREE-INDENT: spaces subnodes should be indented.
@@ -1120,6 +1132,7 @@ AFTER-CREATE-HOOK: A function or a list of functions \(with no arguments)
(make-local-variable 'tree-node-data-equal-fn)
(make-local-variable 'tree-buffer-highlighted-node-data)
(make-local-variable 'tree-buffer-menus)
+ (make-local-variable 'tree-buffer-menu-titles)
(make-local-variable 'tree-buffer-type-facer)
(make-local-variable 'tree-buffer-expand-symbol-before)
(make-local-variable 'tree-buffer-highlight-overlay)
@@ -1146,6 +1159,7 @@ AFTER-CREATE-HOOK: A function or a list of functions \(with no arguments)
(setq tree-buffer-indent tree-indent)
(setq tree-buffer-highlighted-node-data nil)
(setq tree-buffer-menus (tree-buffer-create-menus menus))
+ (setq tree-buffer-menu-titles menu-titles)
(setq tree-buffer-root (tree-node-new "root" 0 "root"))
(setq tree-buffer-type-facer type-facer)
(setq tree-buffer-expand-symbol-before expand-symbol-before)

0 comments on commit 7c82858

Please sign in to comment.