Jean-Marc Lasgouttes wrote:
> Juergen, it looks like we shall reset the column counting if we add a
> \n... I am not sure what the best way would be actually.
What about the attached?
Jürgen
Index: src/paragraph.C
===================================================================
--- src/paragraph.C (Revision 16163)
+++ src/paragraph.C (Arbeitskopie)
@@ -55,6 +55,8 @@
using lyx::pos_type;
+using lyx::support::contains;
+using lyx::support::split;
using lyx::support::subst;
using std::distance;
@@ -735,6 +737,15 @@ string const corrected_env(string const
return output;
}
+
+int adjust_column_count(string const & str, int oldcol)
+{
+ if (!contains(str, "\n"))
+ return oldcol + str.size();
+ else
+ return split(str, '\n').size();
+}
+
} // namespace anon
@@ -778,7 +789,7 @@ int Paragraph::startTeXParParams(BufferP
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 +798,13 @@ int Paragraph::startTeXParParams(BufferP
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 +848,7 @@ int Paragraph::endTeXParParams(BufferPar
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 +857,13 @@ int Paragraph::endTeXParParams(BufferPar
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;
}
}