]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/tex-stream.cc
patch::: 1.0.12.jcn2: opniewvisite
[lilypond.git] / lily / tex-stream.cc
index 9866c231ad07af68c163e4a13decf0885550b2f2..90764d289a87d830a16a99e318fd4e126603402f 100644 (file)
 #include "tex-stream.hh"
 #include "debug.hh"
 
-const int MAXLINELEN = 200;
-
 Tex_stream::Tex_stream (String filename)
+  : Paper_stream (filename)
 {
-  if (filename.length_i () && (filename != "-"))
-    os = new ofstream (filename.ch_C ());
-  else
-//    os = new ostream (cout.ostreambuf ());
-    os = new ostream (cout._strbuf);
-  if (!*os)
-    error (_f ("can't open file: `%s\'", filename));
-  nest_level = 0;
-  line_len_i_ = 0;
-  outputting_comment=false;
-  header();
+  header ();
 }
+
 void
-Tex_stream::header()
+Tex_stream::header ()
 {
+  // urg, merge with Ps
   *os << _ ("% Creator: ");
   if (no_timestamps_global_b)
     *os << "GNU LilyPond\n";
   else
-    *os << get_version_str() << '\n';
+    *os << get_version_str () << '\n';
   *os << _ ("% Automatically generated");
   if (no_timestamps_global_b)
     *os << ".\n";
@@ -50,78 +41,14 @@ Tex_stream::header()
     }
 }
 
-Tex_stream::~Tex_stream()
+Tex_stream::~Tex_stream ()
 {
-  *os << flush;
-  if (!*os)
-    {
-      warning(_ ("error syncing file (disk full?)"));
-      exit_status_i_ = 1;
-    }
-  delete os;
-  assert (nest_level == 0);
 }
 
 // print string. don't forget indent.
-Tex_stream&
+Paper_stream&
 Tex_stream::operator << (Scalar s)
 {
-  for (char const *cp = s.ch_C (); *cp; cp++)
-    {
-       if (outputting_comment)
-         {
-           *os << *cp;
-           if (*cp == '\n')
-             {
-               outputting_comment=false;
-
-             }
-           continue;
-         }
-       line_len_i_ ++;
-       switch (*cp)
-           {
-           case '%':
-               outputting_comment = true;
-               *os << *cp;
-               break;
-           case '{':
-               nest_level++;
-               *os << *cp;
-               break;
-           case '}':
-               nest_level--;
-               *os << *cp;
-
-               if (nest_level < 0)
-                 {
-                   delete os;  // we want to see the remains.
-                   assert (nest_level>=0);
-                 }
-               /* FALLTHROUGH */
-
-           case '\n':
-               break_line();
-               break;
-           case ' ':
-               *os <<  ' ';
-               if (line_len_i_ > MAXLINELEN)
-                  break_line();
-
-               break;
-           default:
-               *os << *cp;
-               break;
-             }
-    }
-  return *this;
-}
-
-void
-Tex_stream::break_line()
-{
-  *os << "%\n";
-  *os << to_str (' ', nest_level);
-  line_len_i_ = 0;
+  return Paper_stream::operator << (s);
 }