mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-13 10:29:29 +02:00
Added code so the unit source changes when you do a SAVE AS
Shane git-svn-id: trunk@193 -
This commit is contained in:
parent
30734a16b7
commit
33d621a672
15
ide/main.pp
15
ide/main.pp
@ -147,6 +147,7 @@ type
|
|||||||
procedure mnuEnvEditorOptionsClicked(Sender : TObject);
|
procedure mnuEnvEditorOptionsClicked(Sender : TObject);
|
||||||
|
|
||||||
Procedure OpenFileDownArrowClicked(Sender : TObject);
|
Procedure OpenFileDownArrowClicked(Sender : TObject);
|
||||||
|
Procedure OpenRecentFile(Sender : TObject);
|
||||||
Procedure FileClosedEvent(Sender : TObject; Filename : String);
|
Procedure FileClosedEvent(Sender : TObject; Filename : String);
|
||||||
Procedure FileOpenedEvent(Sender : TObject; Filename : String);
|
Procedure FileOpenedEvent(Sender : TObject; Filename : String);
|
||||||
Procedure FileSavedEvent(Sender : TObject; Filename : String);
|
Procedure FileSavedEvent(Sender : TObject; Filename : String);
|
||||||
@ -1277,6 +1278,14 @@ Begin
|
|||||||
OpenFilePopupMenu.Popup(0,0);
|
OpenFilePopupMenu.Popup(0,0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Procedure TMainIDE.OpenRecentFile(Sender : TObject);
|
||||||
|
Begin
|
||||||
|
// SourceNotebook.OpenFile(TMenuItem(sender).Caption,True);
|
||||||
|
Application.MEssagebox('Not yet implemented','Error',MB_OK);
|
||||||
|
End;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
{
|
{
|
||||||
This function creates a LFM file from any form.
|
This function creates a LFM file from any form.
|
||||||
@ -1358,7 +1367,7 @@ Begin
|
|||||||
//Add a new menuitem to the popup that displays the filename.
|
//Add a new menuitem to the popup that displays the filename.
|
||||||
MenuItem := TMenuItem.Create(Self);
|
MenuItem := TMenuItem.Create(Self);
|
||||||
MenuItem.Caption := Filename;
|
MenuItem.Caption := Filename;
|
||||||
MenuItem.OnClick := @SourceNotebook.OpenClicked;
|
MenuItem.OnClick := @OpenRecentFile;
|
||||||
OpenFilePopupMenu.Items.Add(MenuItem);
|
OpenFilePopupMenu.Items.Add(MenuItem);
|
||||||
|
|
||||||
Texts := Filename;
|
Texts := Filename;
|
||||||
@ -1782,6 +1791,10 @@ end.
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.63 2001/02/23 18:37:17 lazarus
|
||||||
|
Added code so the unit source changes when you do a SAVE AS
|
||||||
|
Shane
|
||||||
|
|
||||||
Revision 1.62 2001/02/22 17:04:57 lazarus
|
Revision 1.62 2001/02/22 17:04:57 lazarus
|
||||||
added environment options + killed ide unit circles
|
added environment options + killed ide unit circles
|
||||||
|
|
||||||
|
@ -1147,7 +1147,8 @@ Begin
|
|||||||
try
|
try
|
||||||
Add('unit '+FUnitName+';');
|
Add('unit '+FUnitName+';');
|
||||||
Add('');
|
Add('');
|
||||||
Add('{$mode objfpc}{$H+}');
|
Add('{$mode objfpc}');
|
||||||
|
Add('{$H+}');
|
||||||
Add('');
|
Add('');
|
||||||
Add('interface');
|
Add('interface');
|
||||||
Add('');
|
Add('');
|
||||||
@ -1253,13 +1254,65 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
Function TSourceEditor.Save : Boolean;
|
Function TSourceEditor.Save : Boolean;
|
||||||
|
var
|
||||||
|
s : TStringList;
|
||||||
|
I,X : Integer;
|
||||||
|
Texts : String;
|
||||||
|
NewUnitName : String;
|
||||||
|
Found : Boolean;
|
||||||
Begin
|
Begin
|
||||||
Result := True;
|
Result := True;
|
||||||
If Assigned(FOnBeforeSave) then FOnBeforeSave(Self);
|
If Assigned(FOnBeforeSave) then FOnBeforeSave(Self);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
//change the unitname
|
||||||
|
Found := False;
|
||||||
|
S := TStringList.Create;
|
||||||
|
S.Assign(FEditor.Lines);
|
||||||
|
I := 0;
|
||||||
|
NewUnitName := ExtractFileName(FileName); //in case there is a path
|
||||||
|
If ExtractFileExt(FileName) <> '' then
|
||||||
|
NewUnitName := Copy(NewUnitName,1,length(NewUnitName)-length(ExtractFileExt(Filename)));
|
||||||
|
While I < S.Count do
|
||||||
|
Begin
|
||||||
|
Texts := S.Strings[i];
|
||||||
|
Writeln('Texts = '+Texts);
|
||||||
|
if (pos('unit',lowercase(texts)) <> 0) and
|
||||||
|
(pos(lowercase(unitname)+';',Lowercase(texts)) <> 0) then
|
||||||
|
Begin
|
||||||
|
X := pos(lowercase(unitname)+';',Lowercase(texts));
|
||||||
|
delete(Texts,x,length(unitname));
|
||||||
|
insert(NewUnitName,Texts,x);
|
||||||
|
S.Strings[i] := Texts;
|
||||||
|
Found := True;
|
||||||
|
Break;
|
||||||
|
end;
|
||||||
|
inc(i);
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
if Found then
|
||||||
|
Begin
|
||||||
|
I := 0;
|
||||||
|
While I < S.Count do
|
||||||
|
Begin
|
||||||
|
Texts := S.Strings[i];
|
||||||
|
if pos(lowercase(format('{$I %s.lrc}',[UnitName])),lowercase(Texts)) <> 0 then
|
||||||
|
Begin
|
||||||
|
X := pos(lowercase(format('{$I %s.lrc}',[UnitName])),Lowercase(Texts));
|
||||||
|
delete(Texts,x,length(format('{$I %s.lrc}',[UnitName])));
|
||||||
|
insert(format('{$I %s.lrc}',[NewUnitName]),Texts,x);
|
||||||
|
S.Strings[i] := Texts;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
inc(i);
|
||||||
|
end;
|
||||||
|
FEditor.Lines.Assign(s);
|
||||||
|
end;
|
||||||
|
|
||||||
FEditor.Lines.SaveToFile(FileName);
|
FEditor.Lines.SaveToFile(FileName);
|
||||||
FEditor.Modified := False;
|
FEditor.Modified := False;
|
||||||
|
UnitName := NewUnitName;
|
||||||
except
|
except
|
||||||
Result := False;
|
Result := False;
|
||||||
end;
|
end;
|
||||||
@ -2089,12 +2142,6 @@ Procedure TSourceNotebook.OpenClicked(Sender: TObject);
|
|||||||
Var
|
Var
|
||||||
TempEditor : TSourceEditor;
|
TempEditor : TSourceEditor;
|
||||||
Begin
|
Begin
|
||||||
if (sender is TMenuItem)
|
|
||||||
and (TMenuItem(sender).name <> 'FileOpen') then
|
|
||||||
//the down arrow next to open was selected
|
|
||||||
OpenFile(TMenuItem(sender).Caption,True)
|
|
||||||
else
|
|
||||||
Begin
|
|
||||||
FOpenDialog.Title := 'Open';
|
FOpenDialog.Title := 'Open';
|
||||||
if FOpenDialog.Execute then Begin
|
if FOpenDialog.Execute then Begin
|
||||||
//create a new page
|
//create a new page
|
||||||
@ -2115,7 +2162,6 @@ Begin
|
|||||||
TempEditor.Visible := True;
|
TempEditor.Visible := True;
|
||||||
UpdateStatusBar;
|
UpdateStatusBar;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TSourceNotebook.FindClicked(Sender : TObject);
|
Procedure TSourceNotebook.FindClicked(Sender : TObject);
|
||||||
@ -2295,6 +2341,7 @@ Begin
|
|||||||
else
|
else
|
||||||
SaveAsClicked(Sender);
|
SaveAsClicked(Sender);
|
||||||
UpdateStatusBar;
|
UpdateStatusBar;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TSourceNotebook.ActiveUnitName : String;
|
Function TSourceNotebook.ActiveUnitName : String;
|
||||||
|
Loading…
Reference in New Issue
Block a user