Recent

Author Topic: Predefined pascal unit header template in Lazarus IDE  (Read 6422 times)

vladvons

  • Jr. Member
  • **
  • Posts: 65
Predefined pascal unit header template in Lazarus IDE
« on: November 02, 2013, 09:19:50 am »
1) When i create a new pascal unit i want to have at the begining of the unit some title like this:
This title should be automatically generated by Lazarus IDE. It would be good to store own template into some Lazarus directory.
{
Company: My company name
Author: Some author
Creation date: 2013-11-02

GNU license text.....
}

2) Now i have no header in over 300 units.
Should i do this manually?
When i share project sources worldwide i want to fill each unit title with headrer described above.

is it possible some automation using Lazarus?
« Last Edit: November 02, 2013, 07:20:57 pm by vladvons »
Windows 7, Ubuntu 12.04, Lazarus 1.2.2, FPC 2.6.4, PostgreSQL 9.2

Bart

  • Hero Member
  • *****
  • Posts: 5274
    • Bart en Mariska's Webstek
Re: Pascal unit header template
« Reply #1 on: November 02, 2013, 12:31:01 pm »
You could easily write a simple app that does this for you.

Bart

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Pascal unit header template
« Reply #2 on: November 02, 2013, 02:23:21 pm »
Indeed, a simple app could be made for that. The IDE currently doesn't have such a feature.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Pascal unit header template
« Reply #3 on: November 02, 2013, 05:53:02 pm »
For current use you can write a simple 'boiler plate' template that inserts the information you want using the Ctrl-J shortcut. It involves adding a few appropriate lines to the lazarus.dci file.
See here http://wiki.lazarus.freepascal.org/IDE_Window:_Code_Templates

Once you have done that it is available for all future projects as well.
Retro-fitting existing .pas and .pp files with the additional lines would require a simple app to be written.

vladvons

  • Jr. Member
  • **
  • Posts: 65
Re: Pascal unit header template
« Reply #4 on: November 02, 2013, 07:18:03 pm »
For big projects would be convenient to store own header template into lazarus directory. When user choose 'create new pascal unit/form/component' then Lazarus IDE creates it with predefined header template + usual code.
Code: [Select]
{
Company: My company name
Author: Some author
Creation date: 2013-11-02

GNU license text.....
}

unit Unit1;

interface

uses
  Classes, SysUtils;

implementation

end.
Windows 7, Ubuntu 12.04, Lazarus 1.2.2, FPC 2.6.4, PostgreSQL 9.2

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Predefined pascal unit header template in Lazarus IDE
« Reply #5 on: November 03, 2013, 04:56:24 am »
Quote
For big projects would be convenient to store own header template into lazarus directory. When user choose 'create new pascal unit/form/component' then Lazarus IDE creates it with predefined header template + usual code.
Since the standard unit template is hardcoded in TFileDescPascalUnit.CreateSource, you'll need to create an IDE extension to automatically include the header (if you don't want to modify the source).

Researching

  • Full Member
  • ***
  • Posts: 121
Re: Predefined pascal unit header template in Lazarus IDE
« Reply #6 on: November 29, 2018, 12:05:15 am »
[SOLVED: Laz.1.8.4 ]
HOW TO: Modify the original “UNIT.pas” template:
The template is hard-coded inside
\lazarus\components\ideintf\projectintf.pas
So open it, find: “TFileDescPascalUnit.CreateSource”
Understand the code structure
Modify to your wishes.
My version of file: attached projectintf.pas

 

TinyPortal © 2005-2018