2 paper-def.cc -- implement Paper_def
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
13 #include "paper-def.hh"
18 #include "file-results.hh" // urg? header_global_p
19 #include "paper-stream.hh"
21 Paper_def::Paper_def ()
23 lookup_alist_ = SCM_EOL;
27 Paper_def::~Paper_def ()
31 Paper_def::Paper_def (Paper_def const&src)
32 : Music_output_def (src)
35 for (SCM s = src.lookup_alist_; gh_pair_p(s); s = gh_cdr (s))
37 n = scm_acons (gh_caar(s), gh_cdar (s), n);
45 Paper_def::get_var (String s) const
47 return get_realvar (ly_symbol2scm (s.ch_C()));
51 Paper_def::get_scmvar (String s) const
53 return scope_p_->scm_elem (ly_symbol2scm (s.ch_C()));
57 Paper_def::get_realvar (SCM s) const
59 if (!scope_p_->elem_b (s))
61 programming_error ("unknown paper variable: " + ly_symbol2string (s));
64 SCM val = scope_p_->scm_elem (s);
65 if (gh_number_p (val))
67 return gh_scm2double (val);
71 programming_error ("not a real variable");
77 FIXME. This is broken until we have a generic way of
78 putting lists inside the \paper block.
81 Paper_def::line_dimensions_int (int n) const
83 Real lw = get_var ("linewidth");
84 Real ind = n? 0.0:get_var ("indent");
86 return Interval (ind, lw);
90 Paper_def::set_lookup (int i, SCM l)
92 assert (unsmob_lookup (l));
93 lookup_alist_ = scm_assq_set_x(lookup_alist_, gh_int2scm (i), l);
101 Paper_def::interbeam_f (int multiplicity_i) const
103 if (multiplicity_i <= 3)
104 return get_var ("interbeam");
106 return get_var ("interbeam4");
111 Paper_def::print () const
114 Music_output_def::print ();
116 gh_display (lookup_alist_);
121 Paper_def::lookup_l (int i) const
123 SCM l = scm_assq (gh_int2scm(i), lookup_alist_);
124 return l == SCM_BOOL_F ? 0 : unsmob_lookup (gh_cdr (l));
127 int Paper_def::default_count_i_ = 0;
130 Paper_def::get_next_default_count () const
132 return default_count_i_ ++;
136 Paper_def::reset_default_count()
138 default_count_i_ = 0;
143 Paper_def::paper_stream_p () const
145 String outname = base_output_str ();
148 outname += String (".") + output_global_ch;
149 progress_indication (_f ("paper output to %s...",
150 outname == "-" ? String ("<stdout>") : outname));
152 target_str_global_array.push (outname);
153 return new Paper_stream (outname);
158 Paper_def::base_output_str () const
160 String str = get_default_output ();
164 str = default_outname_base_global;
165 int def = get_next_default_count ();
167 str += "-" + to_str (def);