procedure ParseString(TextaAfficher: String; Rv : TRichView);
var
I, J, K, ParaNo, StyleNo : Integer;
TextAff, Temp : String;
Color, BkColor,TempBack : tColor;
function GetCouleur: tColor;
var C1, C2: Char;
begin
Result := ClNone;
C1 := TextaAfficher[i + 1];
C2 := TextaAfficher[i + 2];
if IsNum(C1 + C2) then begin
result := IRC_COLORS[StrToInt(C1 + C2)];
inc(i,2);
end else
if IsNum(C1) then begin
result := IRC_COLORS[StrToInt(C1)];
inc(i);
end;
end;
function GetCouleurFond: tColor;
var
C1, C2: Char;
begin
Result := BkColor;
if TextaAfficher[i + 1] = ',' then begin
C1 := TextaAfficher[i + 2];
C2 := TextaAfficher[i + 3];
if IsNum(C1 + C2) then begin
result := IRC_COLORS[StrToInt(C1 + C2)];
inc(i,3);
end
else
if IsNum(C1) then begin
result := IRC_COLORS[StrToInt(C1)];
inc(i,2)
end;
end;
end;
begin
FPrincipal.Canvas.Lock;
ParaNo := -1;
StyleNo := 0;
I := 1;
BkColor := ClNone;
while i <= Length(TextaAfficher) do begin
case TextaAfficher of
#3 : begin
Color := GetCouleur;
BkColor := GetCouleurFond;
StyleNo := GetStyleNo(#3, Color, BkColor, StyleNo,'',Rv);
inc(i);
end;
#2, #9, #15, #22, #31 : begin
StyleNo := GetStyleNo(TextaAfficher, ClNone, ClNone, StyleNo,'',Rv);
inc(i);
end;
else begin
Textaff := '';
Temp := '';
// si c'est des caracteres affichables on boucle
while not (TextaAfficher in [#2, #3, #9, #15, #22, #31]) and (i <= Length(TextaAfficher)) do
begin
Temp := Temp + TextaAfficher;
TextAff := TextAff + TextaAfficher ;
//------------------------------------------------------------------------------
If (TextaAfficher = ' ') or (i = Length(TextaAfficher)) then begin
K := 0;
While K < 49 do begin
If UpperCase(Trim(Temp)) = Smiles[K] then begin
if i = Length(TextaAfficher) Then J := 0 else J := 1;
RV.AddNL(LeftStr(TextAff,Length(TextAff)-Length(Smiles[K]) - J), StyleNo, ParaNo);
RV.AddBulletEx('', K, FPrincipal.ImgListEmoticom, ParaNo);
TextAff := ' ';
K := 999;
End;
Inc(K);
end;
Temp := '';
end;
//------------------------------------------------------------------------------
inc(i);
end;
rv.AddNL(Textaff, StyleNo, ParaNo);
end;
end;
end;
rv.FormatTail;
FPrincipal.Canvas.UnLock;
end;
P.S: Sorry for the bad englis!!! XD