anchor.diff:    PrevX := 0;
     LastWrappable := -1;
     LastWrappableIsSpace := False;
  +  LastColorMarkup := '';
  +  AfterWrapClMarkup := '';
   
     I := 1;
     while I <= Length(aText) do
  
positive.code:     //This algorithm is not perfect, somehow line width is not within SizeX, but very rare
      if ((dx > aMaxPxWidth) and (LastWrappable <> -1)) or (aText[I] = #124) then
      begin
        if (aText[I] <> #124) and aIndentAfterNL then
        begin
          Insert(INDENT, aText, LastWrappable);
          Inc(I, Length(INDENT));
          Inc(dx, Length(INDENT) * WordSpacing);
        end;
        if LastWrappableIsSpace then
          aText[LastWrappable] := #124 //Replace last whitespace with EOL
        else
          Insert(#124, aText, LastWrappable+1); //Insert EOL after last wrappable char
        Dec(dx, PrevX); //Subtract width since replaced whitespace
        LastWrappable := -1;
      end;
      //Force an EOL part way through a word
  
negative.code:     begin
        Insert(#124, aText, I); //Insert an EOL before this character
        dx := 0;
  
        if LastColorMarkup <> '' then
        begin
          Insert('[]', aText, I);
          Inc(I, 2);
        end;
  
        LineWrapPos := I;
  
        if aIndentAfterNL then
        begin
          Insert(INDENT, aText, I+1);
          Inc(I, Length(INDENT));
          Inc(dx, Length(INDENT) * WordSpacing);
        end;
  
        if LastColorMarkup <> '' then
        begin
          Insert(LastColorMarkup, aText, LineWrapPos+1);
          Inc(I, Length(LastColorMarkup));
        end;
  
        LastWrappable := -1;
      end;
      Inc(I);
    end;
  