diff --git a/ide/codetools.pp b/ide/codetools.pp index 60e20eeb22..e8fba4ed87 100644 --- a/ide/codetools.pp +++ b/ide/codetools.pp @@ -94,7 +94,7 @@ const IdentifierStartChar = ['a'..'z','A'..'Z','_']; IdentifierChar = ['a'..'z','A'..'Z','_','0'..'9']; // ToDo: find the constant in the fpc units. - EndOfLine:shortstring={$IFDEF win32}#13{$ENDIF}#10; + EndOfLine:shortstring={$IFDEF win32}#13+{$ENDIF}#10; function FindIncludeDirective(Source,Section:string; Index:integer; diff --git a/ide/keymapping.pp b/ide/keymapping.pp index 8fd723f499..e9370a79f9 100644 --- a/ide/keymapping.pp +++ b/ide/keymapping.pp @@ -41,6 +41,7 @@ const ecClose = ecOpen + 2; ecJumpToEditor = ecUserFirst + 300; + ecToggleFormUnit = ecUserFirst + 301; ecGotoEditor1 = ecUserFirst + 2000; ecGotoEditor2 = ecGotoEditor1 + 1; @@ -740,6 +741,8 @@ begin Add('Go to source editor 8',ecGotoEditor0,VK_8,[ssAlt],VK_UNKNOWN,[]); Add('Go to source editor 9',ecGotoEditor0,VK_9,[ssAlt],VK_UNKNOWN,[]); Add('Go to source editor 10',ecGotoEditor0,VK_0,[ssAlt],VK_UNKNOWN,[]); + + Add('Toggle between Unit and Form',ecToggleFormUnit,VK_F12,[],VK_UNKNOWN,[]); end; destructor TKeyCommandRelationList.Destroy; @@ -923,3 +926,4 @@ initialization KeyMappingEditForm:=nil; end. + diff --git a/ide/main.pp b/ide/main.pp index 98781352dc..7ff0958d9b 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -134,8 +134,7 @@ type Procedure mnuViewUnitsClicked(Sender : TObject); Procedure mnuViewFormsClicked(Sender : TObject); - Procedure mnuToggleFormClicked(Sender : TObject); - Procedure CodeOrFormActivated(Sender : TObject); + procedure mnuToggleFormUnitClicked(Sender : TObject); procedure mnuNewProjectClicked(Sender : TObject); procedure mnuOpenProjectClicked(Sender : TObject); @@ -164,6 +163,7 @@ type Procedure OnSrcNotebookFileSaveAs(Sender : TObject); Procedure OnSrcNotebookFileClose(Sender : TObject); Procedure OnSrcNotebookSaveAll(Sender : TObject); + Procedure OnSrcNotebookToggleFormUnit(Sender : TObject); // ObjectInspector events procedure OIOnAddAvailableComponent(AComponent:TComponent; var Allowed:boolean); @@ -177,7 +177,6 @@ type private FCodeLastActivated : Boolean; //used for toggling between code and forms - FControlLastActivated : TObject; FSelectedComponent : TRegisteredComponent; fProject: TProject; @@ -224,6 +223,7 @@ type IsPartOfProject:boolean): TModalResult; procedure UpdateCaption; procedure UpdateMainUnitSrcEdit; + procedure DoBringToFrontFormOrUnit; procedure LoadMainMenu; Procedure FormKill(Sender : TObject); @@ -512,7 +512,7 @@ begin Enabled := True; Top := 28; Left := SaveAllSpeedBtn.Left + 26; - OnClick := @mnuToggleFormCLicked; + OnClick := @mnuToggleFormUnitCLicked; Glyph := LoadSpeedBtnPixMap('btn_toggleform'); Visible := True; Flat := true; @@ -575,7 +575,6 @@ begin // connect events SourceNotebook := TSourceNotebook.Create(Self); - SourceNotebook.OnActivate := @CodeOrFormActivated; SourceNotebook.OnNewClicked := @OnSrcNotebookFileNew; SourceNotebook.OnOpenClicked := @ OnSrcNotebookFileOpen; SourceNotebook.OnOpenFileAtCursorClicked := @OnSrcNotebookFileOpenAtCursor; @@ -583,6 +582,7 @@ begin SourceNotebook.OnSaveAsClicked := @OnSrcNotebookFileSaveAs; SourceNotebook.OnCloseClicked := @OnSrcNotebookFileClose; SourceNotebook.OnSaveAllClicked := @OnSrcNotebookSaveAll; + SourceNotebook.OnToggleFormUnitClicked := @OnSrcNotebookToggleFormUnit; itmSearchFind.OnClick := @SourceNotebook.FindClicked; itmSearchFindAgain.OnClick := @SourceNotebook.FindAgainClicked; @@ -981,21 +981,11 @@ end; {------------------------------------------------------------------------------} {------------------------------------------------------------------------------} -Procedure TMainIDE.mnuToggleFormClicked(Sender : TObject); +Procedure TMainIDE.mnuToggleFormUnitClicked(Sender : TObject); Begin writeln('Toggle form clicked'); - - if FCodeLastActivated then - SourceNotebook.DisplayFormForActivePage - else - SourceNotebook.DisplayCodeforControl(FControlLastActivated); -end; - -Procedure TMainIDE.CodeOrFormActivated(Sender : TObject); -Begin - FCodeLastActivated := (TForm(Sender) = TForm(SourceNotebook)); - if FCodeLastActivated then Writeln('TRUE') else Writeln('False'); - FControlLastActivated := Sender; + FCodeLastActivated:=not FCodeLastActivated; + DoBringToFrontFormOrUnit; end; Procedure TMainIDE.SetDesigning(Control : TComponent; Value : Boolean); @@ -1201,6 +1191,10 @@ begin mnuSaveAllClicked(Sender); end; +Procedure TMainIDE.OnSrcNotebookToggleFormUnit(Sender : TObject); +begin + mnuToggleFormUnitClicked(Sender); +end; {------------------------------------------------------------------------------} @@ -1279,7 +1273,6 @@ Begin aForm.Designer := TDesigner.Create(aForm); TDesigner(aForm.Designer).MainIDE := Self; TDesigner(aForm.Designer).FormEditor := FormEditor1; - aForm.OnActivate := @CodeOrFormActivated; end; @@ -1572,6 +1565,7 @@ writeln('TMainIDE.DoNewEditorUnit 6'); end; UpdateMainUnitSrcEdit; + FCodeLastActivated:=not (NewUnitType in [nuForm]); writeln('TMainIDE.DoNewUnit end'); end; @@ -2062,6 +2056,8 @@ writeln('TMainIDE.mnuViewUnitsClicked 2'); end; end; end; + FCodeLastActivated:=not OnlyForms; + DoBringToFrontFormOrUnit; end; writeln('TMainIDE.mnuViewUnitsClicked 3'); finally @@ -2514,6 +2510,27 @@ begin end; end; +procedure TMainIDE.DoBringToFrontFormOrUnit; +var AForm: TCustomForm; + ActiveUnitInfo: TUnitInfo; +begin + if FCodeLastActivated then begin + if SourceNoteBook.NoteBook<>nil then AForm:=SourceNotebook + else AForm:=nil; + end else begin + if (SourceNoteBook.NoteBook<>nil) then begin + ActiveUnitInfo:=Project.UnitWithEditorIndex( + SourceNoteBook.NoteBook.PageIndex); + if (ActiveUnitInfo<>nil) then + AForm:=TCustomForm(ActiveUnitInfo.Form); + end; + end; + if AForm<>nil then begin + AForm.Hide; + AForm.Show; + end; +end; + initialization {$I images/laz_images.lrs} @@ -2526,8 +2543,8 @@ end. { ============================================================================= $Log$ - Revision 1.70 2001/03/08 15:59:06 lazarus - IDE bugfixes and viewunit/forms functionality + Revision 1.71 2001/03/08 23:11:49 lazarus + bugfixes Revision 1.68 2001/03/03 11:06:15 lazarus added project support, codetools diff --git a/ide/project.pp b/ide/project.pp index 38c9374cfd..7aadaa8edf 100644 --- a/ide/project.pp +++ b/ide/project.pp @@ -184,7 +184,7 @@ type //--------------------------------------------------------------------------- TProjectType = // for a description see ProjectTypeDescriptions - (ptApplication, ptCustomProgram, ptProgram); + (ptApplication, ptProgram, ptCustomProgram); TProject = class(TObject) private @@ -291,9 +291,18 @@ const ); +function ProjectTypeNameToType(s:string): TProjectType; + + implementation +function ProjectTypeNameToType(s:string): TProjectType; +begin + for Result:=Low(TProjectType) to High(TProjectType) do + if (lowercase(ProjectTypeNames[Result])=lowercase(s)) then exit; + Result:=ptCustomProgram; +end; { TProjectBookmark } @@ -842,6 +851,8 @@ begin try repeat try + xmlcfg.SetValue('ProjectOptions/General/ProjectType/Value', + ProjectTypeNames[ProjectType]); xmlcfg.SetValue('ProjectOptions/General/MainUnit/Value', MainUnit); xmlcfg.SetValue('ProjectOptions/General/ActiveEditorIndexAtStart/Value' ,ActiveEditorIndexAtStart); @@ -909,6 +920,8 @@ writeln('TProject.ReadProject 2 ',LPIFilename); writeln('TProject.ReadProject 3'); try + ProjectType := ProjectTypeNameToType(xmlcfg.GetValue( + 'ProjectOptions/General/ProjectType/Value', '')); MainUnit := xmlcfg.GetValue('ProjectOptions/General/MainUnit/Value', -1); ActiveEditorIndexAtStart := xmlcfg.GetValue( 'ProjectOptions/General/ActiveEditorIndexAtStart/Value', -1); @@ -1385,8 +1398,8 @@ end. { $Log$ - Revision 1.12 2001/03/08 15:59:06 lazarus - IDE bugfixes and viewunit/forms functionality + Revision 1.13 2001/03/08 23:11:49 lazarus + bugfixes Revision 1.10 2001/03/03 11:06:15 lazarus added project support, codetools diff --git a/ide/uniteditor.pp b/ide/uniteditor.pp index a4f16a9337..19f569004c 100644 --- a/ide/uniteditor.pp +++ b/ide/uniteditor.pp @@ -205,6 +205,7 @@ type FOnSaveClicked : TNotifyEvent; FOnSaveAsClicked : TNotifyEvent; FOnSaveAllClicked : TNotifyEvent; + FOnToggleFormUnitClicked : TNotifyEvent; // PopupMenu Procedure BuildPopupMenu; @@ -268,6 +269,7 @@ type procedure SaveClicked(Sender : TObject); procedure SaveAllClicked(Sender : TObject); procedure SaveAsClicked(Sender : TObject); + procedure ToggleFormUnitClicked(Sender: TObject); procedure FindClicked(Sender : TObject); procedure ReplaceClicked(Sender : TObject); @@ -306,6 +308,8 @@ type read FOnSaveAsClicked write FOnSaveAsClicked; property OnSaveAllClicked : TNotifyEvent read FOnSaveAllClicked write FOnSaveAllClicked; + property OnToggleFormUnitClicked : TNotifyEvent + read FOnToggleFormUnitClicked write FOnToggleFormUnitClicked; end; {Goto dialog} @@ -2378,6 +2382,11 @@ Begin if Assigned(FOnSaveAllClicked) then FOnSaveAllClicked(Sender); end; +procedure TSourceNotebook.ToggleFormUnitClicked(Sender: TObject); +begin + if Assigned(FOnToggleFormUnitClicked) then FOnToggleFormUnitClicked(Sender); +end; + Function TSourceNotebook.GetSourceForUnit(UnitName : String) : TStrings; Var I : Integer; @@ -2515,6 +2524,9 @@ begin if Notebook.Pages.Count>Command-ecGotoEditor1 then Notebook.PageIndex:=Command-ecGotoEditor1; + ecToggleFormUnit: + ToggleFormUnitClicked(self); + end; //case end;