<commit_before>;;;; Copyright (c) 2011-2016 <NAME> <<EMAIL>>
;;;; This code is licensed under the MIT license.

(defpackage :mezzano.gui.filer
  (:use :cl)
  (:export #:spawn))

(in-package :mezzano.gui.filer)

(defvar *up-icon* (mezzano.gui.image:load-image "LOCAL:>Icons>16x16 Up.png"))
(defvar *file-icon* (mezzano.gui.image:load-image "LOCAL:>Icons>16x16 File.png"))
(defvar *folder-icon* (mezzano.gui.image:load-image "LOCAL:>Icons>16x16 Folder.png"))

(defvar *directory-colour* mezzano.gui:*default-foreground-colour*)

(defun colourise-path (path)
  (case (canonical-type-from-pathname-type (pathname-type path))
    (:lisp-source-code (mezzano.gui:make-colour-from-octets #x94 #xBF #xF3))
    (:compiled-lisp-code (mezzano.gui:make-colour-from-octets #xF0 #xAF #x8F))
    (:text (mezzano.gui:make-colour-from-octets #xCC #x93 #x93))
    (:font (mezzano.gui:make-colour-from-octets #x7F #x9F #x7F))
    (:image (mezzano.gui:make-colour-from-octets #xDC #x8C #xC3))
    (:video (mezzano.gui:make-colour-from-octets #xDC #x8C #xC3))
    (:audio (mezzano.gui:make-colour-from-octets #xDC #x8C #xC3))
    (t mezzano.gui:*default-foreground-colour*)))

(defclass filer ()
  ((%fifo :initarg :fifo :reader fifo)
   (%window :initarg :window :reader window)
   (%thread :initarg :thread :reader thread)
   (%font :initarg :font :reader font)
   (%frame :initarg :frame :reader frame)
   (%path :initarg :path :accessor path)
   (%clickables :initarg :clickables :accessor clickables))
  (:default-initargs :clickables '()))

(defgeneric dispatch-event (viewer event))

(defmethod dispatch-event (window (event mezzano.gui.compositor:window-activation-event))
  (setf (mezzano.gui.widgets:activep (frame window)) (mezzano.gui.compositor:state event))
  (mezzano.gui.widgets:draw-frame (frame window)))

(defvar *type-registry*
  '((:lisp-source-code "lisp" "lsp" "asd" "lisp-expr")
    (:compiled-lisp-code "llf")
    (:text "text" "txt" "html" "css" "texinfo" "tex" "sh" "markdown" "md" "el")
    (:font "ttf")
    (:image "png" "jpeg" "jpg")
    (:video "avi")))
    (:audio "wav" "gif")))

(defun canonical-type-from-pathname-type (type-string)
  (when (or (not type-string)
            (equal type-string ""))
    (return-from canonical-type-from-pathname-type :text))
  (when (eql type-string :wild)
    (return-from canonical-type-from-pathname-type :wild))
  (dolist (type *type-registry* (intern (format nil "UNKNOWN-~A" type-string) "KEYWORD"))
    (when (member type-string (rest type) :test #'string-equal)
      (return (first type)))))
<commit_msg>register GIF as video type<commit_after>;;;; Copyright (c) 2011-2016 <NAME> <<EMAIL>>
;;;; This code is licensed under the MIT license.

(defpackage :mezzano.gui.filer
  (:use :cl)
  (:export #:spawn))

(in-package :mezzano.gui.filer)

(defvar *up-icon* (mezzano.gui.image:load-image "LOCAL:>Icons>16x16 Up.png"))
(defvar *file-icon* (mezzano.gui.image:load-image "LOCAL:>Icons>16x16 File.png"))
(defvar *folder-icon* (mezzano.gui.image:load-image "LOCAL:>Icons>16x16 Folder.png"))

(defvar *directory-colour* mezzano.gui:*default-foreground-colour*)

(defun colourise-path (path)
  (case (canonical-type-from-pathname-type (pathname-type path))
    (:lisp-source-code (mezzano.gui:make-colour-from-octets #x94 #xBF #xF3))
    (:compiled-lisp-code (mezzano.gui:make-colour-from-octets #xF0 #xAF #x8F))
    (:text (mezzano.gui:make-colour-from-octets #xCC #x93 #x93))
    (:font (mezzano.gui:make-colour-from-octets #x7F #x9F #x7F))
    (:image (mezzano.gui:make-colour-from-octets #xDC #x8C #xC3))
    (:video (mezzano.gui:make-colour-from-octets #xDC #x8C #xC3))
    (:audio (mezzano.gui:make-colour-from-octets #xDC #x8C #xC3))
    (t mezzano.gui:*default-foreground-colour*)))

(defclass filer ()
  ((%fifo :initarg :fifo :reader fifo)
   (%window :initarg :window :reader window)
   (%thread :initarg :thread :reader thread)
   (%font :initarg :font :reader font)
   (%frame :initarg :frame :reader frame)
   (%path :initarg :path :accessor path)
   (%clickables :initarg :clickables :accessor clickables))
  (:default-initargs :clickables '()))

(defgeneric dispatch-event (viewer event))

(defmethod dispatch-event (window (event mezzano.gui.compositor:window-activation-event))
  (setf (mezzano.gui.widgets:activep (frame window)) (mezzano.gui.compositor:state event))
  (mezzano.gui.widgets:draw-frame (frame window)))

(defvar *type-registry*
  '((:lisp-source-code "lisp" "lsp" "asd" "lisp-expr")
    (:compiled-lisp-code "llf")
    (:text "text" "txt" "html" "css" "texinfo" "tex" "sh" "markdown" "md" "el")
    (:font "ttf")
    (:image "png" "jpeg" "jpg")
    (:video "avi" "gif")
    (:audio "wav")))

(defun canonical-type-from-pathname-type (type-string)
  (when (or (not type-string)
            (equal type-string ""))
    (return-from canonical-type-from-pathname-type :text))
  (when (eql type-string :wild)
    (return-from canonical-type-from-pathname-type :wild))
  (dolist (type *type-registry* (intern (format nil "UNKNOWN-~A" type-string) "KEYWORD"))
    (when (member type-string (rest type) :test #'string-equal)
      (return (first type)))))

{'fraction_non_alphanumeric': 0.1839080459770115, 'fraction_numerical': 0.014806156243911942, 'mean_word_length': 4.55027027027027, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, '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': '6164672', 'n_tokens_mistral': 2065, 'n_tokens_neox': 1962, 'n_words': 424}