📄 rm_jveditorcommon.pas
字号:
FDoubleClick: Boolean;
FMouseDown: Boolean;
{ internal }
FTabStops: AnsiString; // Tabs string is always an AnsiString
FCompound: Integer;
{ visual attributes - properties }
FBorderStyle: TBorderStyle;
FGutterColor: TColor;
FGutterWidth: Integer;
FRightMarginVisible: Boolean;
FRightMargin: Integer;
FRightMarginColor: TColor;
FScrollBars: TScrollStyle;
FDoubleClickLine: Boolean;
FSmartTab: Boolean;
FBackSpaceUnindents: Boolean;
FAutoIndent: Boolean;
FKeepTrailingBlanks: Boolean;
FCursorBeyondEOF: Boolean;
FBlockOverwrite: Boolean;
FPersistentBlocks: Boolean;
FHideCaret: Boolean;
{ non-visual attributes - properties }
FInsertMode: Boolean;
FReadOnly: Boolean;
FModified: Boolean;
FRecording: Boolean;
FBeepOnError: Boolean;
FUseFixedPopup: Boolean;
{ events }
FOnChange: TNotifyEvent;
FOnSelectionChange: TNotifyEvent;
FOnChangeStatus: TNotifyEvent;
FOnScroll: TNotifyEvent;
FOnResize: TNotifyEvent;
FOnDblClick: TNotifyEvent;
FOnPaintGutter: TOnPaintGutter;
FOnGutterClick: TOnGutterClick;
FOnGutterDblClick: TOnGutterClick;
FOnCompletionIdentifier: TOnCompletion;
FOnCompletionTemplate: TOnCompletion;
FOnCompletionDrawItem: TDrawItemEvent;
FOnCompletionMeasureItem: TMeasureItemEvent;
FOnLineInserted: TJvLineChangeEvent;
FOnLineDeleted: TJvLineChangeEvent;
{ internal message processing }
procedure WMEditCommand(var Msg: TMessage); message WM_EDITCOMMAND;
procedure WMCompound(var Msg: TMessage); message WM_COMPOUND;
procedure CMResetCaptureControl(var Msg: TMessage); message CM_RESETCAPTURECONTROL;
{$IFDEF VCL}
procedure WMHScroll(var Msg: TWMHScroll); message WM_HSCROLL;
procedure WMVScroll(var Msg: TWMVScroll); message WM_VSCROLL;
procedure WMSetCursor(var Msg: TWMSetCursor); message WM_SETCURSOR;
procedure WMCopy(var Msg: TMessage); message WM_COPY;
procedure WMCut(var Msg: TMessage); message WM_CUT;
procedure WMPaste(var Msg: TMessage); message WM_PASTE;
procedure WMUndo(var Msg: TMessage); message WM_UNDO;
// (p3) added to be compatible with JvFixedEditPopup
procedure WMClear(var Msg: TMessage); message WM_CLEAR;
procedure EMSetReadOnly(var Msg: TMessage); message EM_SETREADONLY;
procedure EMSetSelection(var Msg: TMessage); message EM_SETSEL;
procedure EMGetSelection(var Msg: TMessage); message EM_GETSEL;
procedure EMCanUndo(var Msg: TMessage); message EM_CANUNDO;
procedure WMGetTextLength(var Msg: TMessage); message WM_GETTEXTLENGTH;
{$ENDIF VCL}
protected
FMyDi: TDynIntArray; //array [0..Max_X] of Integer;
FSelection: TJvSelectionRec;
FCaretX: Integer;
FCaretY: Integer;
FTabPos: array [0..Max_X] of Boolean;
{ FMacro - buffer of TEditCommand, each command represents by two chars }
FMacro: TMacro;
FDefMacro: TMacro;
procedure UpdateEditorSize; virtual;
procedure UpdateEditorView; virtual;
procedure ScrollTimer(Sender: TObject);
function ExpandTabsAnsi(const S: AnsiString): AnsiString; // ClipboardPaste
function GetDefTabStop(X: Integer; Next: Boolean): Integer; virtual;
function GetTabStop(X, Y: Integer; Next: Boolean): Integer; virtual; abstract;
function GetBackStop(X, Y: Integer): Integer; virtual; abstract;
function GetAutoIndentStop(Y: Integer): Integer; virtual; abstract;
function GetAnsiTextLine(Y: Integer; out Text: AnsiString): Boolean; virtual; abstract;
function GetAnsiWordOnCaret: AnsiString; virtual; abstract;
{ triggers when Lines changes }
procedure DoLinesChange(Sender: TObject); virtual;
procedure ReLine; virtual; abstract;
procedure TextAllChangedInternal(Unselect: Boolean); virtual;
{ triggers for descendants }
procedure Changed; dynamic;
procedure TextAllChanged; dynamic;
procedure StatusChanged; dynamic;
procedure SelectionChanged; dynamic;
procedure GetAttr(Line, ColBeg, ColEnd: Integer); virtual;
procedure ChangeAttr(Line, ColBeg, ColEnd: Integer); virtual;
procedure GutterPaint(Canvas: TCanvas); dynamic;
procedure GutterClick(Line: Integer); dynamic;
procedure GutterDblClick(Line: Integer); dynamic;
procedure BookmarkChanged(Bookmark: Integer); dynamic;
procedure CompletionIdentifier(var Cancel: Boolean); dynamic;
procedure CompletionTemplate(var Cancel: Boolean); dynamic;
procedure DoCompletionIdentifier(var Cancel: Boolean);
procedure DoCompletionTemplate(var Cancel: Boolean);
protected
procedure Resize; override;
procedure CreateWnd; override;
procedure CreateParams(var Params: TCreateParams); override;
procedure Loaded; override;
{$IFDEF VisualCLX}
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; override;
{$ENDIF VisualCLX}
procedure ScrollBarScroll(Sender: TObject; ScrollCode: TScrollCode; var
ScrollPos: Integer);
procedure Scroll(Vert: Boolean; ScrollPos: Integer); dynamic;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure KeyPress(var Key: Char); override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer;
{$IFDEF VisualCLX} const {$ENDIF} MousePos: TPoint): Boolean; override;
procedure DblClick; override;
procedure GetDlgCode(var Code: TDlgCodes); override;
procedure FocusSet(PrevWnd: THandle); override;
procedure FocusKilled(NextWnd: THandle); override;
procedure DoPaste; dynamic;
procedure DoCopy; dynamic;
procedure DoCut; dynamic;
procedure CursorChanged; override;
procedure FontChanged; override;
function DoEraseBackground(Canvas: TCanvas; Param: Integer): Boolean; override;
{ IFixedPopupIntf method assignment }
procedure IFixedPopupIntf.Cut = ClipboardCut;
procedure IFixedPopupIntf.Copy = ClipboardCopy;
procedure IFixedPopupIntf.Paste = ClipboardPaste;
procedure IFixedPopupIntf.Delete = DeleteSelected;
protected
{ get/set methods for properties }
procedure SetGutterWidth(AWidth: Integer);
procedure SetGutterColor(AColor: TColor);
procedure SetBorderStyle(Value: TBorderStyle);
function GetSelStart: Integer;
procedure SetSelStart(ASelStart: Integer);
procedure SetSelLength(ASelLength: Integer);
function GetSelLength: Integer;
procedure SetSelBlockFormat(Value: TJvSelBlockFormat);
function GetSelBlockFormat: TJvSelBlockFormat;
procedure SetMode(Index: Integer; Value: Boolean);
procedure SetCaretPosition(Index, Pos: Integer);
procedure SetCols(ACols: Integer);
procedure SetRows(ARows: Integer);
procedure SetScrollBars(Value: TScrollStyle);
procedure SetRightMarginVisible(Value: Boolean);
procedure SetRightMargin(Value: Integer);
procedure SetRightMarginColor(Value: TColor);
procedure SetSelBackColor(const Value: TColor);
procedure SetSelForeColor(const Value: TColor);
procedure SetBracketHighlighting(Value: TJvBracketHighlighting);
procedure SetCurrentLineHighlight(const Value: TColor);
function GetPopupMenu: TPopupMenu; override;
function GetLineCount: Integer; virtual; abstract;
function GetLineLength(Index: Integer): Integer; virtual; abstract;
function FindNotBlankCharPosInLine(Line: Integer): Integer; virtual; abstract;
procedure LockUpdate;
procedure UnlockUpdate;
property UpdateLock: Integer read FUpdateLock;
property Compound: Integer read FCompound;
property EditorClient: TJvEditorClient read FEditorClient;
protected
function GetClipboardBlockFormat: TJvSelBlockFormat;
procedure SetClipboardBlockFormat(const Value: TJvSelBlockFormat);
procedure SetSel(SelX, SelY: Integer);
function IsNewSelection: Boolean;
function IsEmptySelection: Boolean;
procedure PaintSelection;
procedure SetUnSelected;
procedure RemoveSelectedBlock;
procedure PersistentBlocksSetUnSelected;
procedure SetSelUpdateRegion(BegY, EndY: Integer);
procedure AdjustSelLineMode(Restore: Boolean);
procedure AdjustPersistentBlockSelection(X, Y: Integer;
Mode: TAdjustPersistentBlockMode; Args: array of Integer);
protected
LineAttrs: TLineAttrs;
procedure Paint; override;
procedure PaintLine(Line: Integer; ColBeg, ColEnd: Integer); overload;
procedure PaintLineText(Line: Integer; ColBeg, ColEnd: Integer;
var ColPainted: Integer); virtual; abstract;
procedure GetBracketHighlightAttr(Line: Integer; var Attrs: TLineAttrs); virtual;
procedure HighlightBrackets(X, Y: Integer; BetweenSearch: Boolean = False); virtual;
procedure GetBracketHighlightingWords(var Direction: Integer;
const Start: AnsiString; var Stop: AnsiString; var CaseSensitive: Boolean); virtual;
function FontCacheFind(LA: TLineAttr): TFont;
procedure FontCacheClear;
procedure InsertChar(const Key: Word); virtual; abstract;
procedure Mouse2Cell(X, Y: Integer; var CX, CY: Integer);
procedure DrawRightMargin;
procedure SetCaretInternal(X, Y: Integer);
procedure NotUndoable;
procedure NotRedoable;
procedure ChangeBookmark(Bookmark: TBookmarkNum; Valid: Boolean);
procedure BeginRecord;
procedure EndRecord(var AMacro: TMacro);
procedure PlayMacro(const AMacro: TMacro);
function DoCommand(ACommand: TEditCommand; var X, Y: Integer;
var CaretUndo: Boolean): Boolean; virtual; abstract;
procedure LineDeleted(Line: Integer); virtual;
procedure LineInserted(Line: Integer); virtual;
property LineCount: Integer read GetLineCount;
property LineLength[Index: Integer]: Integer read GetLineLength;
property Completion: TJvCompletionBase read FCompletion write FCompletion;
public
Bookmarks: TBookmarks;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
procedure SetLeftTop(ALeftCol, ATopRow: Integer);
procedure PaintLine(Line: Integer); overload;
function CanUndo: Boolean; { IFixedPopupIntf }
function CanRedo: Boolean;
function CanCopy: Boolean; { IFixedPopupIntf }
function CanPaste: Boolean; { IFixedPopupIntf }
function CanCut: Boolean; { IFixedPopupIntf }
function CanSelectAll: Boolean; { IFixedPopupIntf }
procedure SelectAll; { IFixedPopupIntf }
function HasSelection: Boolean; { IFixedPopupIntf }
procedure ClipboardCopy; dynamic; abstract;
procedure ClipboardPaste; dynamic; abstract;
procedure ClipboardCut; dynamic;
procedure DeleteSelected; dynamic; abstract;
procedure ClearSelection; dynamic;
procedure Undo;
procedure Redo; // not implemented yet
procedure SelectRange(BegX, BegY, EndX, EndY: Integer);
function CalcCellRect(X, Y: Integer): TRect;
procedure SetCaret(X, Y: Integer);
procedure CaretFromPos(Pos: Integer; var X, Y: Integer);
function PosFromCaret(X, Y: Integer): Integer;
procedure Mouse2Caret(X, Y: Integer; var CX, CY: Integer);
{ MousePosToCell returns the cell position of the cell where the mouse
cursor is. }
procedure MousePosToCell(X, Y: Integer; var CX, CY: Integer);
procedure CaretCoord(X, Y: Integer; var CX, CY: Integer);
function PosFromMouse(X, Y: Integer): Integer;
procedure PaintCaret(bShow: Boolean);
function GetTextLen: Integer;
procedure SelectWordOnCaret; virtual; abstract;
procedure BeginUpdate;
procedure EndUpdate;
procedure MakeRowVisible(ARow: Integer);
procedure Command(ACommand: TEditCommand); virtual;
procedure PostCommand(ACommand: TEditCommand);
procedure IndentColumns(X: Integer; BegY, EndY: Integer); virtual; abstract;
procedure UnIndentColumns(X: Integer; BegY, EndY: Integer); virtual; abstract;
procedure IndentLines(UnIndent: Boolean; BegY, EndY: Integer);
procedure IndentSelLines(UnIndent: Boolean);
procedure BeginCompound;
procedure EndCompound;
procedure PostBeginCompound;
procedure PostEndCompound;
property Gutter: TJvGutter read FGutter;
property LeftCol: Integer read FLeftCol;
property TopRow: Integer read FTopRow;
property VisibleColCount: Integer read FVisibleColCount;
property VisibleRowCount: Integer read FVisibleRowCount;
property LastVisibleCol: Integer read FLastVisibleCol;
property LastVisibleRow: Integer read FLastVisibleRow;
property Cols: Integer read FCols write SetCols;
property Rows: Integer read FRows write SetRows;
property CaretX: Integer index 0 read FCaretX write SetCaretPosition;
property CaretY: Integer index 1 read FCaretY write SetCaretPosition;
property Modified: Boolean read FModified write FModified;
property SelBlockFormat: TJvSelBlockFormat read GetSelBlockFormat write SetSelBlockFormat default bfNonInclusive;
property SelStart: Integer read GetSelStart write SetSelStart;
property SelLength: Integer read GetSelLength write SetSelLength;
property Keyboard: TJvKeyboard read FKeyboard;
property CellRect: TCellRect read FCellRect;
property UndoBuffer: TJvUndoBuffer read FUndoBuffer;
property GroupUndo: Boolean read FGroupUndo write FGroupUndo default True;
property UndoAfterSave: Boolean read FUndoAfterSave write FUndoAfterSave;
property Recording: Boolean read FRecording;
property UseFixedPopup: Boolean read FUseFixedPopup write FUseFixedPopup;
property LineInformations: TJvLineInformationList read FLineInformations;
public
{ published in descendants }
property BeepOnError: Boolean read FBeepOnError write FBeepOnError default True;
property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle default bsSingle;
property ScrollBars: TScrollStyle read FScrollBars write SetScrollBars default ssBoth;
property Cursor default crIBeam;
property Color default clWindow;
property GutterWidth: Integer read FGutterWidth write SetGutterWidth;
property GutterColor: TColor read FGutterColor write SetGutterColor default clBtnFace;
property RightMarginVisible: Boolean read FRightMarginVisible write SetRightMarginVisible default True;
property RightMargin: Integer read FRightMargin write SetRightMargin default 80;
property RightMarginColor: TColor read FRightMarginColor write SetRightMarginColor default clBtnFace;
property InsertMode: Boolean index 0 read FInsertMode write SetMode default True;
property ReadOnly: Boolean index 1 read FReadOnly write SetMode default False;
property DoubleClickLine: Boolean read FDoubleClickLine write FDoubleClickLine default False;
property TabStops: AnsiString read FTabStops write FTabStops;
property SmartTab: Boolean read FSmartTab write FSmartTab default True;
property BackSpaceUnindents: Boolean read FBackSpaceUnindents write FBackSpaceUnindents default True;
property AutoIndent: Boolean read FAutoIndent write FAutoIndent default True;
property KeepTrailingBlanks: Boolean read FKeepTrailingBlanks write FKeepTrailingBlanks default False;
property CursorBeyondEOF: Boolean read FCursorBeyondEOF write FCursorBeyondEOF default False;
property BlockOverwrite: Boolean read FBlockOverwrite write FBlockOverwrite default True;
property PersistentBlocks: Boolean read FPersistentBlocks write FPersistentBlocks default False;
property BracketHighlighting: TJvBracketHighlighting read FBracketHighlighting write SetBracketHighlighting;
property SelForeColor: TColor read FSelForeColor write SetSelForeColor;
property SelBackColor: TColor read FSelBackColor write SetSelBackColor;
property HideCaret: Boolean read FHideCaret write FHideCaret default False;
property CurrentLineHighlight: TColor read FCurrentLineHighlight write SetCurrentLineHighlight default clNone;
property ErrorHighlighting: TJvErrorHighlighting read FErrorHighlighting;
property OnChangeStatus: TNotifyEvent read FOnChangeStatus write FOnChangeStatus;
property OnScroll: TNotifyEvent read FOnScroll write FOnScroll;
property OnResize: TNotifyEvent read FOnResize write FOnResize;
property OnKeyDown;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -