konilo-extensions/exported/bos.txt

272 lines
17 KiB
Text

0 (bos)
1
2 . BOS is a "block operating system". It's intended to provide a
3 . number of little utilities for working with the Konilo blocks.
4 .
5 . It is intended that this will eventually replace (nonix) with
6 . something less like Unix.
7
8
9
10
11
12
13
14
15
save next new
0 (bos)
1
2 . BOS follows my personal approach to blocks. In this the first
3 . line is the block title. This will have the block name as the
4 . first element, with optional text following. For code, these a
5 . setup as "(name) (comments)", and for data, they are done as
6 . "name comments".
7 .
8 . It's best to keep names short. I find that a max of 20 seems
9 . sufficient to provide unique names to the blocks but still be
10 . easy to type in.
11 .
12 . Multiple blocks with the same name are considered a block set.
13 . This might be similar to a file in more traditional operating
14 . systems.
15
save next new
0 (bos) (directory-listing)
1
2 . I am using a two column display. These pad the columns and
3 . add new lines as needed.
4
5 #1 '~NL var-n
6 :~nl @~NL #2 eq? [ nl #0 !~NL ] if &~NL v:inc ;
7 :~pad #32 block:name s:length n:sub &sp times ;
8
9 :bos:display block:name s:put ~pad ~nl ;
10
11 . Block sets for programs have names starting with a (
12
13 :bos:program? block:name #0 s:fetch $( eq? ;
14
15
save next new
0 (bos) (directory-listing)
1
2 . Display a program listing. This is a top-level combinator;
3 . pass in a quote to do the actual display operation.
4
5 :bos:dir (q-)
6 [ block:set:init #1 !NL
7 [ drop block:set:known?
8 [ block:set:add dup call ] -if ]
9 block:for-each drop nl ] gc ;
10
11
12
13
14
15
save next new
0 (bos) (directory-listing)
1
2 . Display all sets.
3
4 :dir:sets
5 [ bos:display ] bos:dir ;
6
7 :dir:programs
8 [ bos:program? &bos:display if ] bos:dir ;
9
10 :dir:text
11 [ bos:program? &bos:display -if ] bos:dir ;
12
13 :dir:t
14 [ block:name '.txt s:ends-with? &bos:display if ] bos:dir ;
15
save next new
0 (bos) (find-blocks-for-set)
1
2 :~match? (sa-sf) drop block:name over s:eq? ;
3 :~record (f-) [ @Block comma ] if ;
4 :~finish (as-a) drop here n:dec over n:sub over store a:temp ;
5
6 :bos:blocks-for (s-a)
7 [ s:keep here swap #0 comma
8 [ ~match? ~record ] block:for-each ~finish ] gc ;
9
10
11
12
13
14
15
save next new
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
save next new
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
save next new
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
save next new
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
save next new
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
save next new
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
save next new
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
save next new
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
save next new
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
save next new
0 (LOAD:bos)
1
2 '(bos) needs
3
4
5
6
7
8
9
10
11
12
13
14
15
save next new