# HG changeset patch # User # Date 2020-03-23 13:53:15 # Node ID d1c8a2bdbb49e6c6dd3af26264abeb4a7f286fe3 # Parent f7b5d97b5aa1b290ae5f807003d0460547b15b5b Bugfixes diff --git a/TODO b/TODO --- a/TODO +++ b/TODO @@ -1,4 +1,8 @@ +* Remove cl-uglify-js (no support for ES6 at all and no way to monkey-patch it reliably) +* Use Parenscript's async/await +* Use Parenscript's minifier +* WAIT and MENU with async/await * Special locations * Special variables * CLI build for Linux @@ -8,4 +12,4 @@ * Windows GUI (for the compiler) * Save-load game in slots * Resizable frames -** modifying it to suit compiler specifics \ No newline at end of file +** modifying it to suit compiler specifics diff --git a/src/api.ps b/src/api.ps --- a/src/api.ps +++ b/src/api.ps @@ -49,23 +49,30 @@ ;;; Misc +(defm (root api newline) (key) + (this.append-id (this.key-to-id key) "
" t)) + (defm (root api clear-id) (id) - (setf (ps:chain document (get-element-by-id id) inner-text) "")) + (setf (ps:chain document (get-element-by-id id) inner-h-t-m-l) "")) + +(setf (root api text-escaper) (document.create-element :textarea)) + +(defm (root api prepare-contents) (s &optional force-html) + (if (or force-html (var "USEHTML" 0 :num)) + s + (progn + (setf (ps:@ (root api text-escaper) text-content) s) + (ps:@ (root api text-escaper) inner-h-t-m-l)))) (defm (root api get-id) (id &optional force-html) - (if (or force-html (var "USEHTML" 0 :num)) - (ps:chain (document.get-element-by-id id) inner-h-t-m-l) - (ps:chain (document.get-element-by-id id) inner-text))) + (ps:chain (document.get-element-by-id id) inner-h-t-m-l)) (defm (root api set-id) (id contents &optional force-html) - (if (or force-html (var "USEHTML" 0 :num)) - (setf (ps:chain (document.get-element-by-id id) inner-h-t-m-l) contents) - (setf (ps:chain (document.get-element-by-id id) inner-text) contents))) + (setf (ps:chain (document.get-element-by-id id) inner-h-t-m-l) (this.prepare-contents contents force-html))) (defm (root api append-id) (id contents &optional force-html) - (if (or force-html (var "USEHTML" 0 :num)) - (incf (ps:chain (document.get-element-by-id id) inner-h-t-m-l) contents) - (incf (ps:chain (document.get-element-by-id id) inner-text) contents))) + (when contents + (incf (ps:chain (document.get-element-by-id id) inner-h-t-m-l) (this.prepare-contents contents force-html)))) ;;; Function calls @@ -108,10 +115,6 @@ (defm (root api clear-text) (key) (this.clear-id (this.key-to-id key))) -(defm (root api newline) (key) - (let ((div (this.get-frame key))) - (ps:chain div (append-child (document.create-element "br"))))) - (defm (root api enable-frame) (key enable) (let ((obj (this.get-frame key))) (setf obj.style.display (if enable "block" "none")) diff --git a/src/intrinsics.ps b/src/intrinsics.ps --- a/src/intrinsics.ps +++ b/src/intrinsics.ps @@ -289,8 +289,13 @@ ;;; misc -(defm (root lib rgb) () - (api-call report-error "RGB is not implemented.")) +(defm (root lib rgb) (red green blue) + (flet ((rgb-to-hex (comp) + (let ((hex (ps:chain (*number comp) (to-string 16)))) + (if (< (length hex) 2) + (+ "0" hex) + hex)))) + (+ "#" (rgb-to-hex red) (rgb-to-hex green) (rgb-to-hex red)))) (defm (root lib openqst) () (api-call report-error "OPENQST is not supported.")) diff --git a/sugar-qsp.asd b/sugar-qsp.asd --- a/sugar-qsp.asd +++ b/sugar-qsp.asd @@ -6,6 +6,7 @@ :pathname "src/" :serial t :components ((:file "package") + (:file "patches") (:file "ps-macros") (:file "intrinsic-macros") (:file "class")