mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 00:39:44 +02:00
MG: added insert GPL notice
git-svn-id: trunk@3322 -
This commit is contained in:
parent
fb202ba0fe
commit
8c87999185
@ -90,6 +90,21 @@ const
|
||||
( nil, nil, TSynPasSyn, TSynPasSyn, TSynLFMSyn, TSynXMLSyn, TSynHTMLSyn,
|
||||
TSynCPPSyn, TSynPerlSyn);
|
||||
|
||||
|
||||
{ Comments }
|
||||
const
|
||||
DefaultCommentTypes: array[TLazSyntaxHighlighter] of TCommentType = (
|
||||
comtNone, // lshNone
|
||||
comtNone, // lshText
|
||||
comtPascal,// lshFreePascal
|
||||
comtPascal,// lshDelphi
|
||||
comtDelphi,// lshLFM
|
||||
comtHtml, // lshXML
|
||||
comtHtml, // lshHTML
|
||||
comtCPP, // lshCPP
|
||||
comtPerl // lshPerl
|
||||
);
|
||||
|
||||
type
|
||||
{ TEditOptLanguageInfo stores lazarus IDE additional information
|
||||
of a highlighter, such as samplesource, which sample lines are special
|
||||
@ -111,6 +126,7 @@ type
|
||||
SampleSource: string;
|
||||
AddAttrSampleLines: array[TAdditionalHilightAttribute] of integer; // first line = 1
|
||||
MappedAttributes: TStringList; // map attributes to pascal
|
||||
DefaultCommentType: TCommentType;
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
function GetDefaultFilextension: string;
|
||||
@ -127,6 +143,7 @@ type
|
||||
destructor Destroy; override;
|
||||
function FindByName(const Name: string): integer;
|
||||
function FindByClass(CustomSynClass: TCustomSynClass): integer;
|
||||
function FindByHighlighter(Hilighter: TSynCustomHighlighter): integer;
|
||||
function FindByType(AType: TLazSyntaxHighlighter): integer;
|
||||
function GetDefaultFilextension(AType: TLazSyntaxHighlighter): string;
|
||||
property Items[Index: integer]: TEditOptLanguageInfo read GetInfos; default;
|
||||
@ -521,9 +538,9 @@ function ShowEditorOptionsDialog:TModalResult;
|
||||
function StrToLazSyntaxHighlighter(const s: string): TLazSyntaxHighlighter;
|
||||
function ExtensionToLazSyntaxHighlighter(Ext:string): TLazSyntaxHighlighter;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
uses Math;
|
||||
|
||||
const
|
||||
@ -721,6 +738,7 @@ begin
|
||||
NewInfo:=TEditOptLanguageInfo.Create;
|
||||
with NewInfo do begin
|
||||
TheType:=CompatibleLazSyntaxHilighter[lshFreePascal];
|
||||
DefaultCommentType:=DefaultCommentTypes[lshFreePascal];
|
||||
SynClass:=LazSyntaxHighlighterClasses[TheType];
|
||||
FileExtensions:='pp;pas;inc;lpr;lrs;dpr;dpk';
|
||||
SampleSource:=
|
||||
@ -759,6 +777,7 @@ begin
|
||||
NewInfo:=TEditOptLanguageInfo.Create;
|
||||
with NewInfo do begin
|
||||
TheType:=CompatibleLazSyntaxHilighter[lshHTML];
|
||||
DefaultCommentType:=DefaultCommentTypes[lshHTML];
|
||||
SynClass:=LazSyntaxHighlighterClasses[TheType];
|
||||
FileExtensions:='htm;html';
|
||||
SampleSource:=
|
||||
@ -789,6 +808,7 @@ begin
|
||||
NewInfo:=TEditOptLanguageInfo.Create;
|
||||
with NewInfo do begin
|
||||
TheType:=CompatibleLazSyntaxHilighter[lshCPP];
|
||||
DefaultCommentType:=DefaultCommentTypes[lshCPP];
|
||||
SynClass:=LazSyntaxHighlighterClasses[TheType];
|
||||
FileExtensions:='c;cc;cpp;h;hpp';
|
||||
SampleSource:=
|
||||
@ -826,6 +846,7 @@ begin
|
||||
NewInfo:=TEditOptLanguageInfo.Create;
|
||||
with NewInfo do begin
|
||||
TheType:=CompatibleLazSyntaxHilighter[lshXML];
|
||||
DefaultCommentType:=DefaultCommentTypes[lshXML];
|
||||
SynClass:=LazSyntaxHighlighterClasses[TheType];
|
||||
FileExtensions:='xml;xsd;xsl;xslt;dtd';
|
||||
SampleSource:=
|
||||
@ -855,6 +876,7 @@ begin
|
||||
NewInfo:=TEditOptLanguageInfo.Create;
|
||||
with NewInfo do begin
|
||||
TheType:=CompatibleLazSyntaxHilighter[lshLFM];
|
||||
DefaultCommentType:=DefaultCommentTypes[lshLFM];
|
||||
SynClass:=LazSyntaxHighlighterClasses[TheType];
|
||||
FileExtensions:='lfm;dfm;xfm';
|
||||
SampleSource:=
|
||||
@ -886,6 +908,7 @@ begin
|
||||
NewInfo:=TEditOptLanguageInfo.Create;
|
||||
with NewInfo do begin
|
||||
TheType:=CompatibleLazSyntaxHilighter[lshPerl];
|
||||
DefaultCommentType:=DefaultCommentTypes[lshPerl];
|
||||
SynClass:=LazSyntaxHighlighterClasses[TheType];
|
||||
FileExtensions:='pl;pm;cgi';
|
||||
SampleSource:=
|
||||
@ -937,6 +960,16 @@ begin
|
||||
dec(Result);
|
||||
end;
|
||||
|
||||
function TEditOptLangList.FindByHighlighter(Hilighter: TSynCustomHighlighter
|
||||
): integer;
|
||||
begin
|
||||
if Hilighter<>nil then begin
|
||||
Result:=FindByClass(TCustomSynClass(Hilighter.ClassType));
|
||||
end else begin
|
||||
Result:=-1;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TEditOptLangList.FindByType(
|
||||
AType: TLazSyntaxHighlighter): integer;
|
||||
begin
|
||||
|
122
ide/ideprocs.pp
122
ide/ideprocs.pp
@ -32,6 +32,19 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, Laz_XMLCfg, GetText;
|
||||
|
||||
type
|
||||
TCommentType = (
|
||||
comtDefault, // automatically decide
|
||||
comtNone, // no comment
|
||||
comtPascal, // {}
|
||||
comtDelphi, // //
|
||||
comtTurboPascal,// (* *)
|
||||
comtCPP, // /* */
|
||||
comtPerl, // #
|
||||
comtHtml // <!-- -->
|
||||
);
|
||||
TCommentTypes = set of TCommentType;
|
||||
|
||||
//
|
||||
const
|
||||
// ToDo: find the constant in the fpc units.
|
||||
@ -73,10 +86,12 @@ procedure SaveRect(XMLConfig: TXMLConfig; const Path:string; var ARect:TRect);
|
||||
procedure FreeThenNil(var Obj: TObject);
|
||||
function TabsToSpaces(const s: string; TabWidth: integer): string;
|
||||
function CommentLines(const s: string): string;
|
||||
function CommentText(const s: string; CommentType: TCommentType): string;
|
||||
function UncommentLines(const s: string): string;
|
||||
procedure TranslateResourceStrings(const BaseDirectory, CustomLang: string);
|
||||
function NameToValidIdentifier(const s: string): string;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
@ -801,6 +816,113 @@ begin
|
||||
Result:=Dest;
|
||||
end;
|
||||
|
||||
{-------------------------------------------------------------------------------
|
||||
function CommentLines(const s: string; CommentType: TCommentType): string;
|
||||
|
||||
Comment s.
|
||||
-------------------------------------------------------------------------------}
|
||||
function CommentText(const s: string; CommentType: TCommentType): string;
|
||||
|
||||
procedure GetTextInfo(var Len, LineCount: integer;
|
||||
var LastLineEmpty: boolean);
|
||||
var
|
||||
p: integer;
|
||||
begin
|
||||
Len:=length(s);
|
||||
LineCount:=1;
|
||||
p:=1;
|
||||
while p<=Len do
|
||||
if not (s[p] in [#10,#13]) then begin
|
||||
inc(p);
|
||||
end else begin
|
||||
inc(p);
|
||||
inc(LineCount);
|
||||
if (p<=Len) and (s[p] in [#10,#13]) and (s[p]<>s[p-1]) then
|
||||
inc(p);
|
||||
end;
|
||||
LastLineEmpty:=(Len=0) or (s[Len] in [#10,#13]);
|
||||
end;
|
||||
|
||||
procedure DoCommentBlock(const FirstLineStart, LineStart, LastLine: string);
|
||||
var
|
||||
OldLen, NewLen, LineCount, OldPos, NewPos: integer;
|
||||
LastLineEmpty: boolean;
|
||||
begin
|
||||
GetTextInfo(OldLen,LineCount,LastLineEmpty);
|
||||
|
||||
NewLen:=OldLen+length(FirstLineStart)
|
||||
+(LineCount-1)*length(LineStart);
|
||||
if LastLineEmpty then
|
||||
dec(NewLen,length(LineStart))
|
||||
else
|
||||
inc(NewLen,length(EndOfLine));
|
||||
if (LastLine<>'') then begin
|
||||
inc(NewLen,length(LastLine)+length(EndOfLine));
|
||||
end;
|
||||
|
||||
SetLength(Result,NewLen);
|
||||
NewPos:=1;
|
||||
OldPos:=1;
|
||||
|
||||
// add first line start
|
||||
if FirstLineStart<>'' then begin
|
||||
System.Move(FirstLineStart[1],Result[NewPos],length(FirstLineStart));
|
||||
inc(NewPos,length(FirstLineStart));
|
||||
end;
|
||||
// copy all lines and add new linestart
|
||||
while (OldPos<=OldLen) do begin
|
||||
if (not (s[OldPos] in [#10,#13])) then begin
|
||||
Result[NewPos]:=s[OldPos];
|
||||
inc(OldPos);
|
||||
inc(NewPos);
|
||||
end else begin
|
||||
Result[NewPos]:=s[OldPos];
|
||||
inc(OldPos);
|
||||
inc(NewPos);
|
||||
if (OldPos<=OldLen) and (s[OldPos] in [#10,#13])
|
||||
and (s[OldPos]<>s[OldPos-1]) then begin
|
||||
Result[NewPos]:=s[OldPos];
|
||||
inc(OldPos);
|
||||
inc(NewPos);
|
||||
end;
|
||||
// start new line
|
||||
if (LineStart<>'') and (OldPos<OldLen) then begin
|
||||
System.Move(LineStart[1],Result[NewPos],length(LineStart));
|
||||
inc(NewPos,length(LineStart));
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
if not LastLineEmpty then begin
|
||||
System.Move(EndOfLine[1],Result[NewPos],length(EndOfLine));
|
||||
inc(NewPos,length(EndOfLine));
|
||||
end;
|
||||
// add last line
|
||||
if LastLine<>'' then begin
|
||||
System.Move(LastLine[1],Result[NewPos],length(LastLine));
|
||||
inc(NewPos,length(LastLine));
|
||||
System.Move(EndOfLine[1],Result[NewPos],length(EndOfLine));
|
||||
inc(NewPos,length(EndOfLine));
|
||||
end;
|
||||
if NewPos<>NewLen+1 then
|
||||
raise Exception.Create('IDEProcs.CommentText ERROR: '
|
||||
+IntToStr(NewPos-1)+'<>'+IntToStr(NewLen));
|
||||
end;
|
||||
|
||||
begin
|
||||
Result:=s;
|
||||
if CommentType=comtNone then exit;
|
||||
if CommentType=comtDefault then CommentType:=comtPascal;
|
||||
|
||||
case CommentType of
|
||||
comtPascal: DoCommentBlock('{ ',' ','}');
|
||||
comtDelphi: DoCommentBlock('// ','// ','');
|
||||
comtTurboPascal: DoCommentBlock('(* ',' * ',' *)');
|
||||
comtCPP: DoCommentBlock('/* ',' * ',' */');
|
||||
comtPerl: DoCommentBlock('# ','# ','');
|
||||
comtHtml: DoCommentBlock('<!-- ',' ','-->');
|
||||
end;
|
||||
end;
|
||||
|
||||
{-------------------------------------------------------------------------------
|
||||
function CommentLines(const s: string): string;
|
||||
|
||||
|
@ -81,6 +81,8 @@ const
|
||||
ecSelectCodeBlock = ecUserFirst + 56;
|
||||
ecSelectLine = ecUserFirst + 57;
|
||||
ecSelectParagraph = ecUserFirst + 58;
|
||||
|
||||
ecInsertGPLNotice = ecUserFirst + 80;
|
||||
|
||||
ecWordCompletion = ecUserFirst + 100;
|
||||
ecCompleteCode = ecUserFirst + 101;
|
||||
@ -500,6 +502,7 @@ begin
|
||||
ecSelectCodeBlock: Result:= 'Select code block';
|
||||
ecSelectLine: Result:= 'Select line';
|
||||
ecSelectParagraph: Result:= 'Select paragraph';
|
||||
ecInsertGPLNotice: Result:='Insert GPL notice';
|
||||
|
||||
// search menu
|
||||
ecFind: Result:= 'Find text';
|
||||
@ -1167,6 +1170,7 @@ begin
|
||||
Add(C,'Select code block',ecSelectCodeBlock,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
Add(C,'Select line',ecSelectLine,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
Add(C,'Select paragraph',ecSelectParagraph,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
Add(C,'Insert GPL notice',ecInsertGPLNotice,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
Add(C,'Uppercase selection',ecSelectionUpperCase,VK_UNKNOWN, [],VK_UNKNOWN,[]);
|
||||
Add(C,'Lowercase selection',ecSelectionLowerCase,VK_UNKNOWN, [],VK_UNKNOWN,[]);
|
||||
Add(C,'Convert tabs to spaces in selection',ecSelectionTabs2Spaces,VK_UNKNOWN, [],VK_UNKNOWN,[]);
|
||||
|
@ -122,6 +122,9 @@ ResourceString
|
||||
lisMenuSelectCodeBlock = 'Select code block';
|
||||
lisMenuSelectLine = 'Select line';
|
||||
lisMenuSelectParagraph = 'Select paragraph';
|
||||
lisMenuInsertText = 'Insert text';
|
||||
lisMenuInsertGeneral = 'General';
|
||||
lisMenuInsertGPLNotice = 'GPL notice';
|
||||
lisMenuCompleteCode = 'Complete Code';
|
||||
|
||||
lisMenuFind = 'Find';
|
||||
@ -222,29 +225,45 @@ ResourceString
|
||||
+#13
|
||||
+'As Lazarus is growing we need more developers.'#13
|
||||
+'For example: Write a nicer about dialog with a logo.';
|
||||
lsiUnitNameAlreadyExistsCap = 'Unitname already in project';
|
||||
lsiUnitNameAlreadyExistsText = 'The unit "%s" already exists.'#13
|
||||
lisUnitNameAlreadyExistsCap = 'Unitname already in project';
|
||||
lisUnitNameAlreadyExistsText = 'The unit "%s" already exists.'#13
|
||||
+'Ignore will force the renaming,'#13
|
||||
+'Cancel will cancel the saving of this source and'#13
|
||||
+'Abort will abort the whole saving.';
|
||||
lsiInvalidPascalIdentifierCap = 'Invalid Pascal Identifier';
|
||||
lsiInvalidPascalIdentifierText =
|
||||
lisInvalidPascalIdentifierCap = 'Invalid Pascal Identifier';
|
||||
lisInvalidPascalIdentifierText =
|
||||
'The name "%s" is not a valid pascal identifier.';
|
||||
|
||||
// hints
|
||||
lsiHintNewUnit = 'New Unit';
|
||||
lsiHintOpen = 'Open';
|
||||
lsiHintSave = 'Save';
|
||||
lsiHintSaveAll = 'Save all';
|
||||
lsiHintNewForm = 'New Form';
|
||||
lsiHintToggleFormUnit = 'Toggle Form/Unit';
|
||||
lsiHintViewUnits = 'View Units';
|
||||
lsiHintViewForms = 'View Forms';
|
||||
lsiHintRun = 'Run';
|
||||
lsiHintPause = 'Pause';
|
||||
lsiHintStepInto = 'Step Into';
|
||||
lsiHintStepOver = 'Step Over';
|
||||
lisHintNewUnit = 'New Unit';
|
||||
lisHintOpen = 'Open';
|
||||
lisHintSave = 'Save';
|
||||
lisHintSaveAll = 'Save all';
|
||||
lisHintNewForm = 'New Form';
|
||||
lisHintToggleFormUnit = 'Toggle Form/Unit';
|
||||
lisHintViewUnits = 'View Units';
|
||||
lisHintViewForms = 'View Forms';
|
||||
lisHintRun = 'Run';
|
||||
lisHintPause = 'Pause';
|
||||
lisHintStepInto = 'Step Into';
|
||||
lisHintStepOver = 'Step Over';
|
||||
|
||||
lisGPLNotice =
|
||||
'This program is free software; you can redistribute it and/or modify'#13
|
||||
+'it under the terms of the GNU General Public License as published by'#13
|
||||
+'the Free Software Foundation; either version 2 of the License, or'#13
|
||||
+'(at your option) any later version.'#13
|
||||
+''#13
|
||||
+'This program is distributed in the hope that it will be useful,'#13
|
||||
+'but WITHOUT ANY WARRANTY; without even the implied warranty of'#13
|
||||
+'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the'#13
|
||||
+'GNU Library General Public License for more details.'#13
|
||||
+''#13
|
||||
+'You should have received a copy of the GNU General Public License'#13
|
||||
+'along with this program; if not, write to the Free Software'#13
|
||||
+'Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.'#13;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
|
@ -154,6 +154,9 @@ type
|
||||
itmEditSelectCodeBlock: TMenuItem;
|
||||
itmEditSelectLine: TMenuItem;
|
||||
itmEditSelectParagraph: TMenuItem;
|
||||
itmEditInsertText: TMenuItem;
|
||||
itmEditInsertGeneral: TMenuItem;
|
||||
itmEditInsertGPLNotice: TMenuItem;
|
||||
itmEditCompleteCode: TMenuItem;
|
||||
|
||||
itmSearchFind: TMenuItem;
|
||||
@ -500,7 +503,8 @@ begin
|
||||
itmEditSelect.Caption := lisMenuSelect;
|
||||
mnuEdit.Add(itmEditSelect);
|
||||
|
||||
// select sub menu items
|
||||
begin
|
||||
// select sub menu items
|
||||
itmEditSelectAll := TMenuItem.Create(Self);
|
||||
itmEditSelectAll.Name:='itmEditSelectAll';
|
||||
itmEditSelectAll.Caption := lisMenuSelectAll;
|
||||
@ -526,10 +530,31 @@ begin
|
||||
itmEditSelectParagraph.Name:='itmEditSelectParagraph';
|
||||
itmEditSelectParagraph.Caption := lisMenuSelectParagraph;
|
||||
itmEditSelect.Add(itmEditSelectParagraph);
|
||||
end;
|
||||
|
||||
itmEditInsertText := TMenuItem.Create(Self);
|
||||
itmEditInsertText.Name:='itmEditInsertText';
|
||||
itmEditInsertText.Caption := lisMenuInsertText;
|
||||
mnuEdit.Add(itmEditInsertText);
|
||||
|
||||
begin
|
||||
// insert text sub menu items
|
||||
itmEditInsertGeneral := TMenuItem.Create(Self);
|
||||
itmEditInsertGeneral.Name:='itmEditInsertGeneral';
|
||||
itmEditInsertGeneral.Caption := lisMenuInsertGeneral;
|
||||
itmEditInsertText.Add(itmEditInsertGeneral);
|
||||
|
||||
begin
|
||||
// insert general text sub menu items
|
||||
itmEditInsertGPLNotice := TMenuItem.Create(Self);
|
||||
itmEditInsertGPLNotice.Name:='itmEditInsertGPLNotice';
|
||||
itmEditInsertGPLNotice.Caption := lisMenuInsertGPLNotice;
|
||||
itmEditInsertGeneral.Add(itmEditInsertGPLNotice);
|
||||
end;
|
||||
end;
|
||||
|
||||
mnuEdit.Add(CreateMenuSeparator);
|
||||
|
||||
|
||||
itmEditCompleteCode := TMenuItem.Create(Self);
|
||||
itmEditCompleteCode.Name:='itmEditCompleteCode';
|
||||
itmEditCompleteCode.Caption := lisMenuCompleteCode;
|
||||
@ -922,6 +947,7 @@ begin
|
||||
itmEditSelectCodeBlock.ShortCut:=CommandToShortCut(ecSelectCodeBlock);
|
||||
itmEditSelectLine.ShortCut:=CommandToShortCut(ecSelectLine);
|
||||
itmEditSelectParagraph.ShortCut:=CommandToShortCut(ecSelectParagraph);
|
||||
itmEditInsertGPLNotice.ShortCut:=CommandToShortCut(ecInsertGPLNotice);
|
||||
itmEditCompleteCode.ShortCut:=CommandToShortCut(ecCompleteCode);
|
||||
|
||||
itmSearchFind.ShortCut:=CommandToShortCut(ecFind);
|
||||
|
Loading…
Reference in New Issue
Block a user