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

📄 delexpert.pas

📁 delphi代码格式化,最新汉化版
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    Result := nil;
    if Assigned(BorlandIDEServices)
      and Supports(BorlandIDEServices, IOTAModuleServices, SVC) then
    begin
      if AFileName = '' then
        Result := SVC.CurrentModule
      else Result := SVC.FindModule(AFileName);
    end;
  end;

  procedure SaveBreakPoint;
  var DebugSvs: IOTADebuggerServices;
    i: Integer;
  begin
    if Assigned(BorlandIDEServices)
      and Supports(BorlandIDEServices, IOTADebuggerServices, DebugSvs) then
    begin
      SetLength(BreakPoints, DebugSvs.SourceBkptCount);
      for i := 0 to DebugSvs.SourceBkptCount - 1 do
      begin
        BreakPoints[i].StackFramesToLog := DebugSvs.SourceBkpts[i].StackFramesToLog;
        BreakPoints[i].DoHandleExceptions := DebugSvs.SourceBkpts[i].DoHandleExceptions;
        BreakPoints[i].DoIgnoreExceptions := DebugSvs.SourceBkpts[i].DoIgnoreExceptions;
        BreakPoints[i].GroupName := DebugSvs.SourceBkpts[i].GroupName;
        BreakPoints[i].DoBreak := DebugSvs.SourceBkpts[i].DoBreak;
        BreakPoints[i].LogMessage := DebugSvs.SourceBkpts[i].LogMessage;
        BreakPoints[i].EvalExpression := DebugSvs.SourceBkpts[i].EvalExpression;
        BreakPoints[i].LogResult := DebugSvs.SourceBkpts[i].LogResult;
        BreakPoints[i].EnableGroup := DebugSvs.SourceBkpts[i].EnableGroup;
        BreakPoints[i].DisableGroup := DebugSvs.SourceBkpts[i].DisableGroup;
        BreakPoints[i].Enabled := DebugSvs.SourceBkpts[i].Enabled;
        BreakPoints[i].Expression := DebugSvs.SourceBkpts[i].Expression;
        BreakPoints[i].FileName := DebugSvs.SourceBkpts[i].FileName;
        BreakPoints[i].LineNumber := DebugSvs.SourceBkpts[i].LineNumber;
        BreakPoints[i].PassCount := DebugSvs.SourceBkpts[i].PassCount;
      end;
    end;
  end;
var MyDDD: IOTAModule;
  i: Integer;
begin
  ISourceEditor := nil;
  MyDDD := GetTheModule;
  if Assigned(MyDDD) then
    ISourceEditor := MyDDD.CurrentEditor as IOTASourceEditor;
  if Assigned(ISourceEditor) and (ISourceEditor.EditViewCount > 0) then
  begin
    FCurPos := ISourceEditor.EditViews[0].CursorPos;
    for i := 0 to 19 do
    begin
      Bookmarks[i].Exists := False;
      if ISourceEditor.EditViews[0].BookmarkGoto(i) then
      begin
        Bookmarks[i].BookMarkNo := i;
        Bookmarks[i].Exists := True;
        Bookmarks[i].FPos := ISourceEditor.EditViews[0].CursorPos;
      end;
    end;
  end;
  SaveBreakPoint;
end;

procedure TDelExpertDlg.DoFormatFile(AFileName: string);
{.$define tmpFile}
{$IFDEF tmpFile}
const
  TmpFile = 'DELFOR.~$$';
var
  P1: PChar;
  Tmp: file;
  LenP: Integer;
{$ENDIF}
var
  IDEStream: TIDEStream;
  P: PChar;
  bReadOnly: boolean;
begin
  if (ProgressDlg.Visible) then
  begin
    BeforeFormat(AFileName);
    IDEStream := TIDEStream.Create(AFileName);
    try
      try
        OtaAssertSourceEditorNotReadOnly(OtaGetCurrentSourceEditor);
        bReadOnly := false;
      except
        bReadOnly := True;
      end;
      if (not IsReadonlyFile(IDEStream.FileName)) and (not bReadOnly) then
      begin
        Formatter.Clear;
        ProgressDlg.SetFileName(IDEStream.FileName);
        Application.ProcessMessages;
{$IFNDEF tmpFile}
        Formatter.LoadFromList(IDEStream.Lines);
        IDEStream.Lines.Clear;
{$ELSE}
        P1 := IDEStream.GetText;
        if P1 <> nil then
        begin
          LenP := StrLen(P1);
          if LenP > $8FFF then
          begin
            AssignFile(Tmp, TmpFile);
            Rewrite(Tmp, 1);
            BlockWrite(Tmp, P1^, LenP);
            CloseFile(Tmp);
            Formatter.LoadFromFile(TmpFile);
            Erase(Tmp);
          end
          else
            Formatter.Text := P1; {GetTextStr is very slow
          for large strings}
        end
{$ENDIF}
          if Formatter.Parse then
          begin
            P := PChar(Formatter.Text);
            IDEStream.WriteText(P);
          end;
      end
      else
        ShowMessage(ExtractFileName(IDEStream.FileName) +
          ': File or buffer is read only, or not yet saved');
    finally
      Formatter.Clear;
      IDEStream.Free;
      AfterFormat;
    end;
  end;
end;

procedure TDelExpertDlg.FormCreate(Sender: TObject);
var
  DelForName: string;
begin
  DelForName := GetDelForName;
  if DelForName <> '' then
  begin
    if Formatter = nil then
      Formatter := TPascalParser.Create(PChar(ExtractFilePath(DelForName)));
    Formatter.OnProgress := FormatterProgress;
    HelpFile := Formatter.RootDir + 'DelFor.hlp';
    CfgFile := Formatter.RootDir + ExtractFileName(DelForName);
    ChangeFileExt(CfgFile, '.cfg');
  end
  else
  begin
    if Formatter = nil then
      Formatter := TPascalParser.Create('');
    HelpFile := 'DelFor.hlp';
    CfgFile := '';
  end;
  Formatter.CfgFile := CfgFile;
  Formatter.Config(True);
  if ProgressDlg = nil then
    ProgressDlg := TProgressDlg.Create(Application);
  ActiveControl := CurrentBtn;
  Formatter.Deactivate;
end;

procedure TDelExpertDlg.OptionsButtonClick(Sender: TObject);
begin
  if OptionsDlg = nil then
  begin
    OptionsDlg := TOptionsDlg.Create(Application);
    OptionsDlg.HelpFile := PChar(HelpFile);
    OptionsDlg.CapFileNameEdit.OnChange := CapFileNameEditChange;
  end;
  OptionsDlg.Formatter := Formatter;
  OptionsDlg.ShowModal;
end;

procedure TDelExpertDlg.WholeProjBtnClick(Sender: TObject);
var
  Dir: string;
  List: TList;
  I: integer;
begin
  ProgressDlg.Show;
  Dir := ExtractFileDir(ExpandFileName(OtaGetCurrentProjectName));
  if Dir <> '' then
    Chdir(Dir);

  List := TList.Create;
  try
    OtaFillUnitInfoListForCurrentProject(List);
    for I := 0 to List.Count - 1 do
    begin
      FormatFile(nil, TUnitInfo(List.Items[I]).FileName, TUnitInfo(List.Items[I]).UnitName, TUnitInfo(List.Items[I]).FormName);
    end;
  finally
    List.free;
    ProgressDlg.Hide;
  end;
end;

procedure TDelExpertDlg.FormClose(Sender: TObject;
  var Action: TCloseAction);
var i: Integer;
begin
  ProgressDlg.Hide;
  with Formatter do
  begin
    Clear;
    if (FillNewWords = fmAddNewWord) then
      SaveCapFile(CapFileName);
    Deactivate;
  end;
  for i := 0 to ControlCount - 1 do
    if Controls[i] is TButton then
      with (Controls[i] as TButton) do
        Default := Focused
end;

procedure TDelExpertDlg.AllButtonClick(Sender: TObject);
var
  Dir: string;
  List: TList;
  I: integer;
begin
  ProgressDlg.Show;
  Dir := ExtractFileDir(ExpandFileName(OtaGetCurrentProjectName));
  if Dir <> '' then
    Chdir(Dir);

  List := TList.Create;
  try
    OtaFillUnitInfoListForCurrentProject(List);
    for I := 0 to List.Count - 1 do
    begin
      FormatFile(@I, TUnitInfo(List.Items[I]).FileName, TUnitInfo(List.Items[I]).UnitName, TUnitInfo(List.Items[I]).FormName);
    end;
  finally
    List.free;
    ProgressDlg.Hide;
  end;

end;

procedure TDelExpertDlg.HelpBtnClick(Sender: TObject);
begin
  WinHelp(0, PChar(HelpFile), Help_Contents, 0);
end;

procedure TDelExpertDlg.FormShow(Sender: TObject);
var
  ProjectOpened: Boolean;
  S: array[0..260] of Char;
begin
  Formatter.Activate;
  with Formatter do
    if CapFileName <> nil then
    begin
//      SaveFile(CapFileName);
      CapFileName := StrCopy(S, CapFileName);
    end;
  {if file is changed reread}
  ProjectOpened := OtaGetCurrentProjectName <> '';
  AllButton.Enabled := ProjectOpened;
  WholeProjBtn.Enabled := ProjectOpened;
  CurrentBtn.Enabled := OtaGetCurrentSourceFile <> '';
end;

procedure TDelExpertDlg.FormDestroy(Sender: TObject);
begin
  Formatter.Config(False);
  Formatter.Free;
  Formatter := nil;
end;

procedure TDelExpertDlg.Label4Click(Sender: TObject);
begin
  {opens default explorer with the URL of the homepage}
  ShellExecute(HInstance, 'open', 'http://www.dow.wau.nl/aew/delforexp.html',
    nil, nil, SW_SHOW);
end;

procedure TDelExpertDlg.Label6Click(Sender: TObject);
begin
  ShellExecute(HInstance, 'open', 'kmbaojun@msn.com', nil, nil, SW_SHOW);
end;

end.

⌨️ 快捷键说明

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