2 paper-outputter.cc -- implement Paper_outputter
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 Jan Nieuwenhuizen <janneke@gnu.org>
15 #include "dimensions.hh"
16 #include "dictionary-iter.hh"
17 #include "virtual-methods.hh"
18 #include "paper-outputter.hh"
19 #include "paper-stream.hh"
20 #include "molecule.hh"
22 #include "string-convert.hh"
27 #include "identifier.hh"
28 #include "lily-version.hh"
35 Paper_outputter::Paper_outputter (Paper_stream * ps )
38 molecules_ = gh_cons (SCM_EOL, SCM_EOL);
39 last_cons_ = molecules_;
46 verbatim_scheme_b_ = output_global_ch == String ("scm");
48 if (verbatim_scheme_b_)
51 ";;; Usage: guile -s x.scm > x.tex\n"
52 "(primitive-load-path 'lily.scm)\n"
55 "(map (lambda (x) (display (eval x))) '(\n"
62 Paper_outputter::~Paper_outputter ()
64 if (verbatim_scheme_b_)
73 Paper_outputter::output_header ()
77 gh_define ("security-paranoia", SCM_BOOL_T);
80 SCM exp = gh_list (ly_symbol2scm ((String (output_global_ch) + "-scm").ch_C()),
81 ly_quote_scm (ly_symbol2scm ("all-definitions")),
87 if (no_timestamps_global_b)
88 creator = gnu_lilypond_str ();
90 creator = gnu_lilypond_version_str ();
93 if (no_timestamps_global_b)
97 generate = _ (", at ");
99 generate += ctime (&t);
100 generate = generate.left_str (generate.length_i () - 1);
104 gh_list (ly_str02scm (creator.ch_l ()),
105 ly_str02scm (generate.ch_l ()), SCM_UNDEFINED);
108 SCM scm = gh_cons (ly_symbol2scm ("header"), args_scm);
115 Paper_outputter::output_comment (String str)
117 output_scheme (gh_list (ly_symbol2scm ("comment"),
118 ly_str02scm ((char*)str.ch_C()),
125 Paper_outputter::output_scheme (SCM scm)
128 SCM c = gh_cons (scm,gh_cdr (last_cons_));
129 gh_set_cdr_x(last_cons_, c);
139 Paper_outputter::dump ()
142 for (SCM s = gh_cdr (molecules_); gh_pair_p (s); s = gh_cdr (s))
144 dump_scheme (gh_car (s));
150 Paper_outputter::dump_scheme (SCM s)
152 if (verbatim_scheme_b_)
154 SCM result = scm_eval (scm_listify (ly_symbol2scm ("scm->string"),
155 ly_quote_scm (gh_car (s)), SCM_UNDEFINED));
157 *stream_p_ << ly_scm2string (result);
161 SCM result = scm_eval (s);
162 char *c=gh_scm2newstr (result, NULL);
169 Paper_outputter::output_scope (Scope *scope, String prefix)
171 for (Scope_iter i (*scope); i.ok (); i++)
173 if (dynamic_cast<String_identifier*> (i.val ()))
175 String val = *i.val()->access_content_String (false);
177 output_String_def (prefix + i.key (), val);
179 else if(dynamic_cast<Real_identifier*> (i.val ()))
181 Real val = *i.val ()->access_content_Real (false);
183 output_Real_def (prefix + i.key (), val);
185 else if (dynamic_cast<int_identifier*> (i.val ()))
187 int val = *i.val ()->access_content_int (false);
189 output_int_def (prefix + i.key (), val);
195 Paper_outputter::output_version ()
197 String id_str = "Lily was here";
198 if (no_timestamps_global_b)
201 id_str += String (", ") + version_str ();
203 output_String_def ( "mudelatagline", id_str);
204 output_String_def ( "LilyPondVersion", version_str ());
210 Paper_outputter::output_font_def (int i, String str)
212 SCM scm = gh_list (ly_symbol2scm ("font-def"),
214 ly_str02scm (str.ch_l ()),
221 Paper_outputter::output_Real_def (String k, Real v)
224 SCM scm = gh_list (ly_symbol2scm ("lily-def"),
225 ly_str02scm (k.ch_l ()),
226 ly_str02scm (to_str(v).ch_l ()),
232 Paper_outputter::output_String_def (String k, String v)
235 SCM scm = gh_list (ly_symbol2scm ("lily-def"),
236 ly_str02scm (k.ch_l ()),
237 ly_str02scm (v.ch_l ()),
243 Paper_outputter::output_int_def (String k, int v)
245 SCM scm = gh_list (ly_symbol2scm ("lily-def"),
246 ly_str02scm (k.ch_l ()),
247 ly_str02scm (to_str (v).ch_l ()),