⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 synoptionsdlg.pas

📁 用delphi写的delphi源代码 用delphi写的delphi源代码 用delphi写的delphi源代码 用delphi写的delphi源代码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  //### End Code Folding ###
  {$ENDIF}
end;

procedure TSynOptionsForm.cbInsertModeClick(Sender: TObject);
begin
  Source.InsertMode := cbInsertMode.checked;
end;

procedure TSynOptionsForm.cbPastEolClick(Sender: TObject);
begin
  SetOptions(cbPastEol.Checked, eoScrollPastEol);
end;

procedure TSynOptionsForm.cbSelectmodeChange(Sender: TObject);
begin
  Source.SelectionMode := TSynSelectionMode(cbSelectmode.ItemIndex);
end;

procedure TSynOptionsForm.CheckBox1Click(Sender: TObject);
begin
  SetOptions(CheckBox1.Checked, eoColumnEditExtension);
end;

procedure TSynOptionsForm.CurBackColorBoxChange(Sender: TObject);
begin
  Source.ActiveLine.Background := curbackcolorbox.Selected;
end;

procedure TSynOptionsForm.CurTextColorBoxChange(Sender: TObject);
begin
  Source.ActiveLine.Foreground := curtextcolorbox.Selected;
end;

procedure TSynOptionsForm.BackColorBoxChange(Sender: TObject);
begin
  Source.Color := BackColorBox.Selected;
end;

procedure TSynOptionsForm.Execute(default: TSynEditSource;
  SynEdit: TCustomSynEdit);
begin
  FDefault := default;
  if not Assigned(synEdit) then
    Source.Assign(Default)
  else
    Source.Assign(SynEdit);
  SetValue(Source);
  If ShowModal = mrok then
    if not Assigned(synEdit) then
      Default.Assign(Source)
    else
      GetValue(Source, SynEdit);
end;

procedure TSynOptionsForm.Button3Click(Sender: TObject);
begin
  if FDefault <> nil then
    FDefault.Assign(Source);
end;

procedure TSynOptionsForm.SetValue(Source: TSynEditSource);
begin
  {$IFDEF CODEFOLDING}
  //### Code Folding ###
  cbCodeFolding.Visible := true;
  cbCodeFolding.Checked := Source.CodeFolding.Enabled;
  //### End Code Folding ###
  {$ENDIF}
  sBackground.Checked := source.Background.Visible;
  cbSelectMode.ItemIndex := integer(Source.SelectionMode);
  sBlockWidth.Text := IntToStr(Source.BlockWidth);
  sMaxUndo.Text := IntToStr(Source.MaxUndo);
  sTabWidth.Text := IntToStr(Source.TabWidth);
  sMaxScroll.Text := IntToStr(Source.MaxScrollWidth);
  sLineSpacingRule.ItemIndex := Integer(Source.LineSpacingRule);
  sLineSpacing.Text := IntToStr(Source.LineSpacing);
  sShowGutter.Checked := Source.Gutter.Visible;
  sShowLineNumber.Checked := Source.Gutter.ShowLineNumbers;
  sWordwrapStyle.ItemIndex := Integer(Source.WordWrap.Style);
  sWordWrap.Checked := Source.WordWrap.Enabled;
  sWordwrapPos.Text := IntToStr(Source.WordWrap.Position);
  sShowRightEdge.Checked := Source.RightEdge.Visible;
  sRightEdgeMouseMove.Checked := Source.RightEdge.MouseMove;
  sRightEdgePos.Text := IntToStr(Source.RightEdge.Position);
  sShowActiveLine.Checked := Source.ActiveLine.Visible;
  sShowLineDivder.Checked := Source.LineDivider.Visible;
  soAltSetsColumnMode.Checked := GetOptions(eoAltSetsColumnMode);
  soAutoIndent.Checked := GetOptions(eoAutoIndent);
  soDragDropEditing.Checked := GetOptions(eoDragDropEditing);
  soDropFiles.Checked := GetOptions(eoDropFiles);
  soGroupUndo.Checked := GetOptions(eoGroupUndo);
  soShowSpecialChars.Checked := GetOptions(eoShowSpecialChars);
  soSmartTabs.Checked := GetOptions(eoSmartTabs);
  soSmartTabDelete.Checked := GetOptions(eoSmartTabDelete);
  soTabIndent.Checked := GetOptions(eoTabIndent);
  soTabsToSpace.Checked := GetOptions(eoTabsToSpaces);
  Checkbox1.Checked := Getoptions(eoColumnEditExtension);
  cbpasteol.Checked := Getoptions(eoScrollPastEol);
  cbInsertMode.checked := Source.InsertMode;
  FontPreview.Font := Source.Font;
  sFontNameCom.ItemIndex := sFontNameCom.Items.IndexOf(Source.font.Name);
  sFontSizeCom.Text := IntToStr(Source.Font.Size);
  backcolorbox.Selected := Source.Color;
  seltextcolorbox.Selected := source.SelectedColor.Foreground;
  selbackcolorbox.Selected := source.SelectedColor.Background;
  curtextcolorbox.Selected := source.ActiveLine.Foreground;
  curbackcolorbox.Selected := source.ActiveLine.Background;
  CheckBox2.Checked := Source.Gutter.ShowLineModified;
end;

function TSynOptionsForm.GetOptions(Option: TSynEditorOption): Boolean;
begin
  result := Option in Source.Options;
end;

var PixelsPerInch : integer;

function EnumFontName(var EnumLogFont: TEnumLogFont;
  var TextMetric: TNewTextMetric;
  FontType: Integer; Data: LPARAM): Integer;
  export; stdcall;
var
  FaceName: string;
begin
  FaceName := StrPas(EnumLogFont.elfLogFont.lfFaceName);
  with TStrings(Data) do
  begin
    if (IndexOf(FaceName) < 0) and
      ((EnumLogFont.elfLogFont.lfPitchAndFamily and FIXED_PITCH) = FIXED_PITCH) then
      Add(FaceName);
  end;
  Result := 1;
end;

function EnumFontSizes(var EnumLogFont: TEnumLogFont;
  PTextMetric: PNewTextMetric;
  FontType: Integer; Data: LPARAM): Integer;
  export; stdcall;
var
  S: string; I, V, V2: Integer;
begin
  with TStrings(Data) do
  begin
    if (FontType and TRUETYPE_FONTTYPE) <> 0 then
    begin
      Add('8');
      Add('9');
      Add('10');
      Add('11');
      Add('12');
      Add('14');
      Add('15');
      Add('16');
      Add('18');
      Add('20');
      Add('22');
      Add('24');
      Add('26');
      Add('28');
      Add('36');
      Add('42');
      Add('48');
      Add('72');
      Result := 0;
    end
    else
    begin
      v := Round((EnumLogFont.elfLogFont.lfHeight -
        PTextMetric.tmInternalLeading) * 72 / PixelsPerInch);
      s := IntToStr(v);
      Result := 1;
      for i := 0 to Count - 1 do
      begin
        v2 := StrToInt(Strings[i]);
        if v2 = v then exit;
        if v2 > v then
        begin
          Insert(i, s);
          exit;
        end;
      end;
      Add(s);
    end;
  end;
end;

procedure TSynOptionsForm.sFontNameComChange(Sender: TObject);
var
  DC : HDC;
  FS : string;
begin
  FontPreview.Font.Name := sFontNameCom.Text;
  source.Font := FontPreview.Font;
  DC := GetDC(0);
  try
    FS := sFontsizeCom.text;
    PixelsPerInch := GetDeviceCaps(DC, LOGPIXELSY);
    EnumFontFamilies(DC, PChar(sFontNameCom.Text), @EnumFontSizes, Longint(sFontsizeCom.Items));
    sFontsizeCom.Text := fs;
  finally
    ReleaseDC(0, DC);
  end;
end;

procedure TSynOptionsForm.sFontsizeComChange(Sender: TObject);
begin
  FontPreview.Font.Size := StrToInt(sFontSizeCom.Text);
  source.Font := FontPreview.Font;
end;

procedure TSynOptionsForm.sLineNumberStartKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  if not key in [48..57, 65..90, 97..122, 126, 8] then
    key := 0;
end;

procedure TSynOptionsForm.sWordWrapClick(Sender: TObject);
begin
  source.WordWrap.Enabled := sWordWrap.Checked;
  source.WordWrap.Indicator.Visible := sWordWrap.Checked;
end;

procedure TSynOptionsForm.sMaxScrollChange(Sender: TObject);
begin
  Source.MaxScrollWidth := StrToInt(sMaxScroll.Text);
end;

procedure TSynOptionsForm.sRightEdgeMouseMoveClick(Sender: TObject);
begin
  Source.RightEdge.MouseMove := sRightEdgeMouseMove.Checked;
end;

procedure TSynOptionsForm.FormCreate(Sender: TObject);
var
  DC : HDC;
begin
  Source := TSynEditSource.Create(self);
  DC := GetDC(0);
  sFontNameCom.Items.BeginUpdate;
  try
    EnumFontFamilies(DC, nil, @EnumFontName, Longint(sFontNameCom.Items));
  finally
    sFontNameCom.Items.EndUpdate;
    ReleaseDC(0, DC);
  end;
end;

procedure TSynOptionsForm.CheckBox2Click(Sender: TObject);
begin
  Source.Gutter.ShowLineModified := CheckBox2.Checked;
end;

procedure TSynOptionsForm.GetValue(Source: TSynEditSource;
  SynEdit: TCustomSynEdit);
begin
  with SynEdit do
  begin
    BeginUpdate;
    {$IFDEF CODEFOLDING}
    //### Code Folding ###
    CodeFolding.Enabled := Source.CodeFolding.Enabled;
    //### End Code Folding ###
    {$ENDIF}
    Background.Visible := Source.Background.Visible;
    SelectionMode := Source.SelectionMode;
    BlockWidth := Source.BlockWidth;
    MaxUndo := Source.MaxUndo;
    TabWidth := Source.TabWidth;
    MaxScrollWidth := Source.MaxScrollWidth;
    LineSpacingRule := Source.LineSpacingRule;
    LineSpacing := Source.LineSpacing;
    Gutter.Visible := Source.Gutter.Visible;
    Gutter.ShowLineNumbers := Source.Gutter.ShowLineNumbers;
    WordWrap.Style := Source.WordWrap.Style;
    WordWrap.Enabled := Source.WordWrap.Enabled;
    WordWrap.Position := Source.WordWrap.Position;
    RightEdge.Visible := Source.RightEdge.Visible;
    RightEdge.MouseMove := Source.RightEdge.MouseMove;
    RightEdge.Position := Source.RightEdge.Position;
    ActiveLine.Visible := Source.ActiveLine.Visible;
    LineDivider.Visible := Source.LineDivider.Visible;
    Options := Options;
    InsertMode := Source.InsertMode;
    Font := Source.Font;
    Color := Source.Color;
    SelectedColor.Foreground := source.SelectedColor.Foreground;
    SelectedColor.Background := source.SelectedColor.Background;
    ActiveLine.Foreground := source.ActiveLine.Foreground;
    ActiveLine.Background := source.ActiveLine.Background;
    Gutter.ShowLineModified := Source.Gutter.ShowLineModified;
    EndUpdate;
  end;
end;

procedure TSynOptionsForm.sBackgroundClick(Sender: TObject);
begin
  Source.Background.Visible := sBackground.Checked
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -