4 // source file of the LilyPond music typesetter
6 // (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
8 // should i be named Mudela_stream?
12 Lily_stream::Lily_stream( String filename_str )
14 filename_str_ = filename_str;
17 comment_mode_bo_ = false;
24 Lily_stream::~Lily_stream()
28 warning( "lily indent level: " + String( indent_i_ ));
32 Lily_stream::operator <<( String str )
34 static String nobreak_str = "\\`'_-.^<>*@";
35 while ( str.length_i() ) {
36 int max_i = wrap_column_i_ - column_i_ - 1;
37 int i = str.length_i() - 1 <? max_i;
38 int nl_i = str.left_str( i + 1 ).index_i( '\n' );
41 str = str.nomid_str( nl_i, 1 );
44 if ( ( i != str.length_i() - 1 ) && ( nl_i == -1 ) ) {
45 while ( i && ( isalnum( str[ i ] )
46 || ( nobreak_str.index_i( str[ i ] ) != -1 ) ) )
49 if ( !i ) { // no room left
50 if ( column_i_ > 8 * indent_i_ ) {
52 if ( comment_mode_bo_ && ( str[ 0 ] != '%' ) )
56 else { // cannot break neatly...
62 String line = str.left_str( i + 1 );
63 str = str.mid_str( i + 1, INT_MAX );
65 column_i_ += line.length_i();
69 check_comment( line );
70 if ( ( str.length_i() && ( nl_i == -1 ) ) || ( column_i_ >= wrap_column_i_ ) ) {
72 if ( comment_mode_bo_ )
81 Lily_stream::operator <<( Midi_event& midi_event_r )
83 midi_event_r.output_mudela( *this, false );
89 Lily_stream::check_comment( String str )
91 int newline_i = str.index_last_i( '\n' );
92 if ( newline_i != -1 ) {
93 str = str.mid_str( newline_i +1, INT_MAX );
94 comment_mode_bo_ = false;
96 if ( str.index_i( '%' ) != -1 )
97 comment_mode_bo_ = true;
101 Lily_stream::header()
103 *os_p_ << "% Creator: " << mi2mu_version_str() << "\n";
104 *os_p_ << "% Automatically generated, at ";
105 time_t t( time( 0 ) );
106 *os_p_ << ctime( &t );
107 *os_p_ << "% from input file: ";
108 *os_p_ << midi_parser_l_g->filename_str_;
110 *os_p_ << "\\version \"0.0.58\";\n";
113 snapnie: dit kan toch automaties? Zie ook dstream.
116 Lily_stream::indent()
123 Lily_stream::newline()
125 *os_p_ << endl << String( '\t', indent_i_ );
126 column_i_ = indent_i_ * 8;
127 comment_mode_bo_ = false;
133 os_p_ = new ofstream( filename_str_ );
135 error ( "can't open `" + filename_str_ + "\'");
139 Lily_stream::tnedni()
141 assert( indent_i_ > 0 );