Skip to content

Commit

Permalink
intelligent expanded node display and some minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
berndl committed Apr 25, 2001
1 parent cf3e463 commit 81d0cda
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 24 deletions.
9 changes: 7 additions & 2 deletions HISTORY
@@ -1,6 +1,11 @@
Version 1.20 (???):
-------------------

- Now the ECB-buffers are somehow intelligent in displaying expanded nodes
(e.g. a directory with it�s subdirectories). An ECB-buffer now tries always
to make visisble as much as possible of the subnodes of a node if a node
has been expanded (e.g. by clicking onto it�s expand-symbol). (Klaus)

- Now all adviced functions behave only special in the ECB-frame. In each other
frame they behave exactly like the not adviced functions. (Klaus)

Expand All @@ -10,8 +15,8 @@ Version 1.20 (???):
- Source files can now be sorted by name, extension or not sorted at all
(Jesper).

- Added functionality and a customization variable to exclude source files
matching a regular expression (Jesper).
- Now you can precisely define by an exclude and include regexp which files
should be displayed by ECB. (Jesper).

- Jumping to a method/variable from the ECB-method buffer now sets the mark so
the user can easily jump back (see `ecb-method-jump-sets-mark'). (Klaus)
Expand Down
2 changes: 1 addition & 1 deletion README
Expand Up @@ -31,7 +31,7 @@ Installation
Optional byte-compilation steps:

4. Restart Emacs.
5. Call `ecb-bytecompile-ecb'. You can safely ignore all messages.
5. Call `ecb-byte-compile'. You can safely ignore all messages.

(You can also bytecompile ECB from the command-line either by using the
Makefile or by using the batch-file make.bat. Just read the comments in that
Expand Down
14 changes: 8 additions & 6 deletions ecb-layout.el
Expand Up @@ -298,12 +298,14 @@ frame height."
(const :tag "Edit + compile window" edit-and-compile)))


(defcustom ecb-delete-other-windows-behavor 'smart
"*What should ECB do when deleting other windows. This should be used in all
advice to enable/disable smart deletion of other windows."
:group 'ecb-layout
:type '(radio (const :tag "Smart deletion of windows within ECB" smart)
(const :tag "Standard deletion of all windows" standard)))
;; (defcustom ecb-delete-other-windows-behavior 'smart
;; "*What should ECB do when deleting other windows. This should be used in all
;; advice to enable/disable smart deletion of other windows."
;; :group 'ecb-layout
;; :type '(radio (const :tag "Smart deletion of windows within ECB"
;; :value smart)
;; (const :tag "Standard deletion of all windows"
;; :value standard)))

(defcustom ecb-advice-window-functions '(other-window
delete-window
Expand Down
31 changes: 22 additions & 9 deletions ecb.el
Expand Up @@ -195,15 +195,26 @@ and then activating ECB again!"
:type 'string)

(defcustom ecb-source-file-regexps
'("\\(^\\(\\.\\|#\\)\\|~$\\)" "^\\.\\(emacs\\|gnus\\)$")
"*Specifies which files are shown as source files. Consists of one exclude regexp and one include regexp. A file is displayed in the source-buffer of ECB iff:
the file does not match the exclude regexp OR the file matches the include
regexp."
'("\\(^\\(\\.\\|#\\)\\|\\(~$\\|\\.\\(elc\\|obj\\|o\\|lib\\|dll\\|a\\|so\\)$\\)\\)"
"^\\.\\(emacs\\|gnus\\)$")
"*Specifies which files are shown as source files. Consists of one exclude
regexp and one include regexp. A file is displayed in the source-buffer of ECB
iff: The file does not match the exclude regexp OR the file matches the
include regexp. There are three predefined and senseful combinations of an
exclude and include regexp:
- All files
- All, but no backup, object, lib or ini-files \(except .emacs and .gnus). This
means all files except those starting with \".\", \"#\" or ending with
\"~\", \".elc\", \".obj\", \".o\", \".lib\", \".dll\", \".a\", \".so\".
(but including .emacs and .gnus)
- Common source file types (.c, .java etc.)
In addition to these predefined values a custom exclude and include
combination can be defined."
:group 'ecb-sources
:type '(radio (const :tag "All files"
:value ("" ""))
(const :tag "All files except those starting with \".\", \"#\" or ending with \"~\" (but including .emacs and .gnus)"
:value ("\\(^\\(\\.\\|#\\)\\|~$\\)" "^\\.\\(emacs\\|gnus\\)$"))
(const :tag "All, but no backup, object, lib or ini-files \(except .emacs and .gnus)"
:value ("\\(^\\(\\.\\|#\\)\\|\\(~$\\|\\.\\(elc\\|obj\\|o\\|lib\\|dll\\|a\\|so\\)$\\)\\)" "^\\.\\(emacs\\|gnus\\)$"))
(const :tag "Common source file types (.c, .java etc.)"
:value ("" "\\(\\(M\\|m\\)akefile\\|.*\\.\\(java\\|el\\|c\\|cc\\|h\\|hh\\|txt\\|html\\|texi\\|info\\|bnf\\)\\)$"))
(list :tag "Custom (tips: \"$^\" matches no files, \"\" mathes all files)"
Expand Down Expand Up @@ -835,7 +846,7 @@ function is added to the hook `semantic-after-toplevel-bovinate-hook'."
;; `semantic-after-toplevel-bovinate-hook' the cache is
;; always either still valid or rebuild.
;;
;; Ugly fix to make it work with semantic 1.4
;; TODO: Ugly fix to make it work with semantic 1.4
(if (listp (caar semantic-toplevel-bovine-cache))
(car semantic-toplevel-bovine-cache)
semantic-toplevel-bovine-cache)
Expand Down Expand Up @@ -1142,7 +1153,8 @@ Currently the fourth argument TREE-BUFFER-NAME is not used here."
(tree-node-toggle-expanded node))
(ecb-set-selected-directory (tree-node-get-data node))
(ecb-buffer-select ecb-directories-buffer-name)
(tree-buffer-update)))
;; Update the tree-buffer with optimized display of NODE
(tree-buffer-update node)))
(ecb-set-selected-source (tree-node-get-data node)
(and ecb-split-edit-window (eq ecb-button 2))
shift-mode)))
Expand All @@ -1159,7 +1171,8 @@ Currently the fourth argument TREE-BUFFER-NAME is not used here."
(ecb-mouse-over-method-node node)
(when (= 1 (tree-node-get-type node))
(tree-node-toggle-expanded node)
(tree-buffer-update))
;; Update the tree-buffer with optimized display of NODE
(tree-buffer-update node))
(when (tree-node-get-data node)
(ecb-find-file-and-display ecb-path-selected-source
(and ecb-split-edit-window (eq ecb-button 2)))
Expand Down
65 changes: 59 additions & 6 deletions tree-buffer.el
Expand Up @@ -120,7 +120,8 @@ with the same arguments as `tree-node-expanded-fn'."
shift-pressed control-pressed (buffer-name)))
(when (tree-node-is-expandable node)
(tree-node-toggle-expanded node))
(tree-buffer-update))
;; Update the tree-buffer with optimized display of NODE
(tree-buffer-update node))
(when tree-node-selected-fn
(funcall tree-node-selected-fn node mouse-button
shift-pressed control-pressed (buffer-name))))))))
Expand Down Expand Up @@ -216,20 +217,71 @@ inserted and the TEXT itself"
(dolist (node (tree-node-get-children node))
(tree-buffer-add-node node (1+ depth)))))

(defun tree-buffer-update()
(defun tree-node-count-subnodes-to-display(node)
"Returns the number of ALL subnodes of NODE which will currently be displayed
if NODE is expanded, means the number of all the children of NODE \(if NODE is
expanded) plus recursive the number of the children of each expanded child.
Example:
\[-] NODE
\[+] child 1
\[-] child 2
\[+] child 2.1
\[-] child 2.2
\[+] child 2.2.1
\[+] child 2.2.2
\[+] child 2.3
\[-] child 3
\[+] child 3.1
\[+] child 4
The result for NODE here is 10"
(let ((result 0))
(when (and (tree-node-is-expandable node)
(tree-node-is-expanded node))
(setq result (+ result (length (tree-node-get-children node))))
(dolist (child (tree-node-get-children node))
(setq result (+ result (tree-node-count-subnodes-to-display child)))))
result))

(defun tree-buffer-update(&optional node)
"Updates the current tree-buffer. The buffer will be completely rebuild with
it´s current nodes. window-start and point will be preserved."
it´s current nodes. window-start and point will be preserved.
If NODE is not nil and a valid and expanded node with at least one child then
the display of this node is optimized so the node itself and as much as
possible of it´s children \(and also recursive the children of a child if it´s
aleady expanded, see `tree-node-count-subnodes-to-display') are visible in
current tree-buffer."
(let* ((w (get-buffer-window (current-buffer)))
(ws (window-start w))
(p (point))
(buffer-read-only nil))
(exp-node-children-count
(if node
(tree-node-count-subnodes-to-display node)
0))
(buffer-read-only nil)
(next-line-add-newlines nil))
(setq tree-buffer-nodes nil)
(erase-buffer)
(dolist (node (tree-node-get-children tree-buffer-root))
(tree-buffer-add-node node 0))
(tree-buffer-highlight-node-data tree-buffer-highlighted-node-data)
(goto-char p)
(set-window-start w ws)))
(set-window-start w ws)
;; let´s optimize the display of the expanded node NODE and it´s children.
(when (and node (tree-node-is-expanded node))
(goto-line (tree-buffer-find-node node))
;; if the current node is not already displayed in the first line of the
;; window (= condition 1) and if not all of it´s children are visible in
;; the window then we can do some optimization.
(when (and (save-excursion
(previous-line 1)
(pos-visible-in-window-p (point) w))
(not (save-excursion
(next-line exp-node-children-count)
(pos-visible-in-window-p (point) w))))
;; optimize the display of NODE and it´s children so as much as
;; possible are visible.
(recenter (max 0 (- (1- (window-height w))
(1+ exp-node-children-count))))))))

(defun tree-buffer-scroll(point window-start)
"Scrolls current tree-buffer. The window will start at WINDOW-START and
Expand Down Expand Up @@ -359,7 +411,8 @@ EXPAND-SYMBOL-BEFORE: If not nil then the expand-symbol \(is displayed before
(funcall tree-node-expanded-fn node 0 nil nil (buffer-name)))
(when (tree-node-is-expandable node)
(tree-node-toggle-expanded node))
(tree-buffer-update)))))
;; Update the tree-buffer with optimized display of NODE
(tree-buffer-update node)))))

;; mouse-1
(define-key tree-buffer-key-map
Expand Down

0 comments on commit 81d0cda

Please sign in to comment.