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

📄 foptions.pas

📁 Delphi编写的一个支持语法高亮显示和很多语言的文本编辑器
💻 PAS
📖 第 1 页 / 共 4 页
字号:
  chkGroupUndo.Checked := bGroupUndo;
  chkDisableScrollArrows.Checked := bDisableScrollArrows;
  cmbInsertCaret.ItemIndex :=  iInsertCaretMode;
  cmbOverWriteCaret.ItemIndex := iOverWriteCaretMode;
  chkMaximizeOnOpen.Checked := bMaximize;
  chkHIghlightTabs.Checked := bHighlightTabs;

  chkSingle.Checked := bSingleClick;

  { External Browser }
  edtExternalBrowser.Text := sExternalBrowser;

  { Editor - Display Pane }
  chkVisible.Checked := bGutterVisible;
  chkAutoSize.Checked := bGutterAutoSize;
  chkLineNum.Checked := bGutterShowLineNumbers;
  chkZero.Checked := bGutterStartAtZero;
  chkLeading.Checked := bGutterShowLeadingZeros;
  chkGutterFont.Checked := bGutterUseGutterFont;
  clrGutter.Selectioncolor := cGutterColor;

  edtRight.Text := IntToStr(iEdgeColumn);
  clrRight.SelectionColor := iEdgeColor;

  edtExtraLines.Text := IntToStr(iExtraLines);
  edtTabWidth.Text := IntToStr(iTabWidth);

  chkDefault.Checked := bUseDefault;

  chkBKeys.Checked := bBookmarkKeys;
  chkBVisible.Checked := bBookmarksVisible;

  lblEditorFont.Font := fEditorFont;
  lblEditorFont.Caption := fEditorFont.Name + ' ' + IntToStr(fEditorFont.Size) + 'pt';
  lblGutterFont.Font := fGutterFont;
  lblGutterFont.Caption := fGutterFont.Name + ' ' + IntToStr(fGutterFont.Size) + 'pt';

  // Brace highlighting
  chkMatchBrace.Checked := gbHighlightBrackets;
  clBraces.SelectionColor := gcMatchBracketColor;
  chkBraceBadLight.Checked := gbHighlightBadBrackets;
  clBadLight.SelectionColor := gcBadBracketColor;
  clMatchBack.SelectionColor := gcMatchBracketColorBack;
  clBadBack.SelectionColor := gcBadBracketColorBack;
  clTabs.SelectionColor := gcHighlightTabs;

  txtDictionary.Text := strDictionary;
  chkActive.Checked := bAutoCheck;
  chkCursor.Checked := bFromCursor;
  chkIgnoreSingle.Checked := bIgnoreSingleCharacters;
  chkIgnoreNumbers.Checked := bIgnoreNumbers;
  spnSoundExLength.Value := iHashLength;
  cpSpellPenColor.SelectionColor := gcPenColor;

  chkAutocorrectEnabled.Checked := bAEnabled;
  chkAutocorrMouseDown.Checked := bAMouseDown;
  chkAutoCorrBeep.Checked := bABeep;
  chkAutoCorrIgnoreCase.Checked := bAIgnore;
  chkAutoCorrMaintainCase.Checked := bAMaintain;

  ini := TMyReg.Create;

  with ini do begin
  OpenKey('software\cedit\tools', true);
  ToolCount := ReadReg('Count', 0);
    if ToolCount > 0 then begin
      for i := 1 to ToolCount do begin
        New(ptt);
        with lvTools.Items.Add do begin
          Caption := ReadReg('Name_' + IntToStr(i), '');
          ptt^.Name := Caption;
          ptt^.Arguments := ReadReg('Arguments_' + IntToStr(i), '');
          ptt^.ExecuteCmd := ReadReg('ECmd_' + IntToStr(i), '');
          Data := ptt;
        end;
      end;
    end;
  end;
  fAutoCorrect := TStringList.Create;

  if FileExists(ExtractFilePath(Application.ExeName) + 'autocorr.dat') then begin

    fAutoCorrect.LoadFromFile(ExtractFilePath(Application.ExeName) + 'autocorr.dat');
    for i:=0 to fAutoCorrect.Count - 1 do begin
      With lvwAutoCorrect.Items.Add do begin
        Caption := HalfString(fAutoCorrect[i], True);
        SubItems.Add(HalfString(fAutoCorrect[i], False));
      end;
    end;
  end;
  for i:= 0 to tvOptions.Items.Count - 1 do begin
    tvOptions.Items[i].Expand(False);
  end;
end;


procedure TfrmOptions.btnFontClick(Sender: TObject);
begin
  With dlgFont do begin
    Font := lblGutterFont.Font;
    Options := [fdEffects];
    if Execute then begin
      lblGutterFont.Font := dlgFont.Font;
      lblGutterFont.Caption := dlgFont.Font.Name + ' ' + InttoStr(dlgFont.Font.Size) + 'pt';
    end;
  end;

end;

procedure TfrmOptions.btnEdtFontClick(Sender: TObject);
begin
  With dlgFont do begin
    Font := lblEditorFont.Font;
    Options := [fdEffects, fdFixedPitchOnly];
    if Execute then begin
      lblEditorFont.Font := dlgFont.Font;
      lblEditorFont.Caption := dlgFont.Font.Name + ' ' + InttoStr(dlgFont.Font.Size) + 'pt';
    end;
  end;
end;

procedure TfrmOptions.lstElementClick(Sender: TObject);
var
  Attr: TSynHighlighterAttributes;
begin
  if synHighlighter = nil then exit;
  Attr := TSynHighlighterAttributes.Create('');
  Attr.Assign(synHighlighter.Attribute[lstElement.itemindex]);
  clrFore.SelectionColor := attr.Foreground;
  clrBack.SelectionColor := attr.Background;
  chkBold.Checked := (fsBold in attr.Style);
  chkItalic.Checked := (fsItalic in attr.Style);
  chkUnderline.Checked := (fsUnderline in attr.Style);
  chkStrike.Checked := (fsStrikeout in attr.Style);
end;

procedure TfrmOptions.chkBoldClick(Sender: TObject);
var
  Style: TFontStyles;
begin
  if synHighlighter <> nil then begin
    Style := [];
    if chkBold.Checked then
      Include(Style, fsBold);
    if chkItalic.Checked then
      Include(Style, fsItalic);
    if chkUnderLine.Checked then
      Include(Style, fsUnderline);
    if chkStrike.Checked then
      Include(Style, fsStrikeOut);
    synHighlighter.Attribute[lstElement.ItemIndex].Style := Style;
  end;
end;

procedure TfrmOptions.btnCancelClick(Sender: TObject);
begin
  dmMain.LoadHighlighters;
end;

procedure TfrmOptions.clrForeChange(Sender: TObject);
begin
  if synHighlighter <> nil then
    synHighlighter.Attribute[lstElement.ItemIndex].Foreground := clrFore.SelectionColor;
end;

procedure TfrmOptions.WriteOptions;
var
  Reg: TMyReg;
  i: Integer;
  AutoCorrOp:  TAsSynAutoCorrectOptions;
begin

  { Transfer All The Settings On Over to their proper boolean values. }
  { Editor - Options Pane }
  bAutoIndent := chkAutoIndent.Checked;
  bDragDropEditing := chkDDEdit.Checked;
  bDragDropFiles := chkDDFiles.Checked;
  bAltSetsColumnMode := chkAltColumn.Checked;
  bMaintainCaretColumn := chkHoldColumn.Checked;
  bWantTabs := chkWantTabs.Checked;
  bSmartTabs := chkSmartTabs.Checked;
  bSmartTabDelete := chkTabDel.Checked;
  bRightMouseMovesCursor := chkRMouseMovesCursor.Checked;
  bEnhanceHomeKey := chkEnhanceHome.Checked;
  bHideScrollbarsAsNeeded := chkHideScroll.Checked;
  bHalfPageScroll := chkHalfPage.Checked;
  bScrollByOneLess := chkScrollOneLess.Checked;
  bScrollPastEndofFile := chkScrollPastEndofFile.Checked;
  bScrollPastEndofLine := chkScrollPastEndofLine.Checked;
  bShowScrollHint := chkShowScrollHint.Checked;
  bScrollHintFollowsMouse := chkScrollHintFollowsMouse.Checked;
  bTabsToSpaces := chkTabsToSpaces.Checked;
  bTrimTrailingSpaces := chkTrimTrailingSpaces.Checked;
  bGroupUndo := chkGroupUndo.Checked;
  bDisableScrollArrows := chkDisableScrollArrows.Checked;
  iInsertCaretMode := cmbInsertCaret.ItemIndex;
  iOverWriteCaretMode := cmbOverWriteCaret.ItemIndex;
  bMaximize := chkMaximizeOnOpen.Checked;
  bHighlightTabs := chkHighlightTabs.Checked;
  gcHighlightTabs := clTabs.SelectionColor;

  bSingleClick := chkSingle.Checked;

  { Editor - Display Pane }
  bGutterVisible := chkVisible.Checked;
  bGutterAutoSize := chkAutoSize.Checked;
  bGutterShowLineNumbers := chkLineNum.Checked;
  bGutterStartAtZero := chkZero.Checked;
  bGutterShowLeadingZeros := chkLeading.Checked;
  bGutterUseGutterFont := chkGutterFont.Checked;
  cGutterColor := Integer(clrGutter.SelectionColor);

  iEdgeColumn := StrToInt(edtRight.Text);
  iEdgecolor := Integer(clrRight.SelectionColor);
  iExtraLines := StrToInt(edtExtraLines.Text);
  iTabWidth := StrToInt(edtTabWidth.Text);

  bBookmarkKeys := chkBKeys.Checked;
  bBookmarksVisible := chkBVisible.Checked;

  fEditorFont := lblEditorFont.Font;
  fGutterFont := lblGutterFont.Font;

  gbHighlightBrackets := chkMatchBrace.Checked;
  gcMatchBracketColor := Integer(clBraces.SelectionColor);
  gbHighlightBadBrackets := chkBraceBadLight.Checked;
  gcBadBracketColor := Integer(clBadLight.SelectionColor);
  gcMatchBracketColorBack := Integer(clMatchBack.SelectionColor);
  gcBadBracketColorBack := Integer(clBadBack.SelectionColor);

  sDefaultHighlighter := cmbLangs.Text;

  strDictionary := txtDictionary.Text;
  bAutoCheck := chkActive.Checked;
  bFromCursor := chkCursor.Checked;
  bIgnoreSingleCharacters := chkIgnoreSingle.Checked;
  bIgnoreNumbers := chkIgnoreNumbers.Checked;
  iHashLength := spnSoundExLength.Value;
  gcPenColor := cpSpellPenColor.SelectionColor;
  sCheckWhat := mCheckAttribs.Text;

  bAEnabled := chkAutocorrectEnabled.Checked;
  bAMouseDown := chkAutocorrMouseDown.Checked;
  bABeep := chkAutoCorrBeep.Checked;
  bAIgnore := chkAutoCorrIgnoreCase.Checked;
  bAMaintain := chkAutoCorrMaintainCase.Checked;

  sExternalBrowser := edtExternalBrowser.Text;

  { Write it all out now }

  { Editor - General Options }
  Reg := TMyReg.Create;
  { Editor - General Options }
  Reg.OpenKey('software\cedit\settings', True);
  Reg.WriteReg('bAutoIndent', bAutoIndent);
  Reg.WriteReg('bMaximize', bMaximize);
  Reg.WriteReg('bDragDropEditing', bDragDropEditing);
  Reg.WriteReg('bSingleClick', bSingleClick);
  Reg.WriteReg('bDragDropFiles', bDragDropFiles);
  Reg.WriteReg('bAltSetscolumnMode', bAltSetsColumnMode);
  Reg.WriteReg('bMaintainCaretColumn', bMaintainCaretColumn);
  Reg.WriteReg('bWantTabs', bWantTabs);
  Reg.WriteReg('bSmartTabs', bSmartTabs);
  Reg.WriteReg('bSmartTabDelete', bSmartTabDelete);
  Reg.WriteReg('bRightMouseMovesCursor', bRightMouseMovesCursor);
  Reg.WriteReg('bEnhanceHomeKey', bEnhanceHomeKey);
  Reg.WriteReg('bHideScrollBarsAsNeeded', bHideScrollBarsAsNeeded);
  Reg.WriteReg('bHalfPageScroll', bHalfPageScroll);
  Reg.WriteReg('bScrollbyOneLess', bScrollbyOneLess);
  Reg.WriteReg('bScrollPastEndofFile', bScrollPastEndofFile);
  Reg.WriteReg('bScrollPastEndofLine', bScrollPastEndofLine);
  Reg.WriteReg('bShowScrollHint', bShowScrollHint);
  Reg.WriteReg('bScrollHintFollowsMouse', bScrollHintFollowsMouse);
  Reg.WriteReg('bTabsToSpaces', bTabsToSpaces);
  Reg.WriteReg('bTrimTrailingSpaces', bTrimTrailingSpaces);
  Reg.WriteReg('bGroupUndo', bGroupUndo);
  Reg.WriteReg('bDisableScrollArrows', bDisableScrollArrows);
  Reg.WriteInteger('iInsertCaretMode', iInsertCaretMode);
  Reg.WriteInteger('iOverwriteCaretMode', iOverWriteCaretMode);
   { Editor - Gutter Options }
  Reg.WriteReg('bGuttervisible', bGutterVisible);
  Reg.WriteReg('bGutterAutoSize', bGutterAutoSize);
  Reg.WriteReg('bGutterShowLineNumbers', bGutterShowLineNumbers);
  Reg.WriteReg('bGutterStartAtZero', bGutterStartAtZero);
  Reg.WriteReg('bGutterShowLeadingZeros', bGutterShowLeadingZeros);
  Reg.WriteReg('bGutterUseGutterFont', bGutterUseGutterFont);
  Reg.WriteReg('bGutterBold', fsBold in lblGutterFont.Font.Style);
  Reg.WriteReg('bGutterItalic', fsItalic in lblGutterFont.Font.Style);
  Reg.WriteReg('bGutterStrikeOut', fsStrikeOut in lblGutterFont.Font.Style);
  Reg.WriteReg('bGutterUnderline', fsUnderline in lblGutterFont.Font.Style);
  Reg.WriteInteger('iGutterSize', lblGutterFont.Font.Size);
  Reg.WriteString('sGutterName', lblGutterFont.Font.Name);

  { Brace lighting }
  Reg.WriteInteger('BracketColor', gcMatchBracketColor);
  Reg.WriteReg('BraceColor', gbHighlightBrackets);
  Reg.WriteInteger('BadBracketColor', gcBadBracketColor);
  Reg.WriteInteger('BracketColorBack', gcMatchBracketColorBack);
  Reg.WriteInteger('BadBracketColorBack', gcBadBracketColorBack);

  Reg.WriteReg('BadBraceColor', gbHighlightBadBrackets);

  { External Browser }
  Reg.WriteReg('ExternalBrowser', sExternalBrowser);


  { Default Language }
  Reg.WriteReg('sDefaultHighlighter', sDefaultHighlighter);
  Reg.WriteReg('bDefaultHighlighter', bUseDefault);

  { Highlight Tabs }
  Reg.WriteReg('bHighlightTabs', bHighlightTabs);
  Reg.WriteReg('gcHighlightTabs', gcHighlightTabs);

  Reg.WriteInteger('cGutterColor', cGutterColor);
  { Editor - Right Edge Options }
  Reg.WriteInteger('iEdgeColumn', iEdgeColumn);
  Reg.WriteInteger('iEdgeColor', iEdgeColor);
  { Editor - Line/Tab Spacing Options }
  Reg.WriteInteger('iExtraLines', iExtraLines);
  Reg.WriteInteger('iTabWidth', iTabWidth);
  { Editor - Bookmark Options }
  Reg.WriteReg('bBookmarkKeys', bBookmarkKeys);
  Reg.WriteReg('bBookmarksVisible', bBookmarksVisible);
  { Editor - Main }
  Reg.WriteReg('bEditorBold', fsBold in lblEditorFont.Font.Style);
  Reg.WriteReg('bEditorItalic', fsItalic in lblEditorFont.Font.Style);
  Reg.WriteReg('bEditorStrikeOut', fsStrikeOut in lblEditorFont.Font.Style);
  Reg.WriteReg('bEditorUnderline', fsUnderline in lblEditorFont.Font.Style);
  Reg.WriteInteger('iEditorSize', lblEditorFont.Font.Size);
  Reg.WriteString('sEditorName', lblEditorFont.Font.Name);

  Reg.WriteString('strDictionary', strDictionary);
  reg.WriteReg('bAutoCheck', bAutoCheck);
  reg.WriteReg('bFromCursor', bFromCursor);
  reg.WriteReg('bIgnoreSingleCharacters', bIgnoreSingleCharacters);
  reg.WriteReg('bIgnoreNumbers', bIgnoreNumbers);
  reg.WriteInteger('iHashLength', iHashLength);
  reg.WriteInteger('gcPenColor', gcPenColor);

  reg.WriteReg('bAEnabled', bAEnabled);
  reg.WriteReg('bAMouseDown', bAMouseDown);
  reg.WriteReg('bABeep', bABeep);
  reg.WriteReg('bAIgnore', bAIgnore);
  reg.WriteReg('bAMaintain', bAMaintain);
  fAutoCorrect.SaveToFile(ExtractfilePath(Application.exename) + 'autocorr.dat');
  fAutoCorrect.Free;
//  reg.WriteReg('Options','sCheckWhat', sCheckWhat);

  With Reg do begin
      CloseKey;
      OpenKey('Software\cEdit\Tools', True);
      WriteInteger('Count', lvTools.Items.Count);
      for i := 1 to lvTools.Items.Count do begin
        with PToolType(lvTools.Items[i - 1].Data)^ do begin
          WriteReg('Name_' + IntToStr(i), Name);
          WriteReg('Arguments_' + IntToStr(i), Arguments);
          WriteReg('ECmd_' + IntToStr(i), ExecuteCmd);
        end;
      end;
  end;
  With dmMain.synSpell do begin
    if (strDictionary <> dmMain.synSpell.Dictionary) and FileExists(strDictionary) then
      LoadDictionary('', strDictionary);
      if bAutoCheck = True then
        Options := Options + [sscoAutoSpellCheck]
      else
        Options := Options - [sscoAutoSpellCheck];
      if bFromCursor = True then
        Options := Options + [sscoStartFromCursor]
      else
        Options := Options - [sscoStartFromCursor];
      if bIgnoreSingleCharacters = True then
        Options := Options + [sscoIgnoreSingleChars]
      else
        Options := Options - [sscoIgnoreSingleChars];
      if bIgnoreNumbers = True then
        Options := Options + [sscoIgnoreWordsWithNumbers]
      else
        Options := Options - [sscoIgnoreWordsWithNumbers];
      PenColor := gcPenColor;
      HashLength := iHashLength;
  end;

  dmMain.WriteFunctions;
  if bAEnabled then begin
    with dmMain.SynAutoCorrect do begin
      Enabled := true;
      if FileExists(ExtractFilePath(Application.exename) + 'autocorr.dat') then
        LoadFromList(ExtractFilePath(Application.exename) + 'autocorr.dat');
      if bAMouseDown then
        Include(AutoCorrOp, ascoCorrectOnMouseDown);
      {if bABeep then
        Include(AutoCorrOp, ascoSoundOnCorrect);}
      if bAIgnore then
        Include(AutoCorrOp, ascoIgnoreCase);
      if bAMaintain then
        Include(AutoCorrOp, ascoMaintainCase);
      Options := AutoCorrOp;
    end;
  end;


end;

procedure TfrmOptions.clrBackChange(Sender: TObject);
begin
  if synHighlighter <> nil then
    synHighlighter.Attribute[lstElement.ItemIndex].Background := Integer(clrBack.SelectionColor);
end;

procedure TfrmOptions.btnOKClick(Sender: TObject);

var
  i: integer;
begin
  dmMain.SaveHighlighters;
  WriteOptions;
  frmMain.LoadTools;
  For i := 0 to frmMain.MDIChildCount - 1 do begin
    if frmMain.MDIChildren[i] is TfrmDoc then
      (frmMain.MDIChildren[i] as TfrmDoc).LoadSettings;
  end;

end;

procedure TfrmOptions.SpeedButton1Click(Sender: TObject);
var
  ptt: PToolType;
begin
  New(ptt);
  with lvTools.Items.Add do begin
    Caption := SNewTool;
    ImageIndex := -1;
    ptt^.Name := Caption;
    ptt^.ExecuteCmd := '';
    Data := ptt;
    EditCaption;
  end;
end;

procedure TfrmOptions.lvToolsExit(Sender: TObject);
begin
  if not btnOK.Default then begin
    btnOK.Default := true;
    btnCancel.Cancel := true;
  end;
end;

procedure TfrmOptions.lvToolsEditing(Sender: TObject; Item: TListItem;
  var AllowEdit: Boolean);

⌨️ 快捷键说明

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