Forum > Suggestions

SynEdit and gutter — tight in there

<< < (2/3) > >>

Martin_fr:
I see, but not each needs it individual space setting. Some can be grouped.

Anyway, please create a feature request on the issue tracker.

furious programming:
Ok, I checked the TSynEdit component and that's what it currently offers, in the context of my suggestion to add more gutter configuration options. And it looks like most of the spacing is already available, because the component supports it, and the only problem is that you can't set it in the IDE settings window (there are no controls for that). So it turns out that adding the spacing configuration doesn't require much work.


The first thing is the spacing on the sides of the gutter. There are currently two properties for this — SynEdit.Gutter.LeftOffset and SynEdit.Gutter.RightOffset. In practice, they do exactly what I suggested, so you just need to add two SpinEdit to the IDE settings window, used to specify the size of these offsets. These two properties work seamlessly with the automatic width of the gutter — very nice.


The second thing is the offsets of the gutter parts. It's also nice here, because most of it is already implemented. Each part has a Width and AutoSize property that allows you to set an auto width (in terms of content) or a custom width (in pixels). The exception here is the TSynGutterSeparator, which already has an offset implemented (the LineOffset, LineOnRight and LineWidth properties), which now give you the ability to fully configure this part.

Here, the only thing that would fit is to simply add LeftOffset and RightOffset properties to the class of each part and respect them when rendering. However, each part should have two offsets, not just one, because the order of gutter parts (from left to right) can be freely changed and this will and this will always ensure the correct gutter appearance (and by the way will be in line with the properties of the gutter itself). Additional offsets in gutter part classes are also necessary because, for example, TSynGutterChanges always renders the rectangle to its entire area, regardless of its width.


After extending gutter and its parts with offset properties and changing the rendering code, the component will be ready for customization. Then the only thing you need to do is add to the IDE settings window a controls with data that will be assigned to the gutter properties. These settings can be so many (the more the better) that it would be worth to separate them into a new branch. Currently, the visibility and gutter separator settings are in the Editor/Display branch, and it would be better to create a Editor/Gutter branch and put all the gutter-related options there.

PS: it would be nice to give users the ability to change the order of gutter parts. SynEdit already supports this, so it would be nice to be able to customize it.

Martin_fr:
There is a different between on offset and padding  (for the gutter parts).
Well, there are 2 ways of doing it => those are the 2 names I use.

1) Offset
A gutter part has its width. And then there are n pixels offset to the next part.
In that case:
- the main gutter must paint the gaps
- only one offset is needed per part, as it will define the gap.
  Unless you want the comfort of "gap := max(LeftPart.RightOffset, RightPart.LeftOffest)"
- With different colored parts, the gaps will all have the main gutter background color.
  That would be bad, if each gutter part has it's own color, as then the gaps have yet an alternate color....

2) padding.
There is some space where the gutter-part does not draw content. Only its background color is painted.
This is part of the gutter part. So the GutterPart.Width is increased.
The padding is the offset inside the GutterPart at which content is drawn.
Mouseclicks may or may not react in the padded area.


I personally prefer the 2nd "padding" method.

In SynEdit each gutter could implement a padding for the left and right.

In the IDE, ....
we have gutterparts: icon, line, change, separator, fold
both with left and right => 10 spin-edits  (even if only one, and a selector, still 10 setting)
IMHO that is confusing.

- And for example the text, if you want to give it space, you pad it on both sides. So that would be just one IDE setting.
  (same for fold and icon => the only question is, if all of those 3 need individual padding settings...)
- The change indicator probably doesn't need padding. It should paint full width. Any distance is to be hold by the other parts.
  (It might be that the change indicator wants a configurable width.... not sure

So then there would at most be the following spins
- padding line number
- padding icon => here the padding could be the space between 2 icons, and the padding on the outside defaults to half the value.
- maybe padding fold
- if needs must: width of change indicator.





furious programming:
Yes, padding would be a better fit, but offset is compatible with SynEdit properties. Unfortunately, the SynEdit component already has the LeftOffset and RightOffset properties, which should be paddings, not offsets. So here you can choose either a word that correctly describes the part's behavior or one that is compatible with existing properties.


As for part configuration, IMO the best solution would be to create a separate branch in the IDE settings tree that would contain all the gutter-related options. There should be two ListBoxes to configure which parts are visible and which are not. The ListBox on the left would show the ones that we don't want to see in the right ListBox (as in the case of project settings and forms that are to be created automatically). The ListBox on the left would not only show which parts are visible, but would also determine the order of the parts in the gutter. A simple thing, and it will allow you to freely configure the contents of the gutter (parts and order).

Instead of two ListBoxes, there can be one, because instead of moving parts between two ListBoxes, just add a CheckBox called Visible, thanks to which you will be able to turn the visibility of specific parts on and off. After all, there are only a few gutter parts, so one ListBox will be more convenient to use and will take up less space. Perhaps instead of a ListBox, a simple TreeView will be better, because the item icons can inform you whether a part is visible or disabled.

However, in order for the gutter configuration to be convenient, there should also be SynEdit on the page (with some sample content), so that it shows live how the current user settings affect the gutter. So the gutter settings page should look similar to the page for the Editor/Display/Colors branch — on the left a list of gutter parts, on the right SynEdit showing what the gutter will look like, and below the controls for configuring the gutter and its parts. Or vice versa — at the top, the main settings of the gutter (its visibility, left and right offsets, etc., which is what we have now), below the controls for configuring the gutter part, and at the very bottom ListBox (left) and SynEdit (right). I like this order better.


When it comes to spacing configuration, you only need a few controls whose data will be set after selecting a part in the left ListBox. Two SpinEdits are enough for left and right padding. There must be two, because it must be possible to set the paddings separately - the user may want, for example, a large left padding for a line number, but a small (or no) padding on the right. If you give only one SpinEdit to the configuration (the same for both paddings), you will reduce the configuration possibilities, and the gutter parts may look bad if their order changes. Two SpinEdits instead of one doesn't make any difference, because there will still be plenty of space in the IDE settings window, and it will give the user freedom.

In the gutter settings window, there should also be a button to reset its settings, i.e. to restore the default settings (visibility, width and order of all parts). This is in case the user messed up the settings and couldn't get them back. In fact, such a restore button should be in every IDE settings branch — click the Restore button, confirm dialog and all configuration in the active IDE options page will be set to default.

Martin_fr:

--- Quote from: furious programming on March 15, 2023, 12:31:23 pm ---Yes, padding would be a better fit, but offset is compatible with SynEdit properties. Unfortunately, the SynEdit component already has the LeftOffset and RightOffset properties, which should be paddings, not offsets. So here you can choose either a word that correctly describes the part's behavior or one that is compatible with existing properties.

--- End quote ---

Those offsets are only for the overall gutter, and afaik act as padding (since they are part of the gutter). The gutter parts don't have any, yet.




IMHO that is way to much to be there as default (build in).  I can see that as an add on package.

I am not against having options... I have added more than my fair share. Yet that one to me looks like way to much.
And why so much detail on the gutter? Then the same options could be needed for the grid in the object inspector; placing of the main menu; component palette, ...

In any case:

1) Changes to SynEdit.

I am fine with a "padding functionality (separate left/right" to be added to gutter parts.
- I prefer them named padding, even if that is out of line with the naming on the main gutter.
- If needs must, they can go as Offset (by name, but function as padding)

IMHO they should react to mouse events. But I'll accept it either way.

The gutter part for the icons can have an additional "ColumnSpacing".

I will apply a patch/merge-request for such changes

2) Changes to the IDE

2a) Small...
I do not see options for re-ordering.

- We have already visibility for "line numbers" / "separator" (negative index)
+ "fold" part depends on folding enabled. But can have an additional checkbox, as folding can and does work without the gutter part.
+ "changes" can have a checkbox *OR* width-spin (allowing 0 to hide)
+ "icons" can have a checkbox *OR* column count (allowing 0 to hide)

+ "fold", "line", "icons" can each have one "spacing" (i.e. all together 3 value, one for each).
   For the "icons" the spacing also applies between the icons (same spacing as for left/right)

That is more than I was prepared for earlier.

Ideally they get added on the "Editor > Display" page. That is where the existing options are.

They can either be all visible at the same time (that may fill up the page), or have one "selector" (drop-down / combo - though combo may be to much height), and then show the controls  for that gutter-part (controls as specified above / including existing controls).

I will apply a patch/merge-request for such changes (including subset)
For the graphics layout, a mockup may be good for discussion.
For the EditorOptions this should be new *published* properties.



2b) Big...

Anything more than the above... (yet based on the SynEdit changes from point 1)

Either
- A plug-in in a package of its own, via OPM
- Any other team member things its worth while and wants to apply it.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version