mirror of
https://github.com/janet-lang/janet
synced 2025-01-18 19:32:50 +00:00
Add *repl-prompt*.
This commit is contained in:
parent
8084e4c728
commit
2570e0f7a0
@ -2,6 +2,8 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## ??? - Unreleased
|
||||
- Change how JANET_PROFILE is loaded to allow more easily customizing the environment.
|
||||
- Add `*repl-prompt*` dynamic binding to allow customizing the built in repl.
|
||||
- Add multiple path support in the `JANET_PATH` environment variables. This lets
|
||||
user more easily import modules from many directories.
|
||||
|
||||
|
@ -1853,6 +1853,9 @@
|
||||
(defdyn *pretty-format*
|
||||
"Format specifier for the `pp` function")
|
||||
|
||||
(defdyn *repl-prompt*
|
||||
"Allow setting a custom prompt at the default REPL. Not all REPLs will respect this binding.")
|
||||
|
||||
(defn pp
|
||||
``Pretty-print to stdout or `(dyn *out*)`. The format string used is `(dyn *pretty-format* "%q")`.``
|
||||
[x]
|
||||
@ -4643,17 +4646,15 @@
|
||||
(if-not quiet
|
||||
(print "Janet " janet/version "-" janet/build " " (os/which) "/" (os/arch) "/" (os/compiler) " - '(doc)' for help"))
|
||||
(flush)
|
||||
(def env (make-env))
|
||||
(defn getprompt [p]
|
||||
(when-let [custom-prompt (get env *repl-prompt*)] (break (custom-prompt p)))
|
||||
(def [line] (parser/where p))
|
||||
(string "repl:" line ":" (parser/state p :delimiters) "> "))
|
||||
(defn getstdin [prompt buf _]
|
||||
(file/write stdout prompt)
|
||||
(file/flush stdout)
|
||||
(file/read stdin :line buf))
|
||||
(def env (make-env))
|
||||
(when-let [profile.janet (dyn *profilepath*)]
|
||||
(def new-env (dofile profile.janet :exit true))
|
||||
(merge-module env new-env "" false))
|
||||
(when debug-flag
|
||||
(put env *debug* true)
|
||||
(put env *redef* true))
|
||||
@ -4665,6 +4666,8 @@
|
||||
(setdyn *doc-color* (if colorize true))
|
||||
(setdyn *lint-error* error-level)
|
||||
(setdyn *lint-warn* error-level)
|
||||
(when-let [profile.janet (dyn *profilepath*)]
|
||||
(dofile profile.janet :exit true :env env))
|
||||
(repl getchunk nil env)))))
|
||||
|
||||
###
|
||||
|
Loading…
Reference in New Issue
Block a user