added some project flags to start getting rid of TProjectType

git-svn-id: trunk@5900 -
This commit is contained in:
mattias 2004-09-01 10:25:58 +00:00
parent ca675e25c7
commit 4ec908a9f7
3 changed files with 54 additions and 31 deletions

View File

@ -4131,8 +4131,8 @@ begin
AText:=Format(lisAFileAlreadyExistsReplaceIt, ['"', NewFilename, '"', #13]); AText:=Format(lisAFileAlreadyExistsReplaceIt, ['"', NewFilename, '"', #13]);
Result:=MessageDlg(ACaption, AText, mtConfirmation, [mbOk, mbCancel], 0); Result:=MessageDlg(ACaption, AText, mtConfirmation, [mbOk, mbCancel], 0);
if Result=mrCancel then exit; if Result=mrCancel then exit;
end else if Project1.ProjectType in [ptProgram,ptApplication] end
then begin else begin
if FileExists(NewProgramFilename) then begin if FileExists(NewProgramFilename) then begin
ACaption:=lisOverwriteFile; ACaption:=lisOverwriteFile;
AText:=Format(lisAFileAlreadyExistsReplaceIt, ['"', NewProgramFilename, AText:=Format(lisAFileAlreadyExistsReplaceIt, ['"', NewProgramFilename,
@ -4927,9 +4927,8 @@ Begin
Project1.Units[i].UnitName,i,Project1.Units[i]=ActiveUnitInfo)); Project1.Units[i].UnitName,i,Project1.Units[i]=ActiveUnitInfo));
end else if Project1.MainUnitID=i then begin end else if Project1.MainUnitID=i then begin
MainUnitInfo:=Project1.MainUnitInfo; MainUnitInfo:=Project1.MainUnitInfo;
if Project1.ProjectType in [ptProgram,ptApplication,ptCustomProgram] if pfMainUnitIsPascalSource in Project1.Flags then begin
then begin MainUnitName:=CreateSrcEditPageName('',
MainUnitName:=CreateSrcEditPageName(MainUnitInfo.UnitName,
MainUnitInfo.Filename,MainUnitInfo.EditorIndex); MainUnitInfo.Filename,MainUnitInfo.EditorIndex);
if MainUnitName<>'' then begin if MainUnitName<>'' then begin
UnitList.Add(TViewUnitsEntry.Create( UnitList.Add(TViewUnitsEntry.Create(
@ -5768,8 +5767,7 @@ begin
s:='"'+ActiveUnitInfo.Filename+'"' s:='"'+ActiveUnitInfo.Filename+'"'
else else
s:='"'+ActiveSourceEditor.PageName+'"'; s:='"'+ActiveSourceEditor.PageName+'"';
if (Project1.ProjectType in [ptProgram, ptApplication]) if (ActiveUnitInfo.UnitName<>'')
and (ActiveUnitInfo.UnitName<>'')
and (Project1.IndexOfUnitWithName(ActiveUnitInfo.UnitName, and (Project1.IndexOfUnitWithName(ActiveUnitInfo.UnitName,
true,ActiveUnitInfo)>=0) then true,ActiveUnitInfo)>=0) then
begin begin
@ -5786,7 +5784,7 @@ begin
if Result<>mrOk then exit; if Result<>mrOk then exit;
ActiveUnitInfo.IsPartOfProject:=true; ActiveUnitInfo.IsPartOfProject:=true;
if (FilenameIsPascalUnit(ActiveUnitInfo.Filename)) if (FilenameIsPascalUnit(ActiveUnitInfo.Filename))
and (Project1.ProjectType in [ptProgram,ptApplication]) and (pfMainUnitHasUsesSectionForAllUnits in Project1.Flags)
then begin then begin
ActiveUnitInfo.ReadUnitNameFromSource(false); ActiveUnitInfo.ReadUnitNameFromSource(false);
ShortUnitName:=ActiveUnitInfo.CreateUnitName; ShortUnitName:=ActiveUnitInfo.CreateUnitName;
@ -5834,7 +5832,7 @@ Begin
AnUnitInfo:=Project1.Units[TViewUnitsEntry(UnitList[i]).ID]; AnUnitInfo:=Project1.Units[TViewUnitsEntry(UnitList[i]).ID];
AnUnitInfo.IsPartOfProject:=false; AnUnitInfo.IsPartOfProject:=false;
if (Project1.MainUnitID>=0) if (Project1.MainUnitID>=0)
and (Project1.ProjectType in [ptProgram,ptApplication]) and (pfMainUnitHasUsesSectionForAllUnits in Project1.Flags)
then begin then begin
if (AnUnitInfo.UnitName<>'') then begin if (AnUnitInfo.UnitName<>'') then begin
if CodeToolBoss.RemoveUnitFromAllUsesSections( if CodeToolBoss.RemoveUnitFromAllUsesSections(
@ -6046,7 +6044,7 @@ begin
Result := mrCancel; Result := mrCancel;
// Check if we can run this project // Check if we can run this project
if not (Project1.ProjectType in [ptProgram, ptApplication, ptCustomProgram]) if (not (pfRunnable in Project1.Flags))
or (Project1.MainUnitID < 0) or (Project1.MainUnitID < 0)
then Exit; then Exit;
@ -9986,7 +9984,7 @@ begin
BeginCodeTool(ActiveSourceEditor,ActiveUnitInfo,[]); BeginCodeTool(ActiveSourceEditor,ActiveUnitInfo,[]);
AnUnitInfo.IsPartOfProject:=true; AnUnitInfo.IsPartOfProject:=true;
if FilenameIsPascalUnit(AnUnitInfo.Filename) if FilenameIsPascalUnit(AnUnitInfo.Filename)
and (Project1.ProjectType in [ptProgram, ptApplication]) and (pfMainUnitHasUsesSectionForAllUnits in Project1.Flags)
then begin then begin
AnUnitInfo.ReadUnitNameFromSource(false); AnUnitInfo.ReadUnitNameFromSource(false);
ShortUnitName:=AnUnitInfo.UnitName; ShortUnitName:=AnUnitInfo.UnitName;
@ -10016,7 +10014,7 @@ begin
Result:=mrOk; Result:=mrOk;
AnUnitInfo.IsPartOfProject:=false; AnUnitInfo.IsPartOfProject:=false;
if (Project1.MainUnitID>=0) if (Project1.MainUnitID>=0)
and (Project1.ProjectType in [ptProgram, ptApplication]) and (pfMainUnitHasUsesSectionForAllUnits in Project1.Flags)
then begin then begin
BeginCodeTool(ActiveSourceEditor,ActiveUnitInfo,[]); BeginCodeTool(ActiveSourceEditor,ActiveUnitInfo,[]);
ShortUnitName:=AnUnitInfo.UnitName; ShortUnitName:=AnUnitInfo.UnitName;
@ -10638,6 +10636,9 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.765 2004/09/01 10:25:58 mattias
added some project flags to start getting rid of TProjectType
Revision 1.764 2004/09/01 09:43:24 mattias Revision 1.764 2004/09/01 09:43:24 mattias
implemented registration of project file types implemented registration of project file types

View File

@ -287,7 +287,10 @@ type
TProjectFlag = ( TProjectFlag = (
pfSaveClosedUnits, // save info about closed files (not part of project) pfSaveClosedUnits, // save info about closed files (not part of project)
pfSaveOnlyProjectUnits // save no info about foreign files pfSaveOnlyProjectUnits, // save no info about foreign files
pfMainUnitIsPascalSource,// main unit is pascal, even it does not end in .pas/.pp
pfMainUnitHasUsesSectionForAllUnits,// add/remove pascal units to main uses section
pfRunnable // project can be run
); );
TProjectFlags = set of TProjectFlag; TProjectFlags = set of TProjectFlag;
@ -322,7 +325,7 @@ type
fJumpHistory: TProjectJumpHistory; fJumpHistory: TProjectJumpHistory;
fLastReadLPIFileDate: TDateTime; fLastReadLPIFileDate: TDateTime;
fLastReadLPIFilename: string; fLastReadLPIFilename: string;
fMainUnitID: Integer; // only for ptApplication, ptProgram, ptCGIApplication fMainUnitID: Integer;
fModified: boolean; fModified: boolean;
FOnBeginUpdate: TNotifyEvent; FOnBeginUpdate: TNotifyEvent;
FOnEndUpdate: TEndUpdateProjectEvent; FOnEndUpdate: TEndUpdateProjectEvent;
@ -546,9 +549,12 @@ const
'.lpr','.pas','.pas' '.lpr','.pas','.pas'
); );
DefaultProjectFlags = [pfSaveClosedUnits]; DefaultProjectFlags = [pfSaveClosedUnits,pfMainUnitIsPascalSource,
pfMainUnitHasUsesSectionForAllUnits,pfRunnable];
ProjectFlagNames : array[TProjectFlag] of string = ( ProjectFlagNames : array[TProjectFlag] of string = (
'SaveClosedFiles', 'SaveOnlyProjectUnits' 'SaveClosedFiles', 'SaveOnlyProjectUnits',
'MainUnitIsPascalSource', 'MainUnitHasUsesSectionForAllUnits',
'Runnable'
); );
function ProjectTypeNameToType(const s:string): TProjectType; function ProjectTypeNameToType(const s:string): TProjectType;
@ -558,7 +564,7 @@ function ProjectFlagsToStr(Flags: TProjectFlags): string;
implementation implementation
const const
ProjectInfoFileVersion = 3; ProjectInfoFileVersion = 4;
function ProjectFlagsToStr(Flags: TProjectFlags): string; function ProjectFlagsToStr(Flags: TProjectFlags): string;
var f: TProjectFlag; var f: TProjectFlag;
@ -1191,27 +1197,24 @@ begin
// create program source // create program source
NewSource:=TStringList.Create; NewSource:=TStringList.Create;
case fProjectType of case ProjectType of
ptProgram, ptApplication, ptCustomProgram: ptProgram, ptApplication, ptCustomProgram:
begin begin
NewPrgBuf:=CodeToolBoss.CreateFile( NewPrgBuf:=CodeToolBoss.CreateFile(
'project1'+ProjectDefaultExt[fProjectType]); 'project1'+ProjectDefaultExt[ProjectType]);
PrgUnitInfo:=TUnitInfo.Create(NewPrgBuf); PrgUnitInfo:=TUnitInfo.Create(NewPrgBuf);
PrgUnitInfo.IsPartOfProject:=true; PrgUnitInfo.IsPartOfProject:=true;
PrgUnitInfo.SyntaxHighlighter:= PrgUnitInfo.SyntaxHighlighter:=
ExtensionToLazSyntaxHighlighter(ProjectDefaultExt[fProjectType]); ExtensionToLazSyntaxHighlighter(ProjectDefaultExt[ProjectType]);
AddUnit(PrgUnitInfo,false); AddUnit(PrgUnitInfo,false);
MainUnitID:=0; MainUnitID:=0;
with NewSource do begin with NewSource do begin
Add('program Project1;'); Add('program Project1;');
Add(''); Add('');
Add('{$mode objfpc}{$H+}'); Add('{$mode objfpc}{$H+}');
// This results in crashing programs, when stdout is not open
//if fProjectType in [ptApplication] then
// Add('{$AppType Gui} // for win32 applications');
Add(''); Add('');
Add('uses'); Add('uses');
case fProjectType of case ProjectType of
ptProgram, ptCustomProgram: ptProgram, ptCustomProgram:
Add(' Classes;'); Add(' Classes;');
ptApplication: ptApplication:
@ -1224,7 +1227,7 @@ begin
end; end;
Add(''); Add('');
Add('begin'); Add('begin');
case fProjectType of case ProjectType of
ptApplication: ptApplication:
begin begin
Add(' Application.Initialize;'); Add(' Application.Initialize;');
@ -1455,6 +1458,12 @@ var
end; end;
procedure LoadFlags; procedure LoadFlags;
procedure SetFlag(f: TProjectFlag; Value: boolean);
begin
if Value then Include(FFlags,f) else Exclude(FFlags,f);
end;
var f: TProjectFlag; var f: TProjectFlag;
begin begin
FFlags:=[]; FFlags:=[];
@ -1466,6 +1475,14 @@ var
else else
Exclude(FFlags,f); Exclude(FFlags,f);
end; end;
if FileVersion<=3 then begin
// set new flags
SetFlag(pfMainUnitIsPascalSource,
ProjectType in [ptProgram,ptApplication]);
SetFlag(pfMainUnitHasUsesSectionForAllUnits,
ProjectType in [ptProgram,ptApplication]);
SetFlag(pfRunnable,ProjectType in [ptProgram,ptApplication,ptCustomProgram]);
end;
end; end;
begin begin
@ -2451,8 +2468,7 @@ begin
end; end;
end; end;
end; end;
if (OldUnitName<>'') if (OldUnitName<>'') and (pfMainUnitHasUsesSectionForAllUnits in Flags) then
and (ProjectType in [ptProgram, ptApplication]) then
begin begin
// rename unit in program uses section // rename unit in program uses section
CodeToolBoss.RenameUsedUnit(MainUnitInfo.Source CodeToolBoss.RenameUsedUnit(MainUnitInfo.Source
@ -2802,6 +2818,9 @@ end.
{ {
$Log$ $Log$
Revision 1.160 2004/09/01 10:25:58 mattias
added some project flags to start getting rid of TProjectType
Revision 1.159 2004/09/01 09:43:24 mattias Revision 1.159 2004/09/01 09:43:24 mattias
implemented registration of project file types implemented registration of project file types

View File

@ -243,7 +243,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TCustomComboBox.GetSelText: string; function TCustomComboBox.GetSelText: string;
begin begin
debugln('TCustomComboBox.GetSelText '); //debugln('TCustomComboBox.GetSelText ');
if FStyle in [csDropDown, csSimple] then if FStyle in [csDropDown, csSimple] then
Result:= Copy(Text, SelStart, SelLength) Result:= Copy(Text, SelStart, SelLength)
else else
@ -261,7 +261,7 @@ procedure TCustomComboBox.SetSelText(const Val: string);
var var
OldText, NewText: string; OldText, NewText: string;
begin begin
debugln('TCustomComboBox.SetSelText ',Val); //debugln('TCustomComboBox.SetSelText ',Val);
if FStyle in [csDropDown, csSimple] then begin if FStyle in [csDropDown, csSimple] then begin
OldText:=Text; OldText:=Text;
NewText:=LeftStr(OldText,SelStart-1)+Val NewText:=LeftStr(OldText,SelStart-1)+Val
@ -337,7 +337,7 @@ procedure TCustomComboBox.SelectAll;
var var
CurText: String; CurText: String;
begin begin
debugln('TCustomComboBox.SelectAll '); //debugln('TCustomComboBox.SelectAll ');
if (FStyle in [csDropDown, csSimple]) then begin if (FStyle in [csDropDown, csSimple]) then begin
CurText:=Text; CurText:=Text;
if (CurText <> '') then begin if (CurText <> '') then begin
@ -409,7 +409,7 @@ begin
end; end;
if Style=csDropDownList then begin if Style=csDropDownList then begin
debugln('TCustomComboBox.KeyDown '); //debugln('TCustomComboBox.KeyDown ');
// DropDownList: allow only navigation keys // DropDownList: allow only navigation keys
if not (Key in [VK_UP,VK_DOWN,VK_END,VK_HOME,VK_PRIOR,VK_NEXT,VK_TAB, if not (Key in [VK_UP,VK_DOWN,VK_END,VK_HOME,VK_PRIOR,VK_NEXT,VK_TAB,
VK_RETURN]) VK_RETURN])
@ -799,6 +799,9 @@ end;
{ {
$Log$ $Log$
Revision 1.44 2004/09/01 10:25:58 mattias
added some project flags to start getting rid of TProjectType
Revision 1.43 2004/08/30 10:49:20 mattias Revision 1.43 2004/08/30 10:49:20 mattias
fixed focus catch for combobox csDropDownList fixed focus catch for combobox csDropDownList