]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.63
authorfred <fred>
Sun, 24 Mar 2002 19:40:37 +0000 (19:40 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:40:37 +0000 (19:40 +0000)
lily/include/tex-stream.hh
lily/tex-stream.cc

index 4d5805c556b27aafe00ea8145da2330c023707bd..5f0477a51acde09d6409abf84dd68e9a2b64f086 100644 (file)
   It counts braces to prevent nesting errors, and
   it will add a comment sign before each newline.
   */
-struct Tex_stream {
+class Tex_stream {
+    void break_line();
+public:
     bool outputting_comment;
     ostream *os;
     int nest_level;
+    /// to check linelen in output. TeX has limits.
+    int line_len_i_;
     
     /// open a file for writing
     Tex_stream(String filename);
index 5e2e959181c674aa1d29c0427ba55f45bd14df4e..dfa56b1b4d955bc069869775e2d7aa37cbbfee0e 100644 (file)
 #include "tex-stream.hh"
 #include "debug.hh"
 
+const int MAXLINELEN = 200;
+
 Tex_stream::Tex_stream(String filename) 
 {
     os = new ofstream(filename);
     if (!*os)
        error("can't open `" + filename+"\'");
     nest_level = 0;
+    line_len_i_ = 0;
     outputting_comment=false;
     header();
 }
@@ -51,6 +54,7 @@ Tex_stream::operator<<(String s)
            }
            continue;
        }
+       line_len_i_ ++;
        switch(*cp) 
            {
            case '%':
@@ -72,9 +76,14 @@ Tex_stream::operator<<(String s)
                /* FALLTHROUGH */
                
            case '\n':
-               *os << "%\n";
-               *os << String(' ', nest_level);
+               break_line();
                break;        
+           case ' ':
+               *os <<  ' ';
+               if (line_len_i_ > MAXLINELEN) 
+                  break_line(); 
+               
+               break;
            default:
                *os << *cp;
                break;
@@ -83,5 +92,12 @@ Tex_stream::operator<<(String s)
     return *this;
 }
 
+void
+Tex_stream::break_line()
+{
+    *os << "%\n";
+    *os << String(' ', nest_level);
+    line_len_i_ = 0;
+}
 
 /* *************************************************************** */