retroforth/interface/library.retro
crc 1f18b9f2b1 make HOME a floating buffer (reduces image size by 1k cells)
FossilOrigin-Name: 5b35e2c48ba1f114806df1d34ac4996f1684caa22ea11aa4cfd8d99b289b5130
2024-01-10 22:26:59 +00:00

35 lines
899 B
Forth

~~~
:HOME here #4096 + ;
'%s/.config/retroforth/library/%s.retro 'library:.CONFIG s:const
'./library/%s.retro 'library:CWD s:const
:library:cwd library:CWD s:format ;
:library:.config
'HOME HOME unix:getenv
HOME library:.CONFIG s:format ;
:library:filename (s-s)
dup library:cwd
dup file:exists? [ nip ] if; drop
library:.config dup file:exists? [ ] if; drop s:empty ;
:library:contains? (s-f)
&library:cwd &library:.config bi &file:exists? bi@ or ;
:library:load
dup library:contains? [ library:filename include ]
[ 'ERROR:_Library_`%s`_was_not_found s:format s:put nl ] choose ;
'interface/library.retro s:dedup
dup 'library:load d:set-source
dup 'library:contains? d:set-source
dup 'library:filename d:set-source
dup 'library:.config d:set-source
dup 'library:cwd d:set-source
dup 'library:CWD d:set-source
dup 'library:.CONFIG d:set-source
dup 'HOME d:set-source
drop
~~~