View Issue Details

IDProjectCategoryView StatusLast Update
0030012LazarusIDEpublic2016-08-16 23:10
ReportersilvioprogAssigned ToMartin Friebe 
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version1.7 (SVN)Product Build 
Target Version1.8Fixed in Version1.7 (SVN) 
Summary0030012: [FEATURE REQUEST] Source Editor: jump to the marked line by clicking on it
DescriptionHello,

The new Source Editor shows small marks as illustrated in the attached picture. These marks are put in the exactly source line when it has warning, hints, errors, notes etc. However, in the current trunk version, you need to roll the scrollbar to go to the marked line.

It would be nice if these marks could accept clicks, allowing the programmer to jump to the marked line just by clicking on it.

Thank you!
Steps To ReproduceTopic about this feature request: http://lists.lazarus.freepascal.org/pipermail/lazarus/2016-April/098422.html
TagsNo tags attached.
Fixed in Revision52292
LazTarget1.8
Widgetset
Attached Files
  • marks.png (12,831 bytes)
    marks.png (12,831 bytes)
  • SynEditMarkG.diff (1,917 bytes)
    Index: components/synedit/syngutterlineoverview.pp
    ===================================================================
    --- components/synedit/syngutterlineoverview.pp	(revision 52254)
    +++ components/synedit/syngutterlineoverview.pp	(working copy)
    @@ -304,6 +304,7 @@
         function  TextLineToPixelEnd(ALine: Integer): Integer;
         procedure DoResize(Sender: TObject); override;
         Procedure PaintWinControl(Sender: TObject);
    +    Procedure OnClickWinControl(Sender: TObject);
       public
         destructor Destroy; override;
         procedure Assign(Source: TPersistent); override;
    @@ -1267,7 +1268,6 @@
     end;
     
     { TSynGutterLineOverview }
    -
     procedure TSynGutterLineOverview.Init;
     begin
       inherited Init;
    @@ -1277,6 +1277,7 @@
       FWinControl.Parent := SynEdit;
       FWinControl.DoubleBuffered := SynEdit.DoubleBuffered;
       FWinControl.OnPaint := @PaintWinControl;
    +  FWinControl.OnClick := @OnClickWinControl;
     
       FLineMarks := TSynGutterLOvLineMarksList.Create;
       FProviders := TSynGutterLineOverviewProviderList.Create(Self);
    @@ -1423,6 +1424,31 @@
         FLineMarks[i].Paint(FWinControl.Canvas, AClip, 0, MarkHeight);
     end;
     
    +procedure TSynGutterLineOverview.OnClickWinControl(Sender: TObject);
    +var
    +  i, markPixLine: Integer;
    +  TextLine, ClientMouseY : Integer;
    +
    +begin
    +  TextLine := -1;
    +  ClientMouseY := Mouse.CursorPos.y - TWinControl(Sender).ClientOrigin.y;
    +
    +  for i:= 0 to FLineMarks.Count-1 do
    +  begin
    +    markPixLine:= FLineMarks.GetLineMarks(i).PixLine;
    +    if (ClientMouseY >= markPixLine) and (ClientMouseY <= (markPixLine+MarkHeight)) then
    +    begin
    +      TextLine := FLineMarks.GetLineMarks(i).GetMark(0).Line;
    +      break;
    +    end;
    +  end;
    +  // no marker where selected then exit
    +  if TextLine < 0 then exit;
    +
    +  CaretObj.CharPos := 0;
    +  CaretObj.LinePos := TextLine;
    +end;
    +
     function TSynGutterLineOverview.GetMarkHeight: Integer;
     begin
       Result := FLineMarks.ItemHeight;
    
    SynEditMarkG.diff (1,917 bytes)

Activities

silvioprog

2016-04-14 17:41

reporter  

marks.png (12,831 bytes)
marks.png (12,831 bytes)

Ondrej Pokorny

2016-04-16 08:05

reporter   ~0092054

I would say the marks don't need to accept click. The whole bar should accept them.

Vojtech Cihak

2016-04-16 16:51

reporter   ~0092057

Do you mean to evolve the bar to a minimap? https://atom.io/packages/minimap

shobits1

2016-04-29 02:29

reporter  

SynEditMarkG.diff (1,917 bytes)
Index: components/synedit/syngutterlineoverview.pp
===================================================================
--- components/synedit/syngutterlineoverview.pp	(revision 52254)
+++ components/synedit/syngutterlineoverview.pp	(working copy)
@@ -304,6 +304,7 @@
     function  TextLineToPixelEnd(ALine: Integer): Integer;
     procedure DoResize(Sender: TObject); override;
     Procedure PaintWinControl(Sender: TObject);
+    Procedure OnClickWinControl(Sender: TObject);
   public
     destructor Destroy; override;
     procedure Assign(Source: TPersistent); override;
@@ -1267,7 +1268,6 @@
 end;
 
 { TSynGutterLineOverview }
-
 procedure TSynGutterLineOverview.Init;
 begin
   inherited Init;
@@ -1277,6 +1277,7 @@
   FWinControl.Parent := SynEdit;
   FWinControl.DoubleBuffered := SynEdit.DoubleBuffered;
   FWinControl.OnPaint := @PaintWinControl;
+  FWinControl.OnClick := @OnClickWinControl;
 
   FLineMarks := TSynGutterLOvLineMarksList.Create;
   FProviders := TSynGutterLineOverviewProviderList.Create(Self);
@@ -1423,6 +1424,31 @@
     FLineMarks[i].Paint(FWinControl.Canvas, AClip, 0, MarkHeight);
 end;
 
+procedure TSynGutterLineOverview.OnClickWinControl(Sender: TObject);
+var
+  i, markPixLine: Integer;
+  TextLine, ClientMouseY : Integer;
+
+begin
+  TextLine := -1;
+  ClientMouseY := Mouse.CursorPos.y - TWinControl(Sender).ClientOrigin.y;
+
+  for i:= 0 to FLineMarks.Count-1 do
+  begin
+    markPixLine:= FLineMarks.GetLineMarks(i).PixLine;
+    if (ClientMouseY >= markPixLine) and (ClientMouseY <= (markPixLine+MarkHeight)) then
+    begin
+      TextLine := FLineMarks.GetLineMarks(i).GetMark(0).Line;
+      break;
+    end;
+  end;
+  // no marker where selected then exit
+  if TextLine < 0 then exit;
+
+  CaretObj.CharPos := 0;
+  CaretObj.LinePos := TextLine;
+end;
+
 function TSynGutterLineOverview.GetMarkHeight: Integer;
 begin
   Result := FLineMarks.ItemHeight;
SynEditMarkG.diff (1,917 bytes)

shobits1

2016-04-29 02:30

reporter   ~0092285

Last edited: 2016-04-29 02:32

View 2 revisions

I attached a patch which implements this feature, hope it works fine and no problem will arise.

Martin Friebe

2016-05-09 21:32

manager   ~0092476

Thanks for the patch, but I choose a different way.
SynEdit use "MouseActions" for handling clicks.

Note, that if you changed the advanced settings in the IDE, the new clicks will not be added automatically. They will if you reset to the none-advanced settings (there is a reset button on the none advanced option page, in this case).

silvioprog

2016-08-02 07:04

reporter   ~0093958

Thanks for the patch. Just a addition: it should show the hand point (crHandPoint) cursor in the marks, indicating its clickability. :-)

silvioprog

2016-08-16 23:10

reporter   ~0094150

Thank you! (y)

Issue History

Date Modified Username Field Change
2016-04-14 17:41 silvioprog New Issue
2016-04-14 17:41 silvioprog File Added: marks.png
2016-04-14 18:27 Martin Friebe LazTarget => -
2016-04-14 18:27 Martin Friebe Assigned To => Martin Friebe
2016-04-14 18:27 Martin Friebe Status new => acknowledged
2016-04-16 08:05 Ondrej Pokorny Note Added: 0092054
2016-04-16 16:51 Vojtech Cihak Note Added: 0092057
2016-04-29 02:29 shobits1 File Added: SynEditMarkG.diff
2016-04-29 02:30 shobits1 Note Added: 0092285
2016-04-29 02:32 shobits1 Note Edited: 0092285 View Revisions
2016-05-09 21:32 Martin Friebe Fixed in Revision => 52292
2016-05-09 21:32 Martin Friebe LazTarget - => 1.8
2016-05-09 21:32 Martin Friebe Note Added: 0092476
2016-05-09 21:32 Martin Friebe Status acknowledged => resolved
2016-05-09 21:32 Martin Friebe Fixed in Version => 1.7 (SVN)
2016-05-09 21:32 Martin Friebe Resolution open => fixed
2016-05-09 21:32 Martin Friebe Target Version => 1.8
2016-08-02 07:04 silvioprog Note Added: 0093958
2016-08-16 23:10 silvioprog Note Added: 0094150
2016-08-16 23:10 silvioprog Status resolved => closed