1 #include "staffcommands.hh"
3 #include "parseconstruct.hh"
4 #include "getcommand.hh"
7 Staff_commands_at::when()
9 return tdescription_.when;
13 Staff_commands_at::print() const
17 mtor << "Commands at: " ;
18 tdescription_.print();
25 Staff_commands_at::OK()const
29 for (; i.ok() && (i+1).ok(); i++)
30 if (!i->isbreak() && !(i+1)->isbreak())
31 assert(i->priority >= (i+1)->priority);
35 Staff_commands_at::Staff_commands_at(Time_description m)
42 Staff_commands_at::is_breakable()
53 Staff_commands_at::set_breakable()
55 if (is_breakable()) return;
59 bottom().add(new Command(k));
60 k.code = BREAK_MIDDLE;
61 bottom().add(new Command(k));
63 bottom().add(new Command(k));
65 bottom().add(new Command(k));
69 Staff_commands_at::insert_between(Command victim, PCursor<Command*> firstc,
70 PCursor<Command*> last)
72 PCursor<Command*> c(firstc+1);
73 assert(firstc < last&&last.ok());
76 if (c->priority <= victim.priority) {
77 c.insert(new Command(victim));
82 last.insert(new Command(victim));
86 Staff_commands_at::add_command_to_break(Command pre, Command mid,Command post)
88 assert(is_breakable());
89 iter_top(*this,c), f(c), l(c);
98 insert_between(pre, f, l);
100 while (!c->isbreak())
103 insert_between(mid, f, l);
105 while (!c->isbreak())
108 assert(l.ok() && l->code == BREAK_END);
110 insert_between(post, f, l);
115 should move this stuff into inputlanguage.
118 Staff_commands_at::add(Command c)
120 bool encapsulate =false;
125 if (c.code == INTERPRET)
127 Command typeset; // kut met peren
128 typeset.code = TYPESET;
129 typeset.args = c.args;
130 if (c.args[0] == "NEWMEASURE") {
131 add(get_defaultbar_command());
132 } else if (c.args[0] == "BAR") {
134 c.code= NOP; // no INTERPRET (BAR) commands
135 } else if (c.args[0] == "KEY") {
136 typeset.priority = 70;
138 } else if (c.args[0] == "CLEF") {
139 typeset.priority = 90;
141 } else if (c.args[0] == "METER") {
142 typeset.priority = 40;
149 if (c.code == TYPESET) {
150 encapsulate = is_breakable();
151 if (c.args[0] == "BAR") {
154 split_bar_command(pre,mid,post, c.args[1]);
156 { /* every line a currentkey. */
159 kc.args.push( "CURRENTKEY");
163 { /* every line a currentclef. */
166 kc.args.push( "CURRENTCLEF");
171 if (is_breakable()) {
172 if (c.args[0] == "METER") {
176 }else if( c.args[0] == "KEY") {
181 }else if (c.args[0] == "CURRENTKEY" ){
185 if (c.args[0] == "CURRENTCLEF" ){
188 }else if (c.args[0] == "CLEF") {
198 add_command_to_break(pre, mid, post);
201 top().insert(new Command(c));
203 bottom().add(new Command(c));