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

📄 ureplace.pas

📁 一个模拟Delphi的快速开发环境RAD
💻 PAS
字号:
unit UReplace;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ComCtrls;

type
  TReplace = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    Label1: TLabel;
    cbSearch: TComboBox;
    GroupBox1: TGroupBox;
    chkMatchCase: TCheckBox;
    chkWholeWord: TCheckBox;
    chkPrompt: TCheckBox;
    GroupBox2: TGroupBox;
    chkDown: TRadioButton;
    chkUp: TRadioButton;
    GroupBox3: TGroupBox;
    chkEntire: TRadioButton;
    chkSelect: TRadioButton;
    GroupBox4: TGroupBox;
    chkCursor: TRadioButton;
    chkFirst: TRadioButton;
    btnOK: TButton;
    btnCancel: TButton;
    btnAll: TButton;
    Label2: TLabel;
    cbReplace: TComboBox;
    btnHelp: TButton;
    procedure FormCreate(Sender: TObject);
    procedure btnAllClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure cbSearchKeyPress(Sender: TObject; var Key: Char);
    procedure cbReplaceKeyPress(Sender: TObject; var Key: Char);
    procedure btnOKClick(Sender: TObject);
  private
    { Private declarations }
    procedure LoadFindStr;
    procedure SaveReplaceText(ReplaceText:string);
  public
    { Public declarations }
    ReplaceAll:Boolean;
  end;

var
  Replace: TReplace;

implementation

uses uconst,utils;

{$R *.DFM}


// 傈俊 八祸茄 巩磊凯阑 霓焊 冠胶俊 眠啊茄促.
procedure TReplace.LoadFindStr;
var
   I,Pos1:integer;
   TextList: TStringList;
begin
    TextList := TStringList.Create;
    IniFile.ReadSectionValues('FindText',TextList);
    if TextList.Count<1 then Exit;
    cbSearch.Items.Clear;
    for I:=TextList.Count-1 downto 1 do begin
        Pos1:=Pos('=',TextList[I]);
        if Pos1>0 then
           cbSearch.Items.Add(Copy(TextList[I],Pos1+1,Length(TextList[I])));
    end;
    TextList.Free;

    TextList := TStringList.Create;
    IniFile.ReadSectionValues('ReplaceText',TextList);
    if TextList.Count<1 then Exit;
    cbReplace.Items.Clear;
    for I:=TextList.Count-1 downto 1 do begin
        Pos1:=Pos('=',TextList[I]);
        if Pos1>0 then
           cbReplace.Items.Add(Copy(TextList[I],Pos1+1,Length(TextList[I])));
    end;
    TextList.Free;
end;

procedure TReplace.FormCreate(Sender: TObject);
begin
   ReplaceAll:= False;
   LoadFindStr;
end;

procedure TReplace.btnAllClick(Sender: TObject);
begin
   ReplaceAll:= True;
   ModalResult:= mrOK;
   btnOKClick(self);
end;

procedure TReplace.FormActivate(Sender: TObject);
begin
   cbSearch.SetFocus;
end;

procedure TReplace.cbSearchKeyPress(Sender: TObject; var Key: Char);
begin
   if Key=#13 then begin
      cbReplace.SetFocus;
      Key:=#0;
   end;   
end;

procedure TReplace.cbReplaceKeyPress(Sender: TObject; var Key: Char);
begin
   if Key = #13 then  begin
      ModalResult:= mrOK;
      Key:= #0;
   end;
end;

procedure TReplace.btnOKClick(Sender: TObject);
begin
   SaveFindText(cbSearch.Text);
   SaveReplaceText(cbReplace.Text);
end;

// 措摹 巩磊凯阑 ini 颇老俊 历厘茄促.
procedure TReplace.SaveReplaceText(ReplaceText:string);
var
   LastNum:Integer;
   List:TStringList;
begin
   List:=TStringList.Create;
   IniFile.ReadSectionValues('ReplaceText',List);
   if List.Count > 0 then
      if FindItem(List,ReplaceText) then Exit;
   LastNum:=IniFile.ReadInteger('ReplaceText','Last',0);
   if LastNum<20 then  begin
      IniFile.WriteInteger('ReplaceText','Last',LastNum+1);
      IniFile.WriteString('ReplaceText',IntToStr(LastNum+1),ReplaceText);
   end
   else  IniFile.WriteInteger('ReplaceText','Last',0);
end;


end.

⌨️ 快捷键说明

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