synedit.pas
来自「一个mwEdit控件原码,比mwCuuEdit0.92a功能先进.」· PAS 代码 · 共 1,671 行 · 第 1/5 页
PAS
1,671 行
procedure UpdateMouseCursor; virtual;
protected
fGutterWidth: Integer;
fInternalImage: TSynInternalImage;
procedure HideCaret;
procedure ShowCaret;
procedure DoOnClearBookmark(var Mark: TSynEditMark); virtual;
procedure DoOnCommandProcessed(Command: TSynEditorCommand; AChar: char;
Data: pointer); virtual;
// no method DoOnDropFiles, intercept the WM_DROPFILES instead
procedure DoOnGutterClick(Button: TMouseButton; X, Y: integer); virtual;
procedure DoOnPaint; virtual;
procedure DoOnPaintTransientEx(TransientType: TTransientType; Lock: Boolean); virtual;
procedure DoOnPaintTransient(TransientType: TTransientType); virtual; //GBN 2001-10-23
procedure DoOnPlaceMark(var Mark: TSynEditMark); virtual;
procedure DoOnProcessCommand(var Command: TSynEditorCommand;
var AChar: char; Data: pointer); virtual;
function DoOnReplaceText(const ASearch, AReplace: string;
Line, Column: integer): TSynReplaceAction; virtual;
function DoOnSpecialLineColors(Line: integer;
var Foreground, Background: TColor): boolean; virtual;
procedure DoOnStatusChange(Changes: TSynStatusChanges); virtual;
function GetSelEnd: integer; //DDH 10/16/01
function GetSelStart: integer; //DDH 10/16/01
function GetSelLength: integer;
procedure SetSelEnd(const Value: integer); //DDH 10/16/01
procedure SetSelStart(const Value: integer); //DDH 10/16/01
procedure SetSelLength(const Value: integer);
procedure SetAlwaysShowCaret(const Value: Boolean); //DDH 10/16/01
procedure PrepareIdentChars(var IdentChars, WhiteChars: TSynIdentChars); //DDH 11/01/01
procedure LinesHookChanged;
property InternalCaretX: Integer write InternalSetCaretX;
property InternalCaretY: Integer write InternalSetCaretY;
property InternalCaretXY: TBufferCoord write InternalSetCaretXY;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Canvas; //DDH 10/16/01
property SelStart: Integer read GetSelStart write SetSelStart; //DDH 10/16/01
property SelEnd: Integer read GetSelEnd write SetSelEnd; //DDH 10/16/01
property AlwaysShowCaret: Boolean read FAlwaysShowCaret //DDH 10/16/01
write SetAlwaysShowCaret;
procedure UpdateCaret; //DDH 10/16/01 moved from protected to public (needed in Completion Proposal)
{$IFDEF SYN_COMPILER_4_UP} //DDH 10/17/01 change from Fl醰io Etrusco
procedure AddKey(Command: TSynEditorCommand; Key1: word; SS1: TShiftState;
Key2: word = 0; SS2: TShiftState = []);
{$ELSE}
procedure AddKey(Command: TSynEditorCommand; Key1: word; SS1: TShiftState;
Key2: word; SS2: TShiftState);
{$ENDIF}
procedure BeginUndoBlock; //sbs 2000-11-19
procedure BeginUpdate;
function CharIndexToRowCol(Index: integer): TBufferCoord;
procedure Clear;
procedure ClearAll;
procedure ClearBookMark(BookMark: Integer);
procedure ClearSelection;
procedure CommandProcessor(Command: TSynEditorCommand; AChar: char;
Data: pointer); virtual;
procedure ClearUndo;
procedure CopyToClipboard;
procedure CutToClipboard;
procedure DoCopyToClipboard(const SText: string);
procedure DragDrop(Source: TObject; X, Y: Integer); override;
procedure EndUndoBlock; //sbs 2000-11-19
procedure EndUpdate;
procedure EnsureCursorPosVisible;
procedure EnsureCursorPosVisibleEx(ForceToMiddle: Boolean);
procedure FindMatchingBracket; virtual; //GBN 2001-10-23 Moved to public
function GetMatchingBracket: TBufferCoord; virtual;
function GetMatchingBracketEx(const APoint: TBufferCoord): TBufferCoord; virtual;
{$IFDEF SYN_COMPILER_4_UP}
function ExecuteAction(Action: TBasicAction): boolean; override;
{$ENDIF}
procedure ExecuteCommand(Command: TSynEditorCommand; AChar: char;
Data: pointer); virtual;
function GetBookMark(BookMark: integer; var X, Y: integer): boolean;
function GetHighlighterAttriAtRowCol(const XY: TBufferCoord; var Token: string;
var Attri: TSynHighlighterAttributes): boolean;
function GetHighlighterAttriAtRowColEx(const XY: TBufferCoord; var Token: string;
var TokenType, Start: Integer;
var Attri: TSynHighlighterAttributes): boolean; //DDH 10/16/01
function GetPositionOfMouse(out aPos: TBufferCoord): Boolean;
function GetWordAtRowCol(XY: TBufferCoord): string;
procedure GotoBookMark(BookMark: Integer);
procedure GotoLineAndCenter(ALine: Integer);
function IdentChars: TSynIdentChars; //DDH 10/17/01 from Fl醰io Etrusco
procedure InvalidateGutter;
procedure InvalidateGutterLine(aLine: integer);
// note: FirstLine and LastLine don't need to be in correct order
procedure InvalidateGutterLines(FirstLine, LastLine: integer);
procedure InvalidateLine(Line: integer);
procedure InvalidateLines(FirstLine, LastLine: integer); //Fiala 2001-12-17 moved to public
procedure InvalidateSelection;
function IsBookmark(BookMark: integer): boolean;
function IsPointInSelection(const Value: TBufferCoord): boolean;
procedure LockUndo;
function BufferToDisplayPos(const p: TBufferCoord): TDisplayCoord;
function DisplayToBufferPos(const p: TDisplayCoord): TBufferCoord;
function LineToRow(aLine: integer): integer;
function RowToLine(aRow: integer): integer;
function NextWordPos: TBufferCoord; virtual;
function NextWordPosEx(const XY: TBufferCoord): TBufferCoord; virtual;
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
procedure PasteFromClipboard;
function WordStart: TBufferCoord; virtual;
function WordStartEx(const XY: TBufferCoord): TBufferCoord; virtual;
function WordEnd: TBufferCoord; virtual;
function WordEndEx(const XY: TBufferCoord): TBufferCoord; virtual;
function PrevWordPos: TBufferCoord; virtual;
function PrevWordPosEx(const XY: TBufferCoord): TBufferCoord; virtual;
function PixelsToRowColumn(aX, aY: integer): TDisplayCoord;
function PixelsToNearestRowColumn(aX, aY: integer): TDisplayCoord;
procedure Redo;
procedure RegisterCommandHandler(const AHandlerProc: THookedCommandEvent;
AHandlerData: pointer);
function RowColumnToPixels(const RowCol: TDisplayCoord): TPoint;
function RowColToCharIndex(RowCol: TBufferCoord): integer;
function SearchReplace(const ASearch, AReplace: string;
AOptions: TSynSearchOptions): integer;
procedure SelectAll;
procedure SetBookMark(BookMark: Integer; X: Integer; Y: Integer);
procedure SetCaretAndSelection(const ptCaret, ptBefore, ptAfter: TBufferCoord);
procedure SetDefaultKeystrokes; virtual;
procedure SetOptionFlag(Flag: TSynEditorOption; Value: boolean);
procedure SetSelWord;
procedure Undo;
procedure UnlockUndo;
procedure UnregisterCommandHandler(AHandlerProc: THookedCommandEvent);
{$IFDEF SYN_COMPILER_4_UP}
function UpdateAction(Action: TBasicAction): boolean; override;
{$ENDIF}
procedure SetFocus; override;
procedure AddKeyUpHandler (aHandler : TKeyEvent);
procedure RemoveKeyUpHandler (aHandler : TKeyEvent);
procedure AddKeyDownHandler (aHandler : TKeyEvent);
procedure RemoveKeyDownHandler (aHandler : TKeyEvent);
procedure AddKeyPressHandler (aHandler : TKeyPressEvent);
procedure RemoveKeyPressHandler (aHandler : TKeyPressEvent);
procedure AddFocusControl (aControl: TWinControl);
procedure RemoveFocusControl (aControl: TWinControl);
procedure AddMouseDownHandler(aHandler: TMouseEvent);
procedure RemoveMouseDownHandler(aHandler: TMouseEvent);
procedure AddMouseUpHandler(aHandler: TMouseEvent);
procedure RemoveMouseUpHandler(aHandler: TMouseEvent);
procedure AddMouseCursorHandler(aHandler: TMouseCursorEvent);
procedure RemoveMouseCursorHandler(aHandler: TMouseCursorEvent);
{$IFDEF SYN_CLX}
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; override;
{$ELSE}
procedure WndProc(var Msg: TMessage); override;
{$ENDIF}
procedure SetLinesPointer(ASynEdit: TCustomSynEdit); //ddh 2002-7-15
procedure RemoveLinesPointer; //ddh 2002-7-15
procedure HookTextBuffer(aBuffer: TSynEditStringList;
aUndo, aRedo: TSynEditUndoList);
procedure UnHookTextBuffer;
public
property BlockBegin: TBufferCoord read GetBlockBegin write SetBlockBegin;
property BlockEnd: TBufferCoord read GetBlockEnd write SetBlockEnd;
property CanPaste: Boolean read GetCanPaste;
property CanRedo: boolean read GetCanRedo;
property CanUndo: boolean read GetCanUndo;
property CaretX: Integer read fCaretX write SetCaretX;
property CaretY: Integer read fCaretY write SetCaretY;
property CaretXY: TBufferCoord read GetCaretXY write SetCaretXY;
property ActiveLineColor: TColor read fActiveLineColor
write SetActiveLineColor default clNone;
property DisplayX: Integer read GetDisplayX; //GN 10/16/01
property DisplayY: Integer read GetDisplayY; //GN 10/16/01
property DisplayXY: TDisplayCoord read GetDisplayXY;
property DisplayLineCount: integer read GetDisplayLineCount;
property CharsInWindow: Integer read fCharsInWindow;
property CharWidth: integer read fCharWidth;
property Color;
property Font: TFont read GetFont write SetFont;
property Highlighter: TSynCustomHighlighter
read fHighlighter write SetHighlighter;
property LeftChar: Integer read fLeftChar write SetLeftChar;
property LineHeight: integer read fTextHeight;
property LinesInWindow: Integer read fLinesInWindow;
property LineText: string read GetLineText write SetLineText;
property Lines: TStrings read fLines write SetLines;
property Marks: TSynEditMarkList read fMarkList;
property MaxScrollWidth: integer read fMaxScrollWidth write SetMaxScrollWidth
default 1024;
property Modified: Boolean read fModified write SetModified;
property PaintLock: Integer read fPaintLock;
property ReadOnly: Boolean read GetReadOnly write SetReadOnly default FALSE;
property SearchEngine: TSynEditSearchCustom read fSearchEngine write SetSearchEngine;
property SelAvail: Boolean read GetSelAvail;
property SelLength: integer read GetSelLength write SetSelLength;
property SelTabBlock: Boolean read GetSelTabBlock;
property SelTabLine: Boolean read GetSelTabLine;
property SelText: string read GetSelText write SetSelTextExternal;
property Text: string read SynGetText write SynSetText;
property TopLine: Integer read fTopLine write SetTopLine;
property WordAtCursor: string read GetWordAtCursor;
property WordAtMouse: string read GetWordAtMouse;
property UndoList: TSynEditUndoList read fUndoList;
property RedoList: TSynEditUndoList read fRedoList;
public
property OnProcessCommand: TProcessCommandEvent
read FOnProcessCommand write FOnProcessCommand;
property BookMarkOptions: TSynBookMarkOpt
read fBookMarkOpt write fBookMarkOpt;
property BorderStyle: TSynBorderStyle read FBorderStyle write SetBorderStyle
default bsSingle;
property ExtraLineSpacing: integer
read fExtraLineSpacing write SetExtraLineSpacing default 0;
property Gutter: TSynGutter read fGutter write SetGutter;
property HideSelection: boolean read fHideSelection write SetHideSelection
default false;
property InsertCaret: TSynEditCaretType read FInsertCaret
write SetInsertCaret default ctVerticalLine;
property InsertMode: boolean read fInserting write SetInsertMode
default true;
property IsScrolling : Boolean read FIsScrolling;
property Keystrokes: TSynEditKeyStrokes
read FKeystrokes write SetKeystrokes stored False;
property MaxUndo: Integer read GetMaxUndo write SetMaxUndo default 1024;
property Options: TSynEditorOptions read fOptions write SetOptions
default SYNEDIT_DEFAULT_OPTIONS;
property OverwriteCaret: TSynEditCaretType read FOverwriteCaret
write SetOverwriteCaret default ctBlock;
property RightEdge: Integer read fRightEdge write SetRightEdge default 80;
property RightEdgeColor: TColor
read fRightEdgeColor write SetRightEdgeColor default clSilver;
property ScrollHintColor: TColor read fScrollHintColor
write fScrollHintColor default clInfoBk;
property ScrollHintFormat: TScrollHintFormat read fScrollHintFormat
write fScrollHintFormat default shfTopLineOnly;
property ScrollBars: TScrollStyle
read FScrollBars write SetScrollBars default ssBoth;
property SelectedColor: TSynSelectedColor
read FSelectedColor write FSelectedColor;
property SelectionMode: TSynSelectionMode
read FSelectionMode write SetSelectionMode default smNormal;
property TabWidth: integer read fTabWidth write SetTabWidth default 8;
property WantReturns: boolean read fWantReturns write fWantReturns default True;
property WantTabs: boolean read fWantTabs write fWantTabs default False;
property WordWrap: boolean read GetWordWrap write SetWordWrap default False;
property WordWrapGlyph: TSynGlyph read fWordWrapGlyph write SetWordWrapGlyph;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property OnClearBookmark: TPlaceMarkEvent read fOnClearMark
write fOnClearMark;
property OnCommandProcessed: TProcessCommandEvent
read fOnCommandProcessed write fOnCommandProcessed;
property OnContextHelp: TContextHelpEvent
read fOnContextHelp write fOnContextHelp;
property OnDropFiles: TDropFilesEvent read fOnDropFiles write fOnDropFiles;
property OnGutterClick: TGutterClickEvent
read fOnGutterClick write fOnGutterClick;
property OnGutterGetText: TGutterGetTextEvent read fOnGutterGetText
write fOnGutterGetText;
property OnGutterPaint: TGutterPaintEvent read fOnGutterPaint
write fOnGutterPaint;
property OnMouseCursor: TMouseCursorEvent read fOnMouseCursor
write fOnMouseCursor;
property OnPaint: TPaintEvent read fOnPaint write fOnPaint;
property OnPlaceBookmark: TPlaceMarkEvent
read FOnPlaceMark write FOnPlaceMark;
property OnProcessUserCommand: TProcessCommandEvent
read FOnProcessUserCommand write FOnProcessUserCommand;
property OnReplaceText: TReplaceTextEvent read fOnReplaceText
write fOnReplaceText;
property OnSpecialLineColors: TSpecialLineColorsEvent
read fOnSpecialLineColors write fOnSpecialLineColors;
property OnStatusChange: TStatusChangeEvent
read fOnStatusChange write fOnStatusChange;
property OnPaintTransient: TPaintTransient
read fOnPaintTransient write fOnPaintTransient; //GBN 2001-10-23
property OnScroll: TScrollEvent
read fOnScroll write fOnScroll; //GBN 2002-05-14
property OnLineNumber: TLineNumberEvent
read fOnLineNumber write FOnLineNumber;
published
property Cursor default crIBeam;
end;
TSynEdit = class(TCustomSynEdit)
published
// inherited properties
property Align;
{$IFDEF SYN_COMPILER_4_UP}
property Anchors;
property Constraints;
{$ENDIF}
property Color;
property ActiveLineColor;
{$IFDEF SYN_CLX}
{$ELSE}
property Ctl3D;
property ParentCtl3D;
{$ENDIF}
property Enabled;
property Font;
property Height;
property Name;
property ParentColor default False;
property ParentFont default False;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property TabStop default True;
property Visible;
property Width;
// inherited events
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
{$IFDEF SYN_CLX}
{$ELSE}
{$IFDEF SYN_COMPILER_4_UP}
property OnEndDock;
property OnStartDock;
{$ENDIF}
{$ENDIF}
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?