diff --git a/src/klipse/klipse_editors.cljs b/src/klipse/klipse_editors.cljs index 665653bc..f7de1d48 100644 --- a/src/klipse/klipse_editors.cljs +++ b/src/klipse/klipse_editors.cljs @@ -1,7 +1,7 @@ (ns klipse.klipse-editors (:require-macros [gadjett.core :refer [dbg]] - [purnam.core :refer [!]] + [purnam.core :refer [! !>]] [cljs.core.async.macros :refer [go go-loop]]) (:require [goog.dom :as gdom] @@ -65,7 +65,16 @@ (let [result (js {:detail {:result result + :hasError hasError + :resultElement (:result-element @state)}})] + (!> klipse-dom-node.dispatchEvent + (js/CustomEvent. "klipse-snippet-evaled" event-payload)))))) (recur results)))))) (catch :default e (setter e)))))) @@ -102,7 +111,7 @@ (s/def ::codemirror-options map?) (s/def ::editor-mode string?) -(s/fdef editor-options +(s/fdef editor-options :args (s/cat :in-mode ::editor-mode :out-mode ::editor-mode :options-in ::codemirror-options diff --git a/src/klipse/lang/python.cljs b/src/klipse/lang/python.cljs index 744cf9e2..ff6bc79b 100644 --- a/src/klipse/lang/python.cljs +++ b/src/klipse/lang/python.cljs @@ -22,17 +22,17 @@ (init) (let [c (chan)] (!> js/Sk.configure #js {:output #(put! c %) - :read builtin-read }) - (-> + :read builtin-read}) + (-> (!> js/Sk.misceval.asyncToPromise (fn [] (put! c "Output:\n") (! js/Sk.TurtleGraphics.target container-id) (!> js/Sk.importMainWithBody "" false exp true))) (.then (fn [mod] - (!> js/console.info "success to eval skulpt: ")) + (put! c [:ok mod])) (fn [err] - (put! c (str "error: " err))))) + (put! c [:err (str "error:\n" err)])))) c)) (def opts {:editor-in-mode "python"