user30478
user30478

Reputation: 401

How to insert text at caret position in SynEdit

There is a procedure SynEdit.InsertTextAtCaret('Text') for Lazarus version of SynEdit. How to insert text at caret for Delphi version of SynEdit with undo support?

Upvotes: 1

Views: 1867

Answers (2)

Leandro Reis
Leandro Reis

Reputation: 11

you can use this code:

SynEdit1.InsertTextAtCaret('text'); 

Upvotes: 1

DmLam
DmLam

Reputation: 136

There is procedure

TCustomSynEdit.procedure InsertBlock(const BB, BE: TBufferCoord; ChangeStr: PWideChar; AddToUndoList: Boolean);

It inserts ChangeStr changing text from BB to BE position. You may set BB and BE to current caret coordinates and you'll get what you want

For example

SynEdit1.InsertBlock(SynEdit1.CaretXY, SynEdit1.CaretXY, 'test', true);

Upvotes: 3

Related Questions