Skip to content

Commit

Permalink
Fixed SetCaretXYEx misuse
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanMes committed Mar 30, 2015
1 parent f50091c commit 54751ba
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 36 deletions.
4 changes: 3 additions & 1 deletion NEWS.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Version 5.11 - 29 March 2015
Version 5.11 - *

- Fixed crash related to double clicking on a compiler error when a selection was made.
- Upgraded the default compiler to TDM-GCC 4.9.2.
- Improved startup speed.
- Fixed Abort Compilation button not working anymore.
- Fixed crash in TCppParser.CheckForTypedefStruct.
Expand Down
5 changes: 2 additions & 3 deletions Source/Editor.pas
Original file line number Diff line number Diff line change
Expand Up @@ -873,9 +873,8 @@ procedure TEditor.SetCaretPosAndActivate(Line, Col: integer);
if not fText.Focused then
Self.Activate;

// Position the caret
fText.SetCaretXYEx(False, BufferCoord(Col, Line)); // prop CaretXY calls EnsureCursorPosVisibleEx(False)
fText.EnsureCursorPosVisibleEx(True); // scroll to line
// Position the caret, call EnsureCursorPosVisibleEx after setting block
fText.SetCaretXYCentered(True,BufferCoord(Col, Line));
end;

procedure TEditor.CompletionKeyPress(Sender: TObject; var Key: Char);
Expand Down
2 changes: 0 additions & 2 deletions Source/TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
- Messy painting of find results list
- Add proxy support to webupdate
- Unify look and feel of all windows
- Test TDM-GCC 4.9.x
- Rename file functionality (MoveFile)
- Fix TClassBrowser.AdvancedCustomDrawItem crash
- Same word highlight
- Double click on compiler item when selection is available broken

- Implement conditional search
https://sourceforge.net/p/orwelldevcpp/tickets/143/
Expand Down
45 changes: 16 additions & 29 deletions Source/VCL/SynEdit/Source/SynEdit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ TCustomSynEdit = class(TCustomControl)
procedure RedoItem;
procedure InternalSetCaretXY(const Value: TBufferCoord); virtual;
procedure SetCaretXY(const Value: TBufferCoord); virtual;
procedure SetCaretXYEx(CallEnsureCursorPos: Boolean; Value: TBufferCoord); virtual;
procedure SetFontSmoothing(AValue: TSynFontSmoothMethod);
procedure SetName(const Value: TComponentName); override;
procedure SetReadOnly(Value: boolean); virtual;
Expand Down Expand Up @@ -634,7 +635,6 @@ TCustomSynEdit = class(TCustomControl)
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Canvas;
procedure SetCaretXYEx(CallEnsureCursorPos: Boolean; Value: TBufferCoord); virtual;
property SelStart: Integer read GetSelStart write SetSelStart;
property SelEnd: Integer read GetSelEnd write SetSelEnd;
property AlwaysShowCaret: Boolean read FAlwaysShowCaret
Expand Down Expand Up @@ -685,7 +685,7 @@ TCustomSynEdit = class(TCustomControl)
function GetPositionOfMouse(out aPos: TBufferCoord): Boolean;
function GetWordAtRowCol(XY: TBufferCoord): string;
procedure GotoBookMark(BookMark: Integer);
procedure GotoLineAndCenter(ALine: Integer);
procedure SetCaretXYCentered(ForceToMiddle: Boolean; const Value: TBufferCoord);
function IdentChars: TSynIdentChars;
procedure InvalidateGutter;
procedure InvalidateGutterLine(aLine: integer);
Expand Down Expand Up @@ -3693,18 +3693,26 @@ function TCustomSynEdit.GetDisplayXY: TDisplayCoord;
end;

procedure TCustomSynEdit.SetCaretXY(const Value: TBufferCoord);
//there are two setCaretXY methods. One Internal, one External. The published
//property CaretXY (re)sets the block as well
begin
SetCaretXYCentered(False, Value);
end;

procedure TCustomSynEdit.SetCaretXYCentered(ForceToMiddle: Boolean; const Value: TBufferCoord);
begin
IncPaintLock;
try
Include(fStatusChanges, scSelection);
SetCaretXYEx(True, Value);
if ForceToMiddle then
SetCaretXYEx(False, Value) // do not call EnsureCursorPosVisible here
else
SetCaretXYEx(True, Value);
if SelAvail then
InvalidateSelection;
fBlockBegin.Char := fCaretX;
fBlockBegin.Line := fCaretY;
fBlockEnd := fBlockBegin;
if ForceToMiddle then
EnsureCursorPosVisibleEx(True); // but here after block has been set
finally
DecPaintLock;
end;
Expand Down Expand Up @@ -5521,34 +5529,13 @@ procedure TCustomSynEdit.GotoBookMark(BookMark: Integer);
var
iNewPos: TBufferCoord;
begin
if (BookMark in [0..9]) and
assigned(fBookMarks[BookMark]) and
(fBookMarks[BookMark].Line <= fLines.Count) then begin
if (BookMark in [0..9]) and Assigned(fBookMarks[BookMark]) and (fBookMarks[BookMark].Line <= fLines.Count) then begin
iNewPos.Char := fBookMarks[BookMark].Char;
iNewPos.Line := fBookMarks[BookMark].Line;
//call it this way instead to make sure that the caret ends up in the middle
//if it is off screen (like Delphi does with bookmarks)
SetCaretXYEx(False, iNewPos);
EnsureCursorPosVisibleEx(True);
if SelAvail then
InvalidateSelection;
fBlockBegin.Char := fCaretX;
fBlockBegin.Line := fCaretY;
fBlockEnd := fBlockBegin;
SetCaretXYCentered(True, iNewPos);
end;
end;

procedure TCustomSynEdit.GotoLineAndCenter(ALine: Integer);
begin
SetCaretXYEx(False, BufferCoord(1, ALine));
if SelAvail then
InvalidateSelection;
fBlockBegin.Char := fCaretX;
fBlockBegin.Line := fCaretY;
fBlockEnd := fBlockBegin;
EnsureCursorPosVisibleEx(True);
end;

procedure TCustomSynEdit.SetBookMark(BookMark: Integer; X: Integer; Y: Integer);
var
mark: TSynEditMark;
Expand Down Expand Up @@ -6895,7 +6882,7 @@ procedure TCustomSynEdit.ExecuteCommand(Command: TSynEditorCommand; AChar: char;
// Ignore the last line the cursor is placed on
BeginIndex := BlockBegin.Line - 1;
if BlockEnd.Char = 1 then
EndIndex := max(0,BlockEnd.Line - 2)
EndIndex := max(0, BlockEnd.Line - 2)
else
EndIndex := BlockEnd.Line - 1;

Expand Down
2 changes: 1 addition & 1 deletion devcppmingw64.nsi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
####################################################################
# Startup

!define COMPILERNAME "TDM-GCC 4.8.1"
!define COMPILERNAME "TDM-GCC 4.9.2"
!define COMPILERFOLDER "MinGW64"
!define DEVCPP_VERSION "5.11"
!define FINALNAME "Dev-Cpp ${DEVCPP_VERSION} ${COMPILERNAME} Setup.exe"
Expand Down

0 comments on commit 54751ba

Please sign in to comment.