1 #include "scommands.hh"
5 maybe it's time for a "narrowing" cursor?
8 Score_commands::first(Real w
)
10 PCursor
<Command
*> pc(*this);
11 while (pc
.ok() && pc
->when
< w
)
18 Score_commands::last_insertion(Real w
)
20 PCursor
<Command
*> pc(*this);
21 while (pc
.ok() && pc
->when
<= w
)
27 Score_commands::add_seq(svec
<Command
> com
)
31 Real when
= com
[0].when
;
33 PCursor
<Command
*> pc(last_insertion(when
));
34 for (int i
= 0; i
< com
.sz(); i
++) {
35 Command
*c
= new Command(com
[i
]);
36 assert(com
[i
].when
== when
);
45 Score_commands::set_breakable(Real when
)
47 bool found_typeset(false);
48 PCursor
<Command
*> cc
= first(when
);
49 for (; cc
.ok() && cc
->when
== when
; cc
++) {
52 if (cc
->code
== TYPESET
)
56 assert(!found_typeset
);
62 k
.code
= BREAK_MIDDLE
;
72 Score_commands::is_breakable(Real w
)
74 PCursor
<Command
*> cc
= first(w
);
75 for (; cc
.ok() && cc
->when
== w
; cc
++) {
82 Score_commands::add_command_to_break(Command pre
, Command mid
,Command post
)
88 PCursor
<Command
*> c ( first(w
));
91 c
.add(new Command(pre
));
95 c
.add(new Command(mid
));
99 c
.add(new Command(post
));
103 Score_commands::add(Command c
)
105 bool encapsulate
=false;
109 Command
post(c
.when
);
112 if (c
.code
== TYPESET
) {
113 if (c
.args
[0] == "BAR") {
114 set_breakable(c
.when
);
119 if (c
.args
[0] == "METER" && is_breakable(c
.when
)) {
128 add_command_to_break(pre
, mid
, post
);
137 first and last column should be breakable.
138 Remove any command past the last musical column.
141 Score_commands::clean(Real l
)
144 if (!is_breakable(0.0)) {
152 PCursor
<Command
*> bot(bottom());
154 while (bot
.ok() && bot
->when
> l
) {
156 mtor
<<"removing "<< bot
->code
<<" at " << bot
->when
<<'\n';
161 if (!is_breakable(l
)) {
172 Score_commands::OK() const
174 for (PCursor
<Command
*> cc(*this); cc
.ok() && (cc
+1).ok(); cc
++) {
175 assert(cc
->when
<= (cc
+1)->when
);
180 Score_commands::print() const
182 for (PCursor
<Command
*> cc(*this); cc
.ok() ; cc
++) {