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

📄 myidestream.pas

📁 delphi代码格式化,最新汉化版
💻 PAS
字号:
{+--------------------------------------------------------------------------+
| Class:       TIDEStream
| Created:     9.97
| Author:      Martin Waldenburg
| Copyright    1997, all rights reserved.
| Description: A simple and effective interface to the IDE's text buffer
|              You can retrive the text of the IDE's text buffer either
|              as PChar or as string list.
|              You can manipulate it in any way and then replace the
|              whole text with the result of your manipulation.
| Version:     1.1
| Status:      FreeWare
|   Modified to access not only the current file
   by  Egbert van Nes
| Disclaimer:
| This is provided as is, expressly without a warranty of any kind.
| You use it at your own risc.
+--------------------------------------------------------------------------+}
unit MyIDEStream;

interface

uses
  Windows, SysUtils, Messages, Classes, ToolsAPI;

type
  TIDEStream = class(TMemoryStream)
  private
    FLines: TStringList;
    FFileName: string;
    function GetLines: TStringList;
    procedure SetLines(NewValue: TStringList);
  protected
  public
    constructor Create(AFileName: string);
    destructor Destroy; override;
    procedure WriteText(Text: PChar);
    property Capacity;
    property Lines: TStringList read GetLines write SetLines;
    property FileName: string read FFileName;
  published
    procedure Clear;
  end;

//procedure SaveFile(AFileName: string);


implementation
uses Dialogs, Forms, Menus, StdCtrls, ComCtrls, OTAUtils;

//procedure SaveFile(AFileName: string);
//begin
////  FToolServices.SaveFile(AFileName);
//end;

constructor TIDEStream.Create(AFileName: string);
begin
  inherited Create;
  if AFileName = '' then
    begin
      FFileName := OtaGetCurrentSourceFile;
    end
  else
    FFileName := AFileName;
  if LowerCase(ExtractFileExt(FFileName)) = '.dfm' then
    raise Exception.Create('Sorry, must be a PAS or DPR file');
  FLines := TStringList.Create;
end; { Create }

procedure TIDEStream.Clear;
begin
  FLines.Clear;
  inherited Clear;
end; { Clear }

destructor TIDEStream.Destroy;
begin
  FLines.Free;
  inherited Destroy;
end; { Destroy }


procedure TIDEStream.WriteText(Text: PChar);
begin
// OtaInsertTextIntoEditor(PChar(Text));
  OtaSettringAsActiveEditorText(PChar(Text));
end; { WriteText }

function TIDEStream.GetLines: TStringList;
var
  s: string;
begin
  if FLines.Count = 0 then
    begin
      OtaGetActiveEditorTextAsString(s, False);
      FLines.Text := s;
    end;
  Result := FLines;
end; { GetLines }

procedure TIDEStream.SetLines(NewValue: TStringList);
begin
  FLines.Assign(NewValue);
end; { SetLines }

end.

⌨️ 快捷键说明

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