diff --git a/src/ChangeLog b/src/ChangeLog index 36ace4b420..60eff4a3f5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2006-12-08 Jürgen Spitzmüller + + * paragraph.C (startTeXParams, endTeXParams): + reset column count after linebreak. + 2006-12-04 Gregor Gorjanc * paragraph.C (corrected_env, endTeXParams): writeout \begin diff --git a/src/paragraph.C b/src/paragraph.C index fc5f05f62b..dd420ac79a 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -55,6 +55,8 @@ using lyx::pos_type; +using lyx::support::contains; +using lyx::support::rsplit; using lyx::support::subst; using std::distance; @@ -735,6 +737,17 @@ string const corrected_env(string const & suffix, string const & env, return output; } + +int adjust_column_count(string const & str, int oldcol) +{ + if (!contains(str, "\n")) + return oldcol + str.size(); + else { + string tmp; + return rsplit(str, tmp, '\n').size(); + } +} + } // namespace anon @@ -778,7 +791,7 @@ int Paragraph::startTeXParParams(BufferParams const & bparams, else output = corrected_env("\\begin", "flushright", ownerCode()); os << output; - column += output.size(); + column = adjust_column_count(output, column); break; } case LYX_ALIGN_RIGHT: { string output; @@ -787,13 +800,13 @@ int Paragraph::startTeXParParams(BufferParams const & bparams, else output = corrected_env("\\begin", "flushleft", ownerCode()); os << output; - column += output.size(); + column = adjust_column_count(output, column); break; } case LYX_ALIGN_CENTER: { string output; output = corrected_env("\\begin", "center", ownerCode()); os << output; - column += output.size(); + column = adjust_column_count(output, column); break; } } @@ -837,7 +850,7 @@ int Paragraph::endTeXParParams(BufferParams const & bparams, else output = corrected_env("\n\\par\\end", "flushright", ownerCode()); os << output; - column += output.size(); + column = adjust_column_count(output, column); break; } case LYX_ALIGN_RIGHT: { string output; @@ -846,13 +859,13 @@ int Paragraph::endTeXParParams(BufferParams const & bparams, else output = corrected_env("\n\\par\\end", "flushleft", ownerCode()); os << output; - column += output.size(); + column = adjust_column_count(output, column); break; } case LYX_ALIGN_CENTER: { string output; output = corrected_env("\n\\par\\end", "center", ownerCode()); os << output; - column += output.size(); + column = adjust_column_count(output, column); break; } }