📄 urxriched.pas
字号:
EM_AUTOURLDETECT = WM_USER + 91;
EM_GETAUTOURLDETECT = WM_USER + 92;
EM_SETPALETTE = WM_USER + 93;
EM_GETTEXTEX = WM_USER + 94;
EM_GETTEXTLENGTHEX = WM_USER + 95;
EM_SETLANGOPTIONS = WM_USER + 120;
EM_GETLANGOPTIONS = WM_USER + 121;
EM_GETIMECOMPMODE = WM_USER + 122;
{ Options for EM_SETLANGOPTIONS and EM_GETLANGOPTIONS }
IMF_AUTOKEYBOARD = $0001;
IMF_AUTOFONT = $0002;
IMF_IMECANCELCOMPLETE = $0004; { high completes the comp string when aborting, low cancels. }
IMF_IMEALWAYSSENDNOTIFY = $0008;
{ New notifications }
EN_OLEOPFAILED = $0709;
EN_OBJECTPOSITIONS = $070A;
EN_LINK = $070B;
EN_DRAGDROPDONE = $070C;
{ Event notification masks }
ENM_SCROLLEVENTS = $00000008;
ENM_DRAGDROPDONE = $00000010;
ENM_LANGCHANGE = $01000000;
ENM_OBJECTPOSITIONS = $02000000;
ENM_LINK = $04000000;
{ New edit control styles }
ES_NOOLEDRAGDROP = $00000008;
const
CFM_LINK = $00000020; { Exchange hyperlink extension }
CFM_EFFECTS = CFM_BOLD or CFM_ITALIC or CFM_UNDERLINE or CFM_COLOR or
CFM_STRIKEOUT or CFE_PROTECTED or CFM_LINK;
CFM_ALL = CFM_EFFECTS or CFM_SIZE or CFM_FACE or CFM_OFFSET or CFM_CHARSET;
PFM_ALL = PFM_STARTINDENT or PFM_RIGHTINDENT or PFM_OFFSET or
PFM_ALIGNMENT or PFM_TABSTOPS or PFM_NUMBERING or PFM_OFFSETINDENT;
{ New masks and effects -- a parenthesized asterisk indicates that
the data is stored by RichEdit2.0, but not displayed }
CFM_SMALLCAPS = $0040; { (*) }
CFM_ALLCAPS = $0080; { (*) }
CFM_HIDDEN = $0100; { (*) }
CFM_OUTLINE = $0200; { (*) }
CFM_SHADOW = $0400; { (*) }
CFM_EMBOSS = $0800; { (*) }
CFM_IMPRINT = $1000; { (*) }
CFM_DISABLED = $2000;
CFM_REVISED = $4000;
CFM_BACKCOLOR = $04000000;
CFM_LCID = $02000000;
CFM_UNDERLINETYPE = $00800000; { (*) }
CFM_WEIGHT = $00400000;
CFM_SPACING = $00200000; { (*) }
CFM_KERNING = $00100000; { (*) }
CFM_STYLE = $00080000; { (*) }
CFM_ANIMATION = $00040000; { (*) }
CFM_REVAUTHOR = $00008000;
CFE_LINK = $00000020;
CFE_AUTOCOLOR = $40000000; { NOTE: this corresponds to CFM_COLOR, }
{ which controls it }
CFE_SUBSCRIPT = $00010000; { Superscript and subscript are }
CFE_SUPERSCRIPT = $00020000; { mutually exclusive }
CFM_SUBSCRIPT = CFE_SUBSCRIPT or CFE_SUPERSCRIPT;
CFM_SUPERSCRIPT = CFM_SUBSCRIPT;
CFM_EFFECTS2 = CFM_EFFECTS or CFM_DISABLED or CFM_SMALLCAPS or CFM_ALLCAPS or
CFM_HIDDEN or CFM_OUTLINE or CFM_SHADOW or CFM_EMBOSS or
CFM_IMPRINT or CFM_DISABLED or CFM_REVISED or
CFM_SUBSCRIPT or CFM_SUPERSCRIPT or CFM_BACKCOLOR;
CFM_ALL2 = CFM_ALL or CFM_EFFECTS2 or CFM_BACKCOLOR or CFM_LCID or
CFM_UNDERLINETYPE or CFM_WEIGHT or CFM_REVAUTHOR or
CFM_SPACING or CFM_KERNING or CFM_STYLE or CFM_ANIMATION;
CFE_SMALLCAPS = CFM_SMALLCAPS;
CFE_ALLCAPS = CFM_ALLCAPS;
CFE_HIDDEN = CFM_HIDDEN;
CFE_OUTLINE = CFM_OUTLINE;
CFE_SHADOW = CFM_SHADOW;
CFE_EMBOSS = CFM_EMBOSS;
CFE_IMPRINT = CFM_IMPRINT;
CFE_DISABLED = CFM_DISABLED;
CFE_REVISED = CFM_REVISED;
CFE_AUTOBACKCOLOR = CFM_BACKCOLOR;
{ Underline types }
CFU_CF1UNDERLINE = $FF; { map charformat's bit underline to CF2. }
CFU_INVERT = $FE; { For IME composition fake a selection. }
CFU_UNDERLINEDOTTED = $4; { (*) displayed as ordinary underline }
CFU_UNDERLINEDOUBLE = $3; { (*) displayed as ordinary underline }
CFU_UNDERLINEWORD = $2; { (*) displayed as ordinary underline }
CFU_UNDERLINE = $1;
CFU_UNDERLINENONE = 0;
{ PARAFORMAT 2.0 masks and effects }
const
PFM_SPACEBEFORE = $00000040;
PFM_SPACEAFTER = $00000080;
PFM_LINESPACING = $00000100;
PFM_STYLE = $00000400;
PFM_BORDER = $00000800; { (*) }
PFM_SHADING = $00001000; { (*) }
PFM_NUMBERINGSTYLE = $00002000; { (*) }
PFM_NUMBERINGTAB = $00004000; { (*) }
PFM_NUMBERINGSTART = $00008000; { (*) }
PFM_RTLPARA = $00010000;
PFM_KEEP = $00020000; { (*) }
PFM_KEEPNEXT = $00040000; { (*) }
PFM_PAGEBREAKBEFORE = $00080000; { (*) }
PFM_NOLINENUMBER = $00100000; { (*) }
PFM_NOWIDOWCONTROL = $00200000; { (*) }
PFM_DONOTHYPHEN = $00400000; { (*) }
PFM_SIDEBYSIDE = $00800000; { (*) }
PFM_TABLE = $C0000000; { (*) }
{ Note: PARAFORMAT has no effects }
PFM_EFFECTS = PFM_RTLPARA or PFM_KEEP or PFM_KEEPNEXT or PFM_TABLE or
PFM_PAGEBREAKBEFORE or PFM_NOLINENUMBER or
PFM_NOWIDOWCONTROL or PFM_DONOTHYPHEN or PFM_SIDEBYSIDE or PFM_TABLE;
PFM_ALL2 = PFM_ALL or PFM_EFFECTS or PFM_SPACEBEFORE or PFM_SPACEAFTER or
PFM_LINESPACING or PFM_STYLE or PFM_SHADING or PFM_BORDER or
PFM_NUMBERINGTAB or PFM_NUMBERINGSTART or PFM_NUMBERINGSTYLE;
PFE_RTLPARA = PFM_RTLPARA shr 16;
PFE_KEEP = PFM_KEEP shr 16; { (*) }
PFE_KEEPNEXT = PFM_KEEPNEXT shr 16; { (*) }
PFE_PAGEBREAKBEFORE = PFM_PAGEBREAKBEFORE shr 16; { (*) }
PFE_NOLINENUMBER = PFM_NOLINENUMBER shr 16; { (*) }
PFE_NOWIDOWCONTROL = PFM_NOWIDOWCONTROL shr 16; { (*) }
PFE_DONOTHYPHEN = PFM_DONOTHYPHEN shr 16; { (*) }
PFE_SIDEBYSIDE = PFM_SIDEBYSIDE shr 16; { (*) }
PFE_TABLEROW = $C000; { These 3 options are mutually }
PFE_TABLECELLEND = $8000; { exclusive and each imply }
PFE_TABLECELL = $4000; { that para is part of a table }
PFA_JUSTIFY = 4; { New paragraph-alignment option 2.0 (*) }
const
SF_UNICODE = $0010; { Unicode file of some kind }
type
TFindTextExA = record
chrg: TCharRange;
lpstrText: PAnsiChar;
chrgText: TCharRange;
end;
TObjectPositions = packed record
nmhdr: TNMHdr;
cObjectCount: Longint;
pcpPositions: PLongint;
end;
TENLink = record
nmhdr: TNMHdr;
msg: UINT;
wParam: WPARAM;
lParam: LPARAM;
chrg: TCharRange;
end;
TENOleOpFailed = packed record
nmhdr: TNMHdr;
iob: Longint;
lOper: Longint;
hr: HRESULT;
end;
{ flags for the GETTEXTLENGTHEX data structure }
const
GTL_DEFAULT = 0; { do the default (return # of chars) }
GTL_USECRLF = 1; { compute answer using CRLFs for paragraphs }
GTL_PRECISE = 2; { compute a precise answer }
GTL_CLOSE = 4; { fast computation of a "close" answer }
GTL_NUMCHARS = 8; { return the number of characters }
GTL_NUMBYTES = 16; { return the number of _bytes_ }
{ EM_GETTEXTLENGTHEX info; this struct is passed in the wparam of the msg }
type
TGetTextLengthEx = record
flags: DWORD; { flags (see GTL_XXX defines) }
codepage: UINT; { code page for translation }
end;
const
OLEOP_DOVERB = 1;
{$ENDIF RX_D3}
const
FT_DOWN = 1;
type
PENLink = ^TENLink;
PENOleOpFailed = ^TENOleOpFailed;
TFindTextEx = TFindTextExA;
TTextRangeA = record
chrg: TCharRange;
lpstrText: PAnsiChar;
end;
TTextRangeW = record
chrg: TCharRange;
lpstrText: PWideChar;
end;
TTextRange = TTextRangeA;
{$IFDEF RX_D3}
function ResStr(const Ident: string): string;
begin
Result := Ident;
end;
{$ELSE}
function ResStr(Ident: Cardinal): string;
begin
Result := LoadStr(Ident);
end;
{$ENDIF}
{ TRxTextAttributes }
const
AttrFlags: array[TRxAttributeType] of Word = (0, SCF_SELECTION,
SCF_WORD or SCF_SELECTION);
constructor TRxTextAttributes.Create(AOwner: TRxCustomRichEdit;
AttributeType: TRxAttributeType);
begin
inherited Create;
RichEdit := AOwner;
FType := AttributeType;
end;
procedure TRxTextAttributes.InitFormat(var Format: TCharFormat2);
begin
FillChar(Format, SizeOf(Format), 0);
if RichEditVersion >= 2 then Format.cbSize := SizeOf(Format)
else Format.cbSize := SizeOf(TCharFormat);
end;
function TRxTextAttributes.GetConsistentAttributes: TRxConsistentAttributes;
var
Format: TCharFormat2;
begin
Result := [];
if RichEdit.HandleAllocated and (FType <> atDefaultText) then begin
InitFormat(Format);
SendMessage(RichEdit.Handle, EM_GETCHARFORMAT,
AttrFlags[FType], LPARAM(@Format));
with Format do begin
if (dwMask and CFM_BOLD) <> 0 then Include(Result, caBold);
if (dwMask and CFM_COLOR) <> 0 then Include(Result, caColor);
if (dwMask and CFM_FACE) <> 0 then Include(Result, caFace);
if (dwMask and CFM_ITALIC) <> 0 then Include(Result, caItalic);
if (dwMask and CFM_SIZE) <> 0 then Include(Result, caSize);
if (dwMask and CFM_STRIKEOUT) <> 0 then Include(Result, caStrikeOut);
if (dwMask and CFM_UNDERLINE) <> 0 then Include(Result, caUnderline);
if (dwMask and CFM_PROTECTED) <> 0 then Include(Result, caProtected);
if (dwMask and CFM_OFFSET) <> 0 then Include(Result, caOffset);
if (dwMask and CFM_HIDDEN) <> 0 then Include(result, caHidden);
if RichEditVersion >= 2 then begin
if (dwMask and CFM_LINK) <> 0 then Include(Result, caLink);
if (dwMask and CFM_BACKCOLOR) <> 0 then Include(Result, caBackColor);
if (dwMask and CFM_DISABLED) <> 0 then Include(Result, caDisabled);
if (dwMask and CFM_WEIGHT) <> 0 then Include(Result, caWeight);
if (dwMask and CFM_SUBSCRIPT) <> 0 then Include(Result, caSubscript);
if (dwMask and CFM_REVAUTHOR) <> 0 then Include(Result, caRevAuthor);
end;
end;
end;
end;
procedure TRxTextAttributes.GetAttributes(var Format: TCharFormat2);
begin
InitFormat(Format);
if RichEdit.HandleAllocated then
SendMessage(RichEdit.Handle, EM_GETCHARFORMAT, AttrFlags[FType],
LPARAM(@Format));
end;
procedure TRxTextAttributes.SetAttributes(var Format: TCharFormat2);
begin
if RichEdit.HandleAllocated then
SendMessage(RichEdit.Handle, EM_SETCHARFORMAT, AttrFlags[FType],
LPARAM(@Format));
end;
{$IFNDEF VER90}
function TRxTextAttributes.GetCharset: TFontCharset;
var
Format: TCharFormat2;
begin
GetAttributes(Format);
Result := Format.bCharset;
end;
procedure TRxTextAttributes.SetCharset(Value: TFontCharset);
var
Format: TCharFormat2;
begin
InitFormat(Format);
with Format do
begin
dwMask := CFM_CHARSET;
bCharSet := Value;
end;
SetAttributes(Format);
end;
{$ENDIF}
function TRxTextAttributes.GetProtected: Boolean;
var
Format: TCharFormat2;
begin
GetAttributes(Format);
with Format do
Result := (dwEffects and CFE_PROTECTED) <> 0;
end;
procedure TRxTextAttributes.SetProtected(Value: Boolean);
var
Format: TCharFormat2;
begin
InitFormat(Format);
with Format do begin
dwMask := CFM_PROTECTED;
if Value then dwEffects := CFE_PROTECTED;
end;
SetAttributes(Format);
end;
function TRxTextAttributes.GetLink: Boolean;
var
Format: TCharFormat2;
begin
Result := False;
if RichEditVersion < 2 then Exit;
GetAttributes(Format);
with Format do Result := (dwEffects and CFE_LINK) <> 0;
end;
procedure TRxTextAttributes.SetLink(Value: Boolean);
var
Format: TCharFormat2;
begin
if RichEditVersion < 2 then Exit;
InitFormat(Format);
with Format do begin
dwMask := CFM_LINK;
if Value then dwEffects := CFE_LINK;
end;
SetAttributes(Format);
end;
function TRxTextAttributes.GetRevAuthorIndex: Byte;
var
Format: TCharFormat2;
begin
GetAttributes(Format);
Result := Format.bRevAuthor;
end;
procedure TRxTextAttributes.SetRevAuthorIndex(Value: Byte);
var
Format: TCharFormat2;
begin
if RichEditVersion < 2 then Exit;
InitFormat(Format);
with Format do begin
dwMask := CFM_REVAUTHOR;
bRevAuthor := Value;
end;
SetAttributes(Format);
end;
function TRxTextAttributes.GetHidden: Boolean;
var
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -