mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 09:40:21 +00:00
Support of the .pp extension for Pascal
This commit is contained in:
@@ -1568,6 +1568,7 @@ Pascal:
|
||||
- .pas
|
||||
- .dfm
|
||||
- .lpr
|
||||
- .pp
|
||||
|
||||
Perl:
|
||||
type: programming
|
||||
|
||||
127037
lib/linguist/samples.json
127037
lib/linguist/samples.json
File diff suppressed because it is too large
Load Diff
193
samples/Pascal/custforms.pp
Normal file
193
samples/Pascal/custforms.pp
Normal file
@@ -0,0 +1,193 @@
|
||||
unit custforms;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms;
|
||||
|
||||
Type
|
||||
|
||||
{ TCustomFormDescr }
|
||||
|
||||
TCustomFormDescr = Class
|
||||
private
|
||||
FAuthor: String;
|
||||
FCaption: String;
|
||||
FCategory: String;
|
||||
FDescription: String;
|
||||
FFormClass: TFormClass;
|
||||
FLazPackage: String;
|
||||
FUnitName: String;
|
||||
public
|
||||
Constructor Create(AFormClass : TFormClass; const APackage: string);
|
||||
Constructor Create(AFormClass : TFormClass; Const ACaption,ADescription,AUnit,APackage : String);
|
||||
Property FormClass : TFormClass Read FFormClass Write FFormClass;
|
||||
Property Caption : String Read FCaption Write FCaption;
|
||||
Property Description : String Read FDescription Write FDescription;
|
||||
Property UnitName : String Read FUnitName Write FUnitName;
|
||||
Property Category : String Read FCategory Write FCategory;
|
||||
Property Author : String Read FAuthor Write FAuthor;
|
||||
Property LazPackage : String Read FLazPackage Write FLazPackage;
|
||||
end;
|
||||
|
||||
Procedure RegisterCustomForm(Descr : TCustomFormDescr);
|
||||
Procedure RegisterCustomForm(AFormClass : TFormClass; const APackage: string);
|
||||
Procedure RegisterCustomForm(AFormClass : TFormClass; Const AUnitName, APackage : String);
|
||||
|
||||
Procedure Register;
|
||||
|
||||
implementation
|
||||
|
||||
uses ProjectIntf,NewItemIntf,contnrs;
|
||||
|
||||
Const
|
||||
SAppFrameWork = 'Custom forms';
|
||||
SInstanceOf = 'Create a new instance of %s';
|
||||
|
||||
{ TCustomFormDescr }
|
||||
|
||||
constructor TCustomFormDescr.Create(AFormClass: TFormClass;
|
||||
const APackage: string);
|
||||
|
||||
Var
|
||||
N,U : String;
|
||||
|
||||
begin
|
||||
N:=AFormClass.ClassName;
|
||||
U:=N;
|
||||
If (Upcase(U[1])='T') then
|
||||
Delete(U,1,1);
|
||||
Create(AFormClass,N,Format(SInstanceOf,[N]),U,APackage);
|
||||
end;
|
||||
|
||||
constructor TCustomFormDescr.Create(AFormClass: TFormClass;
|
||||
const ACaption, ADescription, AUnit, APackage: String);
|
||||
begin
|
||||
FFormClass:=AFormClass;
|
||||
FCaption:=ACaption;
|
||||
FDescription:=ADescription;
|
||||
FUnitName:=AUnit;
|
||||
FCategory:=SAppFrameWork;
|
||||
FLazPackage:=APackage;
|
||||
end;
|
||||
|
||||
// Registration code.
|
||||
|
||||
Type
|
||||
{ TCustomFormFileDescriptor }
|
||||
TCustomFormFileDescriptor = Class(TFileDescPascalUnitWithResource)
|
||||
private
|
||||
FFormDescr: TCustomFormDescr;
|
||||
Public
|
||||
Constructor Create(ADescr : TCustomFormDescr);
|
||||
Property FormDescr : TCustomFormDescr Read FFormDescr;
|
||||
Function GetLocalizedName : String; override;
|
||||
Function GetLocalizedDescription : String; override;
|
||||
Function GetInterfaceUsesSection : String; override;
|
||||
end;
|
||||
|
||||
{ TCustomFormFileDescriptor }
|
||||
|
||||
constructor TCustomFormFileDescriptor.Create(ADescr: TCustomFormDescr);
|
||||
begin
|
||||
Inherited Create;
|
||||
FFormDescr:=ADescr;
|
||||
ResourceClass:=FFormDescr.FFormClass;
|
||||
Name:=FFormDescr.Caption;
|
||||
RequiredPackages:=ADescr.LazPackage;
|
||||
//Writeln('TCustomFormFileDescriptor.Create RequiredPackages=',RequiredPackages);
|
||||
end;
|
||||
|
||||
function TCustomFormFileDescriptor.GetLocalizedName: String;
|
||||
begin
|
||||
Result:=FFormDescr.Caption;
|
||||
end;
|
||||
|
||||
function TCustomFormFileDescriptor.GetLocalizedDescription: String;
|
||||
begin
|
||||
Result:=FFormDescr.Description;
|
||||
If (FFormDescr.Author<>'') then
|
||||
Result:=Result+LineEnding+'By '+FFormDescr.Author;
|
||||
end;
|
||||
|
||||
function TCustomFormFileDescriptor.GetInterfaceUsesSection: String;
|
||||
begin
|
||||
Result:=inherited GetInterfaceUsesSection;
|
||||
Result:=Result+',Forms,'+FFormDescr.UnitName;
|
||||
end;
|
||||
|
||||
Var
|
||||
CustomFormList : TObjectList;
|
||||
|
||||
Procedure RegisterCustomForm(Descr : TCustomFormDescr);
|
||||
|
||||
begin
|
||||
CustomFormList.Add(Descr);
|
||||
end;
|
||||
|
||||
Procedure RegisterCustomForm(AFormClass : TFormClass; const APackage: string);
|
||||
|
||||
begin
|
||||
RegisterCustomForm(TCustomFormDescr.Create(AFormClass,APackage));
|
||||
end;
|
||||
|
||||
Procedure RegisterCustomForm(AFormClass : TFormClass; Const AUnitName, APackage : String);
|
||||
|
||||
Var
|
||||
D : TCustomFormDescr;
|
||||
|
||||
begin
|
||||
D:=TCustomFormDescr.Create(AFormClass,APackage);
|
||||
D.UnitName:=AUnitName;
|
||||
RegisterCustomForm(D);
|
||||
end;
|
||||
|
||||
|
||||
Procedure Register;
|
||||
|
||||
Var
|
||||
L : TStringList;
|
||||
I : Integer;
|
||||
D : TCustomFormDescr;
|
||||
|
||||
begin
|
||||
L:=TStringList.Create;
|
||||
Try
|
||||
L.Sorted:=True;
|
||||
L.Duplicates:=dupIgnore;
|
||||
For I:=0 to CustomFormList.Count-1 do
|
||||
L.Add(TCustomFormDescr(CustomFormList[i]).Category);
|
||||
For I:=0 to L.Count-1 do
|
||||
begin
|
||||
RegisterNewItemCategory(TNewIDEItemCategory.Create(L[i]));
|
||||
end;
|
||||
Finally
|
||||
L.Free;
|
||||
end;
|
||||
For I:=0 to CustomFormList.Count-1 do
|
||||
begin
|
||||
D:=TCustomFormDescr(CustomFormList[i]);
|
||||
RegisterProjectFileDescriptor(TCustomFormFileDescriptor.Create(D),D.Category);
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure InitCustomForms;
|
||||
|
||||
begin
|
||||
CustomFormList:=TObjectList.Create;
|
||||
end;
|
||||
|
||||
Procedure DoneCustomForms;
|
||||
|
||||
begin
|
||||
FreeAndNil(CustomFormList);
|
||||
end;
|
||||
|
||||
Initialization
|
||||
InitCustomForms;
|
||||
Finalization
|
||||
DoneCustomForms;
|
||||
end.
|
||||
|
||||
51
samples/Pascal/gtkextra.pp
Normal file
51
samples/Pascal/gtkextra.pp
Normal file
@@ -0,0 +1,51 @@
|
||||
{ $Id$ }
|
||||
{
|
||||
---------------------------------------------------------------------------
|
||||
gtkextra.pp - GTK(2) widgetset - additional gdk/gtk functions
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
This unit contains missing gdk/gtk functions and defines for certain
|
||||
versions of gtk or fpc.
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
@created(Sun Jan 28th WET 2006)
|
||||
@lastmod($Date$)
|
||||
@author(Marc Weustink <marc@@dommelstein.nl>)
|
||||
|
||||
*****************************************************************************
|
||||
This file is part of the Lazarus Component Library (LCL)
|
||||
|
||||
See the file COPYING.modifiedLGPL.txt, included in this distribution,
|
||||
for details about the license.
|
||||
*****************************************************************************
|
||||
}
|
||||
|
||||
unit GtkExtra;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
{$I gtkdefines.inc}
|
||||
|
||||
{$ifdef gtk1}
|
||||
{$I gtk1extrah.inc}
|
||||
{$endif}
|
||||
|
||||
{$ifdef gtk2}
|
||||
{$I gtk2extrah.inc}
|
||||
{$endif}
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
{$ifdef gtk1}
|
||||
{$I gtk1extra.inc}
|
||||
{$endif}
|
||||
|
||||
{$ifdef gtk2}
|
||||
{$I gtk2extra.inc}
|
||||
{$endif}
|
||||
|
||||
end.
|
||||
26
samples/Puppet/expiringhost.pp
Normal file
26
samples/Puppet/expiringhost.pp
Normal file
@@ -0,0 +1,26 @@
|
||||
define example::expiringhost($ip, $timestamp) {
|
||||
|
||||
# Calculate the age of this resource by comparing 'now' against $timestamp
|
||||
$age = inline_template("<%= require 'time'; Time.now - Time.parse(timestamp) %>")
|
||||
|
||||
# Max age, in seconds.
|
||||
$maxage = 60
|
||||
|
||||
if $age > $maxage {
|
||||
$expired = true
|
||||
notice("Expiring resource $class[$name] due to age > $maxage (actual: $age)")
|
||||
} else {
|
||||
$expired = false
|
||||
notice("Found recently-active $class[$name] (age: $age)")
|
||||
}
|
||||
|
||||
# I set target to a /tmp path so you can run this example as non-root.
|
||||
# In production, you probabyl won't set target as it defaults to /etc/hosts
|
||||
# (or wherever puppet thinks your platform wants it)
|
||||
host {
|
||||
$name:
|
||||
ip => $ip,
|
||||
target => "/tmp/expiring-hosts-example-output",
|
||||
ensure => $expired ? { true => absent, false => present };
|
||||
}
|
||||
}
|
||||
26
samples/Puppet/stages-example.pp
Normal file
26
samples/Puppet/stages-example.pp
Normal file
@@ -0,0 +1,26 @@
|
||||
class foo {
|
||||
notify {
|
||||
"foo": ;
|
||||
}
|
||||
}
|
||||
|
||||
class bar {
|
||||
notify {
|
||||
"bar": ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
node default {
|
||||
stage {
|
||||
"one": ;
|
||||
"two": ;
|
||||
}
|
||||
|
||||
class {
|
||||
"foo": stage => "one";
|
||||
"bar": stage => "two";
|
||||
}
|
||||
|
||||
Stage["one"] -> Stage["two"]
|
||||
}
|
||||
22
samples/Puppet/unmanaged-notify-puppet25.pp
Normal file
22
samples/Puppet/unmanaged-notify-puppet25.pp
Normal file
@@ -0,0 +1,22 @@
|
||||
# Manually manage /tmp/original
|
||||
# Each puppet run will copy it to /tmp/flag if there's a change and notify
|
||||
# the exec when it changes.
|
||||
#
|
||||
# The idea here is you might need (in some case) to manually manage a file outside
|
||||
# of puppet (in this case, "/tmp/original"). Using this example, you can make puppet
|
||||
# signal other parts of your catalog based on changes to that file.
|
||||
|
||||
file {
|
||||
# This will, when different, copy /tmp/original to /tmp/flag and notify our
|
||||
# exec.
|
||||
"/tmp/flag":
|
||||
source => "file:///tmp/original",
|
||||
notify => Exec["hello world"];
|
||||
}
|
||||
|
||||
exec {
|
||||
"hello world":
|
||||
command => "/bin/echo hello world",
|
||||
refreshonly => true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user