Skip to content

Commit

Permalink
Improve editor ctrl+click
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Dec 9, 2023
1 parent b8557b5 commit 99a9df4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
10 changes: 10 additions & 0 deletions Source/editor/simba.editor.pas
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ TSimbaEditor = class(TSimbaSynEdit)
FLastTextChangeStamp: Int64;
FModifiedEvent: TNotifyEvent;

procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;

procedure FontChanged(Sender: TObject); override;

procedure MaybeReplaceModifiers;
Expand Down Expand Up @@ -276,6 +278,14 @@ procedure TSimbaEditor.SetUseSimbaColors(Value: Boolean);
FAttributes.LoadFromFile(SimbaSettings.Editor.CustomColors.Value);
end;

procedure TSimbaEditor.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if (ssCtrl in Shift) then // Mouse link fix
CaretXY := PixelsToRowColumn(Point(X, Y));

inherited MouseDown(Button, Shift, X, Y);
end;

procedure TSimbaEditor.FontChanged(Sender: TObject);
begin
inherited FontChanged(Sender);
Expand Down
2 changes: 1 addition & 1 deletion Source/simba.internetsocket.pas
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function TSimbaInternetSocket.HasData: Boolean;
FSocket.ReadFlags := MSG_PEEK;

try
Result := FSocket.Read(b, 1) > 0;
Result := FSocket.Read(b{%H-}, 1) > 0;
finally
FSocket.SetSocketBlockingMode(FSocket.Handle, bmBlocking, @FDS);
FSocket.ReadFlags := 0;
Expand Down
8 changes: 1 addition & 7 deletions Source/simba.scripttab.pas
Original file line number Diff line number Diff line change
Expand Up @@ -379,16 +379,10 @@ procedure TSimbaScriptTab.DoEditorModified(Sender: TObject);

procedure TSimbaScriptTab.DoEditorLinkClick(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if (Sender is TSynEdit) then
begin
X := TSynEdit(Sender).PixelsToRowColumn(ScreenToControl(Mouse.CursorPos), []).X;
Y := TSynEdit(Sender).PixelsToRowColumn(ScreenToControl(Mouse.CursorPos), []).Y;
end;

FLinkClick.Script := Script;
FLinkClick.ScriptFileName := ScriptFileName;
FLinkClick.CaretPos := Editor.GetCaretPos(True);
FLinkClick.Expression := Editor.GetExpressionEx(X, Y);
FLinkClick.Expression := Editor.GetExpressionEx(FEditor.CaretX, FEditor.CaretY);

QueueOnMainThread(@DoFindAndShowDeclaration);
end;
Expand Down

0 comments on commit 99a9df4

Please sign in to comment.