fixed insert text GPL and LGPL

git-svn-id: trunk@3938 -
This commit is contained in:
mattias 2003-03-16 11:07:41 +00:00
parent 0046667b33
commit 309a9b60c5
4 changed files with 82 additions and 14 deletions

View File

@ -72,6 +72,11 @@ type
atPoint, atAt, atNumber, atStringConstant, atNewLine,
atSpace, atSymbol);
TAtomTypes = set of TAtomType;
TBeautifyCodeFlag = (
bcfNoIndentOnBreakLine
);
TBeautifyCodeFlags = set of TBeautifyCodeFlag;
TBeautifyCodeOptions = class
private
@ -102,11 +107,16 @@ type
PropertyWriteIdentPrefix: string;
PropertyStoredIdentPostfix: string;
PrivatVariablePrefix: string;
CurFlags: TBeautifyCodeFlags;
function BeautifyProc(const AProcCode: string; IndentSize: integer;
AddBeginEnd: boolean): string;
function BeautifyStatement(const AStatement: string; IndentSize: integer
): string;
function BeautifyStatementLeftAligned(const AStatement: string;
IndentSize: integer): string;
function BeautifyStatement(const AStatement: string; IndentSize: integer;
BeautifyFlags: TBeautifyCodeFlags): string;
function AddClassAndNameToProc(const AProcCode, AClassName,
AMethodName: string): string;
function BeautifyWord(const AWord: string; WordPolicy: TWordPolicy): string;
@ -1023,11 +1033,19 @@ begin
end;
function TBeautifyCodeOptions.BeautifyStatement(const AStatement: string;
IndentSize: integer): string;
IndentSize: integer; BeautifyFlags: TBeautifyCodeFlags): string;
var CurAtom: string;
OldIndent: Integer;
begin
//writeln('**********************************************************');
//writeln('[TBeautifyCodeOptions.BeautifyStatement] "',AStatement,'"');
// set flags
CurFlags:=BeautifyFlags;
if bcfNoIndentOnBreakLine in CurFlags then begin
OldIndent:=Indent;
Indent:=0;
end;
// init
Src:=AStatement;
UpperSrc:=UpperCaseStr(Src);
SrcLen:=length(Src);
@ -1039,6 +1057,7 @@ begin
LastSrcLineStart:=1;
CurLineLen:=length(Result);
LastAtomType:=atNone;
// read atoms
while (CurPos<=SrcLen) do begin
repeat
ReadNextAtom;
@ -1062,10 +1081,27 @@ begin
AddAtom(Result,CurAtom);
LastAtomType:=CurAtomType;
end;
// restore flags
if bcfNoIndentOnBreakLine in CurFlags then begin
Indent:=OldIndent;
end;
CurFlags:=[];
//writeln('[TBeautifyCodeOptions.BeautifyStatement] Result="',Result,'"');
//writeln('**********************************************************');
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,
AMethodName: string): string;
var StartPos, NamePos, ProcLen: integer;

View File

@ -86,17 +86,18 @@ const
ecSelectParagraph = ecUserFirst + 59;
ecInsertGPLNotice = ecUserFirst + 80;
ecInsertUserName = ecUserFirst + 81;
ecInsertDateTime = ecUserFirst + 82;
ecInsertChangeLogEntry = ecUserFirst + 83;
ecInsertCVSAuthor = ecUserFirst + 84;
ecInsertCVSDate = ecUserFirst + 85;
ecInsertCVSHeader = ecUserFirst + 86;
ecInsertCVSID = ecUserFirst + 87;
ecInsertCVSLog = ecUserFirst + 88;
ecInsertCVSName = ecUserFirst + 89;
ecInsertCVSRevision = ecUserFirst + 90;
ecInsertCVSSource = ecUserFirst + 91;
ecInsertLGPLNotice = ecUserFirst + 81;
ecInsertUserName = ecUserFirst + 82;
ecInsertDateTime = ecUserFirst + 83;
ecInsertChangeLogEntry = ecUserFirst + 84;
ecInsertCVSAuthor = ecUserFirst + 85;
ecInsertCVSDate = ecUserFirst + 86;
ecInsertCVSHeader = ecUserFirst + 87;
ecInsertCVSID = ecUserFirst + 88;
ecInsertCVSLog = ecUserFirst + 89;
ecInsertCVSName = ecUserFirst + 90;
ecInsertCVSRevision = ecUserFirst + 91;
ecInsertCVSSource = ecUserFirst + 92;
ecWordCompletion = ecUserFirst + 100;
ecCompleteCode = ecUserFirst + 101;
@ -524,6 +525,7 @@ begin
ecSelectLine : Result:= lismenuselectline;
ecSelectParagraph : Result:= lismenuselectparagraph;
ecInsertGPLNotice : Result:= srkmecInsertGPLNotice;
ecInsertLGPLNotice : Result:= srkmecInsertLGPLNotice;
ecInsertUserName : Result:= srkmecInsertUserName;
ecInsertDateTime : Result:= srkmecInsertDateTime;
ecInsertChangeLogEntry : Result:= srkmecInsertChangeLogEntry;
@ -1284,6 +1286,7 @@ begin
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,'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 date and time',ecInsertDateTime,VK_UNKNOWN,[],VK_UNKNOWN,[]);
Add(C,'Insert ChangeLog entry',ecInsertChangeLogEntry,VK_UNKNOWN,[],VK_UNKNOWN,[]);

View File

@ -143,6 +143,7 @@ resourcestring
lisMenuCompleteCode = 'Complete Code';
lisMenuInsertGPLNotice = 'GPL notice';
lisMenuInsertLGPLNotice = 'LGPL notice';
lisMenuInsertUserName = 'Current username';
lisMenuInsertDateTime = 'Current date and time';
lisMenuInsertChangeLogEntry = 'ChangeLog entry';
@ -281,7 +282,9 @@ resourcestring
lisHintStepOver = 'Step Over';
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 '
+'the Free Software Foundation; either version 2 of the License, or '
+'(at your option) any later version. '
@ -293,7 +296,25 @@ resourcestring
+'%s'
+'You should have received a copy of the GNU General Public License '
+'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
ideStandard = 'Standard';
@ -825,6 +846,7 @@ resourcestring
// edit menu
srkmecSelectionTabs2Spaces = 'Convert tabs to spaces in selection';
srkmecInsertGPLNotice = 'Insert GPL notice';
srkmecInsertLGPLNotice = 'Insert LGPL notice';
srkmecInsertUserName = 'Insert current username';
srkmecInsertDateTime = 'Insert current date and time';
srkmecInsertChangeLogEntry = 'Insert ChangeLog entry';

View File

@ -193,6 +193,7 @@ type
itmEditInsertCVSSource: TMenuItem;
itmEditInsertGPLNotice: TMenuItem;
itmEditInsertLGPLNotice: TMenuItem;
itmEditInsertUsername: TMenuItem;
itmEditInsertDateTime: TMenuItem;
itmEditInsertChangeLogEntry: TMenuItem;
@ -672,6 +673,11 @@ begin
itmEditInsertGPLNotice.Caption := lisMenuInsertGPLNotice;
itmEditInsertGeneral.Add(itmEditInsertGPLNotice);
itmEditInsertLGPLNotice := TMenuItem.Create(Self);
itmEditInsertLGPLNotice.Name:='itmEditInsertLGPLNotice';
itmEditInsertLGPLNotice.Caption := lisMenuInsertLGPLNotice;
itmEditInsertGeneral.Add(itmEditInsertLGPLNotice);
itmEditInsertUsername := TMenuItem.Create(Self);
itmEditInsertUsername.Name:='itmEditInsertUsername';
itmEditInsertUsername.Caption := lisMenuInsertUsername;
@ -1150,6 +1156,7 @@ begin
itmEditInsertCVSSource.ShortCut:=CommandToShortCut(ecInsertCVSSource);
itmEditInsertGPLNotice.ShortCut:=CommandToShortCut(ecInsertGPLNotice);
itmEditInsertLGPLNotice.ShortCut:=CommandToShortCut(ecInsertLGPLNotice);
itmEditInsertUsername.ShortCut:=CommandToShortCut(ecInsertUserName);
itmEditInsertDateTime.ShortCut:=CommandToShortCut(ecInsertDateTime);
itmEditInsertChangeLogEntry.ShortCut:=CommandToShortCut(ecInsertChangeLogEntry);