From c37ba031381f48c975a94db4f1de8a6fd291353f Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 31 Jul 2009 17:47:01 +0000 Subject: [PATCH] Synedit: Select paragraph did ignore the very last line in file / cleanup git-svn-id: trunk@21028 - --- components/synedit/synedit.pp | 56 ++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/components/synedit/synedit.pp b/components/synedit/synedit.pp index 74f5fc1eb7..c391115e70 100644 --- a/components/synedit/synedit.pp +++ b/components/synedit/synedit.pp @@ -823,17 +823,16 @@ type AOptions: TSynSearchOptions; AStart: TPoint): integer; {$ENDIF} procedure SelectAll; - {$IFDEF SYN_LAZARUS} Procedure SetHighlightSearch(const ASearch: String; AOptions: TSynSearchOptions); procedure SelectToBrace; + procedure SetSelWord; deprecated; + procedure SelectWord; procedure SelectLine(WithLeadSpaces: Boolean = True); procedure SelectParagraph; procedure SetUseIncrementalColor(const AValue : Boolean); - {$ENDIF} procedure SetBookMark(BookMark: Integer; X: Integer; Y: Integer); procedure SetDefaultKeystrokes; virtual; procedure SetOptionFlag(Flag: TSynEditorOption; Value: boolean); - procedure SetSelWord; procedure Undo; function GetLineState(ALine: Integer): TSynLineState; function HasDebugMark(ALine: Integer): Boolean; @@ -3768,21 +3767,27 @@ begin SetCaretAndSelection(LogicalToPhysicalPos(LastPt), Point(1, 1), LastPt); end; -{$IFDEF SYN_LAZARUS} procedure TCustomSynEdit.SetHighlightSearch(const ASearch : String; AOptions : TSynSearchOptions); begin fMarkupHighAll.SearchOptions := AOptions; fMarkupHighAll.SearchString := ASearch; end; -{$ENDIF} - -{$IFDEF SYN_LAZARUS} procedure TCustomSynEdit.SelectToBrace; begin FindMatchingBracket(CaretXY,true,true,true,false); end; +procedure TCustomSynEdit.SetSelWord; +begin + SelectWord; +end; + +procedure TCustomSynEdit.SelectWord; +begin + SetWordBlock(PhysicalToLogicalPos(CaretXY)); +end; + procedure TCustomSynEdit.SelectLine(WithLeadSpaces: Boolean = True); begin SetLineBlock(CaretXY, WithLeadSpaces); @@ -3792,7 +3797,6 @@ procedure TCustomSynEdit.SelectParagraph; begin SetParagraphBlock(CaretXY); end; -{$ENDIF} procedure TCustomSynEdit.DoBlockSelectionChanged(Sender : TObject); begin @@ -4569,7 +4573,7 @@ var TempString: string; x: Integer; 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); TempString := FTheLinesView[Value.Y - 1]; if TempString = '' then exit; @@ -4620,21 +4624,30 @@ begin end; procedure TCustomSynEdit.SetParagraphBlock(Value: TPoint); -var ParagraphStartLine, ParagraphEndLine: integer; +var + ParagraphStartLine, ParagraphEndLine, ParagraphEndX: integer; + begin IncPaintLock; - ParagraphStartLine:=MinMax(Value.y, 1, FTheLinesView.Count); - ParagraphEndLine:=MinMax(Value.y+1, 1, FTheLinesView.Count); - while (ParagraphStartLine>1) - and (Trim(FTheLinesView[ParagraphStartLine-1])<>'') do + ParagraphStartLine := MinMax(Value.y, 1, FTheLinesView.Count); + ParagraphEndLine := MinMax(Value.y+1, 1, FTheLinesView.Count); + ParagraphEndX := 1; + while (ParagraphStartLine > 1) and + (Trim(FTheLinesView[ParagraphStartLine-1])<>'') + do dec(ParagraphStartLine); - while (ParagraphEndLine'') do + while (ParagraphEndLine <= FTheLinesView.Count) and + (Trim(FTheLinesView[ParagraphEndLine-1])<>'') + do inc(ParagraphEndLine); - FBlockSelection.StartLineBytePos := Point(1,ParagraphStartLine); - FBlockSelection.EndLineBytePos := Point(1,ParagraphEndLine); + if (ParagraphEndLine > FTheLinesView.Count) then begin + dec(ParagraphEndLine); + ParagraphEndX := length(FTheLinesView[ParagraphEndLine-1]) + 1; + end; + FBlockSelection.StartLineBytePos := Point(1, ParagraphStartLine); + FBlockSelection.EndLineBytePos := Point(ParagraphEndX, ParagraphEndLine); 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); DecPaintLock; end; @@ -6269,11 +6282,6 @@ begin end; {$ENDIF} -procedure TCustomSynEdit.SetSelWord; -begin - SetWordBlock(PhysicalToLogicalPos(CaretXY)); -end; - procedure TCustomSynEdit.SetExtraLineSpacing(const Value: integer); begin if fExtraLineSpacing=Value then exit;