From: fred Date: Sun, 24 Mar 2002 19:40:37 +0000 (+0000) Subject: lilypond-0.0.63 X-Git-Tag: release/1.5.59~4879 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=422d24a0f34300f345c91d98ed6516f41358a7ed;p=lilypond.git lilypond-0.0.63 --- diff --git a/lily/include/tex-stream.hh b/lily/include/tex-stream.hh index 4d5805c556..5f0477a51a 100644 --- a/lily/include/tex-stream.hh +++ b/lily/include/tex-stream.hh @@ -10,10 +10,14 @@ 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); diff --git a/lily/tex-stream.cc b/lily/tex-stream.cc index 5e2e959181..dfa56b1b4d 100644 --- a/lily/tex-stream.cc +++ b/lily/tex-stream.cc @@ -14,12 +14,15 @@ #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; +} /* *************************************************************** */