2 paper-outputter.cc -- implement Paper_outputter
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 Jan Nieuwenhuizen <janneke@gnu.org>
11 #include "paper-outputter.hh"
12 #include "paper-stream.hh"
13 #include "molecule.hh"
16 #include "string-convert.hh"
21 Paper_outputter::Paper_outputter (Paper_stream *s)
27 Paper_outputter::~Paper_outputter ()
30 ly_append (ly_lambda_o (),
31 ly_list1 (ly_append (ly_func_o ("end-output"), SCM_EOL)));
37 Paper_outputter::output_header ()
40 if (no_timestamps_global_b)
41 creator = "GNU LilyPond\n";
43 creator = get_version_str ();
45 if (no_timestamps_global_b)
49 generate = _ (", at ");
51 generate += ctime (&t);
56 gh_cons (gh_str02scm (creator.ch_l ()),
57 gh_cons (gh_str02scm (generate.ch_l ()), SCM_EOL));
60 DOUT << "output_header\n";
61 if (check_debug && !monitor->silent_b ("Guile"))
63 gh_display (args_scm); gh_newline ();
68 ly_append (ly_lambda_o (),
69 ly_list1 (ly_append (ly_func_o ("header"), args_scm)));
75 Paper_outputter::output_molecule (Molecule const*m, Offset o, char const *nm)
78 *outstream_l_ << String ("\n%start: ") << nm << "\n";
80 for (PCursor <Atom*> i (m->atoms_); i.ok (); i++)
82 Offset a_off = i->offset ();
89 ly_append (ly_lambda_o (),
90 ly_list1 (ly_func_o ("empty")));
93 switch_to_font (i->font_);
96 if (check_debug && !monitor->silent_b ("Guile"))
98 gh_display (i->lambda_); gh_newline ();
103 gh_cons (gh_double2scm (a_off.x ()),
104 gh_cons (gh_double2scm (a_off.y ()),
105 gh_cons (i->lambda_, SCM_EOL)));
108 if (check_debug && !monitor->silent_b ("Guile"))
110 gh_display (args_scm); gh_newline ();
115 ly_append (ly_lambda_o (),
116 ly_list1 (ly_append (ly_func_o ("placebox"), args_scm)));
118 output_scheme (box_scm);
123 Paper_outputter::output_comment (String str)
126 *outstream_l_ << "% " << str << "\n";
131 Paper_outputter::output_scheme (SCM scm)
133 String o = String ("\'") + output_global_ch;
135 if (check_debug && !monitor->silent_b ("Guile"))
137 gh_display (scm); gh_newline ();
140 SCM str_scm = gh_call1 (ly_eval (scm), gh_eval_str (o.ch_l ()));
141 char* c = gh_scm2newstr (str_scm, NULL);
143 if (check_debug && !monitor->silent_b ("Guile"))
145 gh_display (str_scm); gh_newline ();
153 Paper_outputter::output_string (String str)
156 *outstream_l_ << str;
160 Paper_outputter::switch_to_font (String fontname)
162 if (fontname.length_i () && (fontname != current_font_))
164 current_font_ = fontname;
167 for (; i< font_arr_.size (); i++)
168 if (font_arr_[i] == fontname)
176 font_arr_.push (fontname);
177 output_font_def (i, fontname);
179 output_font_switch (i);
185 Paper_outputter::start_line ()
188 ly_append (ly_lambda_o (),
189 ly_list1 (ly_append (ly_func_o ("start-line"), SCM_EOL)));
195 26 fonts ought to be enough for anyone.
198 Paper_outputter::output_font_def (int i, String str)
200 //urg, broken with guile-1.3
203 ly_append (ly_lambda_o (),
204 ly_list1 (ly_append (ly_func_o ("font-def"),
205 gh_cons (gh_int2scm (i), gh_cons (gh_str02scm (str.ch_l ()), SCM_EOL)))));
211 Paper_outputter::output_font_switch (int i)
213 //urg, broken with guile-1.2, 1.3
216 ly_append (ly_lambda_o (),
217 ly_list1 (ly_append (ly_func_o ("font-switch"),
218 gh_cons (gh_int2scm (i), SCM_EOL))));
224 Paper_outputter::stop_line ()
227 ly_append (ly_lambda_o (),
228 ly_list1 (ly_append (ly_func_o ("stop-line"), SCM_EOL)));