Added custom prompt.
h3rald h3rald@h3rald.com
Fri, 07 Oct 2016 15:27:53 +0200
4 files changed,
11 insertions(+),
9 deletions(-)
M
lib/min_io.nim
→
lib/min_io.nim
@@ -41,7 +41,7 @@ .symbol("password") do (i: In):
var ed = initEditor() i.push ed.password("Enter Password: ").newVal - .symbol("prompt") do (i: In): + .symbol("ask") do (i: In): var s: MinValue var ed = initEditor() i.reqString s
M
minim.nim
→
minim.nim
@@ -156,17 +156,16 @@ var line: string
echo "$1 v$2" % [appname, version] echo "-> Type 'exit' or 'quit' to exit." var ed = initEditor(historyFile = MINIMHISTORY) - KEYMAP["ctrl+s"] = proc (ed: var LineEditor) = - echo "hello" - when defined(windows): - discard execShellCmd("cls") - else: - discard execShellCmd("clear") while true: let symbols = toSeq(i.scope.symbols.keys) ed.completionCallback = proc(ed: LineEditor): seq[string] = return ed.getCompletions(symbols) - line = ed.readLine(": ") + # evaluate prompt + i.apply(i.scope.getSymbol("prompt")) + var v: MinValue + i.reqString(v) + let prompt = v.getString() + line = ed.readLine(prompt) i.parser.buf = $i.parser.buf & $line i.parser.bufLen = i.parser.buf.len discard i.parser.getToken()
M
minim.vim
→
minim.vim
@@ -10,7 +10,7 @@ endif
setl iskeyword+=?,$,+,*,/,%,=,>,<,&,-,',.,:,@,~,^,! -syntax keyword minimDefaultSymbol ! != $ & ' * + - % ^ -> . .. / : < <= == => =~ > >= @ ROOT aes and append apply at atime b bind bool bool? bury1 bury2 bury3 c call call! capitalize case cd chmod choose clear-stack column-print concat confirm cons cp cpu crypto ctime datetime ddel debug debug? decode decrypt define delete dget dictionary? dig1 dig2 dig3 dip dir? dirname div dprint dprint! dset dump-stack dup dupd echo encode encrypt env? eq eval even? exit fappend file? filename filter first float float? foreach fperms fread from-json fs fsize fstats ftype fwrite gets get-stack getenv gt gte hardlink hidden? i id ifte import indent inspect int int? interpolate interval io join k keys length linrec load load-symbol logic lowercase ls ls-r lt lte map match md5 mkdir mod module mtime mv newline not noteq now num number? odd? or os password pop popd pred prepend print print! prompt puts puts! putenv q quit quotation? quote raise regex remove-symbol repeat replace rest rm rmdir run save-symbol scope scope? seal search select set-stack sha1 sha224 sha256 sha384 sha512 sigil sigils sip size sleep source split stored-symbols str string string? strip succ swap swapd swons symbols symlink symlink? sys system take tformat time timeinfo times timestamp titleize to-json try unit unquote uppercase values version which while with xor zap contains +syntax keyword minimDefaultSymbol ! != $ & ' * + - % ^ -> . .. / : < <= == => =~ > >= @ ROOT aes and append apply ask at atime b bind bool bool? bury1 bury2 bury3 c call call! capitalize case cd chmod choose clear-stack column-print concat confirm cons cp cpu crypto ctime datetime ddel debug debug? decode decrypt define delete dget dictionary? dig1 dig2 dig3 dip dir? dirname div dprint dprint! dset dump-stack dup dupd echo encode encrypt env? eq eval even? exit fappend file? filename filter first float float? foreach fperms fread from-json fs fsize fstats ftype fwrite gets get-stack getenv gt gte hardlink hidden? i id ifte import indent inspect int int? interpolate interval io join k keys length linrec load load-symbol logic lowercase ls ls-r lt lte map match md5 mkdir mod module mtime mv newline not noteq now num number? odd? or os password pop popd pred prepend print print! prompt puts puts! putenv q quit quotation? quote raise regex remove-symbol repeat replace rest rm rmdir run save-symbol scope scope? seal search select set-stack sha1 sha224 sha256 sha384 sha512 sigil sigils sip size sleep source split stored-symbols str string string? strip succ swap swapd swons symbols symlink symlink? sys system take tformat time timeinfo times timestamp titleize to-json try unit unquote uppercase values version which while with xor zap contains syntax match minimDefaultSigil ;\<[:@'~!$%&$=<>^*]; contained
M
prelude.min
→
prelude.min
@@ -69,6 +69,9 @@ (:ms :q :check (check) (ms sleep q) while) :interval
(password aes encode) :encrypt (decode password aes) :decrypt +; Prompt +("[$1]$$ " (.) %) :prompt + ; Load all stored symbols stored-symbols ('load-symbol ROOT with) foreach