You've already forked lazarus-ccr
richmemo: adding quick text insert utils
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3788 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -23,7 +23,7 @@ interface
|
|||||||
{$mode objfpc}{$h+}
|
{$mode objfpc}{$h+}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Types, SysUtils, Classes, LazFileUtils, RichMemo;
|
Types, SysUtils, Classes, Graphics, LazFileUtils, LazUTF8, RichMemo;
|
||||||
|
|
||||||
const
|
const
|
||||||
NoResize : TSize = ( cx: 0; cy : 0 );
|
NoResize : TSize = ( cx: 0; cy : 0 );
|
||||||
@ -50,8 +50,50 @@ function InsertImageFromFileNoResize (const ARichMemo: TCustomRichMemo; APos: In
|
|||||||
|
|
||||||
procedure LoadRTFFile(const ARichMemo: TCustomRichMemo; const FileNameUTF8: string);
|
procedure LoadRTFFile(const ARichMemo: TCustomRichMemo; const FileNameUTF8: string);
|
||||||
|
|
||||||
|
procedure InsertStyledText(const ARichMemo: TCustomRichMemo; const TextUTF8: String; AStyle: TFontStyles;
|
||||||
|
InsPos : Integer = -1 );
|
||||||
|
procedure InsertColorStyledText(const ARichMemo: TCustomRichMemo; const TextUTF8: String; AColor: TColor; AStyle: TFontStyles;
|
||||||
|
InsPos : Integer = -1 );
|
||||||
|
procedure InsertFontText(const ARichMemo: TCustomRichMemo; const TextUTF8: String; prms: TFontParams;
|
||||||
|
InsPos : Integer = -1 );
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
procedure InsertFontText(const ARichMemo: TCustomRichMemo; const TextUTF8: String; prms: TFontParams;
|
||||||
|
InsPos : Integer = -1 );
|
||||||
|
var
|
||||||
|
len : Integer;
|
||||||
|
begin
|
||||||
|
if InsPos<0 then InsPos:=UTF8Length(ARichMemo.Text);
|
||||||
|
len:=ARichMemo.InDelText(TextUTF8, InsPos, 0);
|
||||||
|
ARichMemo.SetTextAttributes(InsPos, len, prms);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure InsertColorStyledText(const ARichMemo: TCustomRichMemo; const TextUTF8: String; AColor: TColor; AStyle: TFontStyles;
|
||||||
|
InsPos : Integer = -1 );
|
||||||
|
var
|
||||||
|
sel: Integer;
|
||||||
|
ft : TFontParams;
|
||||||
|
begin
|
||||||
|
if InsPos<0 then InsPos:=UTF8Length(ARichMemo.Text);
|
||||||
|
ARichMemo.GetTextAttributes(InsPos, ft);
|
||||||
|
ft.Style:=AStyle;
|
||||||
|
ft.Color:=AColor;
|
||||||
|
InsertFontText(ARichMemo, TextUTF8, ft, InsPos);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure InsertStyledText(const ARichMemo: TCustomRichMemo; const TextUTF8: String; AStyle: TFontStyles;
|
||||||
|
InsPos : Integer );
|
||||||
|
var
|
||||||
|
sel: Integer;
|
||||||
|
ft : TFontParams;
|
||||||
|
begin
|
||||||
|
if InsPos<0 then InsPos:=UTF8Length(ARichMemo.Text);
|
||||||
|
ARichMemo.GetTextAttributes(InsPos, ft);
|
||||||
|
ft.Style:=AStyle;
|
||||||
|
InsertFontText(ARichMemo, TextUTF8, ft, InsPos);
|
||||||
|
end;
|
||||||
|
|
||||||
function InsertImageFileDummy(const ARichMemo: TCustomRichMemo; APos: Integer;
|
function InsertImageFileDummy(const ARichMemo: TCustomRichMemo; APos: Integer;
|
||||||
const FileNameUTF8: string;
|
const FileNameUTF8: string;
|
||||||
const AImgSize: TSize): Boolean;
|
const AImgSize: TSize): Boolean;
|
||||||
|
Reference in New Issue
Block a user