aboutsummaryrefslogtreecommitdiff
path: root/iclean.icl
diff options
context:
space:
mode:
authorCamil Staps2016-10-18 23:52:49 +0200
committerCamil Staps2016-10-18 23:53:46 +0200
commitca6d92ece51042024ae99e3e52cfb89801db97b0 (patch)
treee20f3ccfebf068e19962122f545169297334d353 /iclean.icl
parentCleanup (diff)
Template file
Diffstat (limited to 'iclean.icl')
-rw-r--r--iclean.icl20
1 files changed, 19 insertions, 1 deletions
diff --git a/iclean.icl b/iclean.icl
index 6b64d98..7683619 100644
--- a/iclean.icl
+++ b/iclean.icl
@@ -36,6 +36,7 @@ temp_path :== "/tmp/"
temp_module :== "iclean"
readline_history :== "/home/.iclean_history"
template :== map ((+++) "import ") ["StdEnv", "StdDynamic", "genLibTest"]
+template_file :== "/home/.iclean_template"
// END SETTINGS
temp_file :== temp_path +++ temp_module +++ ".icl"
@@ -54,7 +55,8 @@ Start w
# w = setReadLineName "iClean" w
# w = usingHistory w
# w = checkedWorldFunc readHistory "Couldn't read history" readline_history w
-# w = loop template True w
+# (more_template,w) = readTemplate template_file w
+# w = loop (template ++ more_template) True w
# w = checkedWorldFunc writeHistory "Couldn't write history" readline_history w
= w
where
@@ -83,6 +85,22 @@ where
undef :: !String !String -> Bool
undef n h = not (matches (n +++ " ") h)
+ readTemplate :: !String !*World -> *([String], *World)
+ readTemplate f w
+ # (ok,f,w) = fopen f FReadText w
+ | not ok = ([], w)
+ # (lines,f) = readLines f
+ # (ok,w) = fclose f w
+ = (lines, w)
+ where
+ readLines :: !*File -> *([String], *File)
+ readLines f
+ # (end,f) = fend f
+ | end = ([], f)
+ # (line,f) = freadline f
+ # (lines,f) = readLines f
+ = ([line % (0,size line - 2):lines], f)
+
// iClean functions
checkedWorldFunc :: (a *World -> (Bool, *World)) !String !a !*World -> *World
checkedWorldFunc f err s w