mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 23:39:40 +02:00
SynEdit: Fixed paste after auto indent (broke in revision 20682 #db631b7877)
git-svn-id: trunk@20685 -
This commit is contained in:
parent
29b5dce82a
commit
faba3df333
@ -3774,15 +3774,12 @@ end;
|
|||||||
|
|
||||||
procedure TCustomSynEdit.SetCaretX(const Value: Integer);
|
procedure TCustomSynEdit.SetCaretX(const Value: Integer);
|
||||||
begin
|
begin
|
||||||
SetCaretXY(Point(Value, CaretY));
|
FCaret.CharPos := Value;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSynEdit.SetCaretY(const Value: Integer);
|
procedure TCustomSynEdit.SetCaretY(const Value: Integer);
|
||||||
begin
|
begin
|
||||||
FCaret.LinePos := Value;
|
FCaret.LinePos := Value;
|
||||||
if (CompareCarets(FCaret.LineBytePos, FBlockSelection.StartLineBytePos) <> 0)
|
|
||||||
and not(SelAvail or FBlockSelection.SelCanContinue(FCaret)) then
|
|
||||||
FBlockSelection.StartLineBytePos := FCaret.LineBytePos;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomSynEdit.GetCaretXY: TPoint;
|
function TCustomSynEdit.GetCaretXY: TPoint;
|
||||||
@ -3804,9 +3801,6 @@ procedure TCustomSynEdit.SetCaretXY(Value: TPoint);
|
|||||||
// physical position (screen)
|
// physical position (screen)
|
||||||
begin
|
begin
|
||||||
fCaret.LineCharPos:= Value;
|
fCaret.LineCharPos:= Value;
|
||||||
if (CompareCarets(FCaret.LineBytePos, FBlockSelection.StartLineBytePos) <> 0)
|
|
||||||
and not(SelAvail or FBlockSelection.SelCanContinue(FCaret)) then
|
|
||||||
FBlockSelection.StartLineBytePos := FCaret.LineBytePos;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSynEdit.CaretChanged(Sender: TObject);
|
procedure TCustomSynEdit.CaretChanged(Sender: TObject);
|
||||||
|
@ -87,6 +87,7 @@ type
|
|||||||
function AdjustBytePosToCharacterStart(Line: integer; BytePos: integer): integer;
|
function AdjustBytePosToCharacterStart(Line: integer; BytePos: integer): integer;
|
||||||
function GetFirstLineBytePos: TPoint;
|
function GetFirstLineBytePos: TPoint;
|
||||||
function GetLastLineBytePos: TPoint;
|
function GetLastLineBytePos: TPoint;
|
||||||
|
procedure SetCaret(const AValue: TSynEditCaret);
|
||||||
procedure SetEnabled(const Value : Boolean);
|
procedure SetEnabled(const Value : Boolean);
|
||||||
procedure SetActiveSelectionMode(const Value: TSynSelectionMode);
|
procedure SetActiveSelectionMode(const Value: TSynSelectionMode);
|
||||||
procedure SetSelectionMode (const AValue: TSynSelectionMode);
|
procedure SetSelectionMode (const AValue: TSynSelectionMode);
|
||||||
@ -96,6 +97,7 @@ type
|
|||||||
procedure SetEndLineBytePos(Value: TPoint);
|
procedure SetEndLineBytePos(Value: TPoint);
|
||||||
function GetSelText: string;
|
function GetSelText: string;
|
||||||
procedure SetSelText(const Value: string);
|
procedure SetSelText(const Value: string);
|
||||||
|
procedure DoCaretChanged(Sender: TObject);
|
||||||
public
|
public
|
||||||
constructor Create(ALines: TSynEditStrings);
|
constructor Create(ALines: TSynEditStrings);
|
||||||
//destructor Destroy; override;
|
//destructor Destroy; override;
|
||||||
@ -124,7 +126,7 @@ type
|
|||||||
property FirstLineBytePos: TPoint read GetFirstLineBytePos;
|
property FirstLineBytePos: TPoint read GetFirstLineBytePos;
|
||||||
property LastLineBytePos: TPoint read GetLastLineBytePos;
|
property LastLineBytePos: TPoint read GetLastLineBytePos;
|
||||||
property InvalidateLinesMethod : TInvalidateLines write FInvalidateLinesMethod;
|
property InvalidateLinesMethod : TInvalidateLines write FInvalidateLinesMethod;
|
||||||
property Caret: TSynEditCaret read FCaret write FCaret;
|
property Caret: TSynEditCaret read FCaret write SetCaret;
|
||||||
property UndoList: TSynEditUndoList read fUndoList write fUndoList;
|
property UndoList: TSynEditUndoList read fUndoList write fUndoList;
|
||||||
// TODO: Move dependend functions to Lines
|
// TODO: Move dependend functions to Lines
|
||||||
property TabWidth: integer read FTabWidth write FTabWidth;
|
property TabWidth: integer read FTabWidth write FTabWidth;
|
||||||
@ -631,6 +633,14 @@ begin
|
|||||||
SetSelTextPrimitive(smNormal, PChar(Value));
|
SetSelTextPrimitive(smNormal, PChar(Value));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSynEditSelection.DoCaretChanged(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if (not FCaret.IsAtLineChar(StartLineBytePos))
|
||||||
|
and not(SelAvail or SelCanContinue(FCaret))
|
||||||
|
then
|
||||||
|
StartLineBytePos := FCaret.LineBytePos;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSynEditSelection.SetSelTextPrimitive(PasteMode : TSynSelectionMode;
|
procedure TSynEditSelection.SetSelTextPrimitive(PasteMode : TSynSelectionMode;
|
||||||
Value : PChar);
|
Value : PChar);
|
||||||
var
|
var
|
||||||
@ -1020,6 +1030,16 @@ begin
|
|||||||
Result := EndLineBytePos;
|
Result := EndLineBytePos;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSynEditSelection.SetCaret(const AValue: TSynEditCaret);
|
||||||
|
begin
|
||||||
|
if FCaret = AValue then exit;
|
||||||
|
if FCaret <> nil then
|
||||||
|
Caret.RemoveChangeHandler(@DoCaretChanged);
|
||||||
|
FCaret := AValue;
|
||||||
|
if FCaret <> nil then
|
||||||
|
Caret.AddChangeHandler(@DoCaretChanged);
|
||||||
|
end;
|
||||||
|
|
||||||
function TSynEditSelection.SelAvail : Boolean;
|
function TSynEditSelection.SelAvail : Boolean;
|
||||||
begin
|
begin
|
||||||
Result := (FStartBytePos <> FEndBytePos) or
|
Result := (FStartBytePos <> FEndBytePos) or
|
||||||
|
Loading…
Reference in New Issue
Block a user