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 ();
88 i->lambda_ = ly_append (ly_lambda_o (),
89 ly_list1 (ly_func_o ("empty")));
92 switch_to_font (i->font_);
95 if (check_debug && !monitor->silent_b ("Guile"))
97 gh_display (i->lambda_); gh_newline ();
102 gh_cons (gh_double2scm (a_off.x ()),
103 gh_cons (gh_double2scm (a_off.y ()),
104 gh_cons (i->lambda_, SCM_EOL)));
107 if (check_debug && !monitor->silent_b ("Guile"))
109 gh_display (args_scm); gh_newline ();
114 ly_append (ly_lambda_o (),
115 ly_list1 (ly_append (ly_func_o ("placebox"), args_scm)));
117 output_scheme (box_scm);
122 Paper_outputter::output_comment (String str)
125 *outstream_l_ << "% " << str << "\n";
130 Paper_outputter::output_scheme (SCM scm)
132 String o = String ("\'") + output_global_ch;
134 if (check_debug && !monitor->silent_b ("Guile"))
136 gh_display (scm); gh_newline ();
139 // urg; temporary hack to debug scheme error #unknown
140 if (String (output_global_ch) == "scm")
142 // char* c = gh_scm2newstr (scm, NULL);
143 // *outstream_l_ << c << "\n";
145 gh_display (scm); gh_newline ();
148 SCM str_scm = gh_call1 (ly_eval (scm), gh_eval_str (o.ch_l ()));
149 char* c = gh_scm2newstr (str_scm, NULL);
151 if (check_debug && !monitor->silent_b ("Guile"))
153 gh_display (str_scm); gh_newline ();
161 Paper_outputter::output_string (String str)
164 *outstream_l_ << str;
168 Paper_outputter::switch_to_font (String fontname)
170 if (fontname.length_i () && (fontname != current_font_))
172 current_font_ = fontname;
175 for (; i< font_arr_.size (); i++)
176 if (font_arr_[i] == fontname)
184 font_arr_.push (fontname);
185 output_font_def (i, fontname);
187 output_font_switch (i);
193 Paper_outputter::start_line ()
196 ly_append (ly_lambda_o (),
197 ly_list1 (ly_append (ly_func_o ("start-line"), SCM_EOL)));
203 26 fonts ought to be enough for anyone.
206 Paper_outputter::output_font_def (int i, String str)
208 //urg, broken with guile-1.3
211 ly_append (ly_lambda_o (),
212 ly_list1 (ly_append (ly_func_o ("font-def"),
213 gh_cons (gh_int2scm (i), gh_cons (gh_str02scm (str.ch_l ()), SCM_EOL)))));
219 Paper_outputter::output_font_switch (int i)
221 //urg, broken with guile-1.2, 1.3
224 ly_append (ly_lambda_o (),
225 ly_list1 (ly_append (ly_func_o ("font-switch"),
226 gh_cons (gh_int2scm (i), SCM_EOL))));
232 Paper_outputter::stop_line ()
235 ly_append (ly_lambda_o (),
236 ly_list1 (ly_append (ly_func_o ("stop-line"), SCM_EOL)));