all repos — min @ e329114b2f2752c6f366f64eeb2f4908b3ae2b23

A small but practical concatenative programming language.

Implemented support for persistent history.
h3rald h3rald@h3rald.com
Sat, 03 Sep 2016 15:25:22 +0200
commit

e329114b2f2752c6f366f64eeb2f4908b3ae2b23

parent

87950395eaf08a106f123c7cbc12651aa1c515f1

2 files changed, 19 insertions(+), 0 deletions(-)

jump to
M lib/min_lang.nimlib/min_lang.nim

@@ -437,6 +437,14 @@

.symbol("clear") do (i: In): linenoiseClearScreen() + + .symbol("store-symbol") do (i: In): + var s:MinValue + i.reqStringLike s + + + # Sigils + .sigil("'") do (i: In): var s: MinValue i.reqString s
M minim.nimminim.nim

@@ -29,7 +29,10 @@ when defined(windows):

const HOME = getenv("HOMEPATH") when not defined(windows): const HOME = getenv("HOME") + const MINIMRC = HOME / ".minimrc" +const MINIMSYMBOLS = HOME / ".minim_symbols" +const MINIMHISTORY = HOME / ".minim_history" let usage* = " MiNiM v" & version & " - a tiny concatenative programming language" & """

@@ -87,6 +90,10 @@ i.sys_module

i.time_module i.fs_module i.crypto_module + if not MINIMSYMBOLS.fileExists: + MINIMSYMBOLS.writeFile("{}") + if not MINIMHISTORY.fileExists: + MINIMHISTORY.writeFile("") if not MINIMRC.fileExists: saverc() i.eval loadrc()

@@ -126,10 +133,14 @@ while true:

when USE_LINENOISE: CURRSCOPE = i.scope linenoiseSetCompletionCallback completionCallback + discard linenoiseHistorySetMaxLen(1000) + discard linenoiseHistoryLoad(MINIMHISTORY) line = prompt(": ") if line.isNil: echo "-> Exiting..." quit(0) + if $line != "(null)": + discard linenoiseHistorySave(MINIMHISTORY) i.parser.buf = $i.parser.buf & $line i.parser.bufLen = i.parser.buf.len discard i.parser.getToken()