Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2017-04

Modifying the "File -> New Unit" template

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mattias Gaertner
to Graeme Geldenhuys
Hi, Is there a way to modify the standard “file -> new unit” code template that is used? Or is what we see hard-coded into the Lazarus IDE executable?

Right click in the IDE coolbar on the "New unit" button to select another template.
A package can register other templates.

Mattias

Reply by email

Graeme Geldenhuys
to Mattias Gaertner
Mattias Gaertner wrote
Right click in the IDE coolbar on the "New unit" button to select another template.

I meant I want to modify the code that Lazarus IDE gives once I click “File -> New Unit”. I don't want a completely different template. eg: this is the default I see now...

====================
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
  Classes, SysUtils;
implementation
end.
===================

I want to change that so the default has difference uses clauses, defines the text encoding of the source file etc. Where does the above code come from? Hard-coded?

eg:
MSEide has a ‘templates’ folder where all such auto-generated code is defined. Nothing is hard-coded in the MSEide executable. From your answer I assume Lazarus doesn’t do anything like this, and instead hard-codes such default unit templates. :-/

A package can register other templates.

I'll wait on your reply before I delve into this.

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Mattias Gaertner
to Graeme Geldenhuys
[...] I want to change that so the default has difference uses clauses, defines the text encoding of the source file etc. Where does the above code come from? Hard-coded?

Yes, components/ideintf/projectintf.pas TFileDescPascalUnit It creates the code from various IDE options and packages can define their descendants to replace whole or parts.

Show quoted text 5 lines
eg: MSEide has a ‘templates’ folder where all such auto-generated code is defined. Nothing is hard-coded in the MSEide executable. From your answer I assume Lazarus doesn’t do anything like this, and instead hard-codes such default unit templates. :-/

It should be easy to add a "user unit" template, that loads the source from a file and replaces some macros.

Mattias

Reply by email