SynEdit: clean up, using PaintLines own class

git-svn-id: trunk@34594 -
This commit is contained in:
martin 2012-01-05 12:28:52 +00:00
parent 8b71b1eee9
commit 4ffedc9de1

View File

@ -433,7 +433,6 @@ type
FTextArea: TLazSynTextArea; FTextArea: TLazSynTextArea;
fExtraCharSpacing: integer; fExtraCharSpacing: integer;
fLeftChar: Integer; // first visible screen column
fMaxLeftChar: Integer; // 1024 fMaxLeftChar: Integer; // 1024
FOldWidth, FOldHeight: Integer; FOldWidth, FOldHeight: Integer;
@ -512,6 +511,7 @@ type
function GetCharWidth: integer; function GetCharWidth: integer;
function GetDefSelectionMode: TSynSelectionMode; function GetDefSelectionMode: TSynSelectionMode;
function GetFoldState: String; function GetFoldState: String;
function GetLeftChar: Integer;
function GetLineHeight: integer; function GetLineHeight: integer;
function GetLinesInWindow: Integer; function GetLinesInWindow: Integer;
function GetModified: Boolean; function GetModified: Boolean;
@ -955,7 +955,7 @@ type
public public
property CharsInWindow: Integer read GetCharsInWindow; property CharsInWindow: Integer read GetCharsInWindow;
property CharWidth: integer read GetCharWidth; property CharWidth: integer read GetCharWidth;
property LeftChar: Integer read fLeftChar write SetLeftChar; property LeftChar: Integer read GetLeftChar write SetLeftChar;
property LineHeight: integer read GetLineHeight; property LineHeight: integer read GetLineHeight;
property LinesInWindow: Integer read GetLinesInWindow; property LinesInWindow: Integer read GetLinesInWindow;
property MaxLeftChar: integer read fMaxLeftChar write SetMaxLeftChar property MaxLeftChar: integer read fMaxLeftChar write SetMaxLeftChar
@ -1556,6 +1556,11 @@ begin
Result := FFoldedLinesView.GetFoldDescription(0, 0, -1, -1, True); Result := FFoldedLinesView.GetFoldDescription(0, 0, -1, -1, True);
end; end;
function TCustomSynEdit.GetLeftChar: Integer;
begin
Result := FTextArea.LeftChar;
end;
function TCustomSynEdit.GetLineHeight: integer; function TCustomSynEdit.GetLineHeight: integer;
begin begin
Result := FTextArea.LineHeight; Result := FTextArea.LineHeight;
@ -1627,7 +1632,7 @@ function TCustomSynEdit.PixelsToRowColumn(Pixels: TPoint; aFlags: TSynCoordinate
// To get the text/logical position use PixelsToLogicalPos // To get the text/logical position use PixelsToLogicalPos
begin begin
Result.X := ( (Pixels.X Result.X := ( (Pixels.X
+ (fLeftChar-1) * CharWidth + (LeftChar-1) * CharWidth
- FTextArea.TextBounds.Left - FTextArea.TextBounds.Left
+ (CharWidth div 2) + (CharWidth div 2)
) div CharWidth ) div CharWidth
@ -1939,7 +1944,6 @@ begin
{$ENDIF} {$ENDIF}
fWantTabs := False; fWantTabs := False;
fTabWidth := 8; fTabWidth := 8;
fLeftChar := 1;
fTopLine := 1; fTopLine := 1;
FOldTopLine := 1; FOldTopLine := 1;
FOldTopView := 1; FOldTopView := 1;
@ -3115,7 +3119,7 @@ begin
FInternalCaret.AssignFrom(FCaret); FInternalCaret.AssignFrom(FCaret);
FInternalCaret.LineCharPos := PixelsToRowColumn(Point(X,Y)); FInternalCaret.LineCharPos := PixelsToRowColumn(Point(X,Y));
if ((X >= TextLeftPixelOffset(False)) or (fLeftChar <= 1)) and if ((X >= TextLeftPixelOffset(False)) or (LeftChar <= 1)) and
( (X < ClientWidth - TextRightPixelOffset) ( (X < ClientWidth - TextRightPixelOffset)
or (LeftChar >= CurrentMaxLeftChar)) and or (LeftChar >= CurrentMaxLeftChar)) and
((Y >= 0) or (fTopLine <= 1)) and ((Y >= 0) or (fTopLine <= 1)) and
@ -3806,8 +3810,8 @@ procedure TCustomSynEdit.SetLeftChar(Value: Integer);
begin begin
Value := Min(Value, CurrentMaxLeftChar); Value := Min(Value, CurrentMaxLeftChar);
Value := Max(Value, 1); Value := Max(Value, 1);
if Value <> fLeftChar then begin if Value <> FTextArea.LeftChar then begin
fLeftChar := Value; FTextArea.LeftChar := Value;
UpdateScrollBars; UpdateScrollBars;
InvalidateLines(-1, -1); InvalidateLines(-1, -1);
StatusChanged([scLeftChar]); StatusChanged([scLeftChar]);
@ -4002,10 +4006,10 @@ begin
exit; exit;
NewCaretXY:=CaretXY; NewCaretXY:=CaretXY;
if NewCaretXY.X < fLeftChar then if NewCaretXY.X < LeftChar then
NewCaretXY.X := fLeftChar NewCaretXY.X := LeftChar
else if NewCaretXY.X > fLeftChar + CharsInWindow - FScreenCaret.ExtraLineChars then else if NewCaretXY.X > LeftChar + CharsInWindow - FScreenCaret.ExtraLineChars then
NewCaretXY.X := fLeftChar + CharsInWindow - FScreenCaret.ExtraLineChars; NewCaretXY.X := LeftChar + CharsInWindow - FScreenCaret.ExtraLineChars;
if NewCaretXY.Y < fTopLine then if NewCaretXY.Y < fTopLine then
NewCaretXY.Y := fTopLine NewCaretXY.Y := fTopLine
else begin else begin