procedure THighLight.NewTag(
Name : String;
FGColor : String = '000000';
Bolb : Boolean = False;
Italic : Boolean = False;
Underline : Boolean = False
);
var
GdkFGColor : TGdkColor;
BlobFlag : LongWord;
ItalicFlag : LongWord;
UnderlineFlag : LongWord;
begin
gdk_color_parse(PChar('#' + FGColor), @GdkFGColor);
if Bolb then
BlobFlag := PANGO_WEIGHT_BOLD
else
BlobFlag := PANGO_WEIGHT_NORMAL;
if Italic then
ItalicFlag := PANGO_STYLE_ITALIC
else
ItalicFlag := PANGO_STYLE_NORMAL;
if Underline then
UnderlineFlag := PANGO_UNDERLINE_SINGLE
else
UnderlineFlag := PANGO_UNDERLINE_NONE;
gtk_text_buffer_create_tag(GBuffer, PGChar(Name), 'foreground-gdk', [
@GdkFGColor,
'weight' , BlobFlag,
'style' , ItalicFlag,
'underline' , UnderlineFlag
]);
end;
procedure THighLight.SetTag(SelStart, SelLenth: Integer; Style: String);
begin
gtk_text_buffer_get_iter_at_offset(GBuffer, @GStartIter, SelStart);
gtk_text_buffer_get_iter_at_offset(GBuffer, @GEndIter , SelStart + SelLenth);
gtk_text_buffer_apply_tag_by_name (GBuffer, PGChar(Style), @GStartIter, @GEndIter);
end;
procedure THighLight.DelTag(SelStart, SelLenth: Integer; Style: String);
begin
gtk_text_buffer_get_iter_at_offset(GBuffer, @GStartIter, SelStart);
gtk_text_buffer_get_iter_at_offset(GBuffer, @GEndIter , SelStart + SelLenth);
gtk_text_buffer_remove_tag_by_name(GBuffer, PGChar(Style), @GStartIter, @GEndIter);
end;
procedure THighLight.ClearTag();
begin
gtk_text_buffer_get_start_iter (GBuffer, @GStartIter);
gtk_text_buffer_get_end_iter (GBuffer, @GEndIter);
gtk_text_buffer_remove_all_tags(GBuffer, @GStartIter, @GEndIter);
end;