;;; -*- lexical-binding: t -*- ;; ;; -------------------------------------------------------------------------- (require 'cl-lib) (cl-pushnew "." load-path :test #'string=) (require 'luki-lisp) ;; -------------------------------------------------------------------------- (-> 'eieio) (-> 'bad-color) ;; -------------------------------------------------------------------------- (defclass elem () ;;;;; name ((name :initarg :name :type string :initform (@f "element-%d" (random 100))) ;;;;; delete (deletable :initarg :deletable :custom boolean :initform t) (deleted :initarg :deleted :custom boolean :initform nil) (visible :initarg :visible :custom boolean :initform t) ;;;;; move (movable :initarg :movable :custom boolean :initform t) (resizable :initarg :resizable :custom boolean :initform t) (transposable :initarg :transposable :custom boolean :initform t) ;;;;; color (bg :initarg :bg :type (or null string) :initform nil) (fg :initarg :fg :type (or null string) :initform nil) (actual-fg :initarg :acutal-fg :type (or null string) :initform nil) (dist-fg :initarg :dist-fg :type (or null string) :initform nil) (prox :initarg :dist :type float :initform 1.0) ;;;;; data (data :initarg :data :type list :initform nil) (len :initarg :len :type integer :initform 0) (redraw :initarg :redraw :custom boolean :initform t) ;;;;; position (x :initarg :x :type integer :initform 0) (y :initarg :y :type integer :initform 0) (ix :initarg :ix :type integer :initform 0) (iy :initarg :iy :type integer :initform 0) (min-x :initarg :min-x :type integer :initform 0) (min-y :initarg :min-y :type integer :initform 0) (max-x :initarg :max-x :type (or null integer) :initform nil) (max-y :initarg :max-y :type (or null integer) :initform nil) ;;;;; size (w :initarg :w :type integer :initform 0) (h :initarg :h :type integer :initform 0) (w-min :initarg :w-min :type integer :initform 1) (h-min :initarg :h-min :type integer :initform 1) (w-max :initarg :w-max :type integer :initform 78) (h-max :initarg :h-max :type integer :initform 28) ;;;;; sub (pushy :initarg :pushy :custom boolean :initform nil) (resize-wh :initarg :resize-wh :type list :initform nil) (align-center :initarg :align-c :custom boolean :initform nil) (align-rel-xy :initarg :align-rel-xy :type list :initform nil) (sub :initarg :sub :type list :initform nil))) ;; -------------------------------------------------------------------------- (cl-defmethod bad-update ((_ elem)) (ignore)) ;; -------------------------------------------------------------------------- (cl-defmethod bad-set-data ((e elem) (new-data list)) (~ (data len redraw) e (unless (equal new-data '(-1)) (setf data new-data)) (setf len (--- data)) (setf redraw t))) ;; -------------------------------------------------------------------------- (cl-defmethod bad-info ((e elem)) (~ (name x y w h fg bg) e ($ "%s (%d %d) %dx%d chars, color: [fg %s] [bg %s]" name x y w h (& fg (propertize fg 'face `(:foreground ,fg))) (& bg (propertize bg 'face `(:background ,bg)))))) ;; -------------------------------------------------------------------------- (<- 'bad-elem)