SynEdit: Fixed paste after auto indent (broke in revision 20682 #db631b7877)

git-svn-id: trunk@20685 -
This commit is contained in:
martin 2009-06-21 02:05:49 +00:00
parent 29b5dce82a
commit faba3df333
2 changed files with 22 additions and 8 deletions

View File

@ -3774,15 +3774,12 @@ end;
procedure TCustomSynEdit.SetCaretX(const Value: Integer);
begin
SetCaretXY(Point(Value, CaretY));
FCaret.CharPos := Value;
end;
procedure TCustomSynEdit.SetCaretY(const Value: Integer);
begin
FCaret.LinePos := Value;
if (CompareCarets(FCaret.LineBytePos, FBlockSelection.StartLineBytePos) <> 0)
and not(SelAvail or FBlockSelection.SelCanContinue(FCaret)) then
FBlockSelection.StartLineBytePos := FCaret.LineBytePos;
end;
function TCustomSynEdit.GetCaretXY: TPoint;
@ -3804,9 +3801,6 @@ procedure TCustomSynEdit.SetCaretXY(Value: TPoint);
// physical position (screen)
begin
fCaret.LineCharPos:= Value;
if (CompareCarets(FCaret.LineBytePos, FBlockSelection.StartLineBytePos) <> 0)
and not(SelAvail or FBlockSelection.SelCanContinue(FCaret)) then
FBlockSelection.StartLineBytePos := FCaret.LineBytePos;
end;
procedure TCustomSynEdit.CaretChanged(Sender: TObject);

View File

@ -87,6 +87,7 @@ type
function AdjustBytePosToCharacterStart(Line: integer; BytePos: integer): integer;
function GetFirstLineBytePos: TPoint;
function GetLastLineBytePos: TPoint;
procedure SetCaret(const AValue: TSynEditCaret);
procedure SetEnabled(const Value : Boolean);
procedure SetActiveSelectionMode(const Value: TSynSelectionMode);
procedure SetSelectionMode (const AValue: TSynSelectionMode);
@ -96,6 +97,7 @@ type
procedure SetEndLineBytePos(Value: TPoint);
function GetSelText: string;
procedure SetSelText(const Value: string);
procedure DoCaretChanged(Sender: TObject);
public
constructor Create(ALines: TSynEditStrings);
//destructor Destroy; override;
@ -124,7 +126,7 @@ type
property FirstLineBytePos: TPoint read GetFirstLineBytePos;
property LastLineBytePos: TPoint read GetLastLineBytePos;
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;
// TODO: Move dependend functions to Lines
property TabWidth: integer read FTabWidth write FTabWidth;
@ -631,6 +633,14 @@ begin
SetSelTextPrimitive(smNormal, PChar(Value));
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;
Value : PChar);
var
@ -1020,6 +1030,16 @@ begin
Result := EndLineBytePos;
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;
begin
Result := (FStartBytePos <> FEndBytePos) or