mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 23:19:50 +02:00
fixed insert text GPL and LGPL
git-svn-id: trunk@3938 -
This commit is contained in:
parent
0046667b33
commit
309a9b60c5
@ -72,6 +72,11 @@ type
|
|||||||
atPoint, atAt, atNumber, atStringConstant, atNewLine,
|
atPoint, atAt, atNumber, atStringConstant, atNewLine,
|
||||||
atSpace, atSymbol);
|
atSpace, atSymbol);
|
||||||
TAtomTypes = set of TAtomType;
|
TAtomTypes = set of TAtomType;
|
||||||
|
|
||||||
|
TBeautifyCodeFlag = (
|
||||||
|
bcfNoIndentOnBreakLine
|
||||||
|
);
|
||||||
|
TBeautifyCodeFlags = set of TBeautifyCodeFlag;
|
||||||
|
|
||||||
TBeautifyCodeOptions = class
|
TBeautifyCodeOptions = class
|
||||||
private
|
private
|
||||||
@ -102,11 +107,16 @@ type
|
|||||||
PropertyWriteIdentPrefix: string;
|
PropertyWriteIdentPrefix: string;
|
||||||
PropertyStoredIdentPostfix: string;
|
PropertyStoredIdentPostfix: string;
|
||||||
PrivatVariablePrefix: string;
|
PrivatVariablePrefix: string;
|
||||||
|
CurFlags: TBeautifyCodeFlags;
|
||||||
|
|
||||||
function BeautifyProc(const AProcCode: string; IndentSize: integer;
|
function BeautifyProc(const AProcCode: string; IndentSize: integer;
|
||||||
AddBeginEnd: boolean): string;
|
AddBeginEnd: boolean): string;
|
||||||
function BeautifyStatement(const AStatement: string; IndentSize: integer
|
function BeautifyStatement(const AStatement: string; IndentSize: integer
|
||||||
): string;
|
): string;
|
||||||
|
function BeautifyStatementLeftAligned(const AStatement: string;
|
||||||
|
IndentSize: integer): string;
|
||||||
|
function BeautifyStatement(const AStatement: string; IndentSize: integer;
|
||||||
|
BeautifyFlags: TBeautifyCodeFlags): string;
|
||||||
function AddClassAndNameToProc(const AProcCode, AClassName,
|
function AddClassAndNameToProc(const AProcCode, AClassName,
|
||||||
AMethodName: string): string;
|
AMethodName: string): string;
|
||||||
function BeautifyWord(const AWord: string; WordPolicy: TWordPolicy): string;
|
function BeautifyWord(const AWord: string; WordPolicy: TWordPolicy): string;
|
||||||
@ -1023,11 +1033,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TBeautifyCodeOptions.BeautifyStatement(const AStatement: string;
|
function TBeautifyCodeOptions.BeautifyStatement(const AStatement: string;
|
||||||
IndentSize: integer): string;
|
IndentSize: integer; BeautifyFlags: TBeautifyCodeFlags): string;
|
||||||
var CurAtom: string;
|
var CurAtom: string;
|
||||||
|
OldIndent: Integer;
|
||||||
begin
|
begin
|
||||||
//writeln('**********************************************************');
|
//writeln('**********************************************************');
|
||||||
//writeln('[TBeautifyCodeOptions.BeautifyStatement] "',AStatement,'"');
|
//writeln('[TBeautifyCodeOptions.BeautifyStatement] "',AStatement,'"');
|
||||||
|
// set flags
|
||||||
|
CurFlags:=BeautifyFlags;
|
||||||
|
if bcfNoIndentOnBreakLine in CurFlags then begin
|
||||||
|
OldIndent:=Indent;
|
||||||
|
Indent:=0;
|
||||||
|
end;
|
||||||
|
// init
|
||||||
Src:=AStatement;
|
Src:=AStatement;
|
||||||
UpperSrc:=UpperCaseStr(Src);
|
UpperSrc:=UpperCaseStr(Src);
|
||||||
SrcLen:=length(Src);
|
SrcLen:=length(Src);
|
||||||
@ -1039,6 +1057,7 @@ begin
|
|||||||
LastSrcLineStart:=1;
|
LastSrcLineStart:=1;
|
||||||
CurLineLen:=length(Result);
|
CurLineLen:=length(Result);
|
||||||
LastAtomType:=atNone;
|
LastAtomType:=atNone;
|
||||||
|
// read atoms
|
||||||
while (CurPos<=SrcLen) do begin
|
while (CurPos<=SrcLen) do begin
|
||||||
repeat
|
repeat
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
@ -1062,10 +1081,27 @@ begin
|
|||||||
AddAtom(Result,CurAtom);
|
AddAtom(Result,CurAtom);
|
||||||
LastAtomType:=CurAtomType;
|
LastAtomType:=CurAtomType;
|
||||||
end;
|
end;
|
||||||
|
// restore flags
|
||||||
|
if bcfNoIndentOnBreakLine in CurFlags then begin
|
||||||
|
Indent:=OldIndent;
|
||||||
|
end;
|
||||||
|
CurFlags:=[];
|
||||||
//writeln('[TBeautifyCodeOptions.BeautifyStatement] Result="',Result,'"');
|
//writeln('[TBeautifyCodeOptions.BeautifyStatement] Result="',Result,'"');
|
||||||
//writeln('**********************************************************');
|
//writeln('**********************************************************');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TBeautifyCodeOptions.BeautifyStatement(const AStatement: string;
|
||||||
|
IndentSize: integer): string;
|
||||||
|
begin
|
||||||
|
Result:=BeautifyStatement(AStatement,IndentSize,[]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TBeautifyCodeOptions.BeautifyStatementLeftAligned(
|
||||||
|
const AStatement: string; IndentSize: integer): string;
|
||||||
|
begin
|
||||||
|
Result:=BeautifyStatement(AStatement,IndentSize,[bcfNoIndentOnBreakLine]);
|
||||||
|
end;
|
||||||
|
|
||||||
function TBeautifyCodeOptions.AddClassAndNameToProc(const AProcCode, AClassName,
|
function TBeautifyCodeOptions.AddClassAndNameToProc(const AProcCode, AClassName,
|
||||||
AMethodName: string): string;
|
AMethodName: string): string;
|
||||||
var StartPos, NamePos, ProcLen: integer;
|
var StartPos, NamePos, ProcLen: integer;
|
||||||
|
@ -86,17 +86,18 @@ const
|
|||||||
ecSelectParagraph = ecUserFirst + 59;
|
ecSelectParagraph = ecUserFirst + 59;
|
||||||
|
|
||||||
ecInsertGPLNotice = ecUserFirst + 80;
|
ecInsertGPLNotice = ecUserFirst + 80;
|
||||||
ecInsertUserName = ecUserFirst + 81;
|
ecInsertLGPLNotice = ecUserFirst + 81;
|
||||||
ecInsertDateTime = ecUserFirst + 82;
|
ecInsertUserName = ecUserFirst + 82;
|
||||||
ecInsertChangeLogEntry = ecUserFirst + 83;
|
ecInsertDateTime = ecUserFirst + 83;
|
||||||
ecInsertCVSAuthor = ecUserFirst + 84;
|
ecInsertChangeLogEntry = ecUserFirst + 84;
|
||||||
ecInsertCVSDate = ecUserFirst + 85;
|
ecInsertCVSAuthor = ecUserFirst + 85;
|
||||||
ecInsertCVSHeader = ecUserFirst + 86;
|
ecInsertCVSDate = ecUserFirst + 86;
|
||||||
ecInsertCVSID = ecUserFirst + 87;
|
ecInsertCVSHeader = ecUserFirst + 87;
|
||||||
ecInsertCVSLog = ecUserFirst + 88;
|
ecInsertCVSID = ecUserFirst + 88;
|
||||||
ecInsertCVSName = ecUserFirst + 89;
|
ecInsertCVSLog = ecUserFirst + 89;
|
||||||
ecInsertCVSRevision = ecUserFirst + 90;
|
ecInsertCVSName = ecUserFirst + 90;
|
||||||
ecInsertCVSSource = ecUserFirst + 91;
|
ecInsertCVSRevision = ecUserFirst + 91;
|
||||||
|
ecInsertCVSSource = ecUserFirst + 92;
|
||||||
|
|
||||||
ecWordCompletion = ecUserFirst + 100;
|
ecWordCompletion = ecUserFirst + 100;
|
||||||
ecCompleteCode = ecUserFirst + 101;
|
ecCompleteCode = ecUserFirst + 101;
|
||||||
@ -524,6 +525,7 @@ begin
|
|||||||
ecSelectLine : Result:= lismenuselectline;
|
ecSelectLine : Result:= lismenuselectline;
|
||||||
ecSelectParagraph : Result:= lismenuselectparagraph;
|
ecSelectParagraph : Result:= lismenuselectparagraph;
|
||||||
ecInsertGPLNotice : Result:= srkmecInsertGPLNotice;
|
ecInsertGPLNotice : Result:= srkmecInsertGPLNotice;
|
||||||
|
ecInsertLGPLNotice : Result:= srkmecInsertLGPLNotice;
|
||||||
ecInsertUserName : Result:= srkmecInsertUserName;
|
ecInsertUserName : Result:= srkmecInsertUserName;
|
||||||
ecInsertDateTime : Result:= srkmecInsertDateTime;
|
ecInsertDateTime : Result:= srkmecInsertDateTime;
|
||||||
ecInsertChangeLogEntry : Result:= srkmecInsertChangeLogEntry;
|
ecInsertChangeLogEntry : Result:= srkmecInsertChangeLogEntry;
|
||||||
@ -1284,6 +1286,7 @@ begin
|
|||||||
Add(C,'Break line and move cursor',ecLineBreak,VK_RETURN,[],VK_UNKNOWN,[]);
|
Add(C,'Break line and move cursor',ecLineBreak,VK_RETURN,[],VK_UNKNOWN,[]);
|
||||||
Add(C,'Break line, leave cursor',ecInsertLine,VK_N,[ssCtrl],VK_UNKNOWN,[]);
|
Add(C,'Break line, leave cursor',ecInsertLine,VK_N,[ssCtrl],VK_UNKNOWN,[]);
|
||||||
Add(C,'Insert GPL notice',ecInsertGPLNotice,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'Insert GPL notice',ecInsertGPLNotice,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
|
Add(C,'Insert LGPL notice',ecInsertLGPLNotice,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
Add(C,'Insert username',ecInsertUserName,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'Insert username',ecInsertUserName,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
Add(C,'Insert date and time',ecInsertDateTime,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'Insert date and time',ecInsertDateTime,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
Add(C,'Insert ChangeLog entry',ecInsertChangeLogEntry,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'Insert ChangeLog entry',ecInsertChangeLogEntry,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
|
@ -143,6 +143,7 @@ resourcestring
|
|||||||
lisMenuCompleteCode = 'Complete Code';
|
lisMenuCompleteCode = 'Complete Code';
|
||||||
|
|
||||||
lisMenuInsertGPLNotice = 'GPL notice';
|
lisMenuInsertGPLNotice = 'GPL notice';
|
||||||
|
lisMenuInsertLGPLNotice = 'LGPL notice';
|
||||||
lisMenuInsertUserName = 'Current username';
|
lisMenuInsertUserName = 'Current username';
|
||||||
lisMenuInsertDateTime = 'Current date and time';
|
lisMenuInsertDateTime = 'Current date and time';
|
||||||
lisMenuInsertChangeLogEntry = 'ChangeLog entry';
|
lisMenuInsertChangeLogEntry = 'ChangeLog entry';
|
||||||
@ -281,7 +282,9 @@ resourcestring
|
|||||||
lisHintStepOver = 'Step Over';
|
lisHintStepOver = 'Step Over';
|
||||||
|
|
||||||
lisGPLNotice =
|
lisGPLNotice =
|
||||||
'This program is free software; you can redistribute it and/or modify '
|
'Copyright (C) <year> <name of author>'
|
||||||
|
+'%s'
|
||||||
|
+'This program is free software; you can redistribute it and/or modify '
|
||||||
+'it under the terms of the GNU General Public License as published by '
|
+'it under the terms of the GNU General Public License as published by '
|
||||||
+'the Free Software Foundation; either version 2 of the License, or '
|
+'the Free Software Foundation; either version 2 of the License, or '
|
||||||
+'(at your option) any later version. '
|
+'(at your option) any later version. '
|
||||||
@ -293,7 +296,25 @@ resourcestring
|
|||||||
+'%s'
|
+'%s'
|
||||||
+'You should have received a copy of the GNU General Public License '
|
+'You should have received a copy of the GNU General Public License '
|
||||||
+'along with this program; if not, write to the Free Software '
|
+'along with this program; if not, write to the Free Software '
|
||||||
+'Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ';
|
+'Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.';
|
||||||
|
|
||||||
|
lisLGPLNotice =
|
||||||
|
'Copyright (C) <year> <name of author>'
|
||||||
|
+'%s'
|
||||||
|
+'This library is free software; you can redistribute it and/or modify '
|
||||||
|
+'it under the terms of the GNU Library General Public License as published '
|
||||||
|
+'by the Free Software Foundation; either version 2 of the License, or '
|
||||||
|
+'(at your option) any later version. '
|
||||||
|
+'%s'
|
||||||
|
+'This program is distributed in the hope that it will be useful, '
|
||||||
|
+'but WITHOUT ANY WARRANTY; without even the implied warranty of '
|
||||||
|
+'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the '
|
||||||
|
+'GNU Library General Public License for more details. '
|
||||||
|
+'%s'
|
||||||
|
+'You should have received a copy of the GNU Library General Public License '
|
||||||
|
+'along with this library; if not, write to the Free Software '
|
||||||
|
+'Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.';
|
||||||
|
|
||||||
|
|
||||||
//IDE components
|
//IDE components
|
||||||
ideStandard = 'Standard';
|
ideStandard = 'Standard';
|
||||||
@ -825,6 +846,7 @@ resourcestring
|
|||||||
// edit menu
|
// edit menu
|
||||||
srkmecSelectionTabs2Spaces = 'Convert tabs to spaces in selection';
|
srkmecSelectionTabs2Spaces = 'Convert tabs to spaces in selection';
|
||||||
srkmecInsertGPLNotice = 'Insert GPL notice';
|
srkmecInsertGPLNotice = 'Insert GPL notice';
|
||||||
|
srkmecInsertLGPLNotice = 'Insert LGPL notice';
|
||||||
srkmecInsertUserName = 'Insert current username';
|
srkmecInsertUserName = 'Insert current username';
|
||||||
srkmecInsertDateTime = 'Insert current date and time';
|
srkmecInsertDateTime = 'Insert current date and time';
|
||||||
srkmecInsertChangeLogEntry = 'Insert ChangeLog entry';
|
srkmecInsertChangeLogEntry = 'Insert ChangeLog entry';
|
||||||
|
@ -193,6 +193,7 @@ type
|
|||||||
itmEditInsertCVSSource: TMenuItem;
|
itmEditInsertCVSSource: TMenuItem;
|
||||||
|
|
||||||
itmEditInsertGPLNotice: TMenuItem;
|
itmEditInsertGPLNotice: TMenuItem;
|
||||||
|
itmEditInsertLGPLNotice: TMenuItem;
|
||||||
itmEditInsertUsername: TMenuItem;
|
itmEditInsertUsername: TMenuItem;
|
||||||
itmEditInsertDateTime: TMenuItem;
|
itmEditInsertDateTime: TMenuItem;
|
||||||
itmEditInsertChangeLogEntry: TMenuItem;
|
itmEditInsertChangeLogEntry: TMenuItem;
|
||||||
@ -672,6 +673,11 @@ begin
|
|||||||
itmEditInsertGPLNotice.Caption := lisMenuInsertGPLNotice;
|
itmEditInsertGPLNotice.Caption := lisMenuInsertGPLNotice;
|
||||||
itmEditInsertGeneral.Add(itmEditInsertGPLNotice);
|
itmEditInsertGeneral.Add(itmEditInsertGPLNotice);
|
||||||
|
|
||||||
|
itmEditInsertLGPLNotice := TMenuItem.Create(Self);
|
||||||
|
itmEditInsertLGPLNotice.Name:='itmEditInsertLGPLNotice';
|
||||||
|
itmEditInsertLGPLNotice.Caption := lisMenuInsertLGPLNotice;
|
||||||
|
itmEditInsertGeneral.Add(itmEditInsertLGPLNotice);
|
||||||
|
|
||||||
itmEditInsertUsername := TMenuItem.Create(Self);
|
itmEditInsertUsername := TMenuItem.Create(Self);
|
||||||
itmEditInsertUsername.Name:='itmEditInsertUsername';
|
itmEditInsertUsername.Name:='itmEditInsertUsername';
|
||||||
itmEditInsertUsername.Caption := lisMenuInsertUsername;
|
itmEditInsertUsername.Caption := lisMenuInsertUsername;
|
||||||
@ -1150,6 +1156,7 @@ begin
|
|||||||
itmEditInsertCVSSource.ShortCut:=CommandToShortCut(ecInsertCVSSource);
|
itmEditInsertCVSSource.ShortCut:=CommandToShortCut(ecInsertCVSSource);
|
||||||
|
|
||||||
itmEditInsertGPLNotice.ShortCut:=CommandToShortCut(ecInsertGPLNotice);
|
itmEditInsertGPLNotice.ShortCut:=CommandToShortCut(ecInsertGPLNotice);
|
||||||
|
itmEditInsertLGPLNotice.ShortCut:=CommandToShortCut(ecInsertLGPLNotice);
|
||||||
itmEditInsertUsername.ShortCut:=CommandToShortCut(ecInsertUserName);
|
itmEditInsertUsername.ShortCut:=CommandToShortCut(ecInsertUserName);
|
||||||
itmEditInsertDateTime.ShortCut:=CommandToShortCut(ecInsertDateTime);
|
itmEditInsertDateTime.ShortCut:=CommandToShortCut(ecInsertDateTime);
|
||||||
itmEditInsertChangeLogEntry.ShortCut:=CommandToShortCut(ecInsertChangeLogEntry);
|
itmEditInsertChangeLogEntry.ShortCut:=CommandToShortCut(ecInsertChangeLogEntry);
|
||||||
|
Loading…
Reference in New Issue
Block a user