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

📄 editintf.pas

📁 是 delphi6的函数库
💻 PAS
📖 第 1 页 / 共 2 页
字号:

{*******************************************************}
{                                                       }
{       Borland Delphi Visual Component Library         }
{                                                       }
{ Copyright (c) 1995-2001 Borland Software Corporation  }
{                                                       }
{*******************************************************}

unit EditIntf;

interface

uses SysUtils, Windows, Classes, VirtIntf;

const
  cursorPos = Integer(0);
  ViewTopPos = Integer(1);

  atWhiteSpace     = 0;
  atComment        = 1;
  atReservedWord   = 2;
  atIdentifier     = 3;
  atSymbol         = 4;
  atString         = 5;
  atNumber         = 6;
  atFloat          = 7; // not used in Pascal tokenizer
  atOctal          = 8; // not used in Pascal tokenizer
  atHex            = 9; // not used in Pascal tokenizer
  atCharacter      = 10; // not used in Pascal tokenizer
  atPreproc        = 11; // not used in Pascal tokenizer
  atIllegal        = 12; // not used in Pascal tokenizer
  atAssembler      = 13;
  SyntaxOff        = 14;

  MarkedBlock      = 15;
  SearchMatch      = 16;

  lfCurrentCSIP         = $0001;
  lfBreakpointEnabled   = $0002;
  lfBreakpointDisabled  = $0004;
  lfBreakpointInvalid   = $0008;
  lfErrorLine           = $0010;
  lfBreakpointVerified  = $0020;

type
  { Editor position expressed as column/line after tabs are expanded to spaces
    and include the "virtual" editor space (columns beyond the end of lines) }
  TEditPos = packed record
    Col: SmallInt; { Col is one-based }
    Line: Longint; { Line is one-based }
  end;

  { Editor position expressed as character index/line before tabs are expanded
    and does not include the indecies beyond the end of a line }
  TCharPos = packed record
    CharIndex: SmallInt; { CharIndex is zero-based }
    Line: Longint; { Line is one-based }
  end;

  { Use the TIEditReader class to gain read access to an editor buffer:

    NOTES:
      The buffer is accessed as a linear "file" with line breaks included.
      This reader interface could be accessed through a custom read-only
      TStream descendant.

    WARNING!!!
     o A TIEditReader should never be active at the same time as a TIEditWriter.
  }

  TIEditReader = class(TInterface)
  public
    function GetText(Position: Longint; Buffer: PChar; Count: Longint): Longint;
      virtual; stdcall; abstract;
  end;

  { Use the TIEditWriter class to gain write access to an editor buffer:

    NOTES:
     o As with the reader, the buffer is accessed as a linear "file" with
       line breaks included.  The writer uses a "copy in place" metaphor for
       modifying the editor buffer.  In other words, the writer can be thought
       of as simply copying from one buffer to another.  All positions (Pos)
       passed to the function are positions relative to the original file.  Due
       to the "copy" metaphor of the writer it does not support moving backward
       in the editor buffer. It is recommended that all modifications that must
       be performed should be done from the start to the finish.
     o After the TIEditWriter is freed(released), the undo-buffer of the editor
       is flushed unless CreateUndoableWriter was called to obtain the
       TIEditWriter.

    WARNING!!!
     o A TIEditWriter should never be active at the same time as a TIEditReader.
  }

  TIEditWriter = class(TInterface)
  public
    function CopyTo(Pos: Longint): Boolean; virtual; stdcall; abstract;
    function DeleteTo(Pos: Longint): Boolean; virtual; stdcall; abstract;
    function Insert(Text: PChar): Boolean; virtual; stdcall; abstract;
    function Position: Longint; virtual; stdcall; abstract;
    function GetCurrentPos: TCharPos; virtual; stdcall; abstract;

    property CurrentPos: TCharPos read GetCurrentPos;
  end;

  { The TIEditView represents an individual view on an edit buffer:

    This interface allows the cursor and view positions to be accessed and
    updated.  The only restriction on using this interface is that it should
    not be held for any length of time.  Since a view can be deleted at any
    time, the interface could become invalid.
  }

  TIEditView = class(TInterface)
  public
    function GetPos(Index: Integer): TEditPos; virtual; stdcall; abstract;
    procedure SetPos(Index: Integer; Value: TEditPos); virtual; stdcall; abstract;
    function GetViewSize: TSize; virtual; stdcall; abstract;
    function PosToCharPos(Pos: Longint): TCharPos; virtual; stdcall; abstract;
    function CharPosToPos(CharPos: TCharPos): Longint; virtual; stdcall; abstract;
    procedure ConvertPos(EdPosToCharPos: Boolean; var EditPos: TEditPos;
      var CharPos: TCharPos); virtual; stdcall; abstract;
    procedure GetAttributeAtPos(const EdPos: TEditPos; var Element, LineFlag: Integer);
      virtual; stdcall; abstract;

    property CursorPos: TEditPos index CursorPos read GetPos write SetPos;
    property TopPos: TEditPos index ViewTopPos read GetPos write SetPos;
    property ViewSize: TSize read GetViewSize;
  end;

  { The TIEditorInterface is the base interface to an editor buffer:

    Use this interface to obtain TIEditReader, TIEditWriter, and TIEditView
    interfaces.

    NOTE: If the block type is btColumn then the values for BlockStart and
          BlockAfter are actually expressing as TEditPos records.  This
          applies both to getting and setting the values

  }

  TSyntaxHighlighter = (shNone, shPascal, shC, shSQL, shQuery);
  TBlockType = (btInclusive, btLine, btColumn, btNonInclusive, btUnknown);

  TIEditorInterface = class(TInterface)
  public
    function CreateReader: TIEditReader; virtual; stdcall; abstract;
    function CreateWriter: TIEditWriter; virtual; stdcall; abstract;
    function FileName: string; virtual; stdcall; abstract;
    function LinesInBuffer: Longint; virtual; stdcall; abstract;
    function BufferModified: Boolean; virtual; stdcall; abstract;
    function MarkModified: Boolean; virtual; stdcall; abstract;
    function SetSyntaxHighlighter(SyntaxHighlighter: TSyntaxHighlighter): TSyntaxHighlighter;
      virtual; stdcall; abstract;
    function GetViewCount: Integer; virtual; stdcall; abstract;
    function GetView(Index: Integer): TIEditView; virtual; stdcall; abstract;
    function CreateUndoableWriter: TIEditWriter; virtual; stdcall; abstract;
    // These functions will affect all views on this buffer.
    function GetBlockAfter: TCharPos; virtual; stdcall; abstract;
    function GetBlockStart: TCharPos; virtual; stdcall; abstract;
    function GetBlockType: TBlockType; virtual; stdcall; abstract;
    function GetBlockVisible: Boolean; virtual; stdcall; abstract;
    procedure SetBlockAfter(Value: TCharPos); virtual; stdcall; abstract;
    procedure SetBlockStart(Value: TCharPos); virtual; stdcall; abstract;
    procedure SetBlockType(Value: TBlockType); virtual; stdcall; abstract;
    procedure SetBlockVisible(Value: Boolean); virtual; stdcall; abstract;

    property BlockStart: TCharPos read GetBlockStart write SetBlockStart;
    property BlockAfter: TCharPos read GetBlockAfter write SetBlockAfter;
    property BlockType: TBlockType read GetBlockType write SetBlockType;
    property BlockVisible: Boolean read GetBlockVisible write SetBlockVisible;
  end;

  { The TIComponentInterface is the base interface for a component living
    on a form/data module.  Never hold this interface for very long, since
    the component may be deleted at any time.

    GetComponentType   - Returns a string representing the type of the
                         component.
    GetParent          - Returns the interface corresponding to the parent
                         control if a TControl, otherwise returns the owner
                         of the control.  If a TPersistent or the root object
                         then it returns nil.
    IsTControl         - Returns True if component is a TControl descendant
    GetPropCount       - Returns the number of published properties on this
                         component.
    GetPropName        - Given the index, returns the property name.
    GetPropType        - Given the index, returns the property type.
    GetPropTypeByName  - Given the name, returns the property type
    GetPropValue
    GetPropValueByName - Given the index or name, returns the property value.
                         The untyped var must be large enough to hold the
                         returned value.  If the property is a descendant of
                         TPersistent, the return value is a TIComponent-
                         Interface. For properties of any other object type,
                         the return value is nil.
    SetPropValue
    SetPropValueByName - Given the index or name, sets the property value.
    GetControlCount    - Returns the number of child controls (if a TControl
                         descendant, else returns 0).
    GetControl         - Given the index, returns an interface to the
                         child control.
    GetComponentCount  - Returns the number of child components (if a
                         TComponent descendant, else returns 0).
    GetComponent       - Given the index, returns an interface to the
                         child component.
    Select             - Selects the component and updates the Object Inspector.
    Focus              - Same as Select except it brings the form to front with
                         the component selected.  If this interface is a Form/
                         Data Module, then Focus only brings the form to front.
    Delete             - Deletes the component from the form.  Following this
                         call, this interface will now be invalid and must be
                         freed.
  }

  TIComponentInterface = class;

  TPropertyType = (ptUnknown, ptInteger, ptChar, ptEnumeration, ptFloat,
    ptString, ptSet, ptClass, ptMethod, ptWChar, ptLString, ptLWString,
    ptVariant);

  TGetChildCallback = function (Param: Pointer;
    ComponentInterface: TIComponentInterface): Boolean stdcall;

  TIComponentInterface = class(TInterface)
  public
    function GetComponentType: string; virtual; stdcall; abstract;
    function GetComponentHandle: Pointer; virtual; stdcall; abstract;
    function GetParent: TIComponentInterface; virtual; stdcall; abstract;
    function IsTControl: Boolean; virtual; stdcall; abstract;
    function GetPropCount: Integer; virtual; stdcall; abstract;
    function GetPropName(Index: Integer): string; virtual; stdcall; abstract;
    function GetPropType(Index: Integer): TPropertyType; virtual; stdcall; abstract;
    function GetPropTypeByName(const Name: string): TPropertyType;
      virtual; stdcall; abstract;
    function GetPropValue(Index: Integer; var Value): Boolean;
      virtual; stdcall; abstract;
    function GetPropValueByName(const Name: string; var Value): Boolean;
      virtual; stdcall; abstract;
    function SetProp(Index: Integer; const Value): Boolean;
      virtual; stdcall; abstract;
    function SetPropByName(const Name: string; const Value): Boolean;
      virtual; stdcall; abstract;
    function GetChildren(Param: Pointer; Proc: TGetChildCallback): Boolean;
      virtual; stdcall; abstract;
    function GetControlCount: Integer; virtual; stdcall; abstract;
    function GetControl(Index: Integer): TIComponentInterface;
      virtual; stdcall; abstract;
    function GetComponentCount: Integer; virtual; stdcall; abstract;
    function GetComponent(Index: Integer): TIComponentInterface;
      virtual; stdcall; abstract;
    function Select: Boolean; virtual; stdcall; abstract;
    function Focus: Boolean; virtual; stdcall; abstract;
    function Delete: Boolean; virtual; stdcall; abstract;
  end;

  { The TIFormInterface is the base interface to a designed form/data module:

     FileName          - Returns the actual filename of the form.
     FormModified      - Returns True if the form has been modified. This is
                         independent of the source code.
     MarkModified      - Forces the form to be marked as modified.  Returns
                         True is successful.
     GetFormComponent  - Returns a TIComponentInterface representing the root
                         component of the Form/Data module.
     FincComponent     - Given the name, returns a component interface of the
                         component on the Form/Data module.  Nil if the
                         component is not found.
     GetComponentFromHandle - Given the component handle (from
                         TIModuleNotifier.ComponentRenamed or
                         TIComponentInterface.GetComponentHandle) returns a
                         TIComponentInterface for that component.
     GetSelCount       - Returns the number of Selected components
     GetSelComponent   - Returns the index'th selected component on the form/
                         Data Module.
     GetCreateParent   - Returns a TIComponentInterface used to parent the
                         component currently being created.
                         NOTE: This is only valid from a TIModuleNotifier.
                         ComponentRenamed callback when OldName = '' and
                         NewName <> ''
     CreateComponent   - Adds a new component of type "TypeName" to the form.
                         if Container is nil, and the component to be added is
                         a TWinControl, then it is parented to the currently
                         selected container.  If Container is non-nil, and it
                         is a TWinControl, then the component is parented to
                         that control.  Set Name to an empty string to allow
                         the component's name to be auto-generated.  Set W and
                         H to -1 to use the default size of the component. Set
                         X and Y to -1 to center the component on the form.
  }

⌨️ 快捷键说明

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