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

📄 uoptions.pas

📁 delphi 写的delphi的程序 Handel is a free, standalone development tool created with Delphi 3 that enable
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit UOptions;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, ComCtrls, Buttons, ColorGrd, Menus, mwHighlighter,
  mwPasSyn, mwCustomEdit;

type
  TOptions = class(TForm)
    Panel1: TPanel;
    HelpButton: TButton;
    OKButton: TButton;
    Button2: TButton;
    Panel2: TPanel;
    PageControl1: TPageControl;
    PrefPage: TTabSheet;
    GroupBox1: TGroupBox;
    rbDesktopOnly: TRadioButton;
    rbSaveSymbols: TRadioButton;
    GroupBox2: TGroupBox;
    cbASEditor: TCheckBox;
    cbASDesktop: TCheckBox;
    GroupBox3: TGroupBox;
    lbGridX: TLabel;
    lbGridY: TLabel;
    cbDisplayGrid: TCheckBox;
    cbSnapToGrid: TCheckBox;
    ecGridSizeX: TEdit;
    ecGridSizeY: TEdit;
    cbShowComponentCaptions: TCheckBox;
    GroupBox4: TGroupBox;
    cbIntegratedDebugging: TCheckBox;
    cbDebugMainBlock: TCheckBox;
    cbBreakOnException: TCheckBox;
    GroupBox17: TGroupBox;
    lbReposDir: TLabel;
    DelphiPath: TEdit;
    RepositoryBtn: TButton;
    GroupBox12: TGroupBox;
    cbShowProgress: TCheckBox;
    cbCompileMessage: TCheckBox;
    cbMinimizeOnRun: TCheckBox;
    cbHideDesigners: TCheckBox;
    CompilerPage: TTabSheet;
    EditorPage: TTabSheet;
    lbUndo: TLabel;
    Label5: TLabel;
    lbBlockInd: TLabel;
    Label6: TLabel;
    Label21: TLabel;
    GroupBox5: TGroupBox;
    eoIndent: TCheckBox;
    eoInsert: TCheckBox;
    eoUseTabChar: TCheckBox;
    eoOptimalFill: TCheckBox;
    eoOutdent: TCheckBox;
    eoCursorInTabs: TCheckBox;
    eoGroupUndo: TCheckBox;
    eoCursorBeyondEOF: TCheckBox;
    eoUndoAfterSave: TCheckBox;
    eoKeepTrailingBlanks: TCheckBox;
    eoBriefRegExp: TCheckBox;
    eoPersistentBlocks: TCheckBox;
    eoOverwriteBlocks: TCheckBox;
    eoDoubleClickLine: TCheckBox;
    eoFindTextAtCursor: TCheckBox;
    eoHighlight: TCheckBox;
    eoForceCutCopyEnabled: TCheckBox;
    eoSmartTab: TCheckBox;
    eoBlockIndent: TComboBox;
    eoUndoLimit: TComboBox;
    eoTabRack: TComboBox;
    eoHighlightExts: TComboBox;
    SpeedSetting: TComboBox;
    EdDispPage: TTabSheet;
    Label4: TLabel;
    Label7: TLabel;
    Label11: TLabel;
    Label16: TLabel;
    GroupBox11: TGroupBox;
    lbRightMargin: TLabel;
    lbGutterWidth: TLabel;
    eoLineOnMargin: TCheckBox;
    eoRightMargin: TComboBox;
    eoGutterWidth: TComboBox;
    eoVisibleGutter: TCheckBox;
    GroupBox10: TGroupBox;
    eoBriefCursors: TCheckBox;
    eoCreateBackup: TCheckBox;
    eoPreserveLineEnds: TCheckBox;
    eoFullZoom: TCheckBox;
    FontName: TComboBox;
    FontSize: TComboBox;
    eoBindingList: TListBox;
    FontSample: TPanel;
    EdColorPage: TTabSheet;
    Label8: TLabel;
    Label9: TLabel;
    EditControlHere: TLabel;
    Label22: TLabel;
    ElementList: TListBox;
    GroupBox6: TGroupBox;
    Bold: TCheckBox;
    Italic: TCheckBox;
    Underline: TCheckBox;
    GroupBox7: TGroupBox;
    DefaultFore: TCheckBox;
    DefaultBack: TCheckBox;
    ColorSpeedSetting: TComboBox;
    ColorGrid: TColorGrid;
    PalPage: TTabSheet;
    PageLabel: TLabel;
    ToolLabel: TLabel;
    PageListBox: TListBox;
    AddButton: TButton;
    DeleteButton: TButton;
    RenameButton: TButton;
    ResetPaletteBtn: TButton;
    ToolListPanel: TPanel;
    ToolListHeader: THeaderControl;
    ToolListBox: TListBox;
    MoveUp: TButton;
    MoveDn: TButton;
    BrowPage: TTabSheet;
    GroupBox8: TGroupBox;
    cbConstants: TCheckBox;
    cbTypes: TCheckBox;
    cbVariables: TCheckBox;
    cbFunctions: TCheckBox;
    cbProperties: TCheckBox;
    cbInherited: TCheckBox;
    cbNonVirtual: TCheckBox;
    cbPrivate: TCheckBox;
    cbProtected: TCheckBox;
    cbPublic: TCheckBox;
    cbPublished: TCheckBox;
    GroupBox15: TGroupBox;
    rbObjects: TRadioButton;
    rbUnits: TRadioButton;
    rbGlobals: TRadioButton;
    GroupBox9: TGroupBox;
    cbQualifiedSymbols: TCheckBox;
    cbSortAlways: TCheckBox;
    GroupBox16: TGroupBox;
    Label12: TLabel;
    CollapseNodes: TComboBox;
    CodeInsight: TTabSheet;
    GroupBox14: TGroupBox;
    Label13: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    cbCodeCompletion: TCheckBox;
    DelayAmount: TTrackBar;
    cbCodeParameters: TCheckBox;
    cbEvalHints: TCheckBox;
    GroupBox13: TGroupBox;
    Label1: TLabel;
    CodeLabel: TLabel;
    CodeList: TListView;
    AddTemplateBtn: TButton;
    EditTemplateBtn: TButton;
    DeleteTemplateBtn: TButton;
    EnvDlgPopup: TPopupMenu;
    dNextPage: TMenuItem;
    dPrevPage: TMenuItem;
    gbAlterCompiler: TGroupBox;
    edFPC: TEdit;
    btnBrowse: TButton;
    OpenDialog1: TOpenDialog;
    GroupBox18: TGroupBox;
    rbDelphiCompiler: TRadioButton;
    rbFPC: TRadioButton;
    Label2: TLabel;
    CheckBox1: TCheckBox;
    GroupBox19: TGroupBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    CheckBox4: TCheckBox;
    CheckBox5: TCheckBox;
    GroupBox20: TGroupBox;
    CheckBox6: TCheckBox;
    CheckBox7: TCheckBox;
    CheckBox8: TCheckBox;
    CheckBox9: TCheckBox;
    Label3: TLabel;
    ComboBox1: TComboBox;
    GroupBox21: TGroupBox;
    CheckBox10: TCheckBox;
    CheckBox11: TCheckBox;
    Label10: TLabel;
    edOtherFPCOpt: TEdit;
    PasEdit1: TmwCustomEdit;
    PasSyn: TmwPasSyn;
    CodeEdit: TmwCustomEdit;
    cbUnitOnly: TCheckBox;
    procedure FormCreate(Sender: TObject);
    procedure RepositoryBtnClick(Sender: TObject);
    procedure FontSizeClick(Sender: TObject);
    procedure OKButtonClick(Sender: TObject);
    procedure HelpButtonClick(Sender: TObject);
    procedure chkCompilerClick(Sender: TObject);
    procedure btnBrowseClick(Sender: TObject);
    procedure PageListBoxClick(Sender: TObject);
    procedure ToolListBoxDrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    procedure rbFPCClick(Sender: TObject);
    procedure ElementListClick(Sender: TObject);
    procedure ColorGridChange(Sender: TObject);
    procedure BoldClick(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
    procedure CodeListChange(Sender: TObject; Item: TListItem;
      Change: TItemChange);
    procedure DeleteTemplateBtnClick(Sender: TObject);
    procedure AddTemplateBtnClick(Sender: TObject);
  private
    { Private declarations }
    CodeTempList: TStringList;          // code template file list
    procedure GetFontNames;
    procedure DeleteCodeTemplate(Code:string);
    procedure AddCodeTemplate;
  public
    { Public declarations }
    procedure GetPaletteOptions;
  end;

var
  Options: TOptions;

implementation

uses Uconst,FileCtrl, utils, Editor, MainForm, ADDCODET;

{$R *.DFM}

function IsCodeHeader(const Source:string):Boolean ;
begin
   Result:= False;
   if Source = '' then Exit;
   if (Source[1] <> '=') then Result:= True;
end;

procedure TOptions.FormCreate(Sender: TObject);
var
  Index:Integer;
  Name:string;
begin
   if PageControl1.PageCount = 1 then Exit;
   // PageControl1.ActivePage:= PrefPage;
    GetFontNames;
    DelphiPath.Text:=IniFile.ReadString('SYSTEM','DELPHI','');
    Name:= IniFile.ReadString('EDITOR','FontName','Arial');
    Index:= FontName.Items.IndexOf(Name);
    if Index <> -1 then FontName.ItemIndex:= Index;
    with IniFile do begin
       FontSample.Font.Name       := ReadString ('EDITOR'     ,'FontName'       ,'Courier New');
       FontSample.Font.Size       := ReadInteger('EDITOR'     ,'FontSize'       ,10);
       PasEdit1.Font.Name         := ReadString ('EDITOR'     ,'FontName'       ,'Arial');
       PasEdit1.Font.Size         := ReadInteger('EDITOR'     ,'FontSize'       ,10);
       PasEdit1.Color             := ReadInteger('EDITOR'     ,'BackColor'      ,clWhite);
       cbDisplayGrid.Checked      := ReadBool   ('SYSTEM'     ,'DisplayGrid'    ,True);
       eoFindTextAtCursor.Checked := ReadBool   ('EDITOR'     ,'FindTextCursor' ,True);
       cbSnapToGrid.Checked       := ReadBool   ('SYSTEM'     ,'SnapGrid'       ,True);
       eoHighLight.Checked        := ReadBool   ('EDITOR'     ,'HighLight'      ,True);
       rbDelphiCompiler.Checked   := ReadBool   ('SYSTEM'     ,'DefaultCompiler',True);
       edFPC.Text                 := ReadString ('Compiler'   ,'FPC'            ,'');
       edOtherFPCOpt.Text         := ReadString ('Compiler'   ,'OtherOption'    , '');
       PasEdit1.Color             := ReadInteger('EditorColor','WhiteSpace'     , clWhite);
       cbUnitOnly.Checked         := ReadBool   ('SYSTEM','UnitOnly'            , False);
       rbFPC.Checked              := not ReadBool('SYSTEM','DefaultCompiler',True);
       FontSize.Text              := IntToStr(ReadInteger('EDITOR','FONTSIZE' ,10));
       ecGridSizeX.Text           := IntToStr(ReadInteger('SYSTEM','GridSizeX',8));
       ecGridSizeY.Text           := IntToStr(ReadInteger('SYSTEM','GridSizeY',8));
        with PasSyn do
        begin
           AsmAttri.Background       :=
              MakeCommaTextToColor(ReadString('EditorColor','AsmAttri','')       , 1, clWhite);
           AsmAttri.Foreground       :=
              MakeCommaTextToColor(ReadString('EditorColor','AsmAttri','')       , 0, clBlack);
           CommentAttri.Background       :=
              MakeCommaTextToColor(ReadString('EditorColor','CommentAttri','')   , 1, clWhite);
           CommentAttri.Foreground       :=
              MakeCommaTextToColor(ReadString('EditorColor','CommentAttri','')   , 0, clBlack);
           IdentifierAttri.Background       :=
              MakeCommaTextToColor(ReadString('EditorColor','IdentifierAttri',''), 1, clWhite);
           IdentifierAttri.Foreground       :=
              MakeCommaTextToColor(ReadString('EditorColor','IdentifierAttri',''), 0, clBlack);
           KeyAttri.Background       :=
              MakeCommaTextToColor(ReadString('EditorColor','KeyAttri','')       , 1, clWhite);
           KeyAttri.Foreground       :=
              MakeCommaTextToColor(ReadString('EditorColor','KeyAttri','')       , 0, clBlack);
           NumberAttri.Background       :=
              MakeCommaTextToColor(ReadString('EditorColor','NumberAttri','')    , 1, clWhite);
           NumberAttri.Foreground       :=
              MakeCommaTextToColor(ReadString('EditorColor','NumberAttri','')    , 0, clBlack);
           SpaceAttri.Background       :=
              MakeCommaTextToColor(ReadString('EditorColor','SpaceAttri','')     , 1, clWhite);
           SpaceAttri.Foreground       :=
              MakeCommaTextToColor(ReadString('EditorColor','SpaceAttri','')     , 0, clBlack);
           StringAttri.Background       :=
              MakeCommaTextToColor(ReadString('EditorColor','StringAttri','')    , 1, clWhite);
           StringAttri.Foreground       :=
              MakeCommaTextToColor(ReadString('EditorColor','StringAttri','')    , 0, clBlack);
           SymbolAttri.Background       :=
              MakeCommaTextToColor(ReadString('EditorColor','SymbolAttri','')    , 1, clWhite);
           SymbolAttri.Foreground       :=
              MakeCommaTextToColor(ReadString('EditorColor','SymbolAttri','')    , 0, clBlack);
        end;
    end;
    with ColorGrid do
       ForegroundIndex:= ColorToIndex(IniFile.ReadInteger('EDITOR','BackColor',clWhite));
   if not FileExists(FilePath+CodeTemplateName) then Exit;
   CodeTempList:= TStringList.Create;
   CodeTempList.LoadFromFile(FilePath+CodeTemplateName);
end;

function EnumFontsProc(var LogFont: TLogFont; var TextMetric: TTextMetric;
  FontType: Integer; Data: Pointer): Integer; stdcall;
begin
   TStrings(Data).Add(LogFont.lfFaceName);
   Result := 1;
end;

procedure TOptions.GetFontNames;
var
   DC: HDC;
begin
   DC := GetDC(0);
   EnumFonts(DC, nil, @EnumFontsProc, Pointer(FontName.Items));
   ReleaseDC(0, DC);
   FontName.Sorted := True;
end;

procedure TOptions.RepositoryBtnClick(Sender: TObject);
var
  Dir:string;
begin
  Dir:=  DelphiPath.Text;
  if SelectDirectory(Dir, [sdAllowCreate, sdPerformCreate, sdPrompt],0) then
    DelphiPath.Text := Dir;
end;

procedure TOptions.FontSizeClick(Sender: TObject);
begin
    FontSample.Font.Name:= FontName.Text;
    FontSample.Font.Size:= StrToInt(FontSize.Text);
end;

procedure TOptions.OKButtonClick(Sender: TObject);
   function MakeCommaText(Fore, Back: Integer; Bold, Italic, Underline:Boolean): string;
   begin
      Result:= Format('%d, %d, %d, %d, %d', [Fore, Back, Ord(Bold), Ord(Italic), Ord(Underline)]);
   end;
begin
    with IniFile do begin
        WriteString ('SYSTEM'     ,'DELPHI'         , DelphiPath.Text);
        WriteString ('EDITOR'     ,'FONTNAME'       , FontName.Text);
        WriteInteger('EDITOR'     ,'FONTSIZE'       , StrToInt(FontSize.Text));
        WriteBool   ('EDITOR'     ,'HighLight'      , eoHighLight.Checked);
        WriteBool   ('EDITOR'     ,'FindTextCursor' , eoFindTextAtCursor.Checked);
        WriteBool   ('SYSTEM'     ,'DisplayGrid'    , cbDisplayGrid.Checked);
        WriteBool   ('SYSTEM'     ,'SnapGrid'       , cbSnapToGrid.Checked);
        WriteBool   ('SYSTEM'     ,'DefaultCompiler', rbDelphiCompiler.Checked);
        WriteBool   ('SYSTEM'     ,'UnitOnly'       , cbUnitOnly.Checked);
        WriteInteger('SYSTEM'     ,'GridSizeX'      , StrToInt(ecGridSizeX.Text));
        WriteInteger('SYSTEM'     ,'GridSizeY'      , StrToInt(ecGridSizeY.Text));
        WriteString ('Compiler'   ,'FPC'            , edFPC.Text);
        WriteString ('Compiler'   ,'OtherOption'    , edOtherFPCOpt.Text);
        WriteInteger('EditorColor','WhiteSpace'     , PasEdit1.Color);
        with PasSyn do
        begin
           WriteString('EditorColor','AsmAttri',
                        MakeCommaText(AsmAttri.Foreground, AsmAttri.Background,
                                      fsBold in AsmAttri.Style, fsItalic in AsmAttri.Style,
                                      fsUnderline in AsmAttri.Style ));
           WriteString('EditorColor','CommentAttri',
                        MakeCommaText(CommentAttri.Foreground, CommentAttri.Background,
                                      fsBold in CommentAttri.Style, fsItalic in CommentAttri.Style,
                                      fsUnderline in CommentAttri.Style ));
           WriteString('EditorColor','IdentifierAttri',
                        MakeCommaText(IdentifierAttri.Foreground, IdentifierAttri.Background,
                                      fsBold in IdentifierAttri.Style, fsItalic in IdentifierAttri.Style,
                                      fsUnderline in IdentifierAttri.Style ));
           WriteString('EditorColor','KeyAttri',
                        MakeCommaText(KeyAttri.Foreground, KeyAttri.Background,
                                      fsBold in KeyAttri.Style, fsItalic in KeyAttri.Style,
                                      fsUnderline in KeyAttri.Style ));
           WriteString('EditorColor','NumberAttri',
                        MakeCommaText(NumberAttri.Foreground, NumberAttri.Background,
                                      fsBold in NumberAttri.Style, fsItalic in NumberAttri.Style,
                                      fsUnderline in NumberAttri.Style ));
           WriteString('EditorColor','SpaceAttri',
                        MakeCommaText(SpaceAttri.Foreground, SpaceAttri.Background,
                                      fsBold in SpaceAttri.Style, fsItalic in SpaceAttri.Style,
                                      fsUnderline in SpaceAttri.Style ));
           WriteString('EditorColor','StringAttri',
                        MakeCommaText(StringAttri.Foreground, StringAttri.Background,
                                      fsBold in StringAttri.Style, fsItalic in StringAttri.Style,
                                      fsUnderline in StringAttri.Style ));
           WriteString('EditorColor','SymbolAttri',
                        MakeCommaText(SymbolAttri.Foreground, SymbolAttri.Background,
                                      fsBold in SymbolAttri.Style, fsItalic in SymbolAttri.Style,
                                      fsUnderline in SymbolAttri.Style ));
        end;
        FMainForm.ReadEnvirionment;
    end;

⌨️ 快捷键说明

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