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

📄 tdifffrmunit.pas

📁 CVS IDE plugin for Borland Delphi this is a good program,i like this kind of practise
💻 PAS
字号:
(* $Id: TDiffFrmunit.pas,v 1.4 2002/12/27 16:22:43 turbo Exp $
 *
 * Form for showing the difference between two revisions (cvs diff)
 *
 * Copyright 2001 by Thomas Bleier
 * For license details see LICENSE.txt
 *)
unit TDiffFrmunit;
{$I BORCVS.inc}
interface
//---------------------------------------------------------------------------
uses
  Classes,
  Controls,
  StdCtrls,
  Forms,
  TRunCvsFrmunit,
  TFileSelectorFrmunit,
  ExtCtrls;
//---------------------------------------------------------------------------
type
  TDiffFrm = class(TFileSelectorFrm)
    PRevisionsGroup: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    PNoRev: TRadioButton;
    POneRev: TRadioButton;
    PTwoRev: TRadioButton;
    PFirstDate: TCheckBox;
    PSecondDate: TCheckBox;
    PDiffOptions: TGroupBox;
    PDiffIgnoreLine: TCheckBox;
    PDiffIgnoreSpace: TCheckBox;
    PDiffOutput: TRadioGroup;
    PFirst: TComboBox;
    PSecond: TComboBox;
    procedure PRadioChange(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure POkBtnClick(Sender: TObject);
  private
  protected
    procedure GetDirectories(Dirs: TStrings); override;
    procedure ApplyParameters(runcvs: TRunCvsFrm; InDirectory: string = ''); override;
  public
    constructor create(Owner: TComponent); override;
  end;
//---------------------------------------------------------------------------
var
  DiffFrm: TDiffFrm;
//---------------------------------------------------------------------------
(* $Id: TDiffFrmunit.pas,v 1.4 2002/12/27 16:22:43 turbo Exp $
 *
 * Copyright 2001 by Thomas Bleier
 * For license details see LICENSE.txt
 *)

implementation
uses
  sysutils,
  dialogs,
  SettingsStorage,
  Utilityunit;
//---------------------------------------------------------------------------
{$R *.dfm}

//---------------------------------------------------------------------------

constructor TDiffFrm.create(Owner: TComponent);
begin
  inherited create(owner);
  OnlyFileNameasParameter := true;
end;
//---------------------------------------------------------------------------

procedure TDiffFrm.PRadioChange(Sender: TObject);
begin
  if (PNoRev.Checked) then
  begin
    PFirst.Enabled := false;
    PFirstDate.Enabled := false;
    PSecond.Enabled := false;
    PSecondDate.Enabled := false;
  end
  else
    if (POneRev.Checked) then
  begin
    PFirst.Enabled := true;
    PFirstDate.Enabled := true;
    PSecond.Enabled := false;
    PSecondDate.Enabled := false;
  end
  else
    if (PTwoRev.Checked) then
  begin
    PFirst.Enabled := true;
    PFirstDate.Enabled := true;
    PSecond.Enabled := true;
    PSecondDate.Enabled := true;
  end;
end;
//---------------------------------------------------------------------------

procedure TDiffFrm.FormShow(Sender: TObject);
var
  which: integer;
begin
  inherited FormShow(Sender);
  if (PFiles.Enabled) then
    ActiveControl := PFiles
  else
    ActiveControl := PNoRev;
  // load settings
  try
    BEGIN_LOAD_SETTINGS('Diff');
    which := LOAD_INT_SETTING('Which', 0);
    LOAD_COMBOLIST_SETTING('First', PFirst, '');
    PFirstDate.Checked := LOAD_BOOL_SETTING('FirstDate', false);
    LOAD_COMBOLIST_SETTING('Second', PSecond, '');
    PSecondDate.Checked := LOAD_BOOL_SETTING('SecondDate', false);
    PDiffIgnoreSpace.Checked := LOAD_BOOL_SETTING('IgnoreSpaceChange', false);
    PDiffIgnoreLine.Checked := LOAD_BOOL_SETTING('IgnoreBlankLines', false);
    PDiffOutput.ItemIndex := LOAD_INT_SETTING('DiffOutput', 2);
    END_LOAD_SETTINGS;
  except
    which := -1;
  end;
  case which of
    0: PNoRev.Checked := true;

    1: POneRev.Checked := true;

    2: PTwoRev.Checked := true;

  else
    raise Exception.Create('Internal Error: unknown option!');
  end;
  PRadioChange(self);
end;
//---------------------------------------------------------------------------

procedure TDiffFrm.POkBtnClick(Sender: TObject);
var
  which: integer;
begin
  inherited POkBtnClick(Sender);
//  // do better check of input (valid date, valid tag)
  if ((POneRev.Checked or PTwoRev.Checked) and (Trim(PFirst.Text) = '')) then
  begin
    ShowMessage('You have to enter a revision/tag/branch/date!');
    ActiveControl := PFirst;
    exit;
  end;
  if (PTwoRev.Checked and (Trim(PSecond.Text) = '')) then
  begin
    ShowMessage('You have to enter a revision/tag/branch/date!');
    ActiveControl := PSecond;
    exit;
  end;
//  // handle MRU lists
  ADD_COMBO_MRU_ENTRY_MAX(PFirst, DEFAULT_MRU_ENTRIES);
  ADD_COMBO_MRU_ENTRY_MAX(PSecond, DEFAULT_MRU_ENTRIES);
//  // save settings
  if (PNoRev.Checked) then
  begin
    which := 0;
  end
  else
  begin
    if (POneRev.Checked) then
    begin
      which := 1;
    end
    else
    begin
      if (PTwoRev.Checked) then
      begin
        which := 2;
      end
      else
      begin
        raise Exception.Create('Internal Error: unknown option!');
      end;
    end;
  end;

  BEGIN_SAVE_SETTINGS('Diff');
  SAVE_INT_SETTING('Which', which);
  SAVE_COMBOLIST_SETTING('First', PFirst);
  SAVE_BOOL_SETTING('FirstDate', PFirstDate.Checked);
  SAVE_COMBOLIST_SETTING('Second', PSecond);
  SAVE_BOOL_SETTING('SecondDate', PSecondDate.Checked);
  SAVE_BOOL_SETTING('IgnoreSpaceChange', PDiffIgnoreSpace.Checked);
  SAVE_BOOL_SETTING('IgnoreBlankLines', PDiffIgnoreLine.Checked);
  SAVE_INT_SETTING('DiffOutput', PDiffOutput.ItemIndex);
  END_SAVE_SETTINGS;
  ModalResult := mrOk;
end;
//---------------------------------------------------------------------------

procedure TDiffFrm.ApplyParameters(runcvs: TRunCvsFrm; InDirectory: string = '');
begin
  DebugInfo('ApplyParameters');
  inherited ApplyParameters(runcvs);
  runcvs.Command := CVSCMD_DIFF;
  runcvs.CommandOptions.Add('-t');
  if (PDiffIgnoreSpace.Checked) then
    runcvs.CommandOptions.Add('-b');
  if (PDiffIgnoreLine.Checked) then
    runcvs.CommandOptions.Add('-B');

  case (PDiffOutput.ItemIndex) of
    0: ;
    1: runcvs.CommandOptions.Add('-u');
    2: runcvs.CommandOptions.Add('-c');
    3: runcvs.CommandOptions.Add('--side-by-side');
  else
    raise Exception.Create('Internal Error: unknown output format!');
  end;
  if (POneRev.Checked or PTwoRev.Checked) then
  begin
    if (PFirstDate.Checked) then
      runcvs.CommandOptions.Add('-D ' + GetOptQuotedString(PFirst.Text))
    else
      runcvs.CommandOptions.Add('-r ' + GetOptQuotedString(PFirst.Text));
  end;
  if (PTwoRev.Checked) then
  begin
    if (PSecondDate.Checked) then
      runcvs.CommandOptions.Add('-D ' + GetOptQuotedString(PSecond.Text))
    else
      runcvs.CommandOptions.Add('-r ' + GetOptQuotedString(PSecond.Text));
  end;
end;
//---------------------------------------------------------------------------

procedure TDiffFrm.GetDirectories(Dirs: TStrings);
begin

end;

end.

⌨️ 快捷键说明

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