mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-12-12 13:12:14 +00:00
Don't leave open parentheses hanging at line breaks
This commit is contained in:
parent
c733e4229a
commit
9cf9226e86
1 changed files with 21 additions and 0 deletions
|
@ -34,6 +34,7 @@ public:
|
|||
NestDepth = Column = 0;
|
||||
WrapWidth = 72;
|
||||
NeedSpace = false;
|
||||
ConsecOpens = 0;
|
||||
}
|
||||
|
||||
void Open(const char *label)
|
||||
|
@ -43,8 +44,10 @@ public:
|
|||
if (NeedSpace)
|
||||
{
|
||||
Str << ' ';
|
||||
ConsecOpens = 0;
|
||||
}
|
||||
Str << '(';
|
||||
ConsecOpens++;
|
||||
if (label != NULL)
|
||||
{
|
||||
Str.AppendCStrPart(label, labellen);
|
||||
|
@ -66,6 +69,15 @@ public:
|
|||
// Don't break if not needed.
|
||||
if (Column != NestDepth)
|
||||
{
|
||||
if (NeedSpace)
|
||||
{
|
||||
ConsecOpens = 0;
|
||||
}
|
||||
else
|
||||
{ // Move hanging ( characters to the new line
|
||||
Str.Truncate(long(Str.Len() - ConsecOpens));
|
||||
NestDepth -= ConsecOpens;
|
||||
}
|
||||
Str << '\n';
|
||||
Column = NestDepth;
|
||||
NeedSpace = false;
|
||||
|
@ -73,6 +85,14 @@ public:
|
|||
{
|
||||
Str.AppendFormat("%*s", NestDepth, "");
|
||||
}
|
||||
if (ConsecOpens > 0)
|
||||
{
|
||||
for (size_t i = 0; i < ConsecOpens; ++i)
|
||||
{
|
||||
Str << '(';
|
||||
}
|
||||
NestDepth += ConsecOpens;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool CheckWrap(size_t len)
|
||||
|
@ -143,6 +163,7 @@ private:
|
|||
size_t NestDepth;
|
||||
size_t Column;
|
||||
size_t WrapWidth;
|
||||
size_t ConsecOpens;
|
||||
bool NeedSpace;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue