Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

*** empty log message ***

  • Loading branch information...
commit 918dfd57ae85e02b5dcb498d40c292ad162e7d70 1 parent 00ff5fd
creator authored
View
63 ecb2/jn-file-tree.el
@@ -0,0 +1,63 @@
+;;; jn-file-tree.el ---
+
+;; Copyright (C) 2001 by Free Software Foundation, Inc.
+
+;; Author: <Sune Mangs@MAYHEM>
+;; Keywords:
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(require 'jn-tree-node)
+
+(defclass jn-file-tree-node (jn-dynamic-tree-node)
+ ((file-path :initarg :file-path :initform nil)
+ )
+ )
+
+(defun jn-file-tree-node-new (file-path)
+ (let ((node (jn-file-tree-node file-path :file-path file-path)))
+ (unless (file-directory-p file-path)
+ (oset node updated t))
+ node))
+
+(defmethod jn-has-children ((node jn-file-tree-node))
+ (if (jn-is-updated node)
+ (call-next-method)
+ (file-directory-p (oref node file-path))))
+
+(defmethod jn-get-name ((node jn-file-tree-node))
+ (file-name-nondirectory (oref node file-path)))
+
+(defmethod jn-update ((node jn-file-tree-node))
+ (jn-update--internal node
+ (directory-files (oref node file-path) t "[^\\.].*")
+ (function (lambda (item child)
+ (string= (oref child file-path) item)))
+ (function (lambda (item)
+ (jn-file-tree-node-new item)))
+ ))
+
+(provide 'jn-file-tree)
+
+;;; jn-file-tree.el ends here
View
267 ecb2/jn-tree-node.el
@@ -0,0 +1,267 @@
+;;; window.el ---
+
+;; Copyright (C) 2001 by Free Software Foundation, Inc.
+
+;; Author: <Sune Mangs@MAYHEM>
+;; Keywords:
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(require 'eieio)
+(require 'jn-utils)
+
+;;====================================================
+;;
+;;====================================================
+
+(defclass jn-abstract-tree-node () ())
+
+(defun jn-tree-node-iterate--internal (node fn)
+ (funcall fn node)
+ (dolist (child (jn-get-children node))
+ (jn-tree-node-iterate--internal child fn)))
+
+(defun jn-tree-node-conditional-iterate--internal (node fn depth)
+ (when (funcall fn node depth)
+ (dolist (child (jn-get-children node))
+ (jn-tree-node-conditional-iterate--internal child fn (1+ depth)))))
+
+(defmethod jn-iterate ((node jn-abstract-tree-node) (fn function))
+ (jn-tree-node-iterate--internal node fn))
+
+(defmethod jn-conditional-iterate ((node jn-abstract-tree-node) (fn function))
+ (jn-tree-node-conditional-iterate--internal node fn 0))
+
+(defmethod jn-find-first ((node jn-abstract-tree-node) (test-fn function))
+ (catch 'exit
+ (jn-iterate node
+ (function (lambda (node)
+ (if (funcall test-fn node)
+ (throw 'exit node)))))))
+
+(defmethod jn-find-first-with-name ((node jn-abstract-tree-node) (name string))
+ (jn-find-first node (function (lambda (node)
+ (string= name (oref node name))))))
+
+(defmethod jn-get-depth ((node jn-abstract-tree-node))
+ (let ((parent (oref node parent)))
+ (if (not parent)
+ 0
+ (1+ (jn-get-depth parent)))))
+
+(defmethod jn-has-children ((node jn-abstract-tree-node))
+ (< 0 (length (jn-get-children node))))
+
+
+;;====================================================
+;;
+;;====================================================
+
+(defclass jn-changable-tree-node (jn-abstract-tree-node)
+ ((change-listeners :type list
+ :initform nil)
+;; :protection private)
+ )
+ )
+
+(defun jn-tree-node-changed--internal (node)
+ (dolist (listener (oref node change-listeners))
+ (funcall listener node)))
+
+(defmethod jn-changed ((node jn-changable-tree-node))
+ (jn-tree-node-changed--internal node))
+
+(defmethod jn-add-change-listener ((node jn-changable-tree-node) listener)
+ (oset node change-listeners (cons listener (oref node change-listeners))))
+
+(defmethod jn-remove-change-listener ((node jn-changable-tree-node) listener)
+ (oset node change-listeners (delq listener (oref node change-listeners))))
+
+
+;;====================================================
+;;
+;;====================================================
+
+(defclass jn-tree-node-base (jn-changable-tree-node)
+ ((parent :type (or null jn-abstract-tree-node)
+ :initform nil)
+;; :protection private)
+ (children :type list
+ :initform nil)
+;; :protection private)
+ )
+ )
+
+(defmethod jn-get-children ((node jn-tree-node-base))
+ (oref node children))
+
+(defmethod jn-get-parent ((node jn-tree-node-base))
+ (oref node parent))
+
+(defmethod jn-set-parent ((node jn-tree-node-base) (parent jn-tree-node-base))
+ (let ((old-parent (oref node parent)))
+ (when old-parent
+ (oset old-parent children (delq node (oref old-parent children)))
+ (jn-tree-node-changed--internal old-parent))
+ (oset node parent parent)
+ (when parent
+ (oset parent children (append (oref parent children) (list node)))
+ (jn-tree-node-changed--internal parent))
+ (jn-changed node)))
+
+
+;;====================================================
+;;
+;;====================================================
+
+(defclass jn-dynamic-tree-node (jn-tree-node-base)
+ ((updated :initform nil)
+ )
+ )
+
+(defmethod jn-is-updated ((node jn-dynamic-tree-node))
+ (oref node updated))
+
+(defmethod jn-get-children ((node jn-dynamic-tree-node))
+ (unless (oref node updated)
+ (jn-update node))
+ (call-next-method))
+
+(defmethod jn-update--internal ((node jn-dynamic-tree-node) item-list match-fn
+ new-fn)
+ (let ((old-children (oref node children))
+ changed
+ children)
+ (dolist (item item-list)
+ (let ((c (find item old-children :test match-fn)))
+ (setq children
+ (cons (if c
+ c
+ (let ((new-child (funcall new-fn item)))
+ (oset new-child parent node)
+ (setq changed t)
+ new-child))
+ children))))
+ (oset node children (nreverse children))
+ (oset node updated t)))
+; (when (or changed
+; (> (length old-children)
+; (length children)))
+; (jn-changed node))))
+
+
+;;====================================================
+;;
+;;====================================================
+
+(defclass jn-tree-node (jn-tree-node-base)
+ ((name :type string
+ :initform ""
+ :initarg :name)
+ )
+ )
+
+(defun jn-tree-node-new (name &optional parent)
+ (let ((node (jn-tree-node name :name name)))
+ (jn-set-parent node parent)
+ node))
+
+(defmethod jn-get-name ((node jn-tree-node))
+ (oref node name))
+
+(defmethod jn-clear-children ((node jn-tree-node))
+ (oset node children nil)
+ (jn-changed node))
+
+
+;;====================================================
+;;
+;;====================================================
+
+(defclass jn-tree-node-decorator (jn-dynamic-tree-node)
+ ((node :initform nil);; :type (or null jn-changable-tree-node))
+ (updated :initform nil)
+ (callback :initform nil)
+ )
+ )
+
+(defun jn-tree-node-decorator-new (&optional par node)
+ (let ((n (jn-tree-node-decorator "Arne")))
+ (jn-init n)
+ (jn-set-parent n par)
+ (jn-set-node n node)
+ n))
+
+(defmethod jn-init ((dnode jn-tree-node-decorator))
+ (oset dnode callback (jn-create-lambda-with-object-1
+ 'jn-tree-node-decorator-node-changed--internal dnode)))
+
+(defmethod jn-get-name ((dnode jn-tree-node-decorator))
+ (jn-get-name (oref dnode node)))
+
+(defmethod jn-get-children ((dnode jn-tree-node-decorator))
+ (unless (oref dnode updated)
+ (jn-update dnode))
+ (call-next-method))
+
+(defmethod jn-has-children ((dnode jn-tree-node-decorator))
+ (if (oref dnode updated)
+ (call-next-method)
+ (jn-has-children (oref dnode node))))
+
+(defmethod jn-create-child ((dnode jn-tree-node-decorator))
+ (jn-tree-node-decorator "node"))
+
+(defmethod jn-set-node ((node jn-tree-node-decorator) (n jn-changable-tree-node))
+ (let ((old-node (oref node node)))
+ (when old-node
+ (jn-remove-change-listener old-node (oref node callback)))
+ (oset node node n)
+ (oset node updated nil)
+ (when n
+ (jn-add-change-listener n (oref node callback)))
+ (jn-changed node)))
+
+(defmethod jn-get-node ((dnode jn-tree-node-decorator))
+ (oref dnode node))
+
+(defun jn-tree-node-decorator-node-changed--internal (dnode node)
+ (oset dnode updated nil)
+ (jn-changed dnode))
+
+(defmethod jn-update ((node jn-tree-node-decorator))
+ (jn-update--internal node
+ (jn-get-children (oref node node))
+ (function (lambda (item child) (eq (oref child node) item)))
+ (function
+ (lambda (item)
+ (let ((child (jn-create-child node)))
+ (oset child node item)
+ (jn-add-change-listener item (oref child callback))
+ child)))
+ ))
+
+(provide 'jn-tree-node)
+
+;;; window.el ends here
View
220 ecb2/jn-tree-view.el
@@ -0,0 +1,220 @@
+;;; window.el ---
+
+;; Copyright (C) 2001 by Free Software Foundation, Inc.
+
+;; Author: <Sune Mangs@MAYHEM>
+;; Keywords:
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(require 'jn-window)
+(require 'jn-tree-node)
+
+;;====================================================
+;;
+;;====================================================
+
+(defclass jn-tree-view-node (jn-tree-node-decorator)
+ ((expanded :type boolean
+ :initarg :expanded
+ :initform nil
+ :protection private)
+ (lines :type integer :initform 0)
+ )
+ )
+
+(defun jn-tree-view-node-new (&optional expanded)
+ (let ((node (jn-tree-view-node "node" :expanded expanded)))
+ (jn-init node)
+ node))
+
+(defmethod jn-get-display-name ((node jn-tree-view-node))
+ (jn-get-name node))
+
+(defmethod jn-selected ((node jn-tree-view-node))
+ (message (oref node name)))
+
+(defmethod jn-toggle-expanded ((node jn-tree-view-node))
+ (oset node expanded (not (oref node expanded)))
+ (jn-changed node))
+
+(defmethod jn-is-expanded ((node jn-tree-view-node))
+ (oref node expanded))
+
+(defmethod jn-create-child ((node jn-tree-view-node))
+ (jn-tree-view-node-new))
+
+(defmethod jn-selected ((node jn-tree-view-node))
+ (message (concat (jn-get-name node) " selected!")))
+
+(defmethod jn-get-view ((node jn-tree-view-node))
+ (jn-get-view (oref node parent)))
+
+(defmethod jn-changed ((node jn-tree-view-node))
+ (let ((view (jn-get-view node)))
+ (when view
+ (jn-update-node view node))))
+
+
+;;====================================================
+;;
+;;====================================================
+
+(defclass jn-tree-view-root-node (jn-tree-view-node)
+ ((view :initarg :view :type (or null jn-tree-view) :initform nil)
+ )
+ )
+
+(defmethod jn-get-view ((node jn-tree-view-root-node))
+ (oref node view))
+
+
+;;====================================================
+;;
+;;====================================================
+
+(defclass jn-tree-view (jn-general-view)
+ ((root-node ;;:type (or null jn-tree-view-node)
+ :initarg :root-node
+ :initform nil)
+ (nodes :type list
+ :initform nil))
+ "A tree view that contains jn-tree-view-node's. When a node is changed the
+node's lines in the view are updated."
+ )
+
+(defun jn-tree-view-new ()
+ (let ((view (jn-tree-view "View"
+ :root-node
+ (jn-tree-view-root-node "root"))))
+ (oset (jn-get-root view) view view)
+ (jn-init-1 view "Tree View")
+ view))
+
+(defmethod jn-get-root ((view jn-tree-view))
+ (oref view root-node))
+
+(defun jn-tree-view-child-at-line (node line)
+ (dolist (child (jn-get-children node))
+ (if (= line 0)
+ (throw 'exit child)
+ (when (< line (oref child lines))
+ (jn-tree-view-child-at-line child (1- line))))
+ (setq line (- line (oref child lines)))))
+
+(defmethod jn-get-node-at-point ((view jn-tree-view))
+ (let ((linenr (+ (count-lines 1 (point)) (if (= (current-column) 0) 0 -1))))
+ (catch 'exit
+ (jn-tree-view-child-at-line (jn-get-root view) linenr))))
+
+(defmethod jn-selected ((view jn-tree-view))
+ (let ((node (jn-get-node-at-point view)))
+ (when node
+ (if (> (current-column)
+ (+ (length (jn-get-display-name node))
+ (* 2 (- (jn-get-depth node) 1))))
+ (jn-toggle-expanded node)
+ (jn-selected node)))))
+
+(defun jn-buffer-insert-text (text)
+ (let ((p (point)))
+ (insert text)
+ (put-text-property p (+ p (length text)) 'mouse-face 'highlight)))
+
+(defun jn-tree-view-get-node-line (node)
+ "Returns the line number for a node in the view."
+ (let ((parent (jn-get-parent node)))
+ (if parent
+ (+ 1
+ (jn-tree-view-get-node-line parent)
+ (catch 'exit
+ (let ((line 0))
+ (dolist (child (jn-get-children parent))
+ (when (eq child node)
+ (throw 'exit line))
+ (incf line (oref child lines))))))
+ 0)))
+
+(defun jn-tree-view-update-parents-lines (node dl)
+ (let ((parent (jn-get-parent node)))
+ (when parent
+ (oset parent lines (+ (oref parent lines) dl))
+ (jn-tree-view-update-parents-lines parent dl))))
+
+(defun jn-tree-view-update--internal (view node depth)
+ (insert (make-string (* depth 2) ? ))
+ (jn-buffer-insert-text
+ (jn-get-display-name node))
+ (when (jn-has-children node)
+ (insert " ")
+ (jn-buffer-insert-text
+ (concat "["
+ (if (jn-is-expanded node)
+ "-" "+")
+ "]")))
+ (insert "\n")
+ (let ((lines 1))
+ (when (jn-is-expanded node)
+ (dolist (child (jn-get-children node))
+ (incf lines (jn-tree-view-update--internal view child (1+ depth)))))
+ (oset node lines lines)
+ lines))
+
+(defmethod jn-update ((view jn-tree-view))
+ (jn-update-node view (jn-get-root view)))
+
+(defmethod jn-update-node ((view jn-tree-view) node)
+ (let ((win (jn-get-window view)))
+ (when win
+ (save-current-buffer
+ (let* ((b (jn-get-emacs-buffer view))
+ (w (jn-get-emacs-window win))
+ (ws (window-start w))
+ (p (point)))
+ (set-buffer b)
+ (goto-char (point-min))
+ (if (eq node (jn-get-root view))
+ (let ((lines 0))
+ (dolist (child (jn-get-children node))
+ (incf lines (jn-tree-view-update--internal view child 0)))
+ (oset node lines lines))
+ (let* ((line (- (jn-tree-view-get-node-line node) 1))
+ (pos (line-beginning-position (1+ line)))
+ (lines (oref node lines)))
+ (goto-char pos)
+ (delete-region pos
+ (line-beginning-position (1+ lines)))
+ (jn-tree-view-update-parents-lines
+ node
+ (- (jn-tree-view-update--internal view
+ node
+ (- (jn-get-depth node) 1))
+ lines))))
+ (goto-char p)
+ (set-window-start w ws)
+ )))))
+
+(provide 'jn-tree-view)
+
+;;; window.el ends here
View
42 ecb2/jn-utils.el
@@ -0,0 +1,42 @@
+;;; jn-utils.el ---
+
+;; Copyright (C) 2001 by Free Software Foundation, Inc.
+
+;; Author: <Sune Mangs@MAYHEM>
+;; Keywords:
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(defun jn-create-lambda-with-object (fn obj)
+ `(lambda () (,fn ,obj)))
+
+(defun jn-create-lambda-with-object-1 (fn obj)
+ `(lambda (a1) (,fn ,obj a1)))
+
+(defun jn-create-lambda-with-object-2 (fn obj)
+ `(lambda (a2) (,fn ,obj a1 a2)))
+
+(provide 'jn-utils)
+
+;;; jn-utils.el ends here
View
237 ecb2/jn-window.el
@@ -0,0 +1,237 @@
+;;; window.el ---
+
+;; Copyright (C) 2001 by Free Software Foundation, Inc.
+
+;; Author: <Sune Mangs@MAYHEM>
+;; Keywords:
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(require 'eieio)
+
+;;====================================================
+;;
+;;====================================================
+
+(defclass jn-window ()
+ ((parent :type (or null jn-window)
+ :initform nil)
+ )
+ )
+
+(defmethod jn-set-parent ((window jn-window) (parent jn-window-container))
+ (jn-set-window parent window))
+
+
+;;====================================================
+;;
+;;====================================================
+
+(defclass jn-emacs-window (jn-window)
+ ((emacs-window :initarg :emacs-window
+ :initform nil)
+ )
+ )
+
+(defmethod jn-set-size ((window jn-emacs-window) size)
+ (save-selected-window
+ (select-window (oref window emacs-window))
+ (when (car size)
+ (enlarge-window (- (car size) (window-width)) t))
+ (when (cdr size)
+ (enlarge-window (- (cdr size) (window-height))))))
+
+(defmethod jn-get-size ((window jn-emacs-window))
+ (let ((w (oref window emacs-window)))
+ (cons (window-width w) (window-height w))))
+
+(defmethod jn-get-emacs-window ((window jn-emacs-window))
+ (oref window emacs-window))
+
+
+;;====================================================
+;;
+;;====================================================
+
+(defclass jn-view-window (jn-emacs-window)
+ ((view :type (or null jn-view)
+ :initarg :view
+ :initform nil)
+ )
+ )
+
+(defmethod jn-set-view ((window jn-view-window) (view jn-view))
+ (oset window view view)
+ (oset view window window))
+
+
+;;====================================================
+;;
+;;====================================================
+
+(defclass jn-window-container ()
+ ((window :type (or null jn-window)
+ :initform nil)
+ )
+ )
+
+(defmethod jn-set-size ((window-container jn-window-container) size)
+ (jn-set-size (oref window-container window) size))
+
+(defmethod jn-get-size ((window-container jn-window-container))
+ (jn-get-size (oref window-container window)))
+
+(defmethod jn-set-window ((window-container jn-window-container) (window jn-window))
+ (let ((old-window (oref window-container window)))
+ (unless (eq old-window window)
+ (when old-window
+ (oset old-window parent nil))
+ (oset window-container window window)
+ (when window
+ (oset window parent window-container)))))
+
+
+;;====================================================
+;;
+;;====================================================
+
+(defclass jn-frame ()
+ ((window-container :type (or null jn-window-container)
+ :initform nil)
+ )
+ )
+
+(defmethod jn-set-window ((frame jn-frame) (window jn-window))
+ (jn-set-window (oref frame window-container) window))
+
+
+;;====================================================
+;;
+;;====================================================
+
+(defclass jn-split-window (jn-window)
+ ((orientation :type symbol
+ :initarg orientation
+ :initform vertical)
+ (amount :type (or integer float)
+ :initarg amount
+ :initform 0.50)
+ (top-left-container :type (or null jn-window-container)
+ :initform nil)
+ (bottom-right-container :type (or null jn-window-container)
+ :initform nil)
+ )
+ )
+
+(defmethod jn-set-top-left-window ((window jn-split-window) (window window))
+ (jn-set-window (oref window top-left-container) window))
+
+(defmethod jn-set-bottom-right-window ((window jn-split-window) (window window))
+ (jn-set-window (oref window bottom-right-container) window))
+
+(defmethod jn-set-amount ((window jn-split-window) amount)
+ (oset window amount amount)
+ (let ((abs-amount (if (floatp amount)
+ (floor (* amount
+ (if (eq (oref window orientation) 'vertical)
+ (car (jn-get-size window))
+ (cdr (jn-get-size window)))))
+ amount)))
+ (jn-set-size (oref window top-left-container)
+ (if (eq (oref window orientation) 'vertical)
+ (cons nil abs-amount)
+ (cons abs-amount nil)))))
+
+
+;;====================================================
+;;
+;;====================================================
+
+(defclass jn-view ()
+ ((window :type (or null jn-view-window)
+ :initarg :window
+ :initform nil)
+ (emacs-buffer :initform nil)
+ )
+ )
+
+(defmethod jn-init-1 ((view jn-view) buffer)
+ (set-buffer buffer)
+ (make-local-variable 'jn-view)
+ (setq jn-view view)
+ (oset view emacs-buffer buffer))
+
+(defmethod jn-get-emacs-buffer ((view jn-view))
+ (oref view emacs-buffer))
+
+(defmethod jn-get-window ((view jn-view))
+ (oref view window))
+
+(defmethod jn-set-window ((view jn-view) (window jn-view-window))
+ (oset view window window)
+ (set-window-buffer (jn-get-emacs-window window) (jn-get-emacs-buffer view)))
+
+(defvar jn-general-view-key-map nil)
+
+
+;;====================================================
+;;
+;;====================================================
+
+(defclass jn-general-view (jn-view)
+ ()
+ )
+
+(defmethod jn-init-1 ((view jn-general-view) name)
+ (let* ((buffer (get-buffer-create name))
+ (nop (function (lambda () (interactive)))))
+ (save-current-buffer
+ (call-next-method view buffer)
+ (set-buffer buffer)
+ (erase-buffer)
+
+ (make-local-variable 'jn-general-view-key-map)
+ (setq jn-general-view-key-map (make-sparse-keymap))
+
+ ;; Undefine all unwanted mouse events
+ (dolist (key (list
+ [drag-mouse-1] [mouse-1] [double-mouse-1] [triple-mouse-1]
+ [mouse-2] [double-mouse-2] [triple-mouse-2]
+ [mouse-3] [double-mouse-3] [triple-mouse-3]))
+ (define-key jn-general-view-key-map key nop))
+
+ (define-key jn-general-view-key-map
+ [down-mouse-1]
+ (function (lambda (e)
+ (interactive "e")
+ (mouse-set-point e)
+ (jn-selected jn-view))))
+
+ (use-local-map jn-general-view-key-map)
+ )
+ view))
+
+(provide 'jn-window)
+
+;;; window.el ends here
View
83 ecb2/test.el
@@ -0,0 +1,83 @@
+;;; test.el ---
+
+;; Copyright (C) 2001 by Free Software Foundation, Inc.
+
+;; Author: <Sune Mangs@MAYHEM>
+;; Keywords:
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(require 'jn-tree-view)
+(require 'jn-file-tree)
+
+(defvar jn-test-view nil)
+
+(defun jn-create-nodes (node depth name)
+ (let ((child (jn-tree-node-new name node)))
+ (when (< depth 3)
+ (let ((i 0))
+ (while (< i 2)
+ (jn-create-nodes child (1+ depth) (concat name "." (int-to-string i)))
+ (setq i (1+ i)))))))
+
+(defun jn-print-2 (node prefix)
+ (insert (concat prefix (jn-get-name node) "\n"))
+ (dolist (child (jn-get-children node))
+ (jn-print-2 child (concat prefix " "))))
+
+(defun jn-print (node)
+ (set-buffer (get-buffer-create "*test*"))
+ (jn-print-2 node ""))
+
+(defun jn-test ()
+ (interactive)
+ (let ((window (jn-view-window "Window" :emacs-window (selected-window)))
+ (node (jn-tree-node-new "root")))
+ (setq jn-test-view (jn-tree-view-new))
+ (jn-set-view window jn-test-view)
+ (jn-create-nodes node 0 "0")
+ (jn-print node)
+ (jn-set-node (jn-get-root jn-test-view) node)))
+
+(defun jn-test-file-tree ()
+ (interactive)
+ (let ((tree (jn-file-tree-node-new "c:/t2")))
+ (jn-print tree)))
+
+(defun jn-test-file-tree-view ()
+ (interactive)
+ (let ((tree (jn-file-tree-node-new "c:/"))
+ (window (jn-view-window "Window" :emacs-window (selected-window)))
+ (view (jn-tree-view-new)))
+ (jn-set-view window view)
+ (jn-set-node (jn-get-root view) tree)))
+
+(defun jn-test-change ()
+ (interactive)
+ (jn-set-parent
+ (car (jn-get-children
+ (car (jn-get-children (jn-get-node (jn-get-root jn-test-view))))))
+ nil))
+
+;;; test.el ends here
Please sign in to comment.
Something went wrong with that request. Please try again.