;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(ogre)

(libload "treebrowser")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; old-style helpnode

(defmethod helpnode getname() entry)
(defmethod helpnode getkey() ())
(defmethod helpnode getchildren() sons)
(defmethod helpnode getdata() 
  (==> this read)
  (let ((r ()))
    (each ((x lines)) (when (<> 'ex (car x)) (setq r (nconc1 r (cdr x)))))
    r))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defmethod class getname() (pname (classname this)))
(defmethod class getkey() ())
(defmethod class getchildren() (subclasses this))
(defmethod class getdata() 
  (each ((x (methods this))) (pname (methoddef this x))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(de test ()
    (setq z
	  (new ltree-node "asd" 34 
	       (list 
		(new ltree-node "wer" 45)
		(setq zz (new ltree-node "dfg" 56
			      (list
			       (new ltree-node "fghjfghj" 123)
			       (new ltree-node "uytruyt" 543
				    (list
				     (new ltree-node "pupupu" 546)
				     (new ltree-node "hohoho" 1231)
				     (new ltree-node "yuoytop" 3456)))
			       (new ltree-node "fghjfghj" 432))))
		(new ltree-node "eryttr" 76)
		(new ltree-node "wer" 12
		     (list
		      (new ltree-node "mnmnmn" 4343))))))
    (==> z open)
    (==> zz open)
    (==> zz disable)
    (setq w (new windowobject 0 0 300 300 "asd"
		 (setq ex (new explorer z
			       (lambda (c) (print "call1" c))
			       (lambda (c) (print "call2" c))
			       (lambda (c) (print "call3" c))
			       (lambda (c) (print "call4" c)))))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(de help-test ()
    (when (or (not help-root) (not (cdr (car help-root)))) 
      (help-parse "lush-manual.hlp"))
    (setq qq (make-ltree-from-tree (cdr (car help-root))))
    (setq w (new windowobject 0 0 500 500 "asd" 
		 (new viewer 480 480 (setq ex (new explorer qq)) t t))))

(de help-test2 (expr)
    (when (or (not help-root) (not (cdr (car help-root)))) 
      (help-parse "lush-manual.hlp"))
    (de ff (c) (regex-seek expr (==> c getname)))
    (setq qq (filter-ltree-from-tree (cdr (car help-root)) ff))
    (setq w (new windowobject 0 0 500 500 "asd" 
		 (new viewer 480 480 (setq ex (new explorer qq)) t t))))

(de help-test3 (expr)
    (when (or (not help-root) (not (cdr (car help-root)))) 
      (help-parse "lush-manual.hlp"))
    (de ff (c) (regex-seek expr (==> c getname)))
    (setq qq (new ltree-node (sprintf "search for %s" expr) 0))
    (filter-flat-ltree-from-tree (cdr (car help-root)) qq ff)
    (setq w (new windowobject 0 0 500 500 "asd" 
		 (new viewer 480 480 (setq ex (new explorer qq)) t t))))

(de help-test4 ()
    (when (or (not help-root) (not (cdr (car help-root)))) 
      (help-parse "lush-manual.hlp"))
    (setq qq (make-ltree-from-tree (cdr (car help-root))))
    (setq w (new windowobject 0 0 500 500 "asd" 
		 (new column
		      (setq patt (new editstring 24))
		      (new viewer 480 480 (setq ex (new explorer qq)) t t))))
    (==> patt setcall 
	 (lambda (c) 
	   (==> ex setfilter (==> c getdata))
	   (==> ex next-hit))))

(de help-test5 ()
    (when (or (not help-root) (not (cdr (car help-root)))) 
      (help-parse "lush-manual.hlp"))
    (setq w (new windowobject 0 0 550 650 "asd" 
		 (setq zz (new TreeBrowser 512 260 190 
			       (make-ltree-from-tree (cdr (car help-root))))))))

(de class-test1 ()
    (setq w (new windowobject 0 0 550 650 "asd" 
		 (setq zz (new TreeBrowser 512 260 190 
			       (make-ltree-from-tree object))))))

