* * *

Author Topic: ptop formatting? (tab indentation)  (Read 1489 times)

tux-

  • Newbie
  • Posts: 3
ptop formatting? (tab indentation)
« on: June 14, 2018, 12:30:06 pm »
Hello! I am trying out the ptop formatter to see if we can use this for our teams. I have configured most settings to work, but I struggle with one thing. We use one tab for indentation, and I can not figure out how to configure the formatter to use tab for indentation, is it even possible?

jamie

  • Hero Member
  • *****
  • Posts: 810
Re: ptop formatting? (tab indentation)
« Reply #1 on: June 15, 2018, 12:47:13 am »
I do not know what environment you are in but if you down load and install "Lazarus" which uses fpc compiler
you can use their editor which has a code formatter in it. It also has lots of other goodies!


tux-

  • Newbie
  • Posts: 3
Re: ptop formatting? (tab indentation)
« Reply #2 on: June 15, 2018, 07:22:14 am »
Oh, that sounds nice! Unfortunately for me, this problem is not specific to an editor. Need to have a standalone formatter that can run in Visual Studio Code, on githooks, etc. And it also needs to be able to run on Linux and not just Windows. Would make code reviews so much easier if the reviewer did not have to look at formatting! :)

Leledumbo

  • Hero Member
  • *****
  • Posts: 7947
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: ptop formatting? (tab indentation)
« Reply #3 on: June 15, 2018, 01:13:42 pm »
Not at the moment, unless you want to modify the source code. At the start of implementation section of ptopu unit, there's a const named Blank, which is a space character.  If you change that to #9, then indentation would be done with tab instead of space. Note that you might want to change DEFINDENT (at the start of interface section) constant as well, as it defaults to 2 and 2 tabs for indentation doesn't seem to be a good choice.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6500
Re: ptop formatting? (tab indentation)
« Reply #4 on: June 15, 2018, 02:15:58 pm »
Using hard tabs is not very common in the pascal world. It is considered arcane

taazz

  • Hero Member
  • *****
  • Posts: 5336
Re: ptop formatting? (tab indentation)
« Reply #5 on: June 15, 2018, 02:28:42 pm »
It never caught on, no, which is a shame because you can have multiple layouts by changing the size of the tab in the options so if I wish to see 2 spaces per tab or 8 its up to me to decide while the source editing is left unchanged. Arcane though? Oh wait, what do you mean by arcane?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6500
Re: ptop formatting? (tab indentation)
« Reply #6 on: June 15, 2018, 02:55:46 pm »
It never caught on, no, which is a shame because you can have multiple layouts by changing the size of the tab in the options so if I wish to see 2 spaces per tab or 8 its up to me to decide while the source editing is left unchanged.

Yes, that was the theory. Shame it never worked in practice, except for the most limited uses, because touching it with anything else would corrupt the layout completely.

And if you got source from somebody, you had to guestimate the intended tab size first. And 

Quote
Arcane though? Oh wait, what do you mean by arcane?

Obscure, from a forgotten era. It is not used that much anymore to my knowledge, except in some unix config files (and even there it is lessening, Linux was always much more tolerant to this than e.g. BSD) , though every so and so often somebody reinvents it, and thinks it is great. It isn't.

tux-

  • Newbie
  • Posts: 3
Re: ptop formatting? (tab indentation)
« Reply #7 on: June 18, 2018, 02:34:11 pm »
I hope this does not turn into a tabs vs spaces debate, there is enough of those already. I know that most pascal projects uses spaces, and that is probably an indicator to why it seems like the final answer to my original question is "Not at the moment, but since the source is available, it can be fixed.". For those interested, here is a link to a scanner for different languages and what is common in them: https://ukupat.github.io/tabs-or-spaces/ and it confirms that pascal is space oriented. We work with many languages, and some people like two spaces, most like four. So, to let them have the view they prefer, we just do tabs for all projects, and people can have the view where they thrive the most, and are most efficient in. But again, that is just our take on the matter.

bee

  • Sr. Member
  • ****
  • Posts: 348
Re: ptop formatting? (tab indentation)
« Reply #8 on: June 27, 2018, 07:20:29 am »
I hope my online Pascal beautifier would help you. It's using JCF CLI. JCF CLI doesn't require any GUI libraries so it can be run from terminal on any platforms e.g. Windows, Linux, and Mac. JCF CLI can also be used with other Pascal editors, including VS Code, as shown in the project's ReadMe.  :)
« Last Edit: June 27, 2018, 07:27:31 am by bee »
-Bee-

A long time pascal lover.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus