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 )
41 verbatim_scheme_b_ = output_global_ch == String ("scm");
43 if (verbatim_scheme_b_)
46 ";;; Usage: guile -s x.scm > x.tex\n"
47 "(primitive-load-path 'lily.scm)\n"
50 "(map (lambda (x) (display (eval x))) '(\n"
57 Paper_outputter::~Paper_outputter ()
59 if (verbatim_scheme_b_)
68 Paper_outputter::output_header ()
72 gh_define ("security-paranoia", SCM_BOOL_T);
75 SCM exp = gh_list (ly_symbol2scm ((String (output_global_ch) + "-scm").ch_C()),
76 ly_quote_scm (ly_symbol2scm ("all-definitions")),
82 if (no_timestamps_global_b)
83 creator = gnu_lilypond_str ();
85 creator = gnu_lilypond_version_str ();
88 if (no_timestamps_global_b)
92 generate = _ (", at ");
94 generate += ctime (&t);
95 generate = generate.left_str (generate.length_i () - 1);
99 gh_list (ly_str02scm (creator.ch_l ()),
100 ly_str02scm (generate.ch_l ()), SCM_UNDEFINED);
103 SCM scm = gh_cons (ly_symbol2scm ("header"), args_scm);
110 Paper_outputter::output_comment (String str)
112 output_scheme (gh_list (ly_symbol2scm ("comment"),
113 ly_str02scm ((char*)str.ch_C()),
120 Paper_outputter::output_scheme (SCM scm)
123 we don't rename dump_scheme, because we might in the future want
124 to remember Scheme. We don't now, because it sucks up a lot of memory.
131 Paper_outputter::dump_scheme (SCM s)
133 if (verbatim_scheme_b_)
135 SCM result = scm_eval (scm_listify (ly_symbol2scm ("scm->string"),
136 ly_quote_scm (gh_car (s)), SCM_UNDEFINED));
138 *stream_p_ << ly_scm2string (result);
142 SCM result = scm_eval (s);
143 char *c=gh_scm2newstr (result, NULL);
150 Paper_outputter::output_scope (Scope *scope, String prefix)
152 for (Scope_iter i (*scope); i.ok (); i++)
154 if (dynamic_cast<String_identifier*> (i.val ()))
156 String val = *i.val()->access_content_String (false);
158 output_String_def (prefix + i.key (), val);
160 else if(dynamic_cast<Real_identifier*> (i.val ()))
162 Real val = *i.val ()->access_content_Real (false);
164 output_Real_def (prefix + i.key (), val);
166 else if (dynamic_cast<int_identifier*> (i.val ()))
168 int val = *i.val ()->access_content_int (false);
170 output_int_def (prefix + i.key (), val);
176 Paper_outputter::output_version ()
178 String id_str = "Lily was here";
179 if (no_timestamps_global_b)
182 id_str += String (", ") + version_str ();
184 output_String_def ( "mudelatagline", id_str);
185 output_String_def ( "LilyPondVersion", version_str ());
191 Paper_outputter::output_font_def (int i, String str)
193 SCM scm = gh_list (ly_symbol2scm ("font-def"),
195 ly_str02scm (str.ch_l ()),
202 Paper_outputter::output_Real_def (String k, Real v)
205 SCM scm = gh_list (ly_symbol2scm ("lily-def"),
206 ly_str02scm (k.ch_l ()),
207 ly_str02scm (to_str(v).ch_l ()),
213 Paper_outputter::output_String_def (String k, String v)
216 SCM scm = gh_list (ly_symbol2scm ("lily-def"),
217 ly_str02scm (k.ch_l ()),
218 ly_str02scm (v.ch_l ()),
224 Paper_outputter::output_int_def (String k, int v)
226 SCM scm = gh_list (ly_symbol2scm ("lily-def"),
227 ly_str02scm (k.ch_l ()),
228 ly_str02scm (to_str (v).ch_l ()),