📄 syneditsource.pas
字号:
if IsMask(smHighlighter) then
self.Highlighter := TSynEditSource(Source).Highlighter;
if IsMask(smInsertCaret) then
Self.InsertCaret := TSynEditSource(Source).InsertCaret;
if IsMask(smInsertMode) then
Self.insertMode := TSynEditSource(Source).insertMode;
if IsMask(smKeystrokes) then
Self.Keystrokes := TSynEditSource(Source).Keystrokes;
if IsMask(smLines) then
self.Lines := TSynEditSource(Source).Lines;
if IsMask(smLineDivider) then
Self.LineDivider := TSynEditSource(Source).LineDivider;
if IsMask(smLineSpacing) then
Self.LineSpacing := TSynEditSource(Source).LineSpacing;
if IsMask(smLineSpacingRule) then
Self.LineSpacingRule := TSynEditSource(Source).LineSpacingRule;
if IsMask(smMaxScrollWidth) then
Self.MaxScrollWidth := TSynEditSource(Source).MaxScrollWidth;
if IsMask(smMaxUndo) then
Self.MaxUndo := TSynEditSource(Source).MaxUndo;
if IsMask(smOptions) then
Self.Options := TSynEditSource(Source).Options;
if IsMask(smOverwriteCaret) then
Self.OverwriteCaret := TSynEditSource(Source).OverwriteCaret;
if IsMask(smPopupMenu) then
Self.PopupMenu := TSynEditSource(Source).PopupMenu;
if IsMask(smReadOnly) then
Self.ReadOnly := TSynEditSource(Source).ReadOnly;
if IsMask(smRightEdge) then
Self.RightEdge := TSynEditSource(Source).RightEdge;
if IsMask(smScrollBars) then
Self.ScrollBars := TSynEditSource(Source).ScrollBars;
if IsMask(smSelectedColor) then
Self.SelectedColor := TSynEditSource(Source).SelectedColor;
if IsMask(smSelectionMode) then
Self.SelectionMode := TSynEditSource(Source).SelectionMode;
if IsMask(smTabWidth) then
Self.TabWidth := TSynEditSource(Source).TabWidth;
if IsMask(smWantTabs) then
Self.WantTabs := TSynEditSource(Source).WantTabs;
if IsMask(smWordWrap) then
Self.WordWrap := TSynEditSource(Source).WordWrap;
{$IFDEF CODEFOLDING}
//### Code Folding ###
if IsMask(smCodeFolding) then
Self.CodeFolding := TSynEditSource(Source).CodeFolding;
//### End Code Folding ###
{$ENDIF}
end else inherited;
end;
procedure TSynEditSource.AssignTo(Dest: TPersistent);
begin
if Assigned(Dest) and (Dest is TCustomSynEdit) then
begin
TSynEditAcess(Dest).BeginUpdate;
if IsMask(smBackground) then
TSynEditAcess(Dest).Background := Self.Background;
if IsMask(smActiveLine) then
TSynEditAcess(Dest).ActiveLine := self.ActiveLine;
if IsMask(smBlockWidth) then
TSynEditAcess(Dest).BlockWidth := self.BlockWidth;
if IsMask(smBookMarkOptions) then
TSynEditAcess(Dest).BookmarkOptions := self.BookmarkOptions;
if IsMask(smBorderStyle) then
TSynEditAcess(Dest).BorderStyle := self.BorderStyle;
if IsMask(smColor) then
TSynEditAcess(Dest).Color := self.Color;
if IsMask(smFont) then
TSynEditAcess(Dest).Font := self.Font;
if IsMask(smGutter) then
TSynEditAcess(Dest).Gutter := self.Gutter;
if IsMask(smHideSelection) then
TSynEditAcess(Dest).HideSelection := self.HideSelection;
if IsMask(smHighlighter) then
TSynEditAcess(Dest).Highlighter := self.Highlighter;
if IsMask(smInsertCaret) then
TSynEditAcess(Dest).InsertCaret := self.InsertCaret;
if IsMask(smInsertMode) then
TSynEditAcess(Dest).insertMode := self.insertMode;
if IsMask(smKeystrokes) then
TSynEditAcess(Dest).Keystrokes.Assign(self.Keystrokes);
if IsMask(smLines) then
TSynEditAcess(Dest).Lines := self.Lines;
if IsMask(smLineDivider) then
TSynEditAcess(Dest).LineDivider := self.LineDivider;
if IsMask(smLineSpacing) then
TSynEditAcess(Dest).LineSpacing := self.LineSpacing;
if IsMask(smLineSpacingRule) then
TSynEditAcess(Dest).LineSpacingRule := self.LineSpacingRule;
if IsMask(smMaxScrollWidth) then
TSynEditAcess(Dest).MaxScrollWidth := self.MaxScrollWidth;
if IsMask(smMaxUndo) then
TSynEditAcess(Dest).MaxUndo := self.MaxUndo;
if IsMask(smOptions) then
TSynEditAcess(Dest).Options := self.Options;
if IsMask(smOverwriteCaret) then
TSynEditAcess(Dest).OverwriteCaret := self.OverwriteCaret;
if IsMask(smPopupMenu) then
TSynEditAcess(Dest).PopupMenu := self.PopupMenu;
if IsMask(smReadOnly) then
TSynEditAcess(Dest).ReadOnly := self.ReadOnly;
if IsMask(smRightEdge) then
TSynEditAcess(Dest).RightEdge := self.RightEdge;
if IsMask(smScrollBars) then
TSynEditAcess(Dest).ScrollBars := self.ScrollBars;
if IsMask(smSelectedColor) then
TSynEditAcess(Dest).SelectedColor := self.SelectedColor;
if IsMask(smSelectionMode) then
TSynEditAcess(Dest).SelectionMode := self.SelectionMode;
if IsMask(smTabWidth) then
TSynEditAcess(Dest).TabWidth := self.TabWidth;
if IsMask(smWantTabs) then
TSynEditAcess(Dest).WantTabs := self.WantTabs;
if IsMask(smWordWrap) then
TSynEditAcess(Dest).WordWrap := self.WordWrap;
{$IFDEF CODEFOLDING}
//### Code Folding ###
if IsMask(smCodeFolding) then
TSynEditAcess(Dest).CodeFolding := self.CodeFolding;
//### End Code Folding ###
{$ENDIF}
TSynEditAcess(Dest).EndUpdate;
end else inherited;
end;
constructor TSynEditSource.create(AOwner: TComponent);
begin
inherited;
FActiveLine := TSynActiveLine.Create;
FBookmarks:= TSynBookMarkOpt.Create(Self);
FFont:= TFont.Create;
FSynGutter:= TSynGutter.Create;
FKeystrokes:= TSynEditKeyStrokes.Create(Self);
FLines := TStringList.Create;
FLineDivider:= TSynLineDivider.Create;
FRightEdge:= TSynRightEdge.Create;
FSelectedColor:= TSynSelectedColor.Create;
FWordWrap:= TSynWordWrap.Create;
FScrollBars := TSynScrollBars.create;
FBackground := TSynEditBackground.Create;
{$IFDEF CODEFOLDING}
//### Code Folding ###
FCodeFolding := TSynCodeFolding.create;
//### End Code Folding ###
{$ENDIF}
FMask := DefaultSynEditSourceMask;
end;
destructor TSynEditSource.destroy;
begin
FLines.Free;
FRightEdge.Free;
FActiveLine.Free;
FLineDivider.Free;
FWordWrap.Free;
FBookMarks.Free;
FKeyStrokes.Free;
FSynGutter.Free;
FSelectedColor.Free;
FFont.Free;
FScrollBars.free;
FBackground.Free;
{$IFDEF CODEFOLDING}
//### Code Folding ###
fCodeFolding.Free;
//### End Code Folding ###
{$ENDIF}
inherited;
end;
function TSynEditSource.IsMask(Mask: TSynEditSourceMask): Boolean;
begin
result := Mask in FMask;
end;
procedure TSynEditSource.LoadFromIni(IniFile: TCustomIniFile; Section: String);
procedure SetOptions(Add : boolean; value: TSynEditorOption);
begin
If add then
Options := Options + [value]
else Options := Options - [value]
end;
begin
if IniFile <> nil then
with IniFile do
begin
if IsMask(smActiveLine) then
with ActiveLine do
begin
Visible := ReadBool(Section, 'ActiveLine_Visible', Visible);
Indicator.Visible := ReadBool(Section, 'ActiveLine_Indicator', Indicator.Visible);
Background := ReadInteger(Section, 'ActiveLine_Background', Background);
Foreground := ReadInteger(Section, 'ActiveLine_Foreground', Foreground);
end;
if IsMask(smBackground) then
with Background do
begin
Visible := ReadBool(Section, 'Background_Visible', Visible);
RepeatMode := TSynBackgroundRepeatMode(ReadInteger(Section,
'Background_RepeatMode', Integer(RepeatMode)));
end;
if IsMask(smBlockWidth) then
BlockWidth := ReadInteger(Section, 'BlockWidth', BlockWidth);
if IsMask(smBookMarkOptions) then
with BookMarkOptions do
begin
DrawBookmarksFirst := ReadBool(Section, 'BookMarkOptions_DrawBookmarksFirst', DrawBookmarksFirst);
EnableKeys := ReadBool(Section, 'BookMarkOptions_EnableKeys', EnableKeys);
GlyphsVisible := ReadBool(Section, 'BookMarkOptions_GlyphsVisible', GlyphsVisible);
LeftMargin := ReadInteger(Section, 'BookMarkOptions_LeftMargin', LeftMargin);
Xoffset := ReadInteger(Section, 'BookMarkOptions_Xoffset', Xoffset);
end;
if IsMask(smBorderStyle) then
BorderStyle := TBorderStyle(ReadInteger(Section, 'BorderStyle', integer(BorderStyle)));
if IsMask(smColor) then
Color := ReadInteger(Section, 'Color', Color);
if IsMask(smFont) then
StrToFont(ReadString(Section, 'Font', ''), Font);
if IsMask(smGutter) then
with Gutter do
begin
LeftOffsetColor := ReadInteger(Section, 'Gutter_LeftOffsetColor', LeftOffsetColor);
RightOffsetColor := ReadInteger(Section, 'Gutter_RightOffsetColor', RightOffsetColor);
ShowLineModified := ReadBool(Section, 'Gutter_ShowLineModified', ShowLineModified);
LineNormalColor := ReadInteger(Section, 'Gutter_LineNormalColor', LineNormalColor);
LineModifiedColor := ReadInteger(Section, 'Gutter_LineModifiedColor', LineModifiedColor);
AutoSize := ReadBool(Section, 'Gutter_AutoSize', AutoSize);
BorderStyle := TSynGutterBorderStyle(ReadInteger(Section, 'Gutter_BorderStyle', Integer(BorderStyle)));
Color := ReadInteger(Section, 'Gutter_Color', Color);
DigitCount := ReadInteger(Section, 'Gutter_DigitCount', DigitCount);
StrToFont(ReadString(Section, 'Gutter_Font', ''), Font);
LeadingZeros := ReadBool(Section, 'Gutter_LeaderZeros', LeadingZeros);
LeftOffset := ReadInteger(Section, 'Gutter_LeftOffset', LeftOffset);
RightOffset := ReadInteger(Section, 'Gutter_RightOffset', RightOffset);
ShowLineNumbers := ReadBool(Section, 'Gutter_ShowLineNumbers', ShowLineNumbers);
UseFontStyle := ReadBool(Section, 'Gutter_UseFontStyle', UseFontStyle);
Visible := ReadBool(Section, 'Gutter_Visible', Visible);
ZeroStart := ReadBool(Section, 'Gutter_ZeroStart', ZeroStart);
BorderColor := ReadInteger(Section, 'Gutter_BorderColor', BorderColor);
Intens := ReadBool(Section, 'Gutter_Intens', Intens);
LineNumberStart := ReadInteger(Section, 'Gutter_LineNumberStart', LineNumberStart);
Gradient := ReadBool(Section, 'Gutter_Gradient', Gradient);
GradientStartColor := ReadInteger(Section, 'Gutter_GradientStartColor', GradientStartColor);
GradientEndColor := ReadInteger(Section, 'Gutter_GradientEndColor', GradientEndColor);
GradientSteps := ReadInteger(Section, 'Gutter_GradientSteps', GradientSteps);
end;
if IsMask(smHideSelection) then
HideSelection := ReadBool(Section, 'HideSelection', HideSelection);
// if IsMask(smHighlighter) then
if IsMask(smInsertCaret) then
InsertCaret := TSynEditCaretType(ReadInteger(Section, 'InsertCaret', Integer(InsertCaret)));
if IsMask(smInsertMode) then
InsertMode := ReadBool(Section, 'InsertMode', InsertMode);
// if IsMask(smKeystrokes) then
// if IsMask(smLines) then
if IsMask(smLineDivider) then
with LineDivider do
begin
Visible := ReadBool(Section, 'LineDivider_Visible', Visible);
Color := ReadInteger(Section, 'LineDivider_Color', Color);
Style := TPenStyle(ReadInteger(Section, 'LineDivider_Style', Integer(Style)));
end;
if IsMask(smLineSpacing) then
LineSpacing := ReadInteger(Section, 'LineSpacing', LineSpacing);
if IsMask(smLineSpacingRule) then
LineSpacingRule := TLineSpacingRule(ReadInteger(Section, 'LineSpacingRule', Integer(LineSpacingRule)));
if IsMask(smMaxScrollWidth) then
MaxScrollWidth := readInteger(Section, 'MaxScrollWidth', MaxScrollWidth);
if IsMask(smMaxUndo) then
MaxUndo := ReadInteger(Section, 'MaxUndo', MaxUndo);
if IsMask(smOptions) then
begin
SetOptions(ReadBool(Section, 'Options_AutoIndent', eoAutoIndent in Options), eoAutoIndent);
SetOptions(ReadBool(Section, 'Options_AltSetsColumnMode', eoAltSetsColumnMode in Options), eoAltSetsColumnMode);
SetOptions(ReadBool(Section, 'Options_AutoSizeMaxScrollWidth', eoAutoSizeMaxScrollWidth in Options), eoAutoSizeMaxScrollWidth);
SetOptions(ReadBool(Section, 'Options_DragDropEditing', eoDragDropEditing in Options), eoDragDropEditing);
SetOptions(ReadBool(Section, 'Options_DisableScrollArrows', eoDisableScrollArrows in Options), eoDisableScrollArrows);
SetOptions(ReadBool(Section, 'Options_DropFiles', eoDropFiles in Options), eoDropFiles);
SetOptions(ReadBool(Section, 'Options_EnhanceHomeKey', eoEnhanceHomeKey in Options), eoEnhanceHomeKey);
SetOptions(ReadBool(Section, 'Options_EnhanceEndKey', eoEnhanceEndKey in Options), eoEnhanceEndKey);
SetOptions(ReadBool(Section, 'Options_GroupUndo', eoGroupUndo in Options), eoGroupUndo);
SetOptions(ReadBool(Section, 'Options_HalfPageScroll', eoHalfPageScroll in Options), eoHalfPageScroll);
SetOptions(ReadBool(Section, 'Options_HideShowScrollbars', eoHideShowScrollbars in Options), eoHideShowScrollbars);
SetOptions(ReadBool(Section, 'Options_KeepCaretX', eoKeepCaretX in Options), eoKeepCaretX);
SetOptions(ReadBool(Section, 'Options_NoCaret', eoNoCaret in Options), eoNoCaret);
SetOptions(ReadBool(Section, 'Options_NoSelection', eoNoSelection in Options), eoNoSelection);
SetOptions(ReadBool(Section, 'Options_RightMouseMovesCursor', eoRightMouseMovesCursor in Options), eoRightMouseMovesCursor);
SetOptions(ReadBool(Section, 'Options_ScrollByOneLess', eoScrollByOneLess in Options), eoScrollByOneLess);
SetOptions(ReadBool(Section, 'Options_ScrollHintFollows', eoScrollHintFollows in Options), eoScrollHintFollows);
SetOptions(ReadBool(Section, 'Options_ScrollPastEof', eoScrollPastEof in Options), eoScrollPastEof);
SetOptions(ReadBool(Section, 'Options_ScrollPastEol', eoScrollPastEol in Options), eoScrollPastEol);
SetOptions(ReadBool(Section, 'Options_ShowScrollHint', eoShowScrollHint in Options), eoShowScrollHint);
SetOptions(ReadBool(Section, 'Options_ShowSpecialChars', eoShowSpecialChars in Options), eoShowSpecialChars);
SetOptions(ReadBool(Section, 'Options_SmartTabs', eoSmartTabs in Options), eoSmartTabs);
SetOptions(ReadBool(Section, 'Options_SmartTabDelete', eoSmartTabDelete in Options), eoSmartTabDelete);
SetOptions(ReadBool(Section, 'Options_SpecialLineDefaultFg', eoSpecialLineDefaultFg in Options), eoSpecialLineDefaultFg);
SetOptions(ReadBool(Section, 'Options_TabsToSpaces', eoTabsToSpaces in Options), eoTabsToSpaces);
SetOptions(ReadBool(Section, 'Options_TabIndent', eoTabIndent in Options), eoTabIndent);
SetOptions(ReadBool(Section, 'Options_TrimTrailingSpaces', eoTrimTrailingSpaces in Options), eoTrimTrailingSpaces);
SetOptions(ReadBool(Section, 'Options_ColumnEditExtension', eoColumnEditExtension in Options), eoColumnEditExtension);
end;
if IsMask(smOverwriteCaret) then
OverwriteCaret := TSynEditCaretType(ReadInteger(Section, 'OverwriteCaret', Integer(OverwriteCaret)));
// if IsMask(smPopupMenu) then
if IsMask(smReadOnly) then
ReadOnly := ReadBool(Section, 'ReadOnly', ReadOnly);
if IsMask(smRightEdge) then
with RightEdge do
begin
Visible := ReadBool(Section, 'RightEdge_Visible', Visible);
Position := ReadInteger(Section, 'RightEdge_Position', Position);
Color := ReadInteger(Section, 'RightEdge_Color', Color);
Style := TPenStyle(ReadInteger(Section, 'RightEdge_Style', Integer(Style)));
MouseMove := ReadBool(Section, 'RightEdge_MouseMove', MouseMove);
end;
if IsMask(smScrollBars) then
with ScrollBars do
begin
ScrollBars := TScrollStyle(ReadInteger(Section, 'ScrollBars_ScrollBars', Integer(ScrollBars)));
Style := TScrollBarsStyle(ReadInteger(Section, 'ScrollBars_Style', Integer(Style)));
HintColor := ReadInteger(Section, 'ScrollBars_HintColor', HintColor);
HintFormat := TScrollHintFormat(ReadInteger(Section, 'ScrollBars_HintFormat', Integer(HintFormat)));
end;
if IsMask(smSelectedColor) then
with SelectedColor do
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -