#include "lookup.hh"
#include "debug.hh"
+#include "dimensions.hh"
#include "symtable.hh"
-#include "dimension.hh"
-#include "tex.hh"
#include "scalar.hh"
#include "paper-def.hh"
#include "string-convert.hh"
return s;
}
+String
+Lookup::base_output_str () const
+{
+ assert (paper_l_);
+ String str = paper_l_->get_default_output ();
+
+ if (str.empty_b ())
+ {
+ str = default_outname_base_global;
+ int def = paper_l_->get_next_default_count ();
+ if (def)
+ str += "-" + to_str (def);
+ }
+ return str;
+}
+
Atom
Lookup::beam (Real slope, Real width, Real thick) const
{
return a;
}
+String
+Lookup::character_str (int i) const
+{
+ return to_str (i);
+}
+
Atom
Lookup::clef (String st) const
{
#endif
}
+String
+Lookup::print_dimen (Real r) const
+{
+ String s = to_str (r, "%.3f");
+ if (s.index_i ("NaN") != -1)
+ {
+ warning (_ ("NaN"));
+ s = "0.0";
+ }
+ return s;
+}
+
Atom
Lookup::rest (int j, bool o) const
{
Array<String> args;
args.push (print_dimen (height));
args.push (print_dimen (width));
- bs.str_ = substitute_args (bs.str_,args);
- bs.dim_.x () = Interval (0,width);
- bs.dim_.y () = Interval (0,height);
+ bs.str_ = substitute_args (bs.str_, args);
+ bs.dim_.x () = Interval (0, width);
+ bs.dim_.y () = Interval (0, height);
return bs;
}
Atom
Lookup::special_time_signature (String s, Array<Scalar> arr) const
{
- String symbolname="timesig-"+s+"%/%";
- Atom a (afm_find (substitute_args(symbolname,arr)));
- if (!a.empty())
+ String symbolname = "timesig-"+s+"%/%";
+ Atom a (afm_find (substitute_args (symbolname, arr)));
+ if (!a.empty ())
return a;
// Try if the full name was given
- a=afm_find ("timesig-"+s);
- if (!a.empty())
+ a = afm_find ("timesig-"+s);
+ if (!a.empty ())
return a;
// Resort to default layout with numbers
- return time_signature(arr);
+ return time_signature (arr);
+}
+
+static void
+substitute_arg (String& r, String arg)
+{
+ int p = r.index_i ('%');
+ if (p < 0)
+ return ;
+
+ r = r.left_str (p) + arg + r.right_str (r.length_i () - p - 1);
+}
+
+String
+Lookup::substitute_args (String source, Array<String> args) const
+{
+ String str (source);
+ for (int i = 0 ; i < args.size (); i++)
+ substitute_arg (str, args[i]);
+ return str;
+}
+
+String
+Lookup::substitute_args (String source, Array<Scalar> args) const
+{
+ Array<String> sv;
+ for (int i = 0 ; i < args.size (); i++)
+ sv.push (args[i]);
+ return substitute_args (source, sv);
}
Atom
{
Array<String> a;
- a.push (to_str (idx));
+ a.push (character_str (idx));
brace.str_ = substitute_args (brace.str_,a);
brace.dim_[Y_AXIS] = Interval (-y/2,y/2);
}