2021-02-07 21:56:19 +00:00
|
|
|
(local util (require :lib.util))
|
|
|
|
(local core (require :core))
|
|
|
|
(local command (require :core.command))
|
|
|
|
(local keymap (require :core.keymap))
|
|
|
|
(local common (require :core.common))
|
|
|
|
|
2022-04-10 04:20:18 +00:00
|
|
|
(fn selected-form []
|
2021-02-07 21:56:19 +00:00
|
|
|
(let [ldoc core.active_view.doc
|
2022-04-10 04:20:18 +00:00
|
|
|
(aline acol bline bcol) (ldoc:get_selection)]
|
2021-02-07 21:56:19 +00:00
|
|
|
(if (and (= aline bline) (= acol bcol))
|
2022-04-10 04:20:18 +00:00
|
|
|
(ldoc:get_text aline 1 aline 10000000)
|
|
|
|
(ldoc:get_text aline acol bline bcol))))
|
|
|
|
|
|
|
|
(fn inline-eval [eval]
|
|
|
|
(let [ldoc core.active_view.doc
|
|
|
|
(aline acol bline bcol) (ldoc:get_selection)]
|
|
|
|
(ldoc:insert bline bcol (eval (selected-form)))))
|
2021-02-07 21:56:19 +00:00
|
|
|
|
|
|
|
(require :editor.editmode)
|
|
|
|
|
2021-03-29 05:03:43 +00:00
|
|
|
(command.add :editor.replview {
|
|
|
|
"repl:submit" #(core.active_view:submit)
|
|
|
|
})
|
|
|
|
|
2022-04-10 04:20:18 +00:00
|
|
|
(local {: show : submit} (util.require :inspector.debug))
|
2021-03-29 05:03:43 +00:00
|
|
|
(command.add nil {
|
2022-04-10 04:20:18 +00:00
|
|
|
"repl:create" #(show)
|
|
|
|
})
|
|
|
|
(command.add :core.docview {
|
|
|
|
"repl:eval" #(submit nil (selected-form))
|
2021-03-29 05:03:43 +00:00
|
|
|
})
|
|
|
|
(keymap.add {
|
|
|
|
:return "repl:submit"
|
2022-04-10 04:20:18 +00:00
|
|
|
"alt+e" "repl:eval"
|
2021-03-29 05:03:43 +00:00
|
|
|
})
|
|
|
|
|
2021-02-07 21:56:19 +00:00
|
|
|
{: inline-eval}
|