all repos — min @ c88b9dda1fe3ce2b885c9d15e8629abaca535106

A small but practical concatenative programming language.

Added custom prompt.
h3rald h3rald@h3rald.com
Fri, 07 Oct 2016 15:27:53 +0200
commit

c88b9dda1fe3ce2b885c9d15e8629abaca535106

parent

83d498e58c400cdd1b0e83940df83e0baa0d97bd

4 files changed, 11 insertions(+), 9 deletions(-)

jump to
M lib/min_io.nimlib/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.nimminim.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.vimminim.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.minprelude.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