Recent

Author Topic: code completion for case statements with enumerated types  (Read 3062 times)

Syndrome

  • New Member
  • *
  • Posts: 35
code completion for case statements with enumerated types
« on: March 01, 2018, 12:13:24 pm »
does lazarus support it?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki

Syndrome

  • New Member
  • *
  • Posts: 35
Re: code completion for case statements with enumerated types
« Reply #2 on: March 01, 2018, 12:44:28 pm »
you mean http://wiki.lazarus.freepascal.org/New_IDE_features_since#code_macro_OfAll ?

Yes. Thank you. Sadly, it generates unaligned code, but this is better than manually enumerating all the values.

I left an alignment example below. It looks like the "code insertion" feature eats tabs - so i left comments describing the alignment.

Code: Pascal  [Select][+][-]
  1. procedure test_code_completion_for_case_statements;
  2. type
  3.         enumerated_type = (a, b, c, d, e, f, g);
  4. var
  5.         enum:enumerated_type;
  6. begin
  7.         case enum of {<- manually aligned case statement}
  8.                 a: ;   {<- aligned with 2 tabs}
  9.                 b: ;   {<- aligned with 2 tabs}
  10.                 c: ;   {<- aligned with 2 tabs}
  11.                 d: ;   {<- aligned with 2 tabs}
  12.                 e: ;   {<- aligned with 2 tabs}
  13.                 f: ;   {<- aligned with 2 tabs}
  14.                 g: ;   {<- aligned with 2 tabs}
  15.         end;      {<- aligned with 1 tab}
  16.  
  17.         case enum of {<- auto completed case statement}
  18.         a: ;   {<- aligned with 1 space + 1 tab}
  19.          b: ;  {<- aligned with 1 tab + 1 space}
  20.          c: ;  {<- aligned with 1 tab + 1 space}
  21.          d: ;  {<- aligned with 1 tab + 1 space}
  22.          e: ;  {<- aligned with 1 tab + 1 space}
  23.          f: ;  {<- aligned with 1 tab + 1 space}
  24.          g: ;  {<- aligned with 1 tab + 1 space}
  25.  end;     {<- keyword "end" aligned with 1 space}
  26. end;

Do you know how to modify built-in macros? I could try to fix this myself.
« Last Edit: March 01, 2018, 01:17:59 pm by Syndrome »

ASerge

  • Hero Member
  • *****
  • Posts: 2223
Re: code completion for case statements with enumerated types
« Reply #3 on: March 01, 2018, 09:11:43 pm »
I left an alignment example below. It looks like the "code insertion" feature eats tabs - so i left comments describing the alignment.
Do you know how to modify built-in macros? I could try to fix this myself.
Lazarus 1.8.2, Windows, x64.
Auto completed case statement:
Code: Pascal  [Select][+][-]
  1. procedure Test;
  2. type
  3.   TEnum = (a, b, c, d, e, f, g);
  4. var
  5.   Enum: TEnum;
  6. begin
  7.   Enum := a;
  8.   case Enum of
  9.     a: ;
  10.     b: ;
  11.     c: ;
  12.     d: ;
  13.     e: ;
  14.     f: ;
  15.     g: ;
  16.   end;
  17. end;
All correct.

Syndrome

  • New Member
  • *
  • Posts: 35
Re: code completion for case statements with enumerated types
« Reply #4 on: March 02, 2018, 05:35:26 am »
Lazarus 1.8.2. Windows 8.1 x64. All incorrect. I use tabs instead of spaces.

 

TinyPortal © 2005-2018