Recent

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

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • 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: 932
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 x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Pascal

  • Hero Member
  • *****
  • Posts: 932
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 x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • 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: 932
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 x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • 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: 932
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 x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • 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: 9791
  • Debugger - SynEdit - and more
    • wiki
Or you create a separate option page/tab. Like "user defined markup"

mtournay

  • Jr. Member
  • **
  • Posts: 63
Re: Invite to Colorizing TSynEdit ! {Improving Editor for Editing Complex Codes}
« Reply #324 on: February 11, 2021, 06:20:39 pm »
Hi there

Can someone, plz, lpz PLEASE create a 'tip of the day' on front lazarus-ide page so people can find the checkbox to tuen on this amazing functionnality ??

Every time I had to reinstall Lazarus on a new computer, I lost tons of minutes finding this thread, and then finding screen capture inside the thread....

Tanks a lot

Michel
laz 2.06 32b - fpc 3.04 32b - win10 64b

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Invite to Colorizing TSynEdit ! {Improving Editor for Editing Complex Codes}
« Reply #325 on: February 11, 2021, 06:51:07 pm »
Can someone, plz, lpz PLEASE create a 'tip of the day' on front lazarus-ide page so people can find the checkbox to tuen on this amazing functionnality ??

"fold outline" or "user defined markup"?

"user defined markup" already has a T.o.D.


https://svn.freepascal.org/svn/lazaruswebsite/trunk
Tips are in the file tips.txt
Images can be between 300*200 and 400*200 / or will be scaled by the browser

Feel free to submit an addition.

Links to the wiki, not the forum.
e.g. https://wiki.lazarus.freepascal.org/IDE_Window:_Editor_User_Defined_Words


Btw, while (unfortunately) not all config files can be copied, the file EditorOptions.xml can be copied to the new install.
See menu: View > Ide Internals > about IDE => find primary config path => In that folder you find EditorOptions.xml

Patches for an export/import of config will be welcome.

 

TinyPortal © 2005-2018