2 tex-stream.cc -- implement Tex_stream
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
15 #include "tex-stream.hh"
18 const int MAXLINELEN = 200;
20 Tex_stream::Tex_stream (String filename)
22 if (filename.length_i () && (filename != "-"))
23 os = new ofstream (filename.ch_C ());
25 // os = new ostream (cout.ostreambuf ());
26 os = new ostream (cout._strbuf);
28 error (_f ("can't open file: `%s\'", filename));
31 outputting_comment=false;
37 *os << _ ("% Creator: ");
38 if (no_timestamps_global_b)
39 *os << "GNU LilyPond\n";
41 *os << get_version_str() << '\n';
42 *os << _ ("% Automatically generated");
43 if (no_timestamps_global_b)
49 *os << ctime (&t) << "%\n";
53 Tex_stream::~Tex_stream()
58 warning(_ ("error syncing file (disk full?)"));
62 assert (nest_level == 0);
65 // print string. don't forget indent.
67 Tex_stream::operator << (Scalar s)
69 for (char const *cp = s.ch_C (); *cp; cp++)
71 if (outputting_comment)
76 outputting_comment=false;
85 outputting_comment = true;
98 delete os; // we want to see the remains.
99 assert (nest_level>=0);
108 if (line_len_i_ > MAXLINELEN)
121 Tex_stream::break_line()
124 *os << to_str (' ', nest_level);