]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/tex-stream.cc
partial: 1.1.0.jcn
[lilypond.git] / lily / tex-stream.cc
index a9d826c3c77b522e91793dc7e95037a67c551b9b..d8030580020674b707616c0514751cf739a94327 100644 (file)
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-  
-  TODO
+  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 
-  make an abstract interface to output, operations: 
-
-  move (x,y), put (symbol).
 */
 
 #include <fstream.h>
 #include <time.h>
 
-#include "tex.hh"
 #include "main.hh"
 #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();
-}
-void
-Tex_stream::header()
+Tex_stream::Tex_stream (String filename)
+  : Paper_stream (filename)
 {
-  *os << "% Creator: " << get_version_str() << "\n";
-  *os << "% Automatically generated, at ";
-  time_t t (time (0));
-  *os << ctime (&t)<<"\n";
+  header ();
 }
-Tex_stream::~Tex_stream()
+
+Tex_stream::~Tex_stream ()
 {
-  delete os;
-  assert (nest_level == 0);
+  *os << "\n\\EndLilyPondOutput";
 }
 
-// print string. don't forget indent.
-Tex_stream &
-Tex_stream::operator<<(String s)
+void
+Tex_stream::header ()
 {
-  
-  for (char const *cp = s; *cp; cp++) 
+  // urg, merge with Ps
+  *os << _ ("% Creator: ");
+  if (no_timestamps_global_b)
+    *os << "GNU LilyPond\n";
+  else
+    *os << get_version_str () << '\n';
+  *os << _ ("% Automatically generated");
+  if (no_timestamps_global_b)
+    *os << ".\n";
+  else
     {
-       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;
-             }
+      *os << _ (", at ");
+      time_t t (time (0));
+      *os << ctime (&t) << "%\n";
     }
-  return *this;
 }
 
-void
-Tex_stream::break_line()
+// print string. don't forget indent.
+Paper_stream&
+Tex_stream::operator << (Scalar s)
 {
-  *os << "%\n";
-  *os << String (' ', nest_level);
-  line_len_i_ = 0;
+  return Paper_stream::operator << (s);
 }
 
-/* *************************************************************** */