42 const String& pIndentOtherLines ) {
43 String indentOtherLines= pIndentOtherLines.
IsNull() ? indentFirstLine
66 "Paragraphs: PopIndent without prior push." )
71 "Paragraphs: PopIndent without prior push." )
95 #if !ALIB_SINGLE_THREADED
108 #if defined( _WIN32 )
121 integer exceptStart= errPos - 25;
122 if( exceptStart <= 0 ) {
123 exceptPos+= exceptStart;
131 actText.
_( markedBuffer, exceptStart, 50 );
132 if( markedBuffer.
Length() > exceptStart + 50 )
147 searchCharBuf[1]=
'\n';
148 String searchChars(searchCharBuf, 2);
150 #if !ALIB_SINGLE_THREADED
151 lang::OwnerRecursive<RecursiveLock, true> lock(
162 integer pos= parser.template IndexOfAny<lang::Inclusion::Include, NC>( searchChars );
171 if( parser.
CharAt( pos ) ==
'\n' ) {
172 parser.template ConsumeChars<NC, lang::CurrentData::Keep>( pos,
Buffer, 1 );
173 if (
Buffer.CharAtEnd() ==
'\r')
180 lastTextStart=
Buffer.Length();
184 parser.template ConsumeChars<NC, lang::CurrentData::Keep>( pos,
Buffer, 1 );
243 if( lastTextStart <
Buffer.Length() ) {
262 const String& pIndentFirstLine,
263 const String& pIndentOtherLines ) {
266 String indentOtherLines= pIndentOtherLines.
IsNotNull() ? pIndentOtherLines : pIndentFirstLine;
268 bool isFirstLine=
true;
271 bool indentAreJustSpaces=
false;
274 integer maxLineWidthDetectionStartIdx= startIdx;
277 maxLineWidth= (std::max)( maxLineWidth, startIdx - maxLineWidthDetectionStartIdx
279 #
if defined( _WIN32 )
286 if ( startIdx ==
text.Length() )
288 maxLineWidthDetectionStartIdx= startIdx;
292 int isWinNL=
text[ startIdx ] ==
'\r' ? 1 : 0;
293 if (
text[ startIdx + isWinNL ] ==
'\n' ) {
298 indent = isFirstLine ? indentFirstLines : indentOtherLines;
299 indentAreJustSpaces= (indent.template IndexOfAny<lang::Inclusion::Exclude>(
A_CHAR(
" " ) ) < 0 );
303 if ( !indentAreJustSpaces ) {
304 text.InsertAt( indent, startIdx );
305 startIdx+= indent.
Length();
308 #if defined( _WIN32 )
310 text.template InsertChars<NC>(
'\r', 1, startIdx );
315 text.template Delete<NC>(startIdx, 1);
321 startIdx+= 1 + isWinNL;
332 indent = isFirstLine ? indentFirstLines : indentOtherLines;
333 indentAreJustSpaces= (indent.template IndexOfAny<lang::Inclusion::Exclude>(
A_CHAR(
" " ) ) < 0 );
335 text.InsertAt( indent, startIdx );
346 bool isLastLine =
true;
347 bool exceeds =
false;
348 while (++idx <
text.Length() ) {
355 exceeds= lineWidth > 0 && idx - startIdx >= lineWidth;
358 if(idx - startIdx <= lineWidth )
359 lastSpaceInLine= idx;
367 #if defined( _WIN32 )
368 if(
text[idx-1] ==
'\n' &&
text[idx-2] !=
'\r' ) {
369 text.template InsertChars<NC>(
'\r', 1, idx-1 );
373 if(
text[idx-1] ==
'\n' &&
text[idx-2] ==
'\r' ) {
374 text.template Delete<NC>((idx-2), 1);
380 if( exceeds && ( lastSpaceInLine || !isLastLine ) ) {
381 integer wrapPos= lastSpaceInLine > 0 ? lastSpaceInLine : idx;
382 text.template ReplaceSubstring<NC>(
NEW_LINE, wrapPos, 1 );
387 if( justifyChar !=
'\0' ) {
388 integer qtyInserts= lineWidth - (wrapPos - startIdx );
389 if( qtyInserts > 0 ) {
392 while ( leftInsertBoundary < idx &&
text[leftInsertBoundary] ==
' ' )
393 ++leftInsertBoundary;
395 if( leftInsertBoundary < idx ) {
396 while( qtyInserts > 0 ) {
398 bool foundOne=
false;
399 while( qtyInserts > 0 ) {
400 actPos=
text.LastIndexOf(
' ', actPos );
401 if( actPos < leftInsertBoundary )
404 text.InsertChars( justifyChar, 1, actPos );
407 while( --actPos > leftInsertBoundary &&
text[actPos] ==
' ' )
#define ALIB_COMMA_CALLER_PRUNED
#define ALIB_CALLER_NULLED
#define ALIB_ASSERT_ERROR(cond, domain,...)
integer SearchAndReplace(TChar needle, TChar replacement, integer startIdx=0, integer endIdx=strings::MAX_LEN)
TAString & DeleteEnd(integer regionLength)
TAString & _(const TAppendable &src)
constexpr integer Length() const
bool EndsWith(const TString &needle) const
constexpr bool IsNotNull() const
TChar CharAt(integer idx) const
constexpr bool IsNotEmpty() const
constexpr bool IsNull() const
bool ConsumeString(const TString< TChar > &consumable)
TString< TChar > ConsumeToken(TChar separator=',', lang::Inclusion includeSeparator=lang::Inclusion::Include)
std::deque< T, StdMA< T > > StdDequeMA
Type alias in namespace #"%alib".
LocalString< 64 > String64
Type alias name for #"TLocalString;TLocalString<character,64>".
constexpr CString NEW_LINE
A zero-terminated string containing the new-line character sequence.
constexpr const String EMPTY_STRING
An empty string of the default character type.
lang::integer integer
Type alias in namespace #"%alib".
strings::TString< character > String
Type alias in namespace #"%alib".
strings::TSubstring< character > Substring
Type alias in namespace #"%alib".
exceptions::Exception Exception
Type alias in namespace #"%alib".
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace #"%alib".
characters::character character
Type alias in namespace #"%alib".
lang::uinteger uinteger
Type alias in namespace #"%alib".