Recent

Author Topic: [Feature Request] Background color Interface section  (Read 1270 times)

kupferstecher

  • Full Member
  • ***
  • Posts: 222
[Feature Request] Background color Interface section
« on: June 04, 2018, 11:42:57 am »
Hello Lazarus developers :)

in the editor window behind the vertical scroll bar the background color is different for the interface and implementation section. This is very useful. I'd like to see the same for the editor background, i.e. that the text background of the interface section appears in a different color. I think this is not settable by now, right? See the picture how it could look like.

I'm not able to implement that on my own, so I place it here as suggestion.

Regards
kupferstecher

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4944
    • wiki
Re: [Feature Request] Background color Interface section
« Reply #1 on: June 05, 2018, 03:49:35 pm »
I am not sure about such a feature....

But it should be do-able:
components\synedit\synhighlighterpas.pp

in
function TSynPasSyn.GetTokenAttribute: TSynHighlighterAttributes;

check
Code: Pascal  [Select]
  1. if rsInterface in frange then ...
  2.  

then modify the background...
To make that work you need an extra object (just like FCurIDEDirectiveAttri).
Assign it, alter it, return it.

-----------
That is hardcoded. Adding it to the IDE options is a bit more work
« Last Edit: June 05, 2018, 03:52:20 pm by Martin_fr »

kupferstecher

  • Full Member
  • ***
  • Posts: 222
Re: [Feature Request] Background color Interface section
« Reply #2 on: June 05, 2018, 05:54:18 pm »
Hello Martin,

thanks for the instructions. I'll have a try.

kupferstecher

  • Full Member
  • ***
  • Posts: 222
Re: [Feature Request] Background color Interface section
« Reply #3 on: June 11, 2018, 07:24:38 pm »
It took me a while to work it out. The result is not exactly as I expected, see screenshot. Is it possible to get the complete backround of the interface section in the same color?

The code I added in function TSynPasSyn.GetTokenAttribute:
Code: Pascal  [Select]
  1. if rsInterface in frange
  2.   then begin
  3.     FInterfSectionAttri.Assign(Result);
  4.     FInterfSectionAttri.Background:= clSilver;
  5.     Result := FInterfSectionAttri;
  6.   end;    

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4944
    • wiki
Re: [Feature Request] Background color Interface section
« Reply #4 on: June 11, 2018, 08:42:19 pm »
Looks promising.

Look for those methods on the HL:
  GetEol  // should return true, if you want a special attribute for the text past eol
  GetEndOfLineAttribute  // return the attribute

kupferstecher

  • Full Member
  • ***
  • Posts: 222
Re: [Feature Request] Background color Interface section
« Reply #5 on: June 11, 2018, 09:53:21 pm »
It works :)

Please see the attached screenshot.

I know its hardcoded now. So I'll use that style some time and if I like it and see benefits then I'll try to make it configurable. But probably I will need there support as well~

The following code I additionally added in function TSynPasSyn.GetEndOfLineAttribute

Code: Pascal  [Select]
  1.   if rsInterface in frange
  2.   then begin
  3.     if assigned(Result) then FInterfSectionAttri.Assign(Result);
  4.     FInterfSectionAttri.Background:= $00EFECE9; //clSilver;
  5.     Result := FInterfSectionAttri;
  6.   end;