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());
74 assert(firstc
->code
< last
->code
&& last
.ok());
77 while (c
->code
< last
->code
) {
78 if (c
->priority
<= victim
.priority
) {
79 c
.insert(new Command(victim
));
84 last
.insert(new Command(victim
));
88 Staff_commands_at::add_command_to_break(Command pre
, Command mid
,Command post
)
90 assert(is_breakable());
91 iter_top(*this,c
), f(c
), l(c
);
100 insert_between(pre
, f
, l
);
102 while (!c
->isbreak())
105 insert_between(mid
, f
, l
);
107 while (!c
->isbreak())
110 assert(l
.ok() && l
->code
== BREAK_END
);
112 insert_between(post
, f
, l
);
117 should move this stuff into inputlanguage.
120 Staff_commands_at::add(Command c
)
122 bool encapsulate
=false;
127 if (c
.code
== INTERPRET
)
129 Command typeset
; // kut met peren
130 typeset
.code
= TYPESET
;
131 typeset
.args
= c
.args
;
132 if (c
.args
[0] == "NEWMEASURE") {
133 add(get_defaultbar_command());
134 } else if (c
.args
[0] == "BAR") {
136 c
.code
= NOP
; // no INTERPRET (BAR) commands
137 } else if (c
.args
[0] == "KEY") {
138 typeset
.priority
= 70;
140 } else if (c
.args
[0] == "CLEF") {
141 typeset
.priority
= 90;
143 } else if (c
.args
[0] == "METER") {
144 typeset
.priority
= 40;
151 if (c
.code
== TYPESET
) {
152 encapsulate
= is_breakable();
153 if (c
.args
[0] == "BAR") {
156 split_bar_command(pre
,mid
,post
, c
.args
[1]);
158 { /* every line a currentkey. */
161 kc
.args
.push( "CURRENTKEY");
165 { /* every line a currentclef. */
168 kc
.args
.push( "CURRENTCLEF");
173 if (is_breakable()) {
174 if (c
.args
[0] == "METER") {
178 }else if( c
.args
[0] == "KEY") {
183 }else if (c
.args
[0] == "CURRENTKEY" ){
187 if (c
.args
[0] == "CURRENTCLEF" ){
190 }else if (c
.args
[0] == "CLEF") {
200 add_command_to_break(pre
, mid
, post
);
203 top().insert(new Command(c
));
205 bottom().add(new Command(c
));