Skip to content

Commit

Permalink
preparing MiniSteno:addBranch
Browse files Browse the repository at this point in the history
  • Loading branch information
iani committed Jul 12, 2015
1 parent b2372bd commit a451655
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 32 deletions.
57 changes: 28 additions & 29 deletions Classes/MiniSteno/MiniSteno.sc
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,28 @@ https://github.com/telephon/Steno
MiniSteno {
var <tree; // child branches contained in me: chucks, other MiniStenos
var <>parent; // MiniSteno containing me. Needed for remove.
classvar <previous; // chucks traced during build
classvar <>verbose = true;

addBranch { | name = \root, server |
var oldBranch, oldChucks, newChucks, nullGroup;
server = server.asTarget.server;
oldBranch = this.named (name, server);
oldBranch !? { oldChucks = oldBranch.chucks };
nullGroup = GroupLink.nullGroup;
this.setBussesAndGroups(ArBusLink.nullBus, ArBusLink.nullBus, GroupLink.default);
oldChucks do: { | p |
if (newChucks.includes (p).not) { p.setTarget(nullGroup) } // also free busses? !
};
Library.put (MiniSteno, server, name, this);
if (verbose) {
"================================================================".postln;
this.pp;
"================================================================".postln;
};
}

named { | name, server | ^Library.at (MiniSteno, server.asTarget.server, name ) }

named { | server | ^Library.at (MiniSteno, server.asTarget.server ) }
*includes { | chuck | ^this.root includes: chuck }
includes { | chuck |
^this.findParentOf (chuck).notNil;
Expand All @@ -32,6 +51,8 @@ MiniSteno {
^nil;
}



storePrevious { previous = this.chucks }

chucks {
Expand Down Expand Up @@ -63,25 +84,6 @@ MiniSteno {
}

asSteno {}

push { // make this instance the root, and initialize it
Library.put(MiniSteno, Server.default, \root, this);
this.initTree;
}

initTree {
var nullGroup, current;
nullGroup = GroupLink.nullGroup;
this.storePrevious;
this.setBussesAndGroups(ArBusLink.nullBus, ArBusLink.nullBus, GroupLink.default);
current = this.chucks;
previous do: { | p |
if (current.includes (p).not) { p.setTarget(nullGroup) }
};
"================================================================".postln;
this.pp;
"================================================================".postln;
}

*root { | server | ^Library.at(MiniSteno, server.asTarget.server, \root) }

Expand Down Expand Up @@ -124,10 +126,6 @@ MiniSteno {
}
}

addTree {


}
insertAfter { | existingChuck, newChuck |

}
Expand All @@ -142,8 +140,7 @@ MiniSteno {

doIfFound { | element, foundFunc, missingFunc |
var container;
container = this.findPare
ntOf(element);
container = this.findParentOf(element);
if (container.isNil) {
missingFunc.(element, this);
}{
Expand Down Expand Up @@ -199,7 +196,7 @@ Ser : MiniSteno {

+ String {
miniSteno { ^MiniSteno.fromString(this) }
arlink { ^this.miniSteno.push }
arlink { ^this.miniSteno.addBranch }
}

+ Symbol {
Expand All @@ -217,7 +214,9 @@ Ser : MiniSteno {

^Chuck (this)
}
}//:
}

//:
/* Tue, Jun 16 2015, 03:08 EEST
Inspired by Steno of Julian Rohrhuber.
Expand Down
23 changes: 20 additions & 3 deletions Notes/TODOs.org
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,23 @@ Note that these shortcuts must be attached to the source chucks with notificatio
:DATE: <2015-07-06 Mon 12:05>
:END:

Two basic operators/operations only:

1. \writer &> \reader :: compose Ser (writer.reader). Cases:
1. neither writer nor reader are
2. writer is already in the tree but reader is not. In this case insert reader after writer as follows:
1. If writer is not in a ser, then create a ser:
[x.writer...] becomes [x(writer.reader)...]
2. If writer is in a ser (a.b.writer....), Insert reader after writer in existing ser: (a.b.writer.reader...).
3. reader is already in a ser, but writer is not. In this case
1. asdf
4. both reader and writer are already in the global ministeno tree. In that case, do not change the tree, but issue a warning that the tree must be edited with an explicit ministeno specification.
2. \a <&> \b :: compose a and b in parallel. The rules are analogous to 1 above.

****** earlier draft:
:PROPERTIES:
:DATE: <2015-07-09 Thu 15:15>
:END:
- \source &> \effect :: Add \effect serially after \source, and only after source (not after any of its siblings). If another chuck \previous is already connected serially to the output of \source, then add \effect in parallel to the existing one: (source.previous) becomes (source[effect.previous]). But note:
([source.source2]previous) becomes:
([(source.effect)source2]previous)
Expand All @@ -151,17 +168,17 @@ We may want to introduce also <& and <<& for adding siblings to the head of the

Adding \w &> \r to the following trees, results:

****** case 1
******* case 1
before: x.y

after: x.y(w.r)

****** case 2
******* case 2
before: x.w

after x(w.r)

****** case 3
******* case 3

before:

Expand Down

0 comments on commit a451655

Please sign in to comment.