[Gambas-devel] PrettyPrinter for use in IDE

ron ronstk at ...124...
Tue Sep 21 00:38:59 CEST 2004


On Sunday 19 September 2004 21:57, Charlie Reinl wrote:
> Salut,
> 
> I send you the PrettyPrinter, included into the IDE, for that I had to change 
> FEditor.form and *.class.
> 
> These files comme with the code.
> 
> If you like to have a go, please, don't do it in your 
>  ../gambas-0.99/app/gambas make a copy from that directory
> 
> Then merge the changes by copiing PPinstall/app/gambas/* to your test-IDE
> 
> You find the PrettyPrinter in the Contextmenu of the IDE-Editor.
> 
> You should NOT work on real projects, try it with copys of your projects 
> first. OR on your copy of the IDE.
> 
> Attention:  the PrettyPrinter in the Editor menu is not managed, so you can
>   change you sourcecode during debugging !!!!
> 
> Aamicalement
> Charlie
> 

I did and I'm happy :)
Good work Charlie, how survive your keyboard and fingers?
I'll keep it in the editor for further usage/testing.

Some notes:

1)
The DIM in a procedure code blocks.
If I check only 'Indent every..' the DIM's are aligned indented. 
If I check 'Align in Dim (...)' it is not done anymore.
'Align in Dim' must checked for the global part to get it table like,
but then the DIM is not indent anymore in the proc's.

2)
Delete empty lines is nice but keep at least 1 line on top of the procedure.
In the editor you can see it easy by the small line but not on paper.

3)
After 'Indent All' the are blank lines add to the end of the file.
Maybe strip all blank lines at the end, but leave 1 line.
As room for the paste code during cut/past operations.

4)
May be try to separate the options for the global section end the procedure blocks.

5)
I belive 'Adjust All' and 'Adjust Proc' are better, it's a taste.
label 'Indenting Options' may be better 'Adjusting options.
The Adjust instead Indent is because not everything is indented
but more reformat in position in/out-denting :)

6)
One tip for 'Deleting empty lines', I like to keep after a 'END??' a blank line.
Rule: if instr(line,"end") and instr(nextline,"end")=false then add/keep blank line.
The third IF statement block.
This solves also the the separation between procedures.

Example for the point 6.

PRIVATE SUB DoIt(sFile AS String)
DIM sLine      AS String 
DIM bWriteLine AS Boolean

  IF today = 12 THEN today = 13

  IF chkEmpty.value AND Trim(sLine) <> "" THEN ' comment
    sLine = RTrim$(sLine)
    bWriteLine = TRUE
  ENDIF

'  SUB / Function END
  IF Upper$(Trim(sLine)) = Upper$("END") THEN
    IF chkLineSep THEN
      sLine = sLine & CONST_LINE
      bWriteLine = TRUE
    ENDIF
  END IF

'  Select Case
  SELECT CASE i
    CASE 1
      MsgBox "1"
                ' can you solve here to a blank line. ?
    CASE 2
      IF x = 3 THEN Message.Info("2")
      Message.Info("3")
      Message.Info("4")

    DEFAULT
      Message.Info("Arg...")

  END SELECT

  WITH i
    i = i
  END WITH

END





More information about the Devel mailing list