easycustomdlg.pas.svn-base

来自「支持自定义语法高亮显示的编辑器控件」· SVN-BASE 代码 · 共 616 行 · 第 1/2 页

SVN-BASE
616
字号
      FontStyle := FontStyle + [fsUnderline]
    else
      FontStyle := FontStyle - [fsUnderline];
end;

{-------------------------------------------------}

procedure TCustomizeForm.chbForegroundClick(Sender: TObject);
begin
//
end;

{-------------------------------------------------}

procedure TCustomizeForm.chbBackgroundClick(Sender: TObject);
begin
//
end;

{-------------------------------------------------}

procedure TCustomizeForm.ForeColorBtnClick(Sender: TObject);
begin
  with EasycbForegroundColor, ColorDialog1 do
  begin
    Color := ColorToRGB(SelectedColor);
    if Execute then
      CustomColor := Color;
  end;
end;

{-------------------------------------------------}

procedure TCustomizeForm.BackColorBtnClick(Sender: TObject);
begin
  with EasycbBackgroundColor, ColorDialog1 do
  begin
    Color := ColorToRGB(SelectedColor);
    if Execute then
      CustomColor := Color;
  end;
end;

{-------------------------------------------------}

procedure TCustomizeForm.lsbElementsClick(Sender: TObject);
begin
  SetBackAndForeStyles(lsbElements.ItemIndex);
end;

{-------------------------------------------------}

procedure TCustomizeForm.FormDestroy(Sender: TObject);
begin
  FStyles.Free;
  {$IFNDEF EASY_CLX}
  FDialogSettings.SaveSettings;
  {$ENDIF}
end;

{-------------------------------------------------}

procedure TCustomizeForm.cbColorSpeedSettingChange(Sender: TObject);

  procedure LoadStyle_ (Value : TEasyStylesConstArray);
  var
    i : integer;
  begin
    for i := Low(Value) to High(Value) do
    begin
      with TEasyParserStyle(FStyles.Items[i]) do
      begin
        FontStyle := Value[i].Style;
        FontColor := Value[i].Color;
        Color := Value[i].BkColor;
      end;
    end;
  end;

begin
  case cbColorSpeedSetting.ItemIndex of
    0 : LoadStyle_(ctDefault);
    1 : LoadStyle_(ctClassic);
    2 : LoadStyle_(ctOcean);
    3 : LoadStyle_(ctTwilight);
    4 : LoadStyle_(ctVisualStudio);
    5 : LoadStyle_(ctVisualStudioNet);
    else
      LoadStyle_(ctDefault);
  end;
  lsbElementsClick(Self);
end;

{-------------------------------------------------}

procedure TCustomizeForm.EasycbForegroundColorChange(Sender: TObject);
begin
  with FStyles.Items[lsbElements.ItemIndex] do
    FontColor := EasycbForegroundColor.SelectedColor;
end;

{-------------------------------------------------}

procedure TCustomizeForm.EasycbBackgroundColorChange(Sender: TObject);
begin
  with FStyles.Items[lsbElements.ItemIndex] do
    Color := EasycbBackgroundColor.SelectedColor;
end;

{-------------------------------------------------}

procedure TCustomizeForm.chbBoldClick(Sender: TObject);
begin
  with FStyles.Items[lsbElements.ItemIndex] do
    if chbBold.Checked then
      FontStyle := FontStyle + [fsBold]
    else
      FontStyle := FontStyle - [fsBold];
end;

{-------------------------------------------------}

procedure TCustomizeForm.cbEditorFontChange(Sender: TObject);
begin
  with cbEditorFont do
    pnAaBbYyZz.Font.Name := Text;
end;

{-------------------------------------------------}

procedure TCustomizeForm.cbSizeChange(Sender: TObject);
begin
  with cbSize do
    pnAaBbYyZz.Font.Size := StrToInt(Text);
end;

{-------------------------------------------------}

procedure TCustomizeForm.SaveSettings;
begin
  with EasyEditSettings do
  begin
    BeginUpdate;
    try
      if cbAutoIndentMode.Checked then
        SourceOptions := SourceOptions + [srAutoIndent]
      else
        SourceOptions := SourceOptions - [srAutoIndent];
      EditOverwrite := not cbInsertMode.Checked;
      if cbUseTabCharacter.Checked then
        SourceOptions := SourceOptions + [srUseTab]
      else
        SourceOptions := SourceOptions - [srUseTab];
      if cbSmartTab.Checked then
        SourceOptions := SourceOptions + [srSmartTab]
      else
        SourceOptions := SourceOptions - [srSmartTab];
      if cbOptimalFill.Checked then
        SourceOptions := SourceOptions + [srOptimalFill]
      else
        SourceOptions := SourceOptions - [srOptimalFill];
      if cbBackspaceUnindents.Checked then
        SourceOptions := SourceOptions + [srBackUnindents]
      else
        SourceOptions := SourceOptions - [srBackUnindents];
      if cbCursorThroughTabs.Checked then
        SourceOptions := SourceOptions + [srCursorThroughTabs]
      else
        SourceOptions := SourceOptions - [srCursorThroughTabs];
      if cbGroupUndo.Checked then
        SourceOptions := SourceOptions + [srGroupUndo]
      else
        SourceOptions := SourceOptions - [srGroupUndo];
      if cbCursorBeyondEOF.Checked then
        SourceOptions := SourceOptions + [srBeyondEof]
      else
        SourceOptions := SourceOptions - [srBeyondEof];
      if cbCursorBeyondEol.Checked then
        SourceOptions := SourceOptions + [srBeyondEol]
      else
        SourceOptions := SourceOptions - [srBeyondEol];
      if cbPersistentBlocks.Checked then
        Options := Options + [eoPersistentBlocks]
      else
        Options := Options - [eoPersistentBlocks];
      if cbOverwriteBlocks.Checked then
        Options := Options + [eoOverWriteBlocks]
      else
        Options := Options - [eoOverWriteBlocks];
      if cbEnableSelection.Checked then
        Options := Options + [eoEnableSelection]
      else
        Options := Options - [eoEnableSelection];
      if cbEnableDragging.Checked then
        Options := Options + [eoEnableDragging]
      else
        Options := Options - [eoEnableDragging];
      if cbEnableSearchHighlight.Checked then
        Options := Options + [eoEnableSearchHighlight]
      else
        Options := Options - [eoEnableSearchHighlight];
      if cbDoubleClickLine.Checked then
        Options := Options + [eoDblClickLine]
      else
        Options := Options -  [eoDblClickLine];
      if cbFindTextAtCursor.Checked then
        Options := Options + [eoFindTextAtCursor]
      else
        Options := Options - [eoFindTextAtCursor];
      if cbForceCutAndCopyEnabled.Checked then
        Options := Options + [eoForceCutCopy]
      else
        Options := Options - [eoForceCutCopy];
      if chbVisibleRightMargin.Checked then
        Options := Options + [eoPaintMargin]
      else
        Options := Options - [eoPaintMargin];

      if chbVisibleGutter.Checked then
        Options := Options + [eoPaintGutter]
      else
        Options := Options - [eoPaintGutter];

      if cbKeepTrailingBlanks.Checked then
        SourceOptions := SourceOptions + [srLeaveTrailSpaces]
      else
        SourceOptions := SourceOptions - [srLeaveTrailSpaces];

      ColorMapping := TEasyColorMapping(Max(cbColorSpeedSetting.ItemIndex, 0));
      Styles.Assign(FStyles);
      TabStops := cbTabStops.Text;
      KeyMapping := TEasyKeyMapping(Max(cbEditorSpeedSetting.ItemIndex, 0));
      BlockIndent := StrToIntDef(cbBlockIndent.Text, 2);
      Font.Name := cbEditorFont.Text;
      Font.Size := StrToInt(cbSize.Text);
      Margin.Position := StrToIntDef(cbRightMargin.Text, 80);
      Gutter.Width := StrToIntDef(cbGutterWidth.Text, 32);
      if cbPaintOnGutter.Checked then
        LineNumbersOptions := LineNumbersOptions + [lnPaintOnGutter]
      else
        LineNumbersOptions := LineNumbersOptions - [lnPaintOnGutter];
      if cbPaintBeyondEof.Checked then
        LineNumbersOptions := LineNumbersOptions + [lnPaintBeyondEof]
      else
        LineNumbersOptions := LineNumbersOptions - [lnPaintBeyondEof];
      if cbTripleClickLine.Checked then
        Options := Options + [eoTripleClickLine]
      else
        Options := Options - [eoTripleClickLine];
      if cbUndoAfterSave.Checked then
        SourceOptions := SourceOptions + [srUndoAfterSave]
      else
        SourceOptions := SourceOptions - [srUndoAfterSave];
    finally
      EndUpdate;
    end;
  end;
end;

{-------------------------------------------------}

procedure TCustomizeForm.LoadSettings;
begin
  with EasyEditSettings do
  begin
    cbAutoIndentMode.Checked := srAutoIndent in SourceOptions;
    cbInsertMode.Checked := not EditOverwrite;
    cbUseTabCharacter.Checked := srUseTab in SourceOptions;
    cbSmartTab.Checked := srSmartTab in SourceOptions;
    cbOptimalFill.Checked := srOptimalFill in SourceOptions;
    cbBackspaceUnindents.Checked := srBackUnindents in SourceOptions;
    cbCursorThroughTabs.Checked := srCursorThroughTabs in SourceOptions;
    cbGroupUndo.Checked := srGroupUndo in SourceOptions;
    cbCursorBeyondEOF.Checked := srBeyondEof in SourceOptions;
    cbCursorBeyondEol.Checked := srBeyondEol in SourceOptions;
    cbKeepTrailingBlanks.Checked := srLeaveTrailSpaces in SourceOptions;
    cbPersistentBlocks.Checked := eoPersistentBlocks in Options;
    cbOverwriteBlocks.Checked := eoOverWriteBlocks in Options;
    cbEnableSelection.Checked := eoEnableSelection in Options;
    cbEnableDragging.Checked := eoEnableDragging in Options;
    cbEnableSearchHighlight.Checked := eoEnableSearchHighlight in Options;
    cbDoubleClickLine.Checked := eoDblClickLine in Options;
    cbFindTextAtCursor.Checked := eoFindTextAtCursor in Options;
    cbForceCutAndCopyEnabled.Checked := eoForceCutCopy in Options;
    cbEditorSpeedSetting.ItemIndex := Ord(KeyMapping);
    cbBlockIndent.Text := IntToStr(BlockIndent);
    cbTabStops.Text := TabStops;
    cbEditorFont.Text := Font.Name;
    cbSize.Text := IntToStr(Font.Size);
    pnAaBbYyZz.Font.Assign(Font);
    chbVisibleRightMargin.Checked := eoPaintMargin in Options;
    chbVisibleGutter.Checked := eoPaintGutter in Options;
    cbRightMargin.Text := IntToStr(Margin.Position);
    cbGutterWidth.Text := IntToStr(Gutter.Width);
    cbColorSpeedSetting.ItemIndex := Ord(ColorMapping);
    FStyles.Assign(Styles);

    cbPaintOnGutter.Checked := lnPaintOnGutter in LineNumbersOptions;
    cbPaintBeyondEof.Checked := lnPaintBeyondEof in LineNumbersOptions;
    cbTripleClickLine.Checked := eoTripleClickLine in Options;
    cbUndoAfterSave.Checked := srUndoAfterSave in SourceOptions;
  end;
end;

{-------------------------------------------------}

end.

⌨️ 快捷键说明

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