make resourcestring dialog now checks for doubles (idents and values)

git-svn-id: trunk@3925 -
This commit is contained in:
mattias 2003-03-14 14:57:03 +00:00
parent b0b03b2c04
commit 9f4034806d
6 changed files with 548 additions and 130 deletions

View File

@ -39,10 +39,10 @@ uses
{$IFDEF MEM_CHECK} {$IFDEF MEM_CHECK}
MemCheck, MemCheck,
{$ENDIF} {$ENDIF}
Classes, SysUtils, CodeToolsStrConsts, EventCodeTool, CodeTree, CodeAtom, Classes, SysUtils, BasicCodeTools, CodeToolsStrConsts, EventCodeTool,
SourceChanger, DefineTemplates, CodeCache, ExprEval, LinkScanner, CodeTree, CodeAtom, SourceChanger, DefineTemplates, CodeCache, ExprEval,
KeywordFuncLists, TypInfo, AVL_Tree, CustomCodeTool, FindDeclarationTool, LinkScanner, KeywordFuncLists, TypInfo, AVL_Tree, CustomCodeTool,
IdentCompletionTool, ResourceCodeTool, CodeToolsStructs; FindDeclarationTool, IdentCompletionTool, ResourceCodeTool, CodeToolsStructs;
type type
TCodeToolManager = class; TCodeToolManager = class;
@ -237,10 +237,13 @@ type
// gather identifiers (i.e. all visible) // gather identifiers (i.e. all visible)
function GatherIdentifiers(Code: TCodeBuffer; X,Y: integer): boolean; function GatherIdentifiers(Code: TCodeBuffer; X,Y: integer): boolean;
function GetIdentifierAt(Code: TCodeBuffer; X,Y: integer;
var Identifier: string): boolean;
// resource string sections // resource string sections
function GatherResourceStringSections( function GatherResourceStringSections(
Code: TCodeBuffer; X,Y: integer): boolean; Code: TCodeBuffer; X,Y: integer;
CodePositions: TCodeXYPositions): boolean;
function IdentifierExistsInResourceStringSection(Code: TCodeBuffer; function IdentifierExistsInResourceStringSection(Code: TCodeBuffer;
X,Y: integer; const ResStrIdentifier: string): boolean; X,Y: integer; const ResStrIdentifier: string): boolean;
function CreateIdentifierFromStringConst( function CreateIdentifierFromStringConst(
@ -251,6 +254,9 @@ type
StartCode: TCodeBuffer; StartX, StartY: integer; StartCode: TCodeBuffer; StartX, StartY: integer;
EndCode: TCodeBuffer; EndX, EndY: integer; EndCode: TCodeBuffer; EndX, EndY: integer;
var FormatStringConstant, FormatParameters: string): boolean; var FormatStringConstant, FormatParameters: string): boolean;
function GatherResourceStringsWithValue(SectionCode: TCodeBuffer;
SectionX, SectionY: integer; const StringValue: string;
CodePositions: TCodeXYPositions): boolean;
function AddResourcestring(SectionCode: TCodeBuffer; function AddResourcestring(SectionCode: TCodeBuffer;
SectionX, SectionY: integer; SectionX, SectionY: integer;
const NewIdentifier, NewValue: string; const NewIdentifier, NewValue: string;
@ -830,8 +836,27 @@ begin
{$ENDIF} {$ENDIF}
end; end;
function TCodeToolManager.GatherResourceStringSections(Code: TCodeBuffer; X, function TCodeToolManager.GetIdentifierAt(Code: TCodeBuffer; X, Y: integer;
Y: integer): boolean; var Identifier: string): boolean;
var
CleanPos: integer;
begin
Result:=false;
{$IFDEF CTDEBUG}
writeln('TCodeToolManager.GetIdentifierAt A ',Code.Filename,' x=',x,' y=',y);
{$ENDIF}
Code.LineColToPosition(Y,X,CleanPos);
if (CleanPos>0) and (CleanPos<=Code.SourceLength) then begin
Identifier:=GetIdentifier(@Code.Source[CleanPos]);
Result:=true;
end else begin
Identifier:='';
Result:=false;
end;
end;
function TCodeToolManager.GatherResourceStringSections(Code: TCodeBuffer;
X, Y: integer; CodePositions: TCodeXYPositions): boolean;
var var
CursorPos: TCodeXYPosition; CursorPos: TCodeXYPosition;
begin begin
@ -843,9 +868,12 @@ begin
CursorPos.X:=X; CursorPos.X:=X;
CursorPos.Y:=Y; CursorPos.Y:=Y;
CursorPos.Code:=Code; CursorPos.Code:=Code;
ClearPositions; if CodePositions=nil then begin
ClearPositions;
CodePositions:=Positions;
end;
try try
Result:=FCurCodeTool.GatherResourceStringSections(CursorPos,Positions); Result:=FCurCodeTool.GatherResourceStringSections(CursorPos,CodePositions);
except except
on e: Exception do HandleException(e); on e: Exception do HandleException(e);
end; end;
@ -925,6 +953,32 @@ begin
end; end;
end; end;
function TCodeToolManager.GatherResourceStringsWithValue(
SectionCode: TCodeBuffer; SectionX, SectionY: integer;
const StringValue: string; CodePositions: TCodeXYPositions): boolean;
var
CursorPos: TCodeXYPosition;
begin
Result:=false;
{$IFDEF CTDEBUG}
writeln('TCodeToolManager.GatherResourceStringsWithValue A ',Code.Filename,' x=',x,' y=',y);
{$ENDIF}
if not InitCurCodeTool(SectionCode) then exit;
CursorPos.X:=SectionX;
CursorPos.Y:=SectionY;
CursorPos.Code:=SectionCode;
if CodePositions=nil then begin
ClearPositions;
CodePositions:=Positions;
end;
try
Result:=FCurCodeTool.GatherResourceStringsWithValue(CursorPos,StringValue,
CodePositions);
except
on e: Exception do HandleException(e);
end;
end;
function TCodeToolManager.AddResourcestring(SectionCode: TCodeBuffer; SectionX, function TCodeToolManager.AddResourcestring(SectionCode: TCodeBuffer; SectionX,
SectionY: integer; const NewIdentifier, NewValue: string; SectionY: integer; const NewIdentifier, NewValue: string;
InsertAlphabetically: boolean): boolean; InsertAlphabetically: boolean): boolean;

View File

@ -56,8 +56,11 @@ type
procedure Clear; procedure Clear;
function Add(const Position: TCodeXYPosition): integer; function Add(const Position: TCodeXYPosition): integer;
function Add(X,Y: integer; Code: TCodeBuffer): integer; function Add(X,Y: integer; Code: TCodeBuffer): integer;
procedure Assign(Source: TCodeXYPositions);
function IsEqual(Source: TCodeXYPositions): boolean;
function Count: integer; function Count: integer;
procedure Delete(Index: integer); procedure Delete(Index: integer);
function CreateCopy: TCodeXYPositions;
public public
property Items[Index: integer]: PCodeXYPosition property Items[Index: integer]: PCodeXYPosition
read GetItems write SetItems; default; read GetItems write SetItems; default;
@ -160,6 +163,42 @@ begin
Result:=Add(NewItem); Result:=Add(NewItem);
end; end;
procedure TCodeXYPositions.Assign(Source: TCodeXYPositions);
var
i: Integer;
begin
if IsEqual(Source) then exit;
Clear;
for i:=0 to Source.Count-1 do
Add(Source[i]^);
end;
function TCodeXYPositions.IsEqual(Source: TCodeXYPositions): boolean;
var
SrcItem: TCodeXYPosition;
CurItem: TCodeXYPosition;
i: Integer;
begin
if Source=Self then
Result:=true
else if (Source=nil) or (Source.Count<>Count) then
Result:=false
else begin
for i:=0 to Count-1 do begin
SrcItem:=Source[i]^;
CurItem:=Items[i]^;
if (SrcItem.X<>CurItem.X)
or (SrcItem.Y<>CurItem.Y)
or (SrcItem.Code<>CurItem.Code)
then begin
Result:=false;
exit;
end;
end;
Result:=true;
end;
end;
function TCodeXYPositions.Count: integer; function TCodeXYPositions.Count: integer;
begin begin
if FItems<>nil then if FItems<>nil then
@ -177,5 +216,11 @@ begin
FItems.Delete(Index); FItems.Delete(Index);
end; end;
function TCodeXYPositions.CreateCopy: TCodeXYPositions;
begin
Result:=TCodeXYPositions.Create;
Result.Assign(Self);
end;
end. end.

View File

@ -172,15 +172,18 @@ type
function IdentifierExistsInResourceStringSection( function IdentifierExistsInResourceStringSection(
const CursorPos: TCodeXYPosition; const CursorPos: TCodeXYPosition;
const ResStrIdentifier: string): boolean; const ResStrIdentifier: string): boolean;
function GatherResourceStringsWithValue(const CursorPos: TCodeXYPosition;
const StringValue: string;
PositionList: TCodeXYPositions): boolean;
function AddResourcestring(const SectionPos: TCodeXYPosition;
const NewIdentifier, NewValue: string; InsertAlphabetically: boolean;
SourceChangeCache: TSourceChangeCache): boolean;
function CreateIdentifierFromStringConst( function CreateIdentifierFromStringConst(
const StartCursorPos, EndCursorPos: TCodeXYPosition; const StartCursorPos, EndCursorPos: TCodeXYPosition;
var Identifier: string; MaxLen: integer): boolean; var Identifier: string; MaxLen: integer): boolean;
function StringConstToFormatString( function StringConstToFormatString(
const StartCursorPos, EndCursorPos: TCodeXYPosition; const StartCursorPos, EndCursorPos: TCodeXYPosition;
var FormatStringConstant,FormatParameters: string): boolean; var FormatStringConstant,FormatParameters: string): boolean;
function AddResourcestring(const SectionPos: TCodeXYPosition;
const NewIdentifier, NewValue: string; InsertAlphabetically: boolean;
SourceChangeCache: TSourceChangeCache): boolean;
end; end;
@ -1656,6 +1659,56 @@ begin
Result:=FormatStringConstant<>''; Result:=FormatStringConstant<>'';
end; end;
function TStandardCodeTool.GatherResourceStringsWithValue(
const CursorPos: TCodeXYPosition; const StringValue: string;
PositionList: TCodeXYPositions): boolean;
procedure CompareStringConst(ANode: TCodeTreeNode);
var
CurValue: String;
NewCaret: TCodeXYPosition;
begin
MoveCursorToNodeStart(ANode);
ReadNextAtom; // read identifier
if not AtomIsIdentifier(false) then exit;
ReadNextAtom; // read =
if CurPos.Flag<>cafEqual then exit;
ReadNextAtom; // read start of string constant
if not AtomIsStringConstant then exit;
// extract string constant value
CurValue:=ReadStringConstantValue(CurPos.StartPos);
if CurValue<>StringValue then exit;
// values are the same
// -> add it to position list
// get x,y position
if not CleanPosToCaret(ANode.StartPos,NewCaret) then exit;
//writeln('TStandardCodeTool.GatherResourceStringsWithValue Found ',MainFilename,' Y=',NewCaret.Y);
PositionList.Add(NewCaret);
end;
var
CleanCursorPos: integer;
ANode: TCodeTreeNode;
begin
Result:=false;
if PositionList=nil then exit;
// parse source and find clean positions
BuildTreeAndGetCleanPos(trAll,CursorPos,CleanCursorPos,[]);
// find resource string section
ANode:=FindDeepestNodeAtPos(CleanCursorPos,true);
if (ANode=nil) then exit;
ANode:=ANode.GetNodeOfType(ctnResStrSection);
if ANode=nil then exit;
// search identifier in section
ANode:=ANode.FirstChild;
while ANode<>nil do begin
if (ANode.Desc=ctnConstDefinition) then begin
CompareStringConst(ANode);
end;
ANode:=ANode.NextBrother;
end;
end;
function TStandardCodeTool.AddResourcestring(const SectionPos: TCodeXYPosition; function TStandardCodeTool.AddResourcestring(const SectionPos: TCodeXYPosition;
const NewIdentifier, NewValue: string; InsertAlphabetically: boolean; const NewIdentifier, NewValue: string; InsertAlphabetically: boolean;
SourceChangeCache: TSourceChangeCache): boolean; SourceChangeCache: TSourceChangeCache): boolean;

View File

@ -857,12 +857,12 @@ begin
Caption:=lisCodeToolsDefsCreateDefinesForFreePascalCVSSources; Caption:=lisCodeToolsDefsCreateDefinesForFreePascalCVSSources;
FileCount:=2; FileCount:=2;
FileTitles[0]:='FPC CVS source directory'; FileTitles[0]:=lisCodeToolsDefsFPCCVSSourceDirectory;
FileDescs[0]:='The Free Pascal CVS source directory.'; FileDescs[0]:=lisCodeToolsDefsTheFreePascalCVSSourceDir;
FileNames[0]:='~/fpc_sources/1.1/fpc'; FileNames[0]:='~/fpc_sources/1.1/fpc';
FileFlags[0]:=[iftDirectory,iftNotEmpty,iftMustExist]; FileFlags[0]:=[iftDirectory,iftNotEmpty,iftMustExist];
FileTitles[1]:='compiler path'; FileTitles[1]:=lisCodeToolsDefscompilerPath;
FileDescs[1]:='The path to the free pascal compiler for this source.'#13 FileDescs[1]:='The path to the free pascal compiler for this source.'#13
+'Used to autocreate macros.'; +'Used to autocreate macros.';
FileNames[1]:=DefaultCompiler; FileNames[1]:=DefaultCompiler;
@ -920,11 +920,11 @@ begin
InputFileDlg.Macros:=Macros; InputFileDlg.Macros:=Macros;
with InputFileDlg do begin with InputFileDlg do begin
BeginUpdate; BeginUpdate;
Caption:='Create Defines for Lazarus Directory'; Caption:=lisCodeToolsDefsCreateDefinesForLazarusDir;
FileCount:=1; FileCount:=1;
FileTitles[0]:='Lazarus Directory'; FileTitles[0]:=lisCodeToolsDefsLazarusDirectory;
FileDescs[0]:='The Lazarus main directory.'; FileDescs[0]:=lisCodeToolsDefsTheLazarusMainDirectory;
FileNames[0]:=IDEProcs.ProgramDirectory; FileNames[0]:=IDEProcs.ProgramDirectory;
FileFlags[0]:=[iftDirectory,iftNotEmpty,iftMustExist]; FileFlags[0]:=[iftDirectory,iftNotEmpty,iftMustExist];
@ -967,13 +967,12 @@ begin
InputFileDlg.Macros:=Macros; InputFileDlg.Macros:=Macros;
with InputFileDlg do begin with InputFileDlg do begin
BeginUpdate; BeginUpdate;
Caption:='Create Defines for '+DelphiName+' Directory'; Caption:=Format(lisCodeToolsDefsCreateDefinesForDirectory, [DelphiName]);
FileCount:=1; FileCount:=1;
FileTitles[0]:=DelphiName+' directory'; FileTitles[0]:=Format(lisCodeToolsDefsdirectory, [DelphiName]);
FileDescs[0]:='The '+DelphiName+' main directory,'#13 FileDescs[0]:=Format(lisCodeToolsDefsDelphiMainDirectoryDesc, [DelphiName,
+'where Borland has installed all '+DelphiName+' sources.'#13 #13, DelphiName, #13, IntToStr(DelphiVersion)]);
+'For example: C:/Programme/Borland/Delphi'+IntToStr(DelphiVersion);
FileNames[0]:=SetDirSeparators( FileNames[0]:=SetDirSeparators(
'C:/Programme/Borland/Delphi'+IntToStr(DelphiVersion)); 'C:/Programme/Borland/Delphi'+IntToStr(DelphiVersion));
FileFlags[0]:=[iftDirectory,iftNotEmpty,iftMustExist]; FileFlags[0]:=[iftDirectory,iftNotEmpty,iftMustExist];
@ -1006,22 +1005,21 @@ begin
InputFileDlg.Macros:=Macros; InputFileDlg.Macros:=Macros;
with InputFileDlg do begin with InputFileDlg do begin
BeginUpdate; BeginUpdate;
Caption:='Create Defines for '+DelphiName+' Project'; Caption:=Format(lisCodeToolsDefsCreateDefinesForProject, [DelphiName]);
FileCount:=2; FileCount:=2;
FileTitles[0]:=DelphiName+' project directory'; FileTitles[0]:=Format(lisCodeToolsDefsprojectDirectory2, [DelphiName]);
FileDescs[0]:='The '+DelphiName+' project directory,'#13 FileDescs[0]:=Format(lisCodeToolsDefsTheProjectDirectory, [DelphiName, #13]
+'which contains the .dpr, dpk file.'; );
FileNames[0]:=SetDirSeparators('C:/Programme/Borland/Delphi' FileNames[0]:=SetDirSeparators('C:/Programme/Borland/Delphi'
+IntToStr(DelphiVersion)+'/YourProject'); +IntToStr(DelphiVersion)+'/YourProject');
FileFlags[0]:=[iftDirectory,iftNotEmpty,iftMustExist]; FileFlags[0]:=[iftDirectory,iftNotEmpty,iftMustExist];
FileTitles[1]:=DelphiName+' directory'; FileTitles[1]:=Format(lisCodeToolsDefsdirectory, [DelphiName]);
FileDescs[1]:='The '+DelphiName+' main directory,'#13 FileDescs[1]:=Format(lisCodeToolsDefsDelphiMainDirectoryForProject, [
+'where Borland has installed all '+DelphiName+' sources,'#13 DelphiName, #13, DelphiName, #13, DelphiName, #13, IntToStr(DelphiVersion)
+'which are used by this '+DelphiName+' project.'#13 ]);
+'For example: C:/Programme/Borland/Delphi'+IntToStr(DelphiVersion);
FileNames[1]:=SetDirSeparators('C:/Programme/Borland/Delphi' FileNames[1]:=SetDirSeparators('C:/Programme/Borland/Delphi'
+IntToStr(DelphiVersion)); +IntToStr(DelphiVersion));
FileFlags[1]:=[iftDirectory,iftNotEmpty,iftMustExist]; FileFlags[1]:=[iftDirectory,iftNotEmpty,iftMustExist];
@ -1088,7 +1086,8 @@ begin
if ProjectSpecificCheckBox.Checked=(dtfProjectSpecific in SelDefNode.Flags) if ProjectSpecificCheckBox.Checked=(dtfProjectSpecific in SelDefNode.Flags)
then exit; then exit;
if SelDefNode.IsAutoGenerated then begin if SelDefNode.IsAutoGenerated then begin
MessageDlg('Node is readonly','Auto generated nodes can not be edited.', MessageDlg(lisCodeToolsDefsNodeIsReadonly,
lisCodeToolsDefsAutoGeneratedNodesCanNotBeEdited,
mtInformation,[mbCancel],0); mtInformation,[mbCancel],0);
exit; exit;
end; end;
@ -1172,48 +1171,57 @@ begin
Menu := MainMenu; Menu := MainMenu;
// exit menu // exit menu
AddMenuItem(ExitMenuItem,'ExitMenuItem','Exit',nil); AddMenuItem(ExitMenuItem, 'ExitMenuItem', lisCodeToolsDefsExit, nil);
AddMenuItem(SaveAndExitMenuItem,'SaveAndExitMenuItem','Save and Exit', AddMenuItem(SaveAndExitMenuItem, 'SaveAndExitMenuItem',
lisCodeToolsDefsSaveAndExit,
ExitMenuItem); ExitMenuItem);
SaveAndExitMenuItem.OnClick:=@SaveAndExitMenuItemClick; SaveAndExitMenuItem.OnClick:=@SaveAndExitMenuItemClick;
ExitMenuItem.Add(CreateSeperator); ExitMenuItem.Add(CreateSeperator);
AddMenuItem(DontSaveAndExitMenuItem,'DontSaveAndExitMenuItem', AddMenuItem(DontSaveAndExitMenuItem,'DontSaveAndExitMenuItem',
'Exit without Save',ExitMenuItem); lisCodeToolsDefsExitWithoutSave, ExitMenuItem);
DontSaveAndExitMenuItem.OnClick:=@DontSaveAndExitMenuItemClick; DontSaveAndExitMenuItem.OnClick:=@DontSaveAndExitMenuItemClick;
// edit nodes // edit nodes
AddMenuItem(EditMenuItem,'EditMenuItem','Edit',nil); AddMenuItem(EditMenuItem, 'EditMenuItem', lisCodeToolsDefsEdit, nil);
AddMenuItem(MoveNodeUpMenuItem,'MoveNodeUpMenuItem','Move node up', AddMenuItem(MoveNodeUpMenuItem, 'MoveNodeUpMenuItem',
lisCodeToolsDefsMoveNodeUp,
EditMenuItem); EditMenuItem);
MoveNodeUpMenuItem.OnClick:=@MoveNodeUpMenuItemClick; MoveNodeUpMenuItem.OnClick:=@MoveNodeUpMenuItemClick;
AddMenuItem(MoveNodeDownMenuItem,'MoveNodeDownMenuItem','Move node down', AddMenuItem(MoveNodeDownMenuItem, 'MoveNodeDownMenuItem',
lisCodeToolsDefsMoveNodeDown,
EditMenuItem); EditMenuItem);
MoveNodeDownMenuItem.OnClick:=@MoveNodeDownMenuItemClick; MoveNodeDownMenuItem.OnClick:=@MoveNodeDownMenuItemClick;
AddMenuItem(MoveNodeLvlUpMenuItem,'MoveNodeLvlUpMenuItem','Move node one level up', AddMenuItem(MoveNodeLvlUpMenuItem, 'MoveNodeLvlUpMenuItem',
lisCodeToolsDefsMoveNodeOneLevelUp,
EditMenuItem); EditMenuItem);
MoveNodeLvlUpMenuItem.OnClick:=@MoveNodeLvlUpMenuItemClick; MoveNodeLvlUpMenuItem.OnClick:=@MoveNodeLvlUpMenuItemClick;
AddMenuItem(MoveNodeLvlDownMenuItem,'MoveNodeLvlDownMenuItem','Move node one level down', AddMenuItem(MoveNodeLvlDownMenuItem, 'MoveNodeLvlDownMenuItem',
lisCodeToolsDefsMoveNodeOneLevelDown,
EditMenuItem); EditMenuItem);
MoveNodeLvlDownMenuItem.OnClick:=@MoveNodeLvlDownMenuItemClick; MoveNodeLvlDownMenuItem.OnClick:=@MoveNodeLvlDownMenuItemClick;
EditMenuItem.Add(CreateSeperator); EditMenuItem.Add(CreateSeperator);
AddMenuItem(InsertBehindMenuItem,'InsertBehindMenuItem','Insert node below', AddMenuItem(InsertBehindMenuItem, 'InsertBehindMenuItem',
lisCodeToolsDefsInsertNodeBelow,
EditMenuItem); EditMenuItem);
AddMenuItem(InsertAsChildMenuItem,'InsertAsChildMenuItem','Insert node as child', AddMenuItem(InsertAsChildMenuItem, 'InsertAsChildMenuItem',
lisCodeToolsDefsInsertNodeAsChild,
EditMenuItem); EditMenuItem);
EditMenuItem.Add(CreateSeperator); EditMenuItem.Add(CreateSeperator);
AddMenuItem(DeleteNodeMenuItem,'DeleteNodeMenuItem','Delete node', AddMenuItem(DeleteNodeMenuItem, 'DeleteNodeMenuItem',
lisCodeToolsDefsDeleteNode,
EditMenuItem); EditMenuItem);
DeleteNodeMenuItem.OnClick:=@DeleteNodeMenuItemClick; DeleteNodeMenuItem.OnClick:=@DeleteNodeMenuItemClick;
AddMenuItem(ConvertActionMenuItem,'ConvertActionMenuItem','Convert node', AddMenuItem(ConvertActionMenuItem, 'ConvertActionMenuItem',
lisCodeToolsDefsConvertNode,
EditMenuItem); EditMenuItem);
{ EditMenuItem.Add(CreateSeperator); { EditMenuItem.Add(CreateSeperator);
@ -1223,108 +1231,138 @@ begin
'Paste from clipboard',EditMenuItem);} 'Paste from clipboard',EditMenuItem);}
// insert node behind submenu // insert node behind submenu
AddMenuItem(InsertBehindDefineMenuItem,'InsertBehindDefineMenuItem','Define', AddMenuItem(InsertBehindDefineMenuItem, 'InsertBehindDefineMenuItem',
lisCodeToolsDefsDefine,
InsertBehindMenuItem); InsertBehindMenuItem);
AddMenuItem(InsertBehindDefineRecurseMenuItem, AddMenuItem(InsertBehindDefineRecurseMenuItem,
'InsertBehindDefineRecurseMenuItem','Define Recurse', 'InsertBehindDefineRecurseMenuItem',
lisCodeToolsDefsDefineRecurse,
InsertBehindMenuItem); InsertBehindMenuItem);
AddMenuItem(InsertBehindUndefineMenuItem, AddMenuItem(InsertBehindUndefineMenuItem,
'InsertBehindUndefineMenuItem','Undefine', 'InsertBehindUndefineMenuItem', lisCodeToolsDefsUndefine,
InsertBehindMenuItem); InsertBehindMenuItem);
AddMenuItem(InsertBehindUndefineRecurseMenuItem, AddMenuItem(InsertBehindUndefineRecurseMenuItem,
'InsertBehindUndefineRecurseMenuItem','Undefine Recurse', 'InsertBehindUndefineRecurseMenuItem',
lisCodeToolsDefsUndefineRecurse,
InsertBehindMenuItem); InsertBehindMenuItem);
AddMenuItem(InsertBehindUndefineAllMenuItem, AddMenuItem(InsertBehindUndefineAllMenuItem,
'InsertBehindUndefineAllMenuItem','Undefine All', 'InsertBehindUndefineAllMenuItem', lisCodeToolsDefsUndefineAll,
InsertBehindMenuItem); InsertBehindMenuItem);
InsertBehindMenuItem.Add(CreateSeperator); InsertBehindMenuItem.Add(CreateSeperator);
AddMenuItem(InsertBehindBlockMenuItem,'InsertBehindBlockMenuItem','Block', AddMenuItem(InsertBehindBlockMenuItem, 'InsertBehindBlockMenuItem',
lisCodeToolsDefsBlock,
InsertBehindMenuItem); InsertBehindMenuItem);
AddMenuItem(InsertBehindDirectoryMenuItem, AddMenuItem(InsertBehindDirectoryMenuItem,
'InsertBehindDirectoryMenuItem','Directory', 'InsertBehindDirectoryMenuItem',
lisCodeToolsDefsInsertBehindDirectory,
InsertBehindMenuItem); InsertBehindMenuItem);
InsertBehindMenuItem.Add(CreateSeperator); InsertBehindMenuItem.Add(CreateSeperator);
AddMenuItem(InsertBehindIfMenuItem,'InsertBehindIfMenuItem','If', AddMenuItem(InsertBehindIfMenuItem, 'InsertBehindIfMenuItem',
lisCodeToolsDefsIf,
InsertBehindMenuItem); InsertBehindMenuItem);
AddMenuItem(InsertBehindIfDefMenuItem,'InsertBehindIfDefMenuItem','IfDef', AddMenuItem(InsertBehindIfDefMenuItem, 'InsertBehindIfDefMenuItem',
lisCodeToolsDefsIfDef,
InsertBehindMenuItem); InsertBehindMenuItem);
AddMenuItem(InsertBehindIfNotDefMenuItem,'InsertBehindIfNotDefMenuItem','IfNDef', AddMenuItem(InsertBehindIfNotDefMenuItem, 'InsertBehindIfNotDefMenuItem',
lisCodeToolsDefsIfNDef,
InsertBehindMenuItem); InsertBehindMenuItem);
AddMenuItem(InsertBehindElseIfMenuItem,'InsertBehindElseIfMenuItem','ElseIf', AddMenuItem(InsertBehindElseIfMenuItem, 'InsertBehindElseIfMenuItem',
lisCodeToolsDefsElseIf,
InsertBehindMenuItem); InsertBehindMenuItem);
AddMenuItem(InsertBehindElseMenuItem,'InsertBehindElseMenuItem','Else', AddMenuItem(InsertBehindElseMenuItem, 'InsertBehindElseMenuItem',
lisCodeToolsDefsElse,
InsertBehindMenuItem); InsertBehindMenuItem);
for i:=0 to InsertBehindMenuItem.Count-1 do for i:=0 to InsertBehindMenuItem.Count-1 do
if InsertBehindMenuItem[i].Caption<>'-' then if InsertBehindMenuItem[i].Caption<>'-' then
InsertBehindMenuItem[i].OnClick:=@InsertNodeMenuItemClick; InsertBehindMenuItem[i].OnClick:=@InsertNodeMenuItemClick;
// insert node as child submenu // insert node as child submenu
AddMenuItem(InsertAsChildDefineMenuItem,'InsertAsChildDefineMenuItem','Define', AddMenuItem(InsertAsChildDefineMenuItem, 'InsertAsChildDefineMenuItem',
lisCodeToolsDefsDefine,
InsertAsChildMenuItem); InsertAsChildMenuItem);
AddMenuItem(InsertAsChildDefineRecurseMenuItem, AddMenuItem(InsertAsChildDefineRecurseMenuItem,
'InsertAsChildDefineRecurseMenuItem','Define Recurse', 'InsertAsChildDefineRecurseMenuItem',
lisCodeToolsDefsDefineRecurse,
InsertAsChildMenuItem); InsertAsChildMenuItem);
AddMenuItem(InsertAsChildUndefineMenuItem, AddMenuItem(InsertAsChildUndefineMenuItem,
'InsertAsChildUndefineMenuItem','Undefine', 'InsertAsChildUndefineMenuItem', lisCodeToolsDefsUndefine,
InsertAsChildMenuItem); InsertAsChildMenuItem);
AddMenuItem(InsertAsChildUndefineRecurseMenuItem, AddMenuItem(InsertAsChildUndefineRecurseMenuItem,
'InsertAsChildUndefineRecurseMenuItem','Undefine Recurse', 'InsertAsChildUndefineRecurseMenuItem',
lisCodeToolsDefsUndefineRecurse,
InsertAsChildMenuItem); InsertAsChildMenuItem);
AddMenuItem(InsertAsChildUndefineAllMenuItem, AddMenuItem(InsertAsChildUndefineAllMenuItem,
'InsertAsChildUndefineAllMenuItem','Undefine All', 'InsertAsChildUndefineAllMenuItem', lisCodeToolsDefsUndefineAll,
InsertAsChildMenuItem); InsertAsChildMenuItem);
InsertAsChildMenuItem.Add(CreateSeperator); InsertAsChildMenuItem.Add(CreateSeperator);
AddMenuItem(InsertAsChildBlockMenuItem,'InsertAsChildBlockMenuItem','Block', AddMenuItem(InsertAsChildBlockMenuItem, 'InsertAsChildBlockMenuItem',
lisCodeToolsDefsBlock,
InsertAsChildMenuItem); InsertAsChildMenuItem);
AddMenuItem(InsertAsChildDirectoryMenuItem, AddMenuItem(InsertAsChildDirectoryMenuItem,
'InsertAsChildDirectoryMenuItem','Directory', 'InsertAsChildDirectoryMenuItem',
lisCodeToolsDefsInsertBehindDirectory,
InsertAsChildMenuItem); InsertAsChildMenuItem);
InsertAsChildMenuItem.Add(CreateSeperator); InsertAsChildMenuItem.Add(CreateSeperator);
AddMenuItem(InsertAsChildIfMenuItem,'InsertAsChildIfMenuItem','If', AddMenuItem(InsertAsChildIfMenuItem, 'InsertAsChildIfMenuItem',
lisCodeToolsDefsIf,
InsertAsChildMenuItem); InsertAsChildMenuItem);
AddMenuItem(InsertAsChildIfDefMenuItem,'InsertAsChildIfDefMenuItem','IfDef', AddMenuItem(InsertAsChildIfDefMenuItem, 'InsertAsChildIfDefMenuItem',
lisCodeToolsDefsIfDef,
InsertAsChildMenuItem); InsertAsChildMenuItem);
AddMenuItem(InsertAsChildIfNotDefMenuItem,'InsertAsChildIfNotDefMenuItem','IfNDef', AddMenuItem(InsertAsChildIfNotDefMenuItem, 'InsertAsChildIfNotDefMenuItem',
lisCodeToolsDefsIfNDef,
InsertAsChildMenuItem); InsertAsChildMenuItem);
AddMenuItem(InsertAsChildElseIfMenuItem,'InsertAsChildElseIfMenuItem','ElseIf', AddMenuItem(InsertAsChildElseIfMenuItem, 'InsertAsChildElseIfMenuItem',
lisCodeToolsDefsElseIf,
InsertAsChildMenuItem); InsertAsChildMenuItem);
AddMenuItem(InsertAsChildElseMenuItem,'InsertAsChildElseMenuItem','Else', AddMenuItem(InsertAsChildElseMenuItem, 'InsertAsChildElseMenuItem',
lisCodeToolsDefsElse,
InsertAsChildMenuItem); InsertAsChildMenuItem);
for i:=0 to InsertAsChildMenuItem.Count-1 do for i:=0 to InsertAsChildMenuItem.Count-1 do
if InsertAsChildMenuItem[i].Caption<>'-' then if InsertAsChildMenuItem[i].Caption<>'-' then
InsertAsChildMenuItem[i].OnClick:=@InsertNodeMenuItemClick; InsertAsChildMenuItem[i].OnClick:=@InsertNodeMenuItemClick;
// convert node sub menu // convert node sub menu
AddMenuItem(ConvertActionToDefineMenuItem,'ConvertActionToDefineMenuItem','Define', AddMenuItem(ConvertActionToDefineMenuItem, 'ConvertActionToDefineMenuItem',
lisCodeToolsDefsDefine,
ConvertActionMenuItem); ConvertActionMenuItem);
AddMenuItem(ConvertActionToDefineRecurseMenuItem, AddMenuItem(ConvertActionToDefineRecurseMenuItem,
'ConvertActionToDefineRecurseMenuItem','Define Recurse', 'ConvertActionToDefineRecurseMenuItem',
lisCodeToolsDefsDefineRecurse,
ConvertActionMenuItem); ConvertActionMenuItem);
AddMenuItem(ConvertActionToUndefineMenuItem, AddMenuItem(ConvertActionToUndefineMenuItem,
'ConvertActionToUndefineMenuItem','Undefine', 'ConvertActionToUndefineMenuItem', lisCodeToolsDefsUndefine,
ConvertActionMenuItem); ConvertActionMenuItem);
AddMenuItem(ConvertActionToUndefineRecurseMenuItem, AddMenuItem(ConvertActionToUndefineRecurseMenuItem,
'ConvertActionToUndefineRecurseMenuItem','Undefine Recurse', 'ConvertActionToUndefineRecurseMenuItem',
lisCodeToolsDefsUndefineRecurse,
ConvertActionMenuItem); ConvertActionMenuItem);
AddMenuItem(ConvertActionToUndefineAllMenuItem, AddMenuItem(ConvertActionToUndefineAllMenuItem,
'ConvertActionToUndefineAllMenuItem','Undefine All', 'ConvertActionToUndefineAllMenuItem', lisCodeToolsDefsUndefineAll,
ConvertActionMenuItem); ConvertActionMenuItem);
ConvertActionMenuItem.Add(CreateSeperator); ConvertActionMenuItem.Add(CreateSeperator);
AddMenuItem(ConvertActionToBlockMenuItem,'ConvertActionToBlockMenuItem','Block', AddMenuItem(ConvertActionToBlockMenuItem, 'ConvertActionToBlockMenuItem',
lisCodeToolsDefsBlock,
ConvertActionMenuItem); ConvertActionMenuItem);
AddMenuItem(ConvertActionToDirectoryMenuItem, AddMenuItem(ConvertActionToDirectoryMenuItem,
'ConvertActionToDirectoryMenuItem','Directory', 'ConvertActionToDirectoryMenuItem',
lisCodeToolsDefsInsertBehindDirectory,
ConvertActionMenuItem); ConvertActionMenuItem);
ConvertActionMenuItem.Add(CreateSeperator); ConvertActionMenuItem.Add(CreateSeperator);
AddMenuItem(ConvertActionToIfMenuItem,'ConvertActionToIfMenuItem','If', AddMenuItem(ConvertActionToIfMenuItem, 'ConvertActionToIfMenuItem',
lisCodeToolsDefsIf,
ConvertActionMenuItem); ConvertActionMenuItem);
AddMenuItem(ConvertActionToIfDefMenuItem,'ConvertActionToIfDefMenuItem','IfDef', AddMenuItem(ConvertActionToIfDefMenuItem, 'ConvertActionToIfDefMenuItem',
lisCodeToolsDefsIfDef,
ConvertActionMenuItem); ConvertActionMenuItem);
AddMenuItem(ConvertActionToIfNotDefMenuItem,'ConvertActionToIfNotDefMenuItem','IfNDef', AddMenuItem(ConvertActionToIfNotDefMenuItem,
'ConvertActionToIfNotDefMenuItem', lisCodeToolsDefsIfNDef,
ConvertActionMenuItem); ConvertActionMenuItem);
AddMenuItem(ConvertActionToElseIfMenuItem,'ConvertActionToElseIfMenuItem','ElseIf', AddMenuItem(ConvertActionToElseIfMenuItem, 'ConvertActionToElseIfMenuItem',
lisCodeToolsDefsElseIf,
ConvertActionMenuItem); ConvertActionMenuItem);
AddMenuItem(ConvertActionToElseMenuItem,'ConvertActionToElseMenuItem','Else', AddMenuItem(ConvertActionToElseMenuItem, 'ConvertActionToElseMenuItem',
lisCodeToolsDefsElse,
ConvertActionMenuItem); ConvertActionMenuItem);
for i:=0 to ConvertActionMenuItem.Count-1 do for i:=0 to ConvertActionMenuItem.Count-1 do
if ConvertActionMenuItem[i].Caption<>'-' then if ConvertActionMenuItem[i].Caption<>'-' then
@ -1341,25 +1379,25 @@ begin
// templates // templates
AddMenuItem(InsertTemplateMenuItem,'InsertTemplateMenuItem', AddMenuItem(InsertTemplateMenuItem,'InsertTemplateMenuItem',
'Insert Template',nil); lisCodeToolsDefsInsertTemplate, nil);
AddMenuItem(InsertFPCProjectDefinesTemplateMenuItem, AddMenuItem(InsertFPCProjectDefinesTemplateMenuItem,
'InsertFPCProjectDefinesTemplateMenuItem', 'InsertFPCProjectDefinesTemplateMenuItem',
'Insert Free Pascal Project Template', lisCodeToolsDefsInsertFreePascalProjectTe,
InsertTemplateMenuItem); InsertTemplateMenuItem);
InsertFPCProjectDefinesTemplateMenuItem.OnClick:= InsertFPCProjectDefinesTemplateMenuItem.OnClick:=
@InsertFPCProjectDefinesTemplateMenuItemClick; @InsertFPCProjectDefinesTemplateMenuItemClick;
AddMenuItem(InsertFPCompilerDefinesTemplateMenuItem, AddMenuItem(InsertFPCompilerDefinesTemplateMenuItem,
'InsertFPCompilerDefinesTemplateMenuItem', 'InsertFPCompilerDefinesTemplateMenuItem',
'Insert Free Pascal Compiler Template', lisCodeToolsDefsInsertFreePascalCompilerT,
InsertTemplateMenuItem); InsertTemplateMenuItem);
InsertFPCompilerDefinesTemplateMenuItem.OnClick:= InsertFPCompilerDefinesTemplateMenuItem.OnClick:=
@InsertFPCompilerDefinesTemplateMenuItemClick; @InsertFPCompilerDefinesTemplateMenuItemClick;
AddMenuItem(InsertFPCSourceDirTemplateMenuItem, AddMenuItem(InsertFPCSourceDirTemplateMenuItem,
'InsertFPCSourceDirTemplateMenuItem', 'InsertFPCSourceDirTemplateMenuItem',
'Insert Free Pascal CVS Source Template', lisCodeToolsDefsInsertFreePascalCVSSource,
InsertTemplateMenuItem); InsertTemplateMenuItem);
InsertFPCSourceDirTemplateMenuItem.OnClick:= InsertFPCSourceDirTemplateMenuItem.OnClick:=
@InsertFPCSourceDirDefinesTemplateMenuItemClick; @InsertFPCSourceDirDefinesTemplateMenuItemClick;
@ -1367,7 +1405,7 @@ begin
InsertTemplateMenuItem.Add(CreateSeperator); InsertTemplateMenuItem.Add(CreateSeperator);
AddMenuItem(InsertLazarusSourceTemplateMenuItem, AddMenuItem(InsertLazarusSourceTemplateMenuItem,
'InsertLazarusSourceTemplateMenuItem', 'InsertLazarusSourceTemplateMenuItem',
'Insert Lazarus Directory Template', lisCodeToolsDefsInsertLazarusDirectoryTem,
InsertTemplateMenuItem); InsertTemplateMenuItem);
InsertLazarusSourceTemplateMenuItem.OnClick:= InsertLazarusSourceTemplateMenuItem.OnClick:=
@InsertLazarusSourceDefinesTemplateMenuItemClick; @InsertLazarusSourceDefinesTemplateMenuItemClick;
@ -1375,21 +1413,21 @@ begin
InsertTemplateMenuItem.Add(CreateSeperator); InsertTemplateMenuItem.Add(CreateSeperator);
AddMenuItem(InsertDelphi5CompilerDefinesTemplateMenuItem, AddMenuItem(InsertDelphi5CompilerDefinesTemplateMenuItem,
'InsertDelphi5CompilerDefinesTemplateMenuItem', 'InsertDelphi5CompilerDefinesTemplateMenuItem',
'Insert Delphi 5 Compiler Template', lisCodeToolsDefsInsertDelphi5CompilerTemp,
InsertTemplateMenuItem); InsertTemplateMenuItem);
InsertDelphi5CompilerDefinesTemplateMenuItem.OnClick:= InsertDelphi5CompilerDefinesTemplateMenuItem.OnClick:=
@InsertDelphiCompilerDefinesTemplateMenuItemClick; @InsertDelphiCompilerDefinesTemplateMenuItemClick;
AddMenuItem(InsertDelphi5DirectoryTemplateMenuItem, AddMenuItem(InsertDelphi5DirectoryTemplateMenuItem,
'InsertDelphi5DirectoryTemplateMenuItem', 'InsertDelphi5DirectoryTemplateMenuItem',
'Insert Delphi 5 Directory Template', lisCodeToolsDefsInsertDelphi5DirectoryTem,
InsertTemplateMenuItem); InsertTemplateMenuItem);
InsertDelphi5DirectoryTemplateMenuItem.OnClick:= InsertDelphi5DirectoryTemplateMenuItem.OnClick:=
@InsertDelphiDirectoryTemplateMenuItemClick; @InsertDelphiDirectoryTemplateMenuItemClick;
AddMenuItem(InsertDelphi5ProjectTemplateMenuItem, AddMenuItem(InsertDelphi5ProjectTemplateMenuItem,
'InsertDelphi5ProjectTemplateMenuItem', 'InsertDelphi5ProjectTemplateMenuItem',
'Insert Delphi 5 Project Template', lisCodeToolsDefsInsertDelphi5ProjectTempl,
InsertTemplateMenuItem); InsertTemplateMenuItem);
InsertDelphi5ProjectTemplateMenuItem.OnClick:= InsertDelphi5ProjectTemplateMenuItem.OnClick:=
@InsertDelphiProjectTemplateMenuItemClick; @InsertDelphiProjectTemplateMenuItemClick;
@ -1398,21 +1436,21 @@ begin
InsertTemplateMenuItem.Add(CreateSeperator); InsertTemplateMenuItem.Add(CreateSeperator);
AddMenuItem(InsertDelphi6CompilerDefinesTemplateMenuItem, AddMenuItem(InsertDelphi6CompilerDefinesTemplateMenuItem,
'InsertDelphi6CompilerDefinesTemplateMenuItem', 'InsertDelphi6CompilerDefinesTemplateMenuItem',
'Insert Delphi 6 Compiler Template', lisCodeToolsDefsInsertDelphi6CompilerTemp,
InsertTemplateMenuItem); InsertTemplateMenuItem);
InsertDelphi6CompilerDefinesTemplateMenuItem.OnClick:= InsertDelphi6CompilerDefinesTemplateMenuItem.OnClick:=
@InsertDelphiCompilerDefinesTemplateMenuItemClick; @InsertDelphiCompilerDefinesTemplateMenuItemClick;
AddMenuItem(InsertDelphi6DirectoryTemplateMenuItem, AddMenuItem(InsertDelphi6DirectoryTemplateMenuItem,
'InsertDelphi6DirectoryTemplateMenuItem', 'InsertDelphi6DirectoryTemplateMenuItem',
'Insert Delphi 6 Directory Template', lisCodeToolsDefsInsertDelphi6DirectoryTem,
InsertTemplateMenuItem); InsertTemplateMenuItem);
InsertDelphi6DirectoryTemplateMenuItem.OnClick:= InsertDelphi6DirectoryTemplateMenuItem.OnClick:=
@InsertDelphiDirectoryTemplateMenuItemClick; @InsertDelphiDirectoryTemplateMenuItemClick;
AddMenuItem(InsertDelphi6ProjectTemplateMenuItem, AddMenuItem(InsertDelphi6ProjectTemplateMenuItem,
'InsertDelphi6ProjectTemplateMenuItem', 'InsertDelphi6ProjectTemplateMenuItem',
'Insert Delphi 6 Project Template', lisCodeToolsDefsInsertDelphi6ProjectTempl,
InsertTemplateMenuItem); InsertTemplateMenuItem);
InsertDelphi6ProjectTemplateMenuItem.OnClick:= InsertDelphi6ProjectTemplateMenuItem.OnClick:=
@InsertDelphiProjectTemplateMenuItemClick; @InsertDelphiProjectTemplateMenuItemClick;
@ -1428,7 +1466,7 @@ begin
// selected item // selected item
CreateWinControl(SelectedItemGroupBox,TGroupBox,'SelectedItemGroupBox',Self); CreateWinControl(SelectedItemGroupBox,TGroupBox,'SelectedItemGroupBox',Self);
SelectedItemGroupBox.Caption:='Selected Node:'; SelectedItemGroupBox.Caption:=lisCodeToolsDefsSelectedNode;
SelectedItemGroupBox.OnResize:=@SelectedItemGroupBoxResize; SelectedItemGroupBox.OnResize:=@SelectedItemGroupBoxResize;
CreateWinControl(TypeLabel,TLabel,'TypeLabel',SelectedItemGroupBox); CreateWinControl(TypeLabel,TLabel,'TypeLabel',SelectedItemGroupBox);
@ -1436,23 +1474,23 @@ begin
CreateWinControl(ProjectSpecificCheckBox,TCheckBox,'ProjectSpecificCheckBox', CreateWinControl(ProjectSpecificCheckBox,TCheckBox,'ProjectSpecificCheckBox',
SelectedItemGroupBox); SelectedItemGroupBox);
ProjectSpecificCheckBox.Caption:= ProjectSpecificCheckBox.Caption:=
'Node and its children are only valid for this project'; lisCodeToolsDefsNodeAndItsChildrenAreOnly;
ProjectSpecificCheckBox.OnClick:=@ProjectSpecificCheckBoxClick; ProjectSpecificCheckBox.OnClick:=@ProjectSpecificCheckBoxClick;
CreateWinControl(NameLabel,TLabel,'NameLabel',SelectedItemGroupBox); CreateWinControl(NameLabel,TLabel,'NameLabel',SelectedItemGroupBox);
NameLabel.Caption:='Name:'; NameLabel.Caption:=lisCodeToolsDefsName;
CreateWinControl(NameEdit,TEdit,'NameEdit',SelectedItemGroupBox); CreateWinControl(NameEdit,TEdit,'NameEdit',SelectedItemGroupBox);
CreateWinControl(DescriptionLabel,TLabel,'DescriptionLabel', CreateWinControl(DescriptionLabel,TLabel,'DescriptionLabel',
SelectedItemGroupBox); SelectedItemGroupBox);
DescriptionLabel.Caption:='Description:'; DescriptionLabel.Caption:=lisCodeToolsDefsDescription;
CreateWinControl(DescriptionEdit,TEdit,'DescriptionEdit', CreateWinControl(DescriptionEdit,TEdit,'DescriptionEdit',
SelectedItemGroupBox); SelectedItemGroupBox);
CreateWinControl(VariableLabel,TLabel,'VariableLabel',SelectedItemGroupBox); CreateWinControl(VariableLabel,TLabel,'VariableLabel',SelectedItemGroupBox);
VariableLabel.Caption:='Variable:'; VariableLabel.Caption:=lisCodeToolsDefsVariable;
CreateWinControl(VariableEdit,TEdit,'VariableEdit',SelectedItemGroupBox); CreateWinControl(VariableEdit,TEdit,'VariableEdit',SelectedItemGroupBox);
@ -1460,10 +1498,10 @@ begin
SelectedItemGroupBox); SelectedItemGroupBox);
with ValueNoteBook do begin with ValueNoteBook do begin
if PageCount>0 then if PageCount>0 then
Pages[0]:='Value as Text' Pages[0]:=lisCodeToolsDefsValueAsText
else else
Pages.Add('Value as Text'); Pages.Add(lisCodeToolsDefsValueAsText);
Pages.Add('Value as File Paths'); Pages.Add(lisCodeToolsDefsValueAsFilePaths);
OnPageChanged:=@ValueNoteBookPageChanged; OnPageChanged:=@ValueNoteBookPageChanged;
OnResize:=@ValueNoteBookResize; OnResize:=@ValueNoteBookResize;
end; end;
@ -1485,22 +1523,22 @@ begin
CreateWinControl(MoveFilePathUpBitBtn,TBitBtn,'MoveFilePathUpBitBtn', CreateWinControl(MoveFilePathUpBitBtn,TBitBtn,'MoveFilePathUpBitBtn',
ValueNoteBook.Page[1]); ValueNoteBook.Page[1]);
MoveFilePathUpBitBtn.Caption:='Up'; MoveFilePathUpBitBtn.Caption:=dlgUpWord;
MoveFilePathUpBitBtn.OnClick:=@MoveFilePathUpBitBtnClick; MoveFilePathUpBitBtn.OnClick:=@MoveFilePathUpBitBtnClick;
CreateWinControl(MoveFilePathDownBitBtn,TBitBtn,'MoveFilePathDownBitBtn', CreateWinControl(MoveFilePathDownBitBtn,TBitBtn,'MoveFilePathDownBitBtn',
ValueNoteBook.Page[1]); ValueNoteBook.Page[1]);
MoveFilePathDownBitBtn.Caption:='Down'; MoveFilePathDownBitBtn.Caption:=dlgDownWord;
MoveFilePathDownBitBtn.OnClick:=@MoveFilePathDownBitBtnClick; MoveFilePathDownBitBtn.OnClick:=@MoveFilePathDownBitBtnClick;
CreateWinControl(DeleteFilePathBitBtn,TBitBtn,'DeleteFilePathBitBtn', CreateWinControl(DeleteFilePathBitBtn,TBitBtn,'DeleteFilePathBitBtn',
ValueNoteBook.Page[1]); ValueNoteBook.Page[1]);
DeleteFilePathBitBtn.Caption:='Delete'; DeleteFilePathBitBtn.Caption:=dlgEdDelete;
DeleteFilePathBitBtn.OnClick:=@DeleteFilePathBitBtnClick; DeleteFilePathBitBtn.OnClick:=@DeleteFilePathBitBtnClick;
CreateWinControl(InsertFilePathBitBtn,TBitBtn,'InsertFilePathBitBtn', CreateWinControl(InsertFilePathBitBtn,TBitBtn,'InsertFilePathBitBtn',
ValueNoteBook.Page[1]); ValueNoteBook.Page[1]);
InsertFilePathBitBtn.Caption:='Insert'; InsertFilePathBitBtn.Caption:=srVK_INSERT;
InsertFilePathBitBtn.OnClick:=@InsertFilePathBitBtnClick; InsertFilePathBitBtn.OnClick:=@InsertFilePathBitBtnClick;
end; end;
@ -1696,13 +1734,13 @@ begin
SelTreeNode:=DefineTreeView.Selected; SelTreeNode:=DefineTreeView.Selected;
if SelTreeNode<>nil then begin if SelTreeNode<>nil then begin
SelDefNode:=TDefineTemplate(SelTreeNode.Data); SelDefNode:=TDefineTemplate(SelTreeNode.Data);
s:='Action: '+DefineActionNames[SelDefNode.Action]; s:=Format(lisCodeToolsDefsAction, [DefineActionNames[SelDefNode.Action]]);
if SelDefNode.IsAutoGenerated then if SelDefNode.IsAutoGenerated then
s:=s+', auto generated'; s:=Format(lisCodeToolsDefsautoGenerated, [s]);
if SelDefNode.IsProjectSpecific then if SelDefNode.IsProjectSpecific then
s:=s+', project specific'; s:=Format(lisCodeToolsDefsprojectSpecific, [s]);
end else begin end else begin
s:='none selected'; s:=lisCodeToolsDefsnoneSelected;
end; end;
TypeLabel.Caption:=s; TypeLabel.Caption:=s;
end; end;
@ -1748,16 +1786,16 @@ begin
end; end;
if (ParentNode<>nil) and (TDefineTemplate(ParentNode.Data).IsAutoGenerated) if (ParentNode<>nil) and (TDefineTemplate(ParentNode.Data).IsAutoGenerated)
then begin then begin
MessageDlg('Invalid parent','Auto created nodes can not be edited,'#13 MessageDlg(lisCodeToolsDefsInvalidParent, Format(
+'nor can they have non auto created child nodes.',mtInformation,[mbCancel] lisCodeToolsDefsAutoCreatedNodesReadOnly, [#13]), mtInformation,
,0); [mbCancel],0);
exit; exit;
end; end;
if (ParentNode<>nil) if (ParentNode<>nil)
and (not (TDefineTemplate(ParentNode.Data).Action in DefineActionBlocks)) then and (not (TDefineTemplate(ParentNode.Data).Action in DefineActionBlocks)) then
begin begin
MessageDlg('Invalid parent node', MessageDlg(lisCodeToolsDefsInvalidParentNode,
'Parent node can not contain child nodes.', lisCodeToolsDefsParentNodeCanNotContainCh,
mtInformation,[mbCancel],0); mtInformation,[mbCancel],0);
exit; exit;
end; end;
@ -1843,9 +1881,10 @@ function TCodeToolsDefinesEditor.FindUniqueName: string;
var i: integer; var i: integer;
begin begin
i:=1; i:=1;
while (DefineTree.FindDefineTemplateByName('NewNode'+IntToStr(i),false)<>nil) while (DefineTree.FindDefineTemplateByName(lisCodeToolsDefsNewNode+IntToStr(i
), false)<>nil)
do inc(i); do inc(i);
Result:='NewNode'+IntToStr(i); Result:=lisCodeToolsDefsNewNode+IntToStr(i);
end; end;
function TCodeToolsDefinesEditor.ConsistencyCheck: integer; function TCodeToolsDefinesEditor.ConsistencyCheck: integer;
@ -1948,7 +1987,7 @@ begin
IDEDialogLayoutList.ApplyLayout(Self,500, 460); IDEDialogLayoutList.ApplyLayout(Self,500, 460);
if LazarusResources.Find(ClassName)=nil then begin if LazarusResources.Find(ClassName)=nil then begin
Caption:='CodeTools Defines Editor'; Caption:=lisCodeToolsDefsCodeToolsDefinesEditor;
OnResize:=@FormResize; OnResize:=@FormResize;
CreateComponents; CreateComponents;

View File

@ -1055,6 +1055,89 @@ resourcestring
+'or %s/usr/local/bin/fpc @/etc/11fpc.cfg%s.'; +'or %s/usr/local/bin/fpc @/etc/11fpc.cfg%s.';
lisCodeToolsDefsCreateDefinesForFreePascalCVSSources = 'Create Defines for ' lisCodeToolsDefsCreateDefinesForFreePascalCVSSources = 'Create Defines for '
+'Free Pascal CVS Sources'; +'Free Pascal CVS Sources';
lisCodeToolsDefsTheFreePascalCVSSourceDir = 'The Free Pascal CVS source '
+'directory.';
lisCodeToolsDefsCreateDefinesForLazarusDir = 'Create Defines for Lazarus '
+'Directory';
lisCodeToolsDefsLazarusDirectory = 'Lazarus Directory';
lisCodeToolsDefsTheLazarusMainDirectory = 'The Lazarus main directory.';
lisCodeToolsDefsCreateDefinesForDirectory = 'Create Defines for %s Directory';
lisCodeToolsDefsdirectory = '%s directory';
lisCodeToolsDefsDelphiMainDirectoryDesc = 'The %s main directory,%swhere '
+'Borland has installed all %s sources.%sFor example: C:/Programme/'
+'Borland/Delphi%s';
lisCodeToolsDefsCreateDefinesForProject = 'Create Defines for %s Project';
lisCodeToolsDefsprojectDirectory2 = '%s project directory';
lisCodeToolsDefsTheProjectDirectory = 'The %s project directory,%swhich '
+'contains the .dpr, dpk file.';
lisCodeToolsDefsDelphiMainDirectoryForProject = 'The %s main directory,%'
+'swhere Borland has installed all %s sources,%swhich are used by this %s '
+'project.%sFor example: C:/Programme/Borland/Delphi%s';
lisCodeToolsDefsExit = 'Exit';
lisCodeToolsDefsSaveAndExit = 'Save and Exit';
lisCodeToolsDefsExitWithoutSave = 'Exit without Save';
lisCodeToolsDefsEdit = 'Edit';
lisCodeToolsDefsMoveNodeUp = 'Move node up';
lisCodeToolsDefsMoveNodeDown = 'Move node down';
lisCodeToolsDefsMoveNodeOneLevelUp = 'Move node one level up';
lisCodeToolsDefsMoveNodeOneLevelDown = 'Move node one level down';
lisCodeToolsDefsInsertNodeBelow = 'Insert node below';
lisCodeToolsDefsInsertNodeAsChild = 'Insert node as child';
lisCodeToolsDefsDeleteNode = 'Delete node';
lisCodeToolsDefsConvertNode = 'Convert node';
lisCodeToolsDefsDefine = 'Define';
lisCodeToolsDefsDefineRecurse = 'Define Recurse';
lisCodeToolsDefsUndefine = 'Undefine';
lisCodeToolsDefsUndefineRecurse = 'Undefine Recurse';
lisCodeToolsDefsUndefineAll = 'Undefine All';
lisCodeToolsDefsBlock = 'Block';
lisCodeToolsDefsInsertBehindDirectory = 'Directory';
lisCodeToolsDefsIf = 'If';
lisCodeToolsDefsIfDef = 'IfDef';
lisCodeToolsDefsIfNDef = 'IfNDef';
lisCodeToolsDefsElseIf = 'ElseIf';
lisCodeToolsDefsElse = 'Else';
lisCodeToolsDefsInsertTemplate = 'Insert Template';
lisCodeToolsDefsInsertFreePascalProjectTe = 'Insert Free Pascal Project '
+'Template';
lisCodeToolsDefsInsertFreePascalCompilerT = 'Insert Free Pascal Compiler '
+'Template';
lisCodeToolsDefsInsertFreePascalCVSSource = 'Insert Free Pascal CVS Source '
+'Template';
lisCodeToolsDefsInsertLazarusDirectoryTem = 'Insert Lazarus Directory '
+'Template';
lisCodeToolsDefsInsertDelphi5CompilerTemp = 'Insert Delphi 5 Compiler '
+'Template';
lisCodeToolsDefsInsertDelphi5DirectoryTem = 'Insert Delphi 5 Directory '
+'Template';
lisCodeToolsDefsInsertDelphi5ProjectTempl =
'Insert Delphi 5 Project Template';
lisCodeToolsDefsInsertDelphi6CompilerTemp = 'Insert Delphi 6 Compiler '
+'Template';
lisCodeToolsDefsInsertDelphi6DirectoryTem = 'Insert Delphi 6 Directory '
+'Template';
lisCodeToolsDefsInsertDelphi6ProjectTempl =
'Insert Delphi 6 Project Template';
lisCodeToolsDefsSelectedNode = 'Selected Node:';
lisCodeToolsDefsNodeAndItsChildrenAreOnly = 'Node and its children are only '
+'valid for this project';
lisCodeToolsDefsName = 'Name:';
lisCodeToolsDefsDescription = 'Description:';
lisCodeToolsDefsVariable = 'Variable:';
lisCodeToolsDefsValueAsText = 'Value as Text';
lisCodeToolsDefsValueAsFilePaths = 'Value as File Paths';
lisCodeToolsDefsAction = 'Action: %s';
lisCodeToolsDefsautoGenerated = '%s, auto generated';
lisCodeToolsDefsprojectSpecific = '%s, project specific';
lisCodeToolsDefsnoneSelected = 'none selected';
lisCodeToolsDefsInvalidParent = 'Invalid parent';
lisCodeToolsDefsAutoCreatedNodesReadOnly = 'Auto created nodes can not be '
+'edited,%snor can they have non auto created child nodes.';
lisCodeToolsDefsInvalidParentNode = 'Invalid parent node';
lisCodeToolsDefsParentNodeCanNotContainCh = 'Parent node can not contain '
+'child nodes.';
lisCodeToolsDefsNewNode = 'NewNode';
lisCodeToolsDefsCodeToolsDefinesEditor = 'CodeTools Defines Editor';
implementation implementation
end. end.

View File

@ -46,7 +46,11 @@ uses
EditorOptions, InputHistory; EditorOptions, InputHistory;
type type
TResourcestringInsertPolicy = (rsipAppend, rsipAlphabetically); TResourcestringInsertPolicy = (
rsipNone, // do not add/insert
rsipAppend, // append at end
rsipAlphabetically // insert alphabetically
);
TMakeResStrDialog = class(TForm) TMakeResStrDialog = class(TForm)
// source synedit // source synedit
@ -67,6 +71,9 @@ type
// resourcestring section // resourcestring section
ResStrSectionLabel: TLabel; ResStrSectionLabel: TLabel;
ResStrSectionComboBox: TComboBox; ResStrSectionComboBox: TComboBox;
// resourcestrings with same value
ResStrWithSameValueLabel: TLabel;
ResStrWithSameValuesCombobox: TComboBox;
// insert position type // insert position type
AppendResStrRadioButton: TRadioButton; AppendResStrRadioButton: TRadioButton;
InsertAlphabeticallyResStrRadioButton: TRadioButton; InsertAlphabeticallyResStrRadioButton: TRadioButton;
@ -91,6 +98,7 @@ type
procedure MakeResStrDialogResize(Sender: TObject); procedure MakeResStrDialogResize(Sender: TObject);
procedure OkButtonClick(Sender: TObject); procedure OkButtonClick(Sender: TObject);
procedure ResStrSectionComboBoxChange(Sender: TObject); procedure ResStrSectionComboBoxChange(Sender: TObject);
procedure ResStrWithSameValuesComboboxChange(Sender: TObject);
private private
procedure SetupComponents; procedure SetupComponents;
public public
@ -103,13 +111,16 @@ type
procedure FillResourceStringSections(NewPositions: TCodeXYPositions); procedure FillResourceStringSections(NewPositions: TCodeXYPositions);
procedure FillIdentPrefixes; procedure FillIdentPrefixes;
procedure FillIdentLengths; procedure FillIdentLengths;
procedure FillStringsWithSameValue;
procedure UpdateIdentifier; procedure UpdateIdentifier;
procedure UpdateSourcePreview; procedure UpdateSourcePreview;
function GetIdentifier: string; function GetIdentifier: string;
function GetDefaultIdentifier: string; function GetDefaultIdentifier: string;
procedure SetSource(NewCode: TCodeBuffer; procedure SetSource(NewCode: TCodeBuffer;
const NewStartPos, NewEndPos: TPoint); const NewStartPos, NewEndPos: TPoint);
function ResourceStringExists(const Identifier: string): boolean; function ResStrExistsInCurrentSection(const Identifier: string): boolean;
function ResStrExistsInAnySection(const Identifier: string): boolean;
function ResStrExistsWithSameValue(const Identifier: string): boolean;
procedure GetNewSource(var NewSource, ResourceStringValue: string); procedure GetNewSource(var NewSource, ResourceStringValue: string);
procedure Init; procedure Init;
procedure SaveHistories; procedure SaveHistories;
@ -146,7 +157,7 @@ var
ResourcestringSectionID: Integer; ResourcestringSectionID: Integer;
begin begin
MakeResStrDialog:=TMakeResStrDialog.Create(Application); MakeResStrDialog:=TMakeResStrDialog.Create(Application);
MakeResStrDialog.Positions:=CodeToolBoss.Positions; MakeResStrDialog.Positions:=CodeToolBoss.Positions.CreateCopy;
MakeResStrDialog.SetSource(Code,StartPos,EndPos); MakeResStrDialog.SetSource(Code,StartPos,EndPos);
MakeResStrDialog.Init; MakeResStrDialog.Init;
@ -156,10 +167,14 @@ begin
// return results // return results
NewIdentifier:=MakeResStrDialog.GetIdentifier; NewIdentifier:=MakeResStrDialog.GetIdentifier;
MakeResStrDialog.GetNewSource(NewSourceLines,NewIdentifierValue); MakeResStrDialog.GetNewSource(NewSourceLines,NewIdentifierValue);
if MakeResStrDialog.InsertAlphabeticallyResStrRadioButton.Checked then if MakeResStrDialog.ResStrExistsWithSameValue(NewIdentifier) then
InsertPolicy:=rsipAlphabetically InsertPolicy:=rsipNone
else else begin
InsertPolicy:=rsipAppend; if MakeResStrDialog.InsertAlphabeticallyResStrRadioButton.Checked then
InsertPolicy:=rsipAlphabetically
else
InsertPolicy:=rsipAppend;
end;
ResourcestringSectionID:=MakeResStrDialog.ResStrSectionComboBox.ItemIndex; ResourcestringSectionID:=MakeResStrDialog.ResStrSectionComboBox.ItemIndex;
Section:=CodeToolBoss.Positions[ResourcestringSectionID]; Section:=CodeToolBoss.Positions[ResourcestringSectionID];
ResStrSectionCode:=Section^.Code; ResStrSectionCode:=Section^.Code;
@ -169,6 +184,7 @@ begin
// save settings and clean up // save settings and clean up
IDEDialogLayoutList.SaveLayout(MakeResStrDialog); IDEDialogLayoutList.SaveLayout(MakeResStrDialog);
MakeResStrDialog.Positions.Free;
MakeResStrDialog.Free; MakeResStrDialog.Free;
end; end;
@ -230,10 +246,23 @@ begin
Parent.ClientWidth-Left-5,Height); Parent.ClientWidth-Left-5,Height);
end; end;
// existing resourcestrings with same value
with ResStrWithSameValueLabel do begin
SetBounds(ResStrSectionLabel.Left,
ResStrSectionComboBox.Top+ResStrSectionComboBox.Height+9,
150,Height);
end;
with ResStrWithSameValuesCombobox do begin
SetBounds(ResStrWithSameValueLabel.Left+ResStrWithSameValueLabel.Width+5,
ResStrSectionComboBox.Top+ResStrSectionComboBox.Height+5,
Parent.ClientWidth-Left-5,Height);
end;
// insert position type // insert position type
with AppendResStrRadioButton do begin with AppendResStrRadioButton do begin
SetBounds(IdentPrefixLabel.Left, SetBounds(IdentPrefixLabel.Left,
ResStrSectionComboBox.Top+ResStrSectionComboBox.Height+7, ResStrWithSameValuesCombobox.Top+ResStrWithSameValuesCombobox.Height+7,
Min((Parent.ClientWidth-3*Left) div 2,150),Height); Min((Parent.ClientWidth-3*Left) div 2,150),Height);
end; end;
@ -280,19 +309,19 @@ begin
with ConversionGroupBox do begin with ConversionGroupBox do begin
SetBounds(StringConstGroupBox.Left, SetBounds(StringConstGroupBox.Left,
StringConstGroupBox.Top+StringConstGroupBox.Height+5, StringConstGroupBox.Top+StringConstGroupBox.Height+5,
StringConstGroupBox.Width,140); StringConstGroupBox.Width,170);
end; end;
// preview // preview
with SrcPreviewGroupBox do begin with SrcPreviewGroupBox do begin
NewTop:=ConversionGroupBox.Top+ConversionGroupBox.Height+5; NewTop:=ConversionGroupBox.Top+ConversionGroupBox.Height+5;
SetBounds(ConversionGroupBox.Left,NewTop, SetBounds(ConversionGroupBox.Left,NewTop,
ConversionGroupBox.Width,Parent.ClientHeight-NewTop-50); ConversionGroupBox.Width,Parent.ClientHeight-NewTop-45);
end; end;
// ok+cancel buttons // ok+cancel buttons
with OkButton do begin with OkButton do begin
SetBounds(Parent.ClientWidth-200,Parent.ClientHeight-35, SetBounds(Parent.ClientWidth-200,Parent.ClientHeight-32,
Width,Height); Width,Height);
end; end;
@ -312,6 +341,17 @@ begin
mtError,[mbCancel],0); mtError,[mbCancel],0);
exit; exit;
end; end;
if ResStrExistsInAnySection(IdentifierEdit.Text)
and (not ResStrExistsWithSameValue(IdentifierEdit.Text)) then begin
if MessageDlg('Resourcestring already exists',
'The resourcestring "'+IdentifierEdit.Text+'" already exists.'#13
+'Please choose another name.'#13
+'Use Ignore to add it anyway.',
mtWarning,[mbOk,mbIgnore],0)
=mrOk
then
exit;
end;
SaveHistories; SaveHistories;
ModalResult:=mrOk; ModalResult:=mrOk;
end; end;
@ -322,6 +362,17 @@ begin
UpdateSourcePreview; UpdateSourcePreview;
end; end;
procedure TMakeResStrDialog.ResStrWithSameValuesComboboxChange(Sender: TObject);
var
NewIdentifier: String;
i: Integer;
begin
NewIdentifier:=ResStrWithSameValuesCombobox.Text;
i:=ResStrWithSameValuesCombobox.Items.IndexOf(NewIdentifier);
if i<0 then exit;
IdentifierEdit.Text:=NewIdentifier;
end;
procedure TMakeResStrDialog.SetupComponents; procedure TMakeResStrDialog.SetupComponents;
begin begin
SynPasSyn:=TSynPasSyn.Create(Self); SynPasSyn:=TSynPasSyn.Create(Self);
@ -414,6 +465,21 @@ begin
OnChange:=@ResStrSectionComboBoxChange; OnChange:=@ResStrSectionComboBoxChange;
end; end;
// existing resourcestrings with same value
ResStrWithSameValueLabel:=TLabel.Create(Self);
with ResStrWithSameValueLabel do begin
Name:='ResStrWithSameValueLabel';
Parent:=ConversionGroupBox;
Caption:='Strings with same value:';
end;
ResStrWithSameValuesCombobox:=TComboBox.Create(Self);
with ResStrWithSameValuesCombobox do begin
Name:='ResStrWithSameValuesCombobox';
Parent:=ConversionGroupBox;
OnChange:=@ResStrWithSameValuesComboboxChange;
end;
// insert position type // insert position type
AppendResStrRadioButton:=TRadioButton.Create(Self); AppendResStrRadioButton:=TRadioButton.Create(Self);
with AppendResStrRadioButton do begin with AppendResStrRadioButton do begin
@ -553,6 +619,46 @@ begin
end; end;
end; end;
procedure TMakeResStrDialog.FillStringsWithSameValue;
var
i: Integer;
CurSection: TCodeXYPosition;
NewSource, ResourceStringValue: string;
StringConstPositions: TCodeXYPositions;
ExistingIdentifier: string;
begin
// get value of the new resourcestring
GetNewSource(NewSource, ResourceStringValue);
// get all existing resourcestrings with same value
StringConstPositions:=TCodeXYPositions.Create;
for i:=0 to Positions.Count-1 do begin
CurSection:=Positions[i]^;
CodeToolBoss.GatherResourceStringsWithValue(
CurSection.Code,CurSection.X,CurSection.Y,
ResourceStringValue,StringConstPositions);
end;
// fill combobox
ResStrWithSameValuesCombobox.Items.Clear;
for i:=0 to StringConstPositions.Count-1 do begin
CurSection:=StringConstPositions[i]^;
CodeToolBoss.GetIdentifierAt(CurSection.Code,CurSection.X,CurSection.Y,
ExistingIdentifier);
if ExistingIdentifier<>'' then
ResStrWithSameValuesCombobox.Items.Add(ExistingIdentifier);
end;
// enable components for selection
if ResStrWithSameValuesCombobox.Items.Count>0 then begin
ResStrWithSameValuesCombobox.Text:=ResStrWithSameValuesCombobox.Items[0];
ResStrWithSameValuesCombobox.Enabled:=true;
end else begin
ResStrWithSameValuesCombobox.Text:='';
ResStrWithSameValuesCombobox.Enabled:=false;
end;
ResStrWithSameValueLabel.Enabled:=ResStrWithSameValuesCombobox.Enabled;
// clean up
StringConstPositions.Free;
end;
procedure TMakeResStrDialog.UpdateIdentifier; procedure TMakeResStrDialog.UpdateIdentifier;
var var
CustomIdent: Boolean; CustomIdent: Boolean;
@ -591,13 +697,17 @@ var
DefIdenLength: Integer; DefIdenLength: Integer;
i: Integer; i: Integer;
begin begin
if ResStrWithSameValuesCombobox.Items.Count>0 then begin
Result:=ResStrWithSameValuesCombobox.Items[0];
exit;
end;
DefIdenLength:=StrToIntDef(IdentLengthComboBox.Text,8); DefIdenLength:=StrToIntDef(IdentLengthComboBox.Text,8);
if DefIdenLength<1 then DefIdenLength:=1; if DefIdenLength<1 then DefIdenLength:=1;
if DefIdenLength>80 then DefIdenLength:=80; if DefIdenLength>80 then DefIdenLength:=80;
Result:=IdentPrefixComboBox.Text+copy(DefaultIdentifier,1,DefIdenLength); Result:=IdentPrefixComboBox.Text+copy(DefaultIdentifier,1,DefIdenLength);
if ResourceStringExists(Result) then begin if ResStrExistsInCurrentSection(Result) then begin
i:=2; i:=2;
while ResourceStringExists(Result+IntToStr(i)) do inc(i); while ResStrExistsInCurrentSection(Result+IntToStr(i)) do inc(i);
Result:=Result++IntToStr(i); Result:=Result++IntToStr(i);
end; end;
end; end;
@ -610,7 +720,7 @@ begin
EndPos:=NewEndPos; EndPos:=NewEndPos;
end; end;
function TMakeResStrDialog.ResourceStringExists(const Identifier: string function TMakeResStrDialog.ResStrExistsInCurrentSection(const Identifier: string
): boolean; ): boolean;
var var
CodeXY: PCodeXYPosition; CodeXY: PCodeXYPosition;
@ -624,6 +734,38 @@ begin
CodeXY^.Code,CodeXY^.X,CodeXY^.Y,Identifier); CodeXY^.Code,CodeXY^.X,CodeXY^.Y,Identifier);
end; end;
function TMakeResStrDialog.ResStrExistsInAnySection(const Identifier: string
): boolean;
var
CodeXY: PCodeXYPosition;
Index: Integer;
begin
Result:=false;
for Index:=0 to Positions.Count-1 do begin
CodeXY:=Positions.Items[Index];
Result:=CodeToolBoss.IdentifierExistsInResourceStringSection(
CodeXY^.Code,CodeXY^.X,CodeXY^.Y,Identifier);
if Result then exit;
end;
end;
function TMakeResStrDialog.ResStrExistsWithSameValue(const Identifier: string
): boolean;
var
i: Integer;
begin
if Identifier<>'' then begin
for i:=0 to ResStrWithSameValuesCombobox.Items.Count-1 do begin
if AnsiCompareText(Identifier,ResStrWithSameValuesCombobox.Items[i])=0
then begin
Result:=true;
exit;
end;
end;
end;
Result:=false;
end;
procedure TMakeResStrDialog.GetNewSource(var NewSource, procedure TMakeResStrDialog.GetNewSource(var NewSource,
ResourceStringValue: string); ResourceStringValue: string);
var var
@ -665,6 +807,8 @@ begin
FillIdentPrefixes; FillIdentPrefixes;
// identifier lengths // identifier lengths
FillIdentLengths; FillIdentLengths;
// existing resource strings with same value
FillStringsWithSameValue;
// identifier // identifier
CustomIdentifierCheckBox.Checked:=false; CustomIdentifierCheckBox.Checked:=false;
CodeToolBoss.CreateIdentifierFromStringConst(Code,StartPos.X,StartPos.Y, CodeToolBoss.CreateIdentifierFromStringConst(Code,StartPos.X,StartPos.Y,