<commit_before>(in-package :xul-test)

(defun file-string (path)
  (with-open-file (stream path)
    (let ((data (make-string (file-length stream))))
      (read-sequence data stream)
      data)))

(define-component showcase ()
  ((selected-page :accessor selected-page
		  :initform (first *showcase-pages*)))
  (:initialize (showcase)
	       (add-component showcase 'child
			      (make-instance (getf (cdr (selected-page showcase)) :component))))
  (:render (showcase)
	   (<:list-box
	     (<:style= "width:10em")
	     (on-select= (lambda (index)
			   (setf (selected-page showcase)
				 (nth index *showcase-pages*))
			   (add-component showcase 'child
					  (make-instance (getf (cdr (selected-page showcase)) :component)))))
	     (loop for page in *showcase-pages*
		do
		  (<:list-item (<:label (car page))
			       (when (equalp (selected-page showcase)
					     page)
				 (<:selected= t)))))
	   (<:splitter (<:collapse= :before)
		       (<:grippy))
	   (<:tab-box (<:flex= 1)
		      (<:tabs
			(<:tab (<:label= "Examples"))
			(<:tab (<:label= "Source")))
		      (<:tab-panels
			(<:tab-panel (<:height= 800)
				     (<:width= 600)
			  (<:vbox (<:flex= 1)
				  (<:style= "overflow:auto")
				  (render (get-component showcase 'child))))
			(<:tab-panel (<:style= "overflow:auto;")
			  (<:description (<:style= "white-space: pre-wrap;")
					 (let ((source (getf (cdr (selected-page showcase)) :source)))
					   (file-string source))))))))

(defparameter *showcase-pages*
  (flet ((source (filename)
	   (asdf:system-relative-pathname :cl-xul (format nil "test/showcase/~A" filename))))
    `(("Buttons"
       :component buttons-showcase
       :source ,(source "buttons.lisp"))
      ("Checkboxes"
       :component checkboxes-showcase
       :source ,(source "checkboxes.lisp"))
      ("Radiobuttons"
       :component radiobuttons-showcase
       :source ,(source "radiobuttons.lisp"))
      ("Images"
       :component images-showcase
       :source ,(source "images.lisp"))
      ("Lists"
       :component lists-showcase
       :source ,(source "lists.lisp"))
      ("Components"
       :component components-showcase
       :source ,(source "components.lisp"))
      ("Embedded"
       :component showcase
       :source ,(source "showcase.lisp")))))

(defun showcase ()
  (let ((app
	 (make-instance 'xul-application
			:name "showcase"
			:root-component (make-instance 'showcase)
			:build-id "0001"
			:id "Showcase")))
    (run-app app))) 
<commit_msg>Showcase: menubar<commit_after>(in-package :xul-test)

(defun file-string (path)
  (with-open-file (stream path)
    (let ((data (make-string (file-length stream))))
      (read-sequence data stream)
      data)))

(define-component showcase ()
  ((selected-page :accessor selected-page
		  :initform (first *showcase-pages*)))
  (:initialize (showcase)
	       (add-component showcase 'child
			      (make-instance (getf (cdr (selected-page showcase)) :component))))
  (:render (showcase)
	   (<:vbox (<:flex= 1)
		   (<:toolbox
		     (<:menu-bar
		       (<:menu (<:label= "File")
			       (<:accesskey= "f")
			       (<:menu-popup
				 (<:menu-item (<:label= "Quit")
					      (<:on-command= "window.close();"))))
		       (<:menu (<:label= "Help")
			       (<:accesskey= "h")
			       (<:menu-popup
				 (<:menu-item (<:label= "About")
					      (<:on-command= "alert('CL-XUL Common Lisp XUL bindings');"))))))
		   (<:hbox (<:flex= 1)
			   (<:list-box
			     (<:style= "width:10em")
			     (on-select= (lambda (index)
					   (setf (selected-page showcase)
						 (nth index *showcase-pages*))
					   (add-component showcase 'child
							  (make-instance (getf (cdr (selected-page showcase)) :component)))))
			     (loop for page in *showcase-pages*
				do
				  (<:list-item (<:label (car page))
					       (when (equalp (selected-page showcase)
							     page)
						 (<:selected= t)))))
			   (<:splitter (<:collapse= :before)
				       (<:grippy))
			   (<:tab-box (<:flex= 1)
				      (<:tabs
					(<:tab (<:label= "Examples"))
					(<:tab (<:label= "Source")))
				      (<:tab-panels
					(<:tab-panel (<:height= 800)
						     (<:width= 600)
						     (<:vbox (<:flex= 1)
							     (<:style= "overflow:auto")
							     (render (get-component showcase 'child))))
					(<:tab-panel (<:style= "overflow:auto;")
						     (<:description (<:style= "white-space: pre-wrap;")
								    (let ((source (getf (cdr (selected-page showcase)) :source)))
								      (file-string source))))))))))

(defparameter *showcase-pages*
  (flet ((source (filename)
	   (asdf:system-relative-pathname :cl-xul (format nil "test/showcase/~A" filename))))
    `(("Buttons"
       :component buttons-showcase
       :source ,(source "buttons.lisp"))
      ("Checkboxes"
       :component checkboxes-showcase
       :source ,(source "checkboxes.lisp"))
      ("Radiobuttons"
       :component radiobuttons-showcase
       :source ,(source "radiobuttons.lisp"))
      ("Images"
       :component images-showcase
       :source ,(source "images.lisp"))
      ("Lists"
       :component lists-showcase
       :source ,(source "lists.lisp"))
      ("Components"
       :component components-showcase
       :source ,(source "components.lisp"))
      ("Embedded"
       :component showcase
       :source ,(source "showcase.lisp")))))

(defun showcase ()
  (let ((app
	 (make-instance 'xul-application
			:name "showcase"
			:root-component (make-instance 'showcase)
			:build-id "0001"
			:id "Showcase")))
    (run-app app))) 

{'fraction_non_alphanumeric': 0.18290258449304175, 'fraction_numerical': 0.005422013374299656, 'mean_word_length': 2.679521276595745, 'pattern_counts': {'":': 0, '<': 75, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2823420', 'n_tokens_mistral': 2204, 'n_tokens_neox': 1776, 'n_words': 417}