
09.03.2013, 04:20
|
 |
LMD-DML
|
|
Регистрация: 12.07.2009
Адрес: Богородское
Сообщения: 3,025
Версия Delphi: D7E
Репутация: 1834
|
|
Цитата:
Сообщение от mars2107
...[color:Краси;1 0 1][color:вый т;1 1 0][color:екст;1 0 1]...
|
Код:
var
Col: array [0..7] of TColor =
(clBlue,clSkyBlue,clWhite,clYellow,clRed,clPurple,clGreen,clBlack);
mean: array [0..7] of string =
('0 0 1','0 1 1','1 1 1','1 1 0','1 0 0','1 0 1','0 1 0','0 0 0');
procedure TForm1.Button1Click(Sender: TObject);
var
i,b: integer;
str,tmp,m: string;
flg: boolean;
begin
tmp:=Edit1.Text;
RichEdit1.Lines.BeginUpdate;
b:=0;
for i:=1 to Length(tmp) do
begin
if tmp[i]=':' then b:=i;
if tmp[i]=';' then
begin
str:=Copy(tmp,b+1,i-(b+1));
m:=Copy(tmp,i+1,5);
RichEdit1.Text:=RichEdit1.Text+str;
RichEdit1.SelStart:= Length(RichEdit1.Text) - Length(str);
RichEdit1.SelLength := Length(RichEdit1.Text);
for b:= Low(mean) to High(mean) do if m = mean[b] then
RichEdit1.SelAttributes.Color:=Col[b];
end;
end;
RichEdit1.Lines.EndUpdate;
end;
Цитата:
...Имеется текст который нужно поделить на символы и упаковать в теги...
|
Код:
procedure TForm1.Button2Click(Sender: TObject);
var
i, b: integer;
str: string;
begin
str:='[color:';
b:=0;
for i:=1 to length(Edit2.Text) do
begin
str:=str+Edit2.Text[i];
inc(b);
if b= StrToInt(Edit3.Text)then
begin
b:=0;
str:= str+';0 0 0][color:';
end;
end;
Edit2.Text:=str+';0 0 0]';
end;
Цитата:
...в поле где вводим текст нужно сделать чтоб при выделении текста можно было нажать на нужный цвет и во втором поле был нужный результат...
|
Код:
procedure TForm1.ColorBox1Change(Sender: TObject);
begin
RichEdit1.SelAttributes.Color:= ColorBox1.Selected;
end;
|