Recent

Author Topic: Invite to Colorizing TSynEdit ! {Improving Editor for Editing Complex Codes}  (Read 111324 times)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5697
    • wiki
Re: Invite to Colorizing TSynEdit ! {Improving Editor for Editing Complex Codes}
« Reply #315 on: February 01, 2017, 12:52:45 pm »
You will be amazed how many different people will want many different colors....


For example, I would like colors by keyword.

That is
- try except: always red, nested in a different shade of red (1 or 2 shades, then repeat)
- "if" always green (nested with shades of green)
- "else" yellow
- loops: blue

Also I would have the keyword underlined in color, but not change the font color. Or maybe have they keyword not changed at all.

Also maybe only outline if/while , if they have a begin / or if they have nested if/while ....

There are millions of ways.....

Pascal

  • Hero Member
  • *****
  • Posts: 832
Re: Invite to Colorizing TSynEdit ! {Improving Editor for Editing Complex Codes}
« Reply #316 on: February 01, 2017, 01:41:20 pm »
I managed to get it look an behave like CNPack (at least from what i've seen on the screenshots) (Patch V20)
laz trunk - fpc trunk 32bit - Windows 10 Pro x64 (1803)

Pascal

  • Hero Member
  • *****
  • Posts: 832
Re: Invite to Colorizing TSynEdit ! {Improving Editor for Editing Complex Codes}
« Reply #317 on: February 01, 2017, 01:59:33 pm »
You will be amazed how many different people will want many different colors....


For example, I would like colors by keyword.

That is
- try except: always red, nested in a different shade of red (1 or 2 shades, then repeat)
- "if" always green (nested with shades of green)
- "else" yellow
- loops: blue

Also I would have the keyword underlined in color, but not change the font color. Or maybe have they keyword not changed at all.

Also maybe only outline if/while , if they have a begin / or if they have nested if/while ....

There are millions of ways.....

Next step is to publish MarkupInfo for each color. So you can decide the colors (frame, text, background), underline, style.
If you whant to have colors by keyord we need multiple arrays of MarkuInfo and we have to store the desired color array in the FoldAction
and we also have to have levels per color array.
laz trunk - fpc trunk 32bit - Windows 10 Pro x64 (1803)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5697
    • wiki
Re: Invite to Colorizing TSynEdit ! {Improving Editor for Editing Complex Codes}
« Reply #318 on: February 01, 2017, 03:23:09 pm »
Quote
Next step is to publish MarkupInfo for each color. So you can decide the colors (frame, text, background), underline, style.
If you whant to have colors by keyord we need multiple arrays of MarkuInfo and we have to store the desired color array in the FoldAction
and we also have to have levels per color array.

Actually no it does not go into FoldConfig....

Markup should not know about the language, yes, but... that refers to hard coded.

There be nothing wrong with having a config like
foo.ApplyToBlockType: integer;

and in IDE/User code setting
foo.ApplyToBlockType:= ord(cfbtIfThen);

This may be a list of integers, since there probably be groups.
Or you have the group mapping separate. (map each block-type to a group)
---------------------------

Then either have multiple lists of markup info, or subclass Markupinfo and add a property (either  ApplyToBlockType or ApplyToBlockGROUP (if you have group mapping)

You can then internally filter the markup list into a list for each group.

------------------------------
The other challenge is to find a good representation in IDE options. So users can easily set it up.

I once had the problem with mouse-options. I ended up with 2 pages. One for easy config. And an advanced one....




Pascal

  • Hero Member
  • *****
  • Posts: 832
Re: Invite to Colorizing TSynEdit ! {Improving Editor for Editing Complex Codes}
« Reply #319 on: February 01, 2017, 03:30:43 pm »
Do you think we can fix the state of the markup like it is now (patch v20, like in the pictures)?
Then i can go on with configuring colors (stage 1).
laz trunk - fpc trunk 32bit - Windows 10 Pro x64 (1803)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5697
    • wiki
Re: Invite to Colorizing TSynEdit ! {Improving Editor for Editing Complex Codes}
« Reply #320 on: February 01, 2017, 04:17:01 pm »
havent looked at the patch yet. asap

Pascal

  • Hero Member
  • *****
  • Posts: 832
Martin,

how can we add the posibility for the user to change the colors?

I could think of having an array of 10 TSynSelectedColor (MarkupInfo1..10 or an array).
If the MarkupInfo is enabled (IsEnabled) it will be used for outline coloring.

Where and how can i add the functionality to the preferences?
laz trunk - fpc trunk 32bit - Windows 10 Pro x64 (1803)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5697
    • wiki
Fixed amount of colors is probably easiest. Before looking at how, I suggest to plan what. And that divides into what now, and what maybe later.

There may be plenty of requests what others want, and if some of them will be considered then better to design it flexible.

Ideas that I would have:

1) make the number of colors (before rotate) configurable (collection?)
At least on the markup class, the IDE option dialog may show fixed amount for now, since that will be considerable easier.

2) 2 markup info per color.
- One for the keyword
- One for the horiz line
e.g. I would like the keyword in my source to either have no highlight at all, or just a bottom-border (underline)
So you need an extra color for the vertical line.

3) Not sure, might go to far, but different color-sets for different block types. eg red-ish reserved for try except.

Depending on that you can decide what to add to the module.

IDE config is a bit more complex.
Search the svn history for when I added a color to ide/EditorOptions

All colors are stored on the highlighter
In the IDE that is in ide/SourceMarks TAdditionalHilightAttribute. Which is an enum. and that is why it will be easier to have a fixed amount in the IDE (yet there could be a config to only use n out of the overall available).

TAdditionalHilightAttribute is then used a lot in ide/EditorOptions to define names and other info

And at last have a look at TColorSchemeLanguage.ApplyTo

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5697
    • wiki
Or you create a separate option page/tab. Like "user defined markup"