mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-21 22:39:30 +02:00
make resourcestring dialog now checks for doubles (idents and values)
git-svn-id: trunk@3925 -
This commit is contained in:
parent
b0b03b2c04
commit
9f4034806d
@ -39,10 +39,10 @@ uses
|
||||
{$IFDEF MEM_CHECK}
|
||||
MemCheck,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, CodeToolsStrConsts, EventCodeTool, CodeTree, CodeAtom,
|
||||
SourceChanger, DefineTemplates, CodeCache, ExprEval, LinkScanner,
|
||||
KeywordFuncLists, TypInfo, AVL_Tree, CustomCodeTool, FindDeclarationTool,
|
||||
IdentCompletionTool, ResourceCodeTool, CodeToolsStructs;
|
||||
Classes, SysUtils, BasicCodeTools, CodeToolsStrConsts, EventCodeTool,
|
||||
CodeTree, CodeAtom, SourceChanger, DefineTemplates, CodeCache, ExprEval,
|
||||
LinkScanner, KeywordFuncLists, TypInfo, AVL_Tree, CustomCodeTool,
|
||||
FindDeclarationTool, IdentCompletionTool, ResourceCodeTool, CodeToolsStructs;
|
||||
|
||||
type
|
||||
TCodeToolManager = class;
|
||||
@ -237,10 +237,13 @@ type
|
||||
|
||||
// gather identifiers (i.e. all visible)
|
||||
function GatherIdentifiers(Code: TCodeBuffer; X,Y: integer): boolean;
|
||||
function GetIdentifierAt(Code: TCodeBuffer; X,Y: integer;
|
||||
var Identifier: string): boolean;
|
||||
|
||||
// resource string sections
|
||||
function GatherResourceStringSections(
|
||||
Code: TCodeBuffer; X,Y: integer): boolean;
|
||||
Code: TCodeBuffer; X,Y: integer;
|
||||
CodePositions: TCodeXYPositions): boolean;
|
||||
function IdentifierExistsInResourceStringSection(Code: TCodeBuffer;
|
||||
X,Y: integer; const ResStrIdentifier: string): boolean;
|
||||
function CreateIdentifierFromStringConst(
|
||||
@ -251,6 +254,9 @@ type
|
||||
StartCode: TCodeBuffer; StartX, StartY: integer;
|
||||
EndCode: TCodeBuffer; EndX, EndY: integer;
|
||||
var FormatStringConstant, FormatParameters: string): boolean;
|
||||
function GatherResourceStringsWithValue(SectionCode: TCodeBuffer;
|
||||
SectionX, SectionY: integer; const StringValue: string;
|
||||
CodePositions: TCodeXYPositions): boolean;
|
||||
function AddResourcestring(SectionCode: TCodeBuffer;
|
||||
SectionX, SectionY: integer;
|
||||
const NewIdentifier, NewValue: string;
|
||||
@ -830,8 +836,27 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function TCodeToolManager.GatherResourceStringSections(Code: TCodeBuffer; X,
|
||||
Y: integer): boolean;
|
||||
function TCodeToolManager.GetIdentifierAt(Code: TCodeBuffer; X, Y: integer;
|
||||
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
|
||||
CursorPos: TCodeXYPosition;
|
||||
begin
|
||||
@ -843,9 +868,12 @@ begin
|
||||
CursorPos.X:=X;
|
||||
CursorPos.Y:=Y;
|
||||
CursorPos.Code:=Code;
|
||||
ClearPositions;
|
||||
if CodePositions=nil then begin
|
||||
ClearPositions;
|
||||
CodePositions:=Positions;
|
||||
end;
|
||||
try
|
||||
Result:=FCurCodeTool.GatherResourceStringSections(CursorPos,Positions);
|
||||
Result:=FCurCodeTool.GatherResourceStringSections(CursorPos,CodePositions);
|
||||
except
|
||||
on e: Exception do HandleException(e);
|
||||
end;
|
||||
@ -925,6 +953,32 @@ begin
|
||||
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,
|
||||
SectionY: integer; const NewIdentifier, NewValue: string;
|
||||
InsertAlphabetically: boolean): boolean;
|
||||
|
@ -56,8 +56,11 @@ type
|
||||
procedure Clear;
|
||||
function Add(const Position: TCodeXYPosition): integer;
|
||||
function Add(X,Y: integer; Code: TCodeBuffer): integer;
|
||||
procedure Assign(Source: TCodeXYPositions);
|
||||
function IsEqual(Source: TCodeXYPositions): boolean;
|
||||
function Count: integer;
|
||||
procedure Delete(Index: integer);
|
||||
function CreateCopy: TCodeXYPositions;
|
||||
public
|
||||
property Items[Index: integer]: PCodeXYPosition
|
||||
read GetItems write SetItems; default;
|
||||
@ -160,6 +163,42 @@ begin
|
||||
Result:=Add(NewItem);
|
||||
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;
|
||||
begin
|
||||
if FItems<>nil then
|
||||
@ -177,5 +216,11 @@ begin
|
||||
FItems.Delete(Index);
|
||||
end;
|
||||
|
||||
function TCodeXYPositions.CreateCopy: TCodeXYPositions;
|
||||
begin
|
||||
Result:=TCodeXYPositions.Create;
|
||||
Result.Assign(Self);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -172,15 +172,18 @@ type
|
||||
function IdentifierExistsInResourceStringSection(
|
||||
const CursorPos: TCodeXYPosition;
|
||||
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(
|
||||
const StartCursorPos, EndCursorPos: TCodeXYPosition;
|
||||
var Identifier: string; MaxLen: integer): boolean;
|
||||
function StringConstToFormatString(
|
||||
const StartCursorPos, EndCursorPos: TCodeXYPosition;
|
||||
var FormatStringConstant,FormatParameters: string): boolean;
|
||||
function AddResourcestring(const SectionPos: TCodeXYPosition;
|
||||
const NewIdentifier, NewValue: string; InsertAlphabetically: boolean;
|
||||
SourceChangeCache: TSourceChangeCache): boolean;
|
||||
end;
|
||||
|
||||
|
||||
@ -1656,6 +1659,56 @@ begin
|
||||
Result:=FormatStringConstant<>'';
|
||||
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;
|
||||
const NewIdentifier, NewValue: string; InsertAlphabetically: boolean;
|
||||
SourceChangeCache: TSourceChangeCache): boolean;
|
||||
|
@ -857,12 +857,12 @@ begin
|
||||
Caption:=lisCodeToolsDefsCreateDefinesForFreePascalCVSSources;
|
||||
FileCount:=2;
|
||||
|
||||
FileTitles[0]:='FPC CVS source directory';
|
||||
FileDescs[0]:='The Free Pascal CVS source directory.';
|
||||
FileTitles[0]:=lisCodeToolsDefsFPCCVSSourceDirectory;
|
||||
FileDescs[0]:=lisCodeToolsDefsTheFreePascalCVSSourceDir;
|
||||
FileNames[0]:='~/fpc_sources/1.1/fpc';
|
||||
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
|
||||
+'Used to autocreate macros.';
|
||||
FileNames[1]:=DefaultCompiler;
|
||||
@ -920,11 +920,11 @@ begin
|
||||
InputFileDlg.Macros:=Macros;
|
||||
with InputFileDlg do begin
|
||||
BeginUpdate;
|
||||
Caption:='Create Defines for Lazarus Directory';
|
||||
Caption:=lisCodeToolsDefsCreateDefinesForLazarusDir;
|
||||
FileCount:=1;
|
||||
|
||||
FileTitles[0]:='Lazarus Directory';
|
||||
FileDescs[0]:='The Lazarus main directory.';
|
||||
FileTitles[0]:=lisCodeToolsDefsLazarusDirectory;
|
||||
FileDescs[0]:=lisCodeToolsDefsTheLazarusMainDirectory;
|
||||
FileNames[0]:=IDEProcs.ProgramDirectory;
|
||||
FileFlags[0]:=[iftDirectory,iftNotEmpty,iftMustExist];
|
||||
|
||||
@ -967,13 +967,12 @@ begin
|
||||
InputFileDlg.Macros:=Macros;
|
||||
with InputFileDlg do begin
|
||||
BeginUpdate;
|
||||
Caption:='Create Defines for '+DelphiName+' Directory';
|
||||
Caption:=Format(lisCodeToolsDefsCreateDefinesForDirectory, [DelphiName]);
|
||||
FileCount:=1;
|
||||
|
||||
FileTitles[0]:=DelphiName+' directory';
|
||||
FileDescs[0]:='The '+DelphiName+' main directory,'#13
|
||||
+'where Borland has installed all '+DelphiName+' sources.'#13
|
||||
+'For example: C:/Programme/Borland/Delphi'+IntToStr(DelphiVersion);
|
||||
FileTitles[0]:=Format(lisCodeToolsDefsdirectory, [DelphiName]);
|
||||
FileDescs[0]:=Format(lisCodeToolsDefsDelphiMainDirectoryDesc, [DelphiName,
|
||||
#13, DelphiName, #13, IntToStr(DelphiVersion)]);
|
||||
FileNames[0]:=SetDirSeparators(
|
||||
'C:/Programme/Borland/Delphi'+IntToStr(DelphiVersion));
|
||||
FileFlags[0]:=[iftDirectory,iftNotEmpty,iftMustExist];
|
||||
@ -1006,22 +1005,21 @@ begin
|
||||
InputFileDlg.Macros:=Macros;
|
||||
with InputFileDlg do begin
|
||||
BeginUpdate;
|
||||
Caption:='Create Defines for '+DelphiName+' Project';
|
||||
Caption:=Format(lisCodeToolsDefsCreateDefinesForProject, [DelphiName]);
|
||||
|
||||
FileCount:=2;
|
||||
|
||||
FileTitles[0]:=DelphiName+' project directory';
|
||||
FileDescs[0]:='The '+DelphiName+' project directory,'#13
|
||||
+'which contains the .dpr, dpk file.';
|
||||
FileTitles[0]:=Format(lisCodeToolsDefsprojectDirectory2, [DelphiName]);
|
||||
FileDescs[0]:=Format(lisCodeToolsDefsTheProjectDirectory, [DelphiName, #13]
|
||||
);
|
||||
FileNames[0]:=SetDirSeparators('C:/Programme/Borland/Delphi'
|
||||
+IntToStr(DelphiVersion)+'/YourProject');
|
||||
FileFlags[0]:=[iftDirectory,iftNotEmpty,iftMustExist];
|
||||
|
||||
FileTitles[1]:=DelphiName+' directory';
|
||||
FileDescs[1]:='The '+DelphiName+' main directory,'#13
|
||||
+'where Borland has installed all '+DelphiName+' sources,'#13
|
||||
+'which are used by this '+DelphiName+' project.'#13
|
||||
+'For example: C:/Programme/Borland/Delphi'+IntToStr(DelphiVersion);
|
||||
FileTitles[1]:=Format(lisCodeToolsDefsdirectory, [DelphiName]);
|
||||
FileDescs[1]:=Format(lisCodeToolsDefsDelphiMainDirectoryForProject, [
|
||||
DelphiName, #13, DelphiName, #13, DelphiName, #13, IntToStr(DelphiVersion)
|
||||
]);
|
||||
FileNames[1]:=SetDirSeparators('C:/Programme/Borland/Delphi'
|
||||
+IntToStr(DelphiVersion));
|
||||
FileFlags[1]:=[iftDirectory,iftNotEmpty,iftMustExist];
|
||||
@ -1088,7 +1086,8 @@ begin
|
||||
if ProjectSpecificCheckBox.Checked=(dtfProjectSpecific in SelDefNode.Flags)
|
||||
then exit;
|
||||
if SelDefNode.IsAutoGenerated then begin
|
||||
MessageDlg('Node is readonly','Auto generated nodes can not be edited.',
|
||||
MessageDlg(lisCodeToolsDefsNodeIsReadonly,
|
||||
lisCodeToolsDefsAutoGeneratedNodesCanNotBeEdited,
|
||||
mtInformation,[mbCancel],0);
|
||||
exit;
|
||||
end;
|
||||
@ -1172,48 +1171,57 @@ begin
|
||||
Menu := MainMenu;
|
||||
|
||||
// exit menu
|
||||
AddMenuItem(ExitMenuItem,'ExitMenuItem','Exit',nil);
|
||||
AddMenuItem(SaveAndExitMenuItem,'SaveAndExitMenuItem','Save and Exit',
|
||||
AddMenuItem(ExitMenuItem, 'ExitMenuItem', lisCodeToolsDefsExit, nil);
|
||||
AddMenuItem(SaveAndExitMenuItem, 'SaveAndExitMenuItem',
|
||||
lisCodeToolsDefsSaveAndExit,
|
||||
ExitMenuItem);
|
||||
SaveAndExitMenuItem.OnClick:=@SaveAndExitMenuItemClick;
|
||||
ExitMenuItem.Add(CreateSeperator);
|
||||
AddMenuItem(DontSaveAndExitMenuItem,'DontSaveAndExitMenuItem',
|
||||
'Exit without Save',ExitMenuItem);
|
||||
lisCodeToolsDefsExitWithoutSave, ExitMenuItem);
|
||||
DontSaveAndExitMenuItem.OnClick:=@DontSaveAndExitMenuItemClick;
|
||||
|
||||
// edit nodes
|
||||
AddMenuItem(EditMenuItem,'EditMenuItem','Edit',nil);
|
||||
AddMenuItem(MoveNodeUpMenuItem,'MoveNodeUpMenuItem','Move node up',
|
||||
AddMenuItem(EditMenuItem, 'EditMenuItem', lisCodeToolsDefsEdit, nil);
|
||||
AddMenuItem(MoveNodeUpMenuItem, 'MoveNodeUpMenuItem',
|
||||
lisCodeToolsDefsMoveNodeUp,
|
||||
EditMenuItem);
|
||||
MoveNodeUpMenuItem.OnClick:=@MoveNodeUpMenuItemClick;
|
||||
|
||||
AddMenuItem(MoveNodeDownMenuItem,'MoveNodeDownMenuItem','Move node down',
|
||||
AddMenuItem(MoveNodeDownMenuItem, 'MoveNodeDownMenuItem',
|
||||
lisCodeToolsDefsMoveNodeDown,
|
||||
EditMenuItem);
|
||||
MoveNodeDownMenuItem.OnClick:=@MoveNodeDownMenuItemClick;
|
||||
|
||||
AddMenuItem(MoveNodeLvlUpMenuItem,'MoveNodeLvlUpMenuItem','Move node one level up',
|
||||
AddMenuItem(MoveNodeLvlUpMenuItem, 'MoveNodeLvlUpMenuItem',
|
||||
lisCodeToolsDefsMoveNodeOneLevelUp,
|
||||
EditMenuItem);
|
||||
MoveNodeLvlUpMenuItem.OnClick:=@MoveNodeLvlUpMenuItemClick;
|
||||
|
||||
AddMenuItem(MoveNodeLvlDownMenuItem,'MoveNodeLvlDownMenuItem','Move node one level down',
|
||||
AddMenuItem(MoveNodeLvlDownMenuItem, 'MoveNodeLvlDownMenuItem',
|
||||
lisCodeToolsDefsMoveNodeOneLevelDown,
|
||||
EditMenuItem);
|
||||
MoveNodeLvlDownMenuItem.OnClick:=@MoveNodeLvlDownMenuItemClick;
|
||||
|
||||
EditMenuItem.Add(CreateSeperator);
|
||||
|
||||
AddMenuItem(InsertBehindMenuItem,'InsertBehindMenuItem','Insert node below',
|
||||
AddMenuItem(InsertBehindMenuItem, 'InsertBehindMenuItem',
|
||||
lisCodeToolsDefsInsertNodeBelow,
|
||||
EditMenuItem);
|
||||
|
||||
AddMenuItem(InsertAsChildMenuItem,'InsertAsChildMenuItem','Insert node as child',
|
||||
AddMenuItem(InsertAsChildMenuItem, 'InsertAsChildMenuItem',
|
||||
lisCodeToolsDefsInsertNodeAsChild,
|
||||
EditMenuItem);
|
||||
|
||||
EditMenuItem.Add(CreateSeperator);
|
||||
|
||||
AddMenuItem(DeleteNodeMenuItem,'DeleteNodeMenuItem','Delete node',
|
||||
AddMenuItem(DeleteNodeMenuItem, 'DeleteNodeMenuItem',
|
||||
lisCodeToolsDefsDeleteNode,
|
||||
EditMenuItem);
|
||||
DeleteNodeMenuItem.OnClick:=@DeleteNodeMenuItemClick;
|
||||
|
||||
AddMenuItem(ConvertActionMenuItem,'ConvertActionMenuItem','Convert node',
|
||||
AddMenuItem(ConvertActionMenuItem, 'ConvertActionMenuItem',
|
||||
lisCodeToolsDefsConvertNode,
|
||||
EditMenuItem);
|
||||
|
||||
{ EditMenuItem.Add(CreateSeperator);
|
||||
@ -1223,108 +1231,138 @@ begin
|
||||
'Paste from clipboard',EditMenuItem);}
|
||||
|
||||
// insert node behind submenu
|
||||
AddMenuItem(InsertBehindDefineMenuItem,'InsertBehindDefineMenuItem','Define',
|
||||
AddMenuItem(InsertBehindDefineMenuItem, 'InsertBehindDefineMenuItem',
|
||||
lisCodeToolsDefsDefine,
|
||||
InsertBehindMenuItem);
|
||||
AddMenuItem(InsertBehindDefineRecurseMenuItem,
|
||||
'InsertBehindDefineRecurseMenuItem','Define Recurse',
|
||||
'InsertBehindDefineRecurseMenuItem',
|
||||
lisCodeToolsDefsDefineRecurse,
|
||||
InsertBehindMenuItem);
|
||||
AddMenuItem(InsertBehindUndefineMenuItem,
|
||||
'InsertBehindUndefineMenuItem','Undefine',
|
||||
'InsertBehindUndefineMenuItem', lisCodeToolsDefsUndefine,
|
||||
InsertBehindMenuItem);
|
||||
AddMenuItem(InsertBehindUndefineRecurseMenuItem,
|
||||
'InsertBehindUndefineRecurseMenuItem','Undefine Recurse',
|
||||
'InsertBehindUndefineRecurseMenuItem',
|
||||
lisCodeToolsDefsUndefineRecurse,
|
||||
InsertBehindMenuItem);
|
||||
AddMenuItem(InsertBehindUndefineAllMenuItem,
|
||||
'InsertBehindUndefineAllMenuItem','Undefine All',
|
||||
'InsertBehindUndefineAllMenuItem', lisCodeToolsDefsUndefineAll,
|
||||
InsertBehindMenuItem);
|
||||
InsertBehindMenuItem.Add(CreateSeperator);
|
||||
AddMenuItem(InsertBehindBlockMenuItem,'InsertBehindBlockMenuItem','Block',
|
||||
AddMenuItem(InsertBehindBlockMenuItem, 'InsertBehindBlockMenuItem',
|
||||
lisCodeToolsDefsBlock,
|
||||
InsertBehindMenuItem);
|
||||
AddMenuItem(InsertBehindDirectoryMenuItem,
|
||||
'InsertBehindDirectoryMenuItem','Directory',
|
||||
'InsertBehindDirectoryMenuItem',
|
||||
lisCodeToolsDefsInsertBehindDirectory,
|
||||
InsertBehindMenuItem);
|
||||
InsertBehindMenuItem.Add(CreateSeperator);
|
||||
AddMenuItem(InsertBehindIfMenuItem,'InsertBehindIfMenuItem','If',
|
||||
AddMenuItem(InsertBehindIfMenuItem, 'InsertBehindIfMenuItem',
|
||||
lisCodeToolsDefsIf,
|
||||
InsertBehindMenuItem);
|
||||
AddMenuItem(InsertBehindIfDefMenuItem,'InsertBehindIfDefMenuItem','IfDef',
|
||||
AddMenuItem(InsertBehindIfDefMenuItem, 'InsertBehindIfDefMenuItem',
|
||||
lisCodeToolsDefsIfDef,
|
||||
InsertBehindMenuItem);
|
||||
AddMenuItem(InsertBehindIfNotDefMenuItem,'InsertBehindIfNotDefMenuItem','IfNDef',
|
||||
AddMenuItem(InsertBehindIfNotDefMenuItem, 'InsertBehindIfNotDefMenuItem',
|
||||
lisCodeToolsDefsIfNDef,
|
||||
InsertBehindMenuItem);
|
||||
AddMenuItem(InsertBehindElseIfMenuItem,'InsertBehindElseIfMenuItem','ElseIf',
|
||||
AddMenuItem(InsertBehindElseIfMenuItem, 'InsertBehindElseIfMenuItem',
|
||||
lisCodeToolsDefsElseIf,
|
||||
InsertBehindMenuItem);
|
||||
AddMenuItem(InsertBehindElseMenuItem,'InsertBehindElseMenuItem','Else',
|
||||
AddMenuItem(InsertBehindElseMenuItem, 'InsertBehindElseMenuItem',
|
||||
lisCodeToolsDefsElse,
|
||||
InsertBehindMenuItem);
|
||||
for i:=0 to InsertBehindMenuItem.Count-1 do
|
||||
if InsertBehindMenuItem[i].Caption<>'-' then
|
||||
InsertBehindMenuItem[i].OnClick:=@InsertNodeMenuItemClick;
|
||||
|
||||
// insert node as child submenu
|
||||
AddMenuItem(InsertAsChildDefineMenuItem,'InsertAsChildDefineMenuItem','Define',
|
||||
AddMenuItem(InsertAsChildDefineMenuItem, 'InsertAsChildDefineMenuItem',
|
||||
lisCodeToolsDefsDefine,
|
||||
InsertAsChildMenuItem);
|
||||
AddMenuItem(InsertAsChildDefineRecurseMenuItem,
|
||||
'InsertAsChildDefineRecurseMenuItem','Define Recurse',
|
||||
'InsertAsChildDefineRecurseMenuItem',
|
||||
lisCodeToolsDefsDefineRecurse,
|
||||
InsertAsChildMenuItem);
|
||||
AddMenuItem(InsertAsChildUndefineMenuItem,
|
||||
'InsertAsChildUndefineMenuItem','Undefine',
|
||||
'InsertAsChildUndefineMenuItem', lisCodeToolsDefsUndefine,
|
||||
InsertAsChildMenuItem);
|
||||
AddMenuItem(InsertAsChildUndefineRecurseMenuItem,
|
||||
'InsertAsChildUndefineRecurseMenuItem','Undefine Recurse',
|
||||
'InsertAsChildUndefineRecurseMenuItem',
|
||||
lisCodeToolsDefsUndefineRecurse,
|
||||
InsertAsChildMenuItem);
|
||||
AddMenuItem(InsertAsChildUndefineAllMenuItem,
|
||||
'InsertAsChildUndefineAllMenuItem','Undefine All',
|
||||
'InsertAsChildUndefineAllMenuItem', lisCodeToolsDefsUndefineAll,
|
||||
InsertAsChildMenuItem);
|
||||
InsertAsChildMenuItem.Add(CreateSeperator);
|
||||
AddMenuItem(InsertAsChildBlockMenuItem,'InsertAsChildBlockMenuItem','Block',
|
||||
AddMenuItem(InsertAsChildBlockMenuItem, 'InsertAsChildBlockMenuItem',
|
||||
lisCodeToolsDefsBlock,
|
||||
InsertAsChildMenuItem);
|
||||
AddMenuItem(InsertAsChildDirectoryMenuItem,
|
||||
'InsertAsChildDirectoryMenuItem','Directory',
|
||||
'InsertAsChildDirectoryMenuItem',
|
||||
lisCodeToolsDefsInsertBehindDirectory,
|
||||
InsertAsChildMenuItem);
|
||||
InsertAsChildMenuItem.Add(CreateSeperator);
|
||||
AddMenuItem(InsertAsChildIfMenuItem,'InsertAsChildIfMenuItem','If',
|
||||
AddMenuItem(InsertAsChildIfMenuItem, 'InsertAsChildIfMenuItem',
|
||||
lisCodeToolsDefsIf,
|
||||
InsertAsChildMenuItem);
|
||||
AddMenuItem(InsertAsChildIfDefMenuItem,'InsertAsChildIfDefMenuItem','IfDef',
|
||||
AddMenuItem(InsertAsChildIfDefMenuItem, 'InsertAsChildIfDefMenuItem',
|
||||
lisCodeToolsDefsIfDef,
|
||||
InsertAsChildMenuItem);
|
||||
AddMenuItem(InsertAsChildIfNotDefMenuItem,'InsertAsChildIfNotDefMenuItem','IfNDef',
|
||||
AddMenuItem(InsertAsChildIfNotDefMenuItem, 'InsertAsChildIfNotDefMenuItem',
|
||||
lisCodeToolsDefsIfNDef,
|
||||
InsertAsChildMenuItem);
|
||||
AddMenuItem(InsertAsChildElseIfMenuItem,'InsertAsChildElseIfMenuItem','ElseIf',
|
||||
AddMenuItem(InsertAsChildElseIfMenuItem, 'InsertAsChildElseIfMenuItem',
|
||||
lisCodeToolsDefsElseIf,
|
||||
InsertAsChildMenuItem);
|
||||
AddMenuItem(InsertAsChildElseMenuItem,'InsertAsChildElseMenuItem','Else',
|
||||
AddMenuItem(InsertAsChildElseMenuItem, 'InsertAsChildElseMenuItem',
|
||||
lisCodeToolsDefsElse,
|
||||
InsertAsChildMenuItem);
|
||||
for i:=0 to InsertAsChildMenuItem.Count-1 do
|
||||
if InsertAsChildMenuItem[i].Caption<>'-' then
|
||||
InsertAsChildMenuItem[i].OnClick:=@InsertNodeMenuItemClick;
|
||||
|
||||
// convert node sub menu
|
||||
AddMenuItem(ConvertActionToDefineMenuItem,'ConvertActionToDefineMenuItem','Define',
|
||||
AddMenuItem(ConvertActionToDefineMenuItem, 'ConvertActionToDefineMenuItem',
|
||||
lisCodeToolsDefsDefine,
|
||||
ConvertActionMenuItem);
|
||||
AddMenuItem(ConvertActionToDefineRecurseMenuItem,
|
||||
'ConvertActionToDefineRecurseMenuItem','Define Recurse',
|
||||
'ConvertActionToDefineRecurseMenuItem',
|
||||
lisCodeToolsDefsDefineRecurse,
|
||||
ConvertActionMenuItem);
|
||||
AddMenuItem(ConvertActionToUndefineMenuItem,
|
||||
'ConvertActionToUndefineMenuItem','Undefine',
|
||||
'ConvertActionToUndefineMenuItem', lisCodeToolsDefsUndefine,
|
||||
ConvertActionMenuItem);
|
||||
AddMenuItem(ConvertActionToUndefineRecurseMenuItem,
|
||||
'ConvertActionToUndefineRecurseMenuItem','Undefine Recurse',
|
||||
'ConvertActionToUndefineRecurseMenuItem',
|
||||
lisCodeToolsDefsUndefineRecurse,
|
||||
ConvertActionMenuItem);
|
||||
AddMenuItem(ConvertActionToUndefineAllMenuItem,
|
||||
'ConvertActionToUndefineAllMenuItem','Undefine All',
|
||||
'ConvertActionToUndefineAllMenuItem', lisCodeToolsDefsUndefineAll,
|
||||
ConvertActionMenuItem);
|
||||
ConvertActionMenuItem.Add(CreateSeperator);
|
||||
AddMenuItem(ConvertActionToBlockMenuItem,'ConvertActionToBlockMenuItem','Block',
|
||||
AddMenuItem(ConvertActionToBlockMenuItem, 'ConvertActionToBlockMenuItem',
|
||||
lisCodeToolsDefsBlock,
|
||||
ConvertActionMenuItem);
|
||||
AddMenuItem(ConvertActionToDirectoryMenuItem,
|
||||
'ConvertActionToDirectoryMenuItem','Directory',
|
||||
'ConvertActionToDirectoryMenuItem',
|
||||
lisCodeToolsDefsInsertBehindDirectory,
|
||||
ConvertActionMenuItem);
|
||||
ConvertActionMenuItem.Add(CreateSeperator);
|
||||
AddMenuItem(ConvertActionToIfMenuItem,'ConvertActionToIfMenuItem','If',
|
||||
AddMenuItem(ConvertActionToIfMenuItem, 'ConvertActionToIfMenuItem',
|
||||
lisCodeToolsDefsIf,
|
||||
ConvertActionMenuItem);
|
||||
AddMenuItem(ConvertActionToIfDefMenuItem,'ConvertActionToIfDefMenuItem','IfDef',
|
||||
AddMenuItem(ConvertActionToIfDefMenuItem, 'ConvertActionToIfDefMenuItem',
|
||||
lisCodeToolsDefsIfDef,
|
||||
ConvertActionMenuItem);
|
||||
AddMenuItem(ConvertActionToIfNotDefMenuItem,'ConvertActionToIfNotDefMenuItem','IfNDef',
|
||||
AddMenuItem(ConvertActionToIfNotDefMenuItem,
|
||||
'ConvertActionToIfNotDefMenuItem', lisCodeToolsDefsIfNDef,
|
||||
ConvertActionMenuItem);
|
||||
AddMenuItem(ConvertActionToElseIfMenuItem,'ConvertActionToElseIfMenuItem','ElseIf',
|
||||
AddMenuItem(ConvertActionToElseIfMenuItem, 'ConvertActionToElseIfMenuItem',
|
||||
lisCodeToolsDefsElseIf,
|
||||
ConvertActionMenuItem);
|
||||
AddMenuItem(ConvertActionToElseMenuItem,'ConvertActionToElseMenuItem','Else',
|
||||
AddMenuItem(ConvertActionToElseMenuItem, 'ConvertActionToElseMenuItem',
|
||||
lisCodeToolsDefsElse,
|
||||
ConvertActionMenuItem);
|
||||
for i:=0 to ConvertActionMenuItem.Count-1 do
|
||||
if ConvertActionMenuItem[i].Caption<>'-' then
|
||||
@ -1341,25 +1379,25 @@ begin
|
||||
|
||||
// templates
|
||||
AddMenuItem(InsertTemplateMenuItem,'InsertTemplateMenuItem',
|
||||
'Insert Template',nil);
|
||||
lisCodeToolsDefsInsertTemplate, nil);
|
||||
|
||||
AddMenuItem(InsertFPCProjectDefinesTemplateMenuItem,
|
||||
'InsertFPCProjectDefinesTemplateMenuItem',
|
||||
'Insert Free Pascal Project Template',
|
||||
lisCodeToolsDefsInsertFreePascalProjectTe,
|
||||
InsertTemplateMenuItem);
|
||||
InsertFPCProjectDefinesTemplateMenuItem.OnClick:=
|
||||
@InsertFPCProjectDefinesTemplateMenuItemClick;
|
||||
|
||||
AddMenuItem(InsertFPCompilerDefinesTemplateMenuItem,
|
||||
'InsertFPCompilerDefinesTemplateMenuItem',
|
||||
'Insert Free Pascal Compiler Template',
|
||||
lisCodeToolsDefsInsertFreePascalCompilerT,
|
||||
InsertTemplateMenuItem);
|
||||
InsertFPCompilerDefinesTemplateMenuItem.OnClick:=
|
||||
@InsertFPCompilerDefinesTemplateMenuItemClick;
|
||||
|
||||
AddMenuItem(InsertFPCSourceDirTemplateMenuItem,
|
||||
'InsertFPCSourceDirTemplateMenuItem',
|
||||
'Insert Free Pascal CVS Source Template',
|
||||
lisCodeToolsDefsInsertFreePascalCVSSource,
|
||||
InsertTemplateMenuItem);
|
||||
InsertFPCSourceDirTemplateMenuItem.OnClick:=
|
||||
@InsertFPCSourceDirDefinesTemplateMenuItemClick;
|
||||
@ -1367,7 +1405,7 @@ begin
|
||||
InsertTemplateMenuItem.Add(CreateSeperator);
|
||||
AddMenuItem(InsertLazarusSourceTemplateMenuItem,
|
||||
'InsertLazarusSourceTemplateMenuItem',
|
||||
'Insert Lazarus Directory Template',
|
||||
lisCodeToolsDefsInsertLazarusDirectoryTem,
|
||||
InsertTemplateMenuItem);
|
||||
InsertLazarusSourceTemplateMenuItem.OnClick:=
|
||||
@InsertLazarusSourceDefinesTemplateMenuItemClick;
|
||||
@ -1375,21 +1413,21 @@ begin
|
||||
InsertTemplateMenuItem.Add(CreateSeperator);
|
||||
AddMenuItem(InsertDelphi5CompilerDefinesTemplateMenuItem,
|
||||
'InsertDelphi5CompilerDefinesTemplateMenuItem',
|
||||
'Insert Delphi 5 Compiler Template',
|
||||
lisCodeToolsDefsInsertDelphi5CompilerTemp,
|
||||
InsertTemplateMenuItem);
|
||||
InsertDelphi5CompilerDefinesTemplateMenuItem.OnClick:=
|
||||
@InsertDelphiCompilerDefinesTemplateMenuItemClick;
|
||||
|
||||
AddMenuItem(InsertDelphi5DirectoryTemplateMenuItem,
|
||||
'InsertDelphi5DirectoryTemplateMenuItem',
|
||||
'Insert Delphi 5 Directory Template',
|
||||
lisCodeToolsDefsInsertDelphi5DirectoryTem,
|
||||
InsertTemplateMenuItem);
|
||||
InsertDelphi5DirectoryTemplateMenuItem.OnClick:=
|
||||
@InsertDelphiDirectoryTemplateMenuItemClick;
|
||||
|
||||
AddMenuItem(InsertDelphi5ProjectTemplateMenuItem,
|
||||
'InsertDelphi5ProjectTemplateMenuItem',
|
||||
'Insert Delphi 5 Project Template',
|
||||
lisCodeToolsDefsInsertDelphi5ProjectTempl,
|
||||
InsertTemplateMenuItem);
|
||||
InsertDelphi5ProjectTemplateMenuItem.OnClick:=
|
||||
@InsertDelphiProjectTemplateMenuItemClick;
|
||||
@ -1398,21 +1436,21 @@ begin
|
||||
InsertTemplateMenuItem.Add(CreateSeperator);
|
||||
AddMenuItem(InsertDelphi6CompilerDefinesTemplateMenuItem,
|
||||
'InsertDelphi6CompilerDefinesTemplateMenuItem',
|
||||
'Insert Delphi 6 Compiler Template',
|
||||
lisCodeToolsDefsInsertDelphi6CompilerTemp,
|
||||
InsertTemplateMenuItem);
|
||||
InsertDelphi6CompilerDefinesTemplateMenuItem.OnClick:=
|
||||
@InsertDelphiCompilerDefinesTemplateMenuItemClick;
|
||||
|
||||
AddMenuItem(InsertDelphi6DirectoryTemplateMenuItem,
|
||||
'InsertDelphi6DirectoryTemplateMenuItem',
|
||||
'Insert Delphi 6 Directory Template',
|
||||
lisCodeToolsDefsInsertDelphi6DirectoryTem,
|
||||
InsertTemplateMenuItem);
|
||||
InsertDelphi6DirectoryTemplateMenuItem.OnClick:=
|
||||
@InsertDelphiDirectoryTemplateMenuItemClick;
|
||||
|
||||
AddMenuItem(InsertDelphi6ProjectTemplateMenuItem,
|
||||
'InsertDelphi6ProjectTemplateMenuItem',
|
||||
'Insert Delphi 6 Project Template',
|
||||
lisCodeToolsDefsInsertDelphi6ProjectTempl,
|
||||
InsertTemplateMenuItem);
|
||||
InsertDelphi6ProjectTemplateMenuItem.OnClick:=
|
||||
@InsertDelphiProjectTemplateMenuItemClick;
|
||||
@ -1428,7 +1466,7 @@ begin
|
||||
|
||||
// selected item
|
||||
CreateWinControl(SelectedItemGroupBox,TGroupBox,'SelectedItemGroupBox',Self);
|
||||
SelectedItemGroupBox.Caption:='Selected Node:';
|
||||
SelectedItemGroupBox.Caption:=lisCodeToolsDefsSelectedNode;
|
||||
SelectedItemGroupBox.OnResize:=@SelectedItemGroupBoxResize;
|
||||
|
||||
CreateWinControl(TypeLabel,TLabel,'TypeLabel',SelectedItemGroupBox);
|
||||
@ -1436,23 +1474,23 @@ begin
|
||||
CreateWinControl(ProjectSpecificCheckBox,TCheckBox,'ProjectSpecificCheckBox',
|
||||
SelectedItemGroupBox);
|
||||
ProjectSpecificCheckBox.Caption:=
|
||||
'Node and its children are only valid for this project';
|
||||
lisCodeToolsDefsNodeAndItsChildrenAreOnly;
|
||||
ProjectSpecificCheckBox.OnClick:=@ProjectSpecificCheckBoxClick;
|
||||
|
||||
CreateWinControl(NameLabel,TLabel,'NameLabel',SelectedItemGroupBox);
|
||||
NameLabel.Caption:='Name:';
|
||||
NameLabel.Caption:=lisCodeToolsDefsName;
|
||||
|
||||
CreateWinControl(NameEdit,TEdit,'NameEdit',SelectedItemGroupBox);
|
||||
|
||||
CreateWinControl(DescriptionLabel,TLabel,'DescriptionLabel',
|
||||
SelectedItemGroupBox);
|
||||
DescriptionLabel.Caption:='Description:';
|
||||
DescriptionLabel.Caption:=lisCodeToolsDefsDescription;
|
||||
|
||||
CreateWinControl(DescriptionEdit,TEdit,'DescriptionEdit',
|
||||
SelectedItemGroupBox);
|
||||
|
||||
CreateWinControl(VariableLabel,TLabel,'VariableLabel',SelectedItemGroupBox);
|
||||
VariableLabel.Caption:='Variable:';
|
||||
VariableLabel.Caption:=lisCodeToolsDefsVariable;
|
||||
|
||||
CreateWinControl(VariableEdit,TEdit,'VariableEdit',SelectedItemGroupBox);
|
||||
|
||||
@ -1460,10 +1498,10 @@ begin
|
||||
SelectedItemGroupBox);
|
||||
with ValueNoteBook do begin
|
||||
if PageCount>0 then
|
||||
Pages[0]:='Value as Text'
|
||||
Pages[0]:=lisCodeToolsDefsValueAsText
|
||||
else
|
||||
Pages.Add('Value as Text');
|
||||
Pages.Add('Value as File Paths');
|
||||
Pages.Add(lisCodeToolsDefsValueAsText);
|
||||
Pages.Add(lisCodeToolsDefsValueAsFilePaths);
|
||||
OnPageChanged:=@ValueNoteBookPageChanged;
|
||||
OnResize:=@ValueNoteBookResize;
|
||||
end;
|
||||
@ -1485,22 +1523,22 @@ begin
|
||||
|
||||
CreateWinControl(MoveFilePathUpBitBtn,TBitBtn,'MoveFilePathUpBitBtn',
|
||||
ValueNoteBook.Page[1]);
|
||||
MoveFilePathUpBitBtn.Caption:='Up';
|
||||
MoveFilePathUpBitBtn.Caption:=dlgUpWord;
|
||||
MoveFilePathUpBitBtn.OnClick:=@MoveFilePathUpBitBtnClick;
|
||||
|
||||
CreateWinControl(MoveFilePathDownBitBtn,TBitBtn,'MoveFilePathDownBitBtn',
|
||||
ValueNoteBook.Page[1]);
|
||||
MoveFilePathDownBitBtn.Caption:='Down';
|
||||
MoveFilePathDownBitBtn.Caption:=dlgDownWord;
|
||||
MoveFilePathDownBitBtn.OnClick:=@MoveFilePathDownBitBtnClick;
|
||||
|
||||
CreateWinControl(DeleteFilePathBitBtn,TBitBtn,'DeleteFilePathBitBtn',
|
||||
ValueNoteBook.Page[1]);
|
||||
DeleteFilePathBitBtn.Caption:='Delete';
|
||||
DeleteFilePathBitBtn.Caption:=dlgEdDelete;
|
||||
DeleteFilePathBitBtn.OnClick:=@DeleteFilePathBitBtnClick;
|
||||
|
||||
CreateWinControl(InsertFilePathBitBtn,TBitBtn,'InsertFilePathBitBtn',
|
||||
ValueNoteBook.Page[1]);
|
||||
InsertFilePathBitBtn.Caption:='Insert';
|
||||
InsertFilePathBitBtn.Caption:=srVK_INSERT;
|
||||
InsertFilePathBitBtn.OnClick:=@InsertFilePathBitBtnClick;
|
||||
end;
|
||||
|
||||
@ -1696,13 +1734,13 @@ begin
|
||||
SelTreeNode:=DefineTreeView.Selected;
|
||||
if SelTreeNode<>nil then begin
|
||||
SelDefNode:=TDefineTemplate(SelTreeNode.Data);
|
||||
s:='Action: '+DefineActionNames[SelDefNode.Action];
|
||||
s:=Format(lisCodeToolsDefsAction, [DefineActionNames[SelDefNode.Action]]);
|
||||
if SelDefNode.IsAutoGenerated then
|
||||
s:=s+', auto generated';
|
||||
s:=Format(lisCodeToolsDefsautoGenerated, [s]);
|
||||
if SelDefNode.IsProjectSpecific then
|
||||
s:=s+', project specific';
|
||||
s:=Format(lisCodeToolsDefsprojectSpecific, [s]);
|
||||
end else begin
|
||||
s:='none selected';
|
||||
s:=lisCodeToolsDefsnoneSelected;
|
||||
end;
|
||||
TypeLabel.Caption:=s;
|
||||
end;
|
||||
@ -1748,16 +1786,16 @@ begin
|
||||
end;
|
||||
if (ParentNode<>nil) and (TDefineTemplate(ParentNode.Data).IsAutoGenerated)
|
||||
then begin
|
||||
MessageDlg('Invalid parent','Auto created nodes can not be edited,'#13
|
||||
+'nor can they have non auto created child nodes.',mtInformation,[mbCancel]
|
||||
,0);
|
||||
MessageDlg(lisCodeToolsDefsInvalidParent, Format(
|
||||
lisCodeToolsDefsAutoCreatedNodesReadOnly, [#13]), mtInformation,
|
||||
[mbCancel],0);
|
||||
exit;
|
||||
end;
|
||||
if (ParentNode<>nil)
|
||||
and (not (TDefineTemplate(ParentNode.Data).Action in DefineActionBlocks)) then
|
||||
begin
|
||||
MessageDlg('Invalid parent node',
|
||||
'Parent node can not contain child nodes.',
|
||||
MessageDlg(lisCodeToolsDefsInvalidParentNode,
|
||||
lisCodeToolsDefsParentNodeCanNotContainCh,
|
||||
mtInformation,[mbCancel],0);
|
||||
exit;
|
||||
end;
|
||||
@ -1843,9 +1881,10 @@ function TCodeToolsDefinesEditor.FindUniqueName: string;
|
||||
var i: integer;
|
||||
begin
|
||||
i:=1;
|
||||
while (DefineTree.FindDefineTemplateByName('NewNode'+IntToStr(i),false)<>nil)
|
||||
while (DefineTree.FindDefineTemplateByName(lisCodeToolsDefsNewNode+IntToStr(i
|
||||
), false)<>nil)
|
||||
do inc(i);
|
||||
Result:='NewNode'+IntToStr(i);
|
||||
Result:=lisCodeToolsDefsNewNode+IntToStr(i);
|
||||
end;
|
||||
|
||||
function TCodeToolsDefinesEditor.ConsistencyCheck: integer;
|
||||
@ -1948,7 +1987,7 @@ begin
|
||||
IDEDialogLayoutList.ApplyLayout(Self,500, 460);
|
||||
|
||||
if LazarusResources.Find(ClassName)=nil then begin
|
||||
Caption:='CodeTools Defines Editor';
|
||||
Caption:=lisCodeToolsDefsCodeToolsDefinesEditor;
|
||||
OnResize:=@FormResize;
|
||||
|
||||
CreateComponents;
|
||||
|
@ -1055,6 +1055,89 @@ resourcestring
|
||||
+'or %s/usr/local/bin/fpc @/etc/11fpc.cfg%s.';
|
||||
lisCodeToolsDefsCreateDefinesForFreePascalCVSSources = 'Create Defines for '
|
||||
+'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
|
||||
end.
|
||||
|
@ -46,7 +46,11 @@ uses
|
||||
EditorOptions, InputHistory;
|
||||
|
||||
type
|
||||
TResourcestringInsertPolicy = (rsipAppend, rsipAlphabetically);
|
||||
TResourcestringInsertPolicy = (
|
||||
rsipNone, // do not add/insert
|
||||
rsipAppend, // append at end
|
||||
rsipAlphabetically // insert alphabetically
|
||||
);
|
||||
|
||||
TMakeResStrDialog = class(TForm)
|
||||
// source synedit
|
||||
@ -67,6 +71,9 @@ type
|
||||
// resourcestring section
|
||||
ResStrSectionLabel: TLabel;
|
||||
ResStrSectionComboBox: TComboBox;
|
||||
// resourcestrings with same value
|
||||
ResStrWithSameValueLabel: TLabel;
|
||||
ResStrWithSameValuesCombobox: TComboBox;
|
||||
// insert position type
|
||||
AppendResStrRadioButton: TRadioButton;
|
||||
InsertAlphabeticallyResStrRadioButton: TRadioButton;
|
||||
@ -91,6 +98,7 @@ type
|
||||
procedure MakeResStrDialogResize(Sender: TObject);
|
||||
procedure OkButtonClick(Sender: TObject);
|
||||
procedure ResStrSectionComboBoxChange(Sender: TObject);
|
||||
procedure ResStrWithSameValuesComboboxChange(Sender: TObject);
|
||||
private
|
||||
procedure SetupComponents;
|
||||
public
|
||||
@ -103,13 +111,16 @@ type
|
||||
procedure FillResourceStringSections(NewPositions: TCodeXYPositions);
|
||||
procedure FillIdentPrefixes;
|
||||
procedure FillIdentLengths;
|
||||
procedure FillStringsWithSameValue;
|
||||
procedure UpdateIdentifier;
|
||||
procedure UpdateSourcePreview;
|
||||
function GetIdentifier: string;
|
||||
function GetDefaultIdentifier: string;
|
||||
procedure SetSource(NewCode: TCodeBuffer;
|
||||
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 Init;
|
||||
procedure SaveHistories;
|
||||
@ -146,7 +157,7 @@ var
|
||||
ResourcestringSectionID: Integer;
|
||||
begin
|
||||
MakeResStrDialog:=TMakeResStrDialog.Create(Application);
|
||||
MakeResStrDialog.Positions:=CodeToolBoss.Positions;
|
||||
MakeResStrDialog.Positions:=CodeToolBoss.Positions.CreateCopy;
|
||||
MakeResStrDialog.SetSource(Code,StartPos,EndPos);
|
||||
MakeResStrDialog.Init;
|
||||
|
||||
@ -156,10 +167,14 @@ begin
|
||||
// return results
|
||||
NewIdentifier:=MakeResStrDialog.GetIdentifier;
|
||||
MakeResStrDialog.GetNewSource(NewSourceLines,NewIdentifierValue);
|
||||
if MakeResStrDialog.InsertAlphabeticallyResStrRadioButton.Checked then
|
||||
InsertPolicy:=rsipAlphabetically
|
||||
else
|
||||
InsertPolicy:=rsipAppend;
|
||||
if MakeResStrDialog.ResStrExistsWithSameValue(NewIdentifier) then
|
||||
InsertPolicy:=rsipNone
|
||||
else begin
|
||||
if MakeResStrDialog.InsertAlphabeticallyResStrRadioButton.Checked then
|
||||
InsertPolicy:=rsipAlphabetically
|
||||
else
|
||||
InsertPolicy:=rsipAppend;
|
||||
end;
|
||||
ResourcestringSectionID:=MakeResStrDialog.ResStrSectionComboBox.ItemIndex;
|
||||
Section:=CodeToolBoss.Positions[ResourcestringSectionID];
|
||||
ResStrSectionCode:=Section^.Code;
|
||||
@ -169,6 +184,7 @@ begin
|
||||
// save settings and clean up
|
||||
IDEDialogLayoutList.SaveLayout(MakeResStrDialog);
|
||||
|
||||
MakeResStrDialog.Positions.Free;
|
||||
MakeResStrDialog.Free;
|
||||
end;
|
||||
|
||||
@ -230,10 +246,23 @@ begin
|
||||
Parent.ClientWidth-Left-5,Height);
|
||||
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
|
||||
with AppendResStrRadioButton do begin
|
||||
SetBounds(IdentPrefixLabel.Left,
|
||||
ResStrSectionComboBox.Top+ResStrSectionComboBox.Height+7,
|
||||
ResStrWithSameValuesCombobox.Top+ResStrWithSameValuesCombobox.Height+7,
|
||||
Min((Parent.ClientWidth-3*Left) div 2,150),Height);
|
||||
end;
|
||||
|
||||
@ -280,19 +309,19 @@ begin
|
||||
with ConversionGroupBox do begin
|
||||
SetBounds(StringConstGroupBox.Left,
|
||||
StringConstGroupBox.Top+StringConstGroupBox.Height+5,
|
||||
StringConstGroupBox.Width,140);
|
||||
StringConstGroupBox.Width,170);
|
||||
end;
|
||||
|
||||
// preview
|
||||
with SrcPreviewGroupBox do begin
|
||||
NewTop:=ConversionGroupBox.Top+ConversionGroupBox.Height+5;
|
||||
SetBounds(ConversionGroupBox.Left,NewTop,
|
||||
ConversionGroupBox.Width,Parent.ClientHeight-NewTop-50);
|
||||
ConversionGroupBox.Width,Parent.ClientHeight-NewTop-45);
|
||||
end;
|
||||
|
||||
// ok+cancel buttons
|
||||
with OkButton do begin
|
||||
SetBounds(Parent.ClientWidth-200,Parent.ClientHeight-35,
|
||||
SetBounds(Parent.ClientWidth-200,Parent.ClientHeight-32,
|
||||
Width,Height);
|
||||
end;
|
||||
|
||||
@ -312,6 +341,17 @@ begin
|
||||
mtError,[mbCancel],0);
|
||||
exit;
|
||||
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;
|
||||
ModalResult:=mrOk;
|
||||
end;
|
||||
@ -322,6 +362,17 @@ begin
|
||||
UpdateSourcePreview;
|
||||
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;
|
||||
begin
|
||||
SynPasSyn:=TSynPasSyn.Create(Self);
|
||||
@ -414,6 +465,21 @@ begin
|
||||
OnChange:=@ResStrSectionComboBoxChange;
|
||||
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
|
||||
AppendResStrRadioButton:=TRadioButton.Create(Self);
|
||||
with AppendResStrRadioButton do begin
|
||||
@ -553,6 +619,46 @@ begin
|
||||
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;
|
||||
var
|
||||
CustomIdent: Boolean;
|
||||
@ -591,13 +697,17 @@ var
|
||||
DefIdenLength: Integer;
|
||||
i: Integer;
|
||||
begin
|
||||
if ResStrWithSameValuesCombobox.Items.Count>0 then begin
|
||||
Result:=ResStrWithSameValuesCombobox.Items[0];
|
||||
exit;
|
||||
end;
|
||||
DefIdenLength:=StrToIntDef(IdentLengthComboBox.Text,8);
|
||||
if DefIdenLength<1 then DefIdenLength:=1;
|
||||
if DefIdenLength>80 then DefIdenLength:=80;
|
||||
Result:=IdentPrefixComboBox.Text+copy(DefaultIdentifier,1,DefIdenLength);
|
||||
if ResourceStringExists(Result) then begin
|
||||
if ResStrExistsInCurrentSection(Result) then begin
|
||||
i:=2;
|
||||
while ResourceStringExists(Result+IntToStr(i)) do inc(i);
|
||||
while ResStrExistsInCurrentSection(Result+IntToStr(i)) do inc(i);
|
||||
Result:=Result++IntToStr(i);
|
||||
end;
|
||||
end;
|
||||
@ -610,7 +720,7 @@ begin
|
||||
EndPos:=NewEndPos;
|
||||
end;
|
||||
|
||||
function TMakeResStrDialog.ResourceStringExists(const Identifier: string
|
||||
function TMakeResStrDialog.ResStrExistsInCurrentSection(const Identifier: string
|
||||
): boolean;
|
||||
var
|
||||
CodeXY: PCodeXYPosition;
|
||||
@ -624,6 +734,38 @@ begin
|
||||
CodeXY^.Code,CodeXY^.X,CodeXY^.Y,Identifier);
|
||||
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,
|
||||
ResourceStringValue: string);
|
||||
var
|
||||
@ -665,6 +807,8 @@ begin
|
||||
FillIdentPrefixes;
|
||||
// identifier lengths
|
||||
FillIdentLengths;
|
||||
// existing resource strings with same value
|
||||
FillStringsWithSameValue;
|
||||
// identifier
|
||||
CustomIdentifierCheckBox.Checked:=false;
|
||||
CodeToolBoss.CreateIdentifierFromStringConst(Code,StartPos.X,StartPos.Y,
|
||||
|
Loading…
Reference in New Issue
Block a user