39 lines
1.3 KiB
Plaintext
39 lines
1.3 KiB
Plaintext
|
(local core (require :core))
|
||
|
(local style (require :core.style))
|
||
|
(local util (require :plugins.fennel-xl.util))
|
||
|
(local repl (require :plugins.fennel-xl.repl))
|
||
|
(local ReplView (require :plugins.fennel-xl.replview))
|
||
|
(local replsession (require :plugins.fennel-xl.replsession))
|
||
|
(require :plugins.fennel-xl.localrepl)
|
||
|
(require :plugins.fennel-xl.nrepl-session)
|
||
|
|
||
|
(local module (util.hot-table ...))
|
||
|
|
||
|
(fn find-existing-inspector-window [name]
|
||
|
(var result nil)
|
||
|
(each [_ view (ipairs (core.root_view.root_node:get_children)) :until result]
|
||
|
(when (= view.inspector-name name)
|
||
|
(set result view)))
|
||
|
result)
|
||
|
|
||
|
(fn create-inspector-window [name ?value]
|
||
|
(let [node (core.root_view:get_active_node)
|
||
|
conn (repl.new name (if ?value :local nil))
|
||
|
view (ReplView conn)]
|
||
|
(set view.inspector-name name)
|
||
|
(set view.title name)
|
||
|
(view:append {:draw (fn [_ _ x y] (when (and x y) (renderer.draw_text style.font name x y style.text) (+ (style.font:get_height) style.padding.y)))})
|
||
|
(when ?value
|
||
|
(view:append (repl.mk-result [?value])))
|
||
|
(node:split :right view)
|
||
|
view))
|
||
|
|
||
|
(lambda module.show [?value ?name]
|
||
|
(let [name (replsession.session-id ?name)]
|
||
|
(or (find-existing-inspector-window name) (create-inspector-window name ?value))))
|
||
|
|
||
|
(lambda module.submit [chunk ?name]
|
||
|
(: (module.show ?name) :submit chunk))
|
||
|
|
||
|
module.hot
|