Synedit: Select paragraph did ignore the very last line in file / cleanup

git-svn-id: trunk@21028 -
This commit is contained in:
martin 2009-07-31 17:47:01 +00:00
parent 11435c4016
commit c37ba03138

View File

@ -823,17 +823,16 @@ type
AOptions: TSynSearchOptions; AStart: TPoint): integer; AOptions: TSynSearchOptions; AStart: TPoint): integer;
{$ENDIF} {$ENDIF}
procedure SelectAll; procedure SelectAll;
{$IFDEF SYN_LAZARUS}
Procedure SetHighlightSearch(const ASearch: String; AOptions: TSynSearchOptions); Procedure SetHighlightSearch(const ASearch: String; AOptions: TSynSearchOptions);
procedure SelectToBrace; procedure SelectToBrace;
procedure SetSelWord; deprecated;
procedure SelectWord;
procedure SelectLine(WithLeadSpaces: Boolean = True); procedure SelectLine(WithLeadSpaces: Boolean = True);
procedure SelectParagraph; procedure SelectParagraph;
procedure SetUseIncrementalColor(const AValue : Boolean); procedure SetUseIncrementalColor(const AValue : Boolean);
{$ENDIF}
procedure SetBookMark(BookMark: Integer; X: Integer; Y: Integer); procedure SetBookMark(BookMark: Integer; X: Integer; Y: Integer);
procedure SetDefaultKeystrokes; virtual; procedure SetDefaultKeystrokes; virtual;
procedure SetOptionFlag(Flag: TSynEditorOption; Value: boolean); procedure SetOptionFlag(Flag: TSynEditorOption; Value: boolean);
procedure SetSelWord;
procedure Undo; procedure Undo;
function GetLineState(ALine: Integer): TSynLineState; function GetLineState(ALine: Integer): TSynLineState;
function HasDebugMark(ALine: Integer): Boolean; function HasDebugMark(ALine: Integer): Boolean;
@ -3768,21 +3767,27 @@ begin
SetCaretAndSelection(LogicalToPhysicalPos(LastPt), Point(1, 1), LastPt); SetCaretAndSelection(LogicalToPhysicalPos(LastPt), Point(1, 1), LastPt);
end; end;
{$IFDEF SYN_LAZARUS}
procedure TCustomSynEdit.SetHighlightSearch(const ASearch : String; AOptions : TSynSearchOptions); procedure TCustomSynEdit.SetHighlightSearch(const ASearch : String; AOptions : TSynSearchOptions);
begin begin
fMarkupHighAll.SearchOptions := AOptions; fMarkupHighAll.SearchOptions := AOptions;
fMarkupHighAll.SearchString := ASearch; fMarkupHighAll.SearchString := ASearch;
end; end;
{$ENDIF}
{$IFDEF SYN_LAZARUS}
procedure TCustomSynEdit.SelectToBrace; procedure TCustomSynEdit.SelectToBrace;
begin begin
FindMatchingBracket(CaretXY,true,true,true,false); FindMatchingBracket(CaretXY,true,true,true,false);
end; end;
procedure TCustomSynEdit.SetSelWord;
begin
SelectWord;
end;
procedure TCustomSynEdit.SelectWord;
begin
SetWordBlock(PhysicalToLogicalPos(CaretXY));
end;
procedure TCustomSynEdit.SelectLine(WithLeadSpaces: Boolean = True); procedure TCustomSynEdit.SelectLine(WithLeadSpaces: Boolean = True);
begin begin
SetLineBlock(CaretXY, WithLeadSpaces); SetLineBlock(CaretXY, WithLeadSpaces);
@ -3792,7 +3797,6 @@ procedure TCustomSynEdit.SelectParagraph;
begin begin
SetParagraphBlock(CaretXY); SetParagraphBlock(CaretXY);
end; end;
{$ENDIF}
procedure TCustomSynEdit.DoBlockSelectionChanged(Sender : TObject); procedure TCustomSynEdit.DoBlockSelectionChanged(Sender : TObject);
begin begin
@ -4569,7 +4573,7 @@ var
TempString: string; TempString: string;
x: Integer; x: Integer;
begin begin
{ Value is the position of the Carat in bytes } { Value is the position of the Caret in bytes }
Value.y := MinMax(Value.y, 1, FTheLinesView.Count); Value.y := MinMax(Value.y, 1, FTheLinesView.Count);
TempString := FTheLinesView[Value.Y - 1]; TempString := FTheLinesView[Value.Y - 1];
if TempString = '' then exit; if TempString = '' then exit;
@ -4620,21 +4624,30 @@ begin
end; end;
procedure TCustomSynEdit.SetParagraphBlock(Value: TPoint); procedure TCustomSynEdit.SetParagraphBlock(Value: TPoint);
var ParagraphStartLine, ParagraphEndLine: integer; var
ParagraphStartLine, ParagraphEndLine, ParagraphEndX: integer;
begin begin
IncPaintLock; IncPaintLock;
ParagraphStartLine:=MinMax(Value.y, 1, FTheLinesView.Count); ParagraphStartLine := MinMax(Value.y, 1, FTheLinesView.Count);
ParagraphEndLine:=MinMax(Value.y+1, 1, FTheLinesView.Count); ParagraphEndLine := MinMax(Value.y+1, 1, FTheLinesView.Count);
while (ParagraphStartLine>1) ParagraphEndX := 1;
and (Trim(FTheLinesView[ParagraphStartLine-1])<>'') do while (ParagraphStartLine > 1) and
(Trim(FTheLinesView[ParagraphStartLine-1])<>'')
do
dec(ParagraphStartLine); dec(ParagraphStartLine);
while (ParagraphEndLine<FTheLinesView.Count) while (ParagraphEndLine <= FTheLinesView.Count) and
and (Trim(FTheLinesView[ParagraphEndLine-1])<>'') do (Trim(FTheLinesView[ParagraphEndLine-1])<>'')
do
inc(ParagraphEndLine); inc(ParagraphEndLine);
FBlockSelection.StartLineBytePos := Point(1,ParagraphStartLine); if (ParagraphEndLine > FTheLinesView.Count) then begin
FBlockSelection.EndLineBytePos := Point(1,ParagraphEndLine); dec(ParagraphEndLine);
ParagraphEndX := length(FTheLinesView[ParagraphEndLine-1]) + 1;
end;
FBlockSelection.StartLineBytePos := Point(1, ParagraphStartLine);
FBlockSelection.EndLineBytePos := Point(ParagraphEndX, ParagraphEndLine);
FBlockSelection.ActiveSelectionMode := smNormal; FBlockSelection.ActiveSelectionMode := smNormal;
CaretXY:=FBlockSelection.EndLineBytePos; CaretXY := FBlockSelection.EndLineBytePos;
//DebugLn(' FFF3 ',Value.X,',',Value.Y,' BlockBegin=',BlockBegin.X,',',BlockBegin.Y,' BlockEnd=',BlockEnd.X,',',BlockEnd.Y); //DebugLn(' FFF3 ',Value.X,',',Value.Y,' BlockBegin=',BlockBegin.X,',',BlockBegin.Y,' BlockEnd=',BlockEnd.X,',',BlockEnd.Y);
DecPaintLock; DecPaintLock;
end; end;
@ -6269,11 +6282,6 @@ begin
end; end;
{$ENDIF} {$ENDIF}
procedure TCustomSynEdit.SetSelWord;
begin
SetWordBlock(PhysicalToLogicalPos(CaretXY));
end;
procedure TCustomSynEdit.SetExtraLineSpacing(const Value: integer); procedure TCustomSynEdit.SetExtraLineSpacing(const Value: integer);
begin begin
if fExtraLineSpacing=Value then exit; if fExtraLineSpacing=Value then exit;