branch: master commit 291a1159e624118173caaaba987018cb3b369676 Author: Alexey Veretennikov <alexey.veretenni...@gmail.com> Commit: Alexey Veretennikov <alexey.veretenni...@gmail.com>
Header is now customizable --- ztree-diff.el | 44 ++++++++++++++++++++++++++++++++++++++------ ztree-util.el | 7 +++++++ ztree-view.el | 12 +----------- ztree.el | 21 ++++++++++++++++++--- 4 files changed, 64 insertions(+), 20 deletions(-) diff --git a/ztree-diff.el b/ztree-diff.el index a4439e2..84f7b37 100644 --- a/ztree-diff.el +++ b/ztree-diff.el @@ -33,6 +33,22 @@ "Hidden files regexp. By default all filest starting with dot '.', including . and ..") +(defface ztreep-diff-header-face + '((((type tty pc) (class color)) :foreground "lightblue" :weight bold) + (((background dark)) (:height 1.2 :foreground "lightblue" :weight bold)) + (t :height 1.2 :foreground "darkblue" :weight bold)) + "*Face used for the header in Ztree Diff buffer." + :group 'Ztree-diff :group 'font-lock-highlighting-faces) +(defvar ztreep-diff-header-face 'ztreep-diff-header-face) + +(defface ztreep-diff-header-small-face + '((((type tty pc) (class color)) :foreground "lightblue" :weight bold) + (((background dark)) (:foreground "lightblue" :weight bold)) + (t :weight bold :foreground "darkblue")) + "*Face used for the header in Ztree Diff buffer." + :group 'Ztree-diff :group 'font-lock-highlighting-faces) +(defvar ztreep-diff-header-small-face 'ztreep-diff-header-small-face) + (defface ztreep-diff-model-diff-face '((t (:foreground "red"))) "*Face used for different files in Ztree-diff." @@ -45,23 +61,39 @@ including . and ..") :group 'Ztree-diff :group 'font-lock-highlighting-faces) (defvar ztreep-diff-model-add-face 'ztreep-diff-model-add-face) +(defface ztreep-diff-model-normal-face + '((t (:foreground "#7f7f7f"))) + "*Face used for non-modified files in Ztree-diff." + :group 'Ztree-diff :group 'font-lock-highlighting-faces) +(defvar ztreep-diff-model-normal-face 'ztreep-diff-model-normal-face) + + (defun ztree-diff-model-face (node) (let ((diff (ztree-diff-model-differet node))) (cond ((eq diff 'diff) ztreep-diff-model-diff-face) ((eq diff 'new) ztreep-diff-model-add-face) - (t nil)))) - + (t ztreep-diff-model-normal-face)))) (defun ztree-diff-insert-buffer-header () - (insert "Differences tree") + (insert-with-face "Differences tree" ztreep-diff-header-face) + (newline) + (insert-with-face"Legend:" ztreep-diff-header-small-face) + (newline) + (insert-with-face " Normal file " ztreep-diff-model-normal-face) + (insert-with-face "- same on both sides" ztreep-diff-header-small-face) (newline) - (insert "==============") + (insert-with-face " Orphan file " ztreep-diff-model-add-face) + (insert-with-face "- does not exist on other side" ztreep-diff-header-small-face) + (newline) + (insert-with-face " Mismatch file " ztreep-diff-model-diff-face) + (insert-with-face "- different from other side" ztreep-diff-header-small-face) + (newline) + (insert-with-face "==============" ztreep-diff-header-face) (newline)) - (defun ztree-diff (dir1 dir2) "Creates an interactive buffer with the directory tree of the path given" - (interactive "DLeft directory \nDRight directory") + (interactive "DLeft directory \nDRight directory ") (let* ((difference (ztree-diff-model-create dir1 dir2)) (buf-name (concat "*" (ztree-diff-model-short-name difference) "*"))) (ztree-view buf-name diff --git a/ztree-util.el b/ztree-util.el index 6b99797..1e90a80 100644 --- a/ztree-util.el +++ b/ztree-util.el @@ -56,4 +56,11 @@ Used since car-safe returns nil for atoms" (if (atom value) value (car value))) +(defun insert-with-face (text face) + "Insert text with the face provided" + (let ((start (point))) + (insert text) + (put-text-property start (point) 'face face))) + + (provide 'ztree-util) diff --git a/ztree-view.el b/ztree-view.el index 51181df..8c1f889 100644 --- a/ztree-view.el +++ b/ztree-view.el @@ -140,14 +140,6 @@ the buffer is split to 2 trees") map) "Keymap for `ztree-mode'.") -(defface ztreep-header-face - '((((type tty pc) (class color)) :foreground "lightblue" :weight bold) - (((background dark)) (:height 1.2 :foreground "lightblue" :weight bold)) - (t :height 1.2 :foreground "darkblue" :weight bold)) - "*Face used for the header in Ztree buffer." - :group 'Ztree :group 'font-lock-highlighting-faces) -(defvar ztreep-header-face 'ztreep-header-face) - (defface ztreep-node-face '((((background dark)) (:foreground "#ffffff")) @@ -490,9 +482,7 @@ apparently shall not be visible" (setq ztree-line-tree-properties (make-hash-table))) (toggle-read-only) (erase-buffer) - (let ((start (point))) - (funcall ztree-tree-header-fun) - (set-text-properties start (point) '(face ztreep-header-face))) + (funcall ztree-tree-header-fun) (setq ztree-start-line (line-number-at-pos (point))) (ztree-insert-node-contents ztree-start-node) (scroll-to-line (if line line ztree-start-line)) diff --git a/ztree.el b/ztree.el index 1a4bf93..f79c2c0 100644 --- a/ztree.el +++ b/ztree.el @@ -62,13 +62,28 @@ including . and ..") ;; +;; Faces +;; + +(defface ztreep-header-face + '((((type tty pc) (class color)) :foreground "lightblue" :weight bold) + (((background dark)) (:height 1.2 :foreground "lightblue" :weight bold)) + (t :height 1.2 :foreground "darkblue" :weight bold)) + "*Face used for the header in Ztree buffer." + :group 'Ztree :group 'font-lock-highlighting-faces) +(defvar ztreep-header-face 'ztreep-header-face) + + +;; ;; File bindings to the directory tree control ;; (defun ztree-insert-buffer-header () - (insert "Directory tree") - (newline) - (insert "==============") + (let ((start (point))) + (insert "Directory tree") + (newline) + (insert "==============") + (set-text-properties start (point) '(face ztreep-header-face))) (newline)) (defun ztree (path)