?? myidestream.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 + -