mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 20:40:40 +02:00
MG: added Revert
git-svn-id: trunk@1782 -
This commit is contained in:
parent
63573ad171
commit
3a4fe1163d
@ -230,7 +230,7 @@ begin
|
|||||||
UnitFile := MainIDE.FindUnitFile(ALocation.SrcFile);
|
UnitFile := MainIDE.FindUnitFile(ALocation.SrcFile);
|
||||||
if UnitFile = ''
|
if UnitFile = ''
|
||||||
then UnitFile := ALocation.SrcFile;
|
then UnitFile := ALocation.SrcFile;
|
||||||
if MainIDE.DoOpenEditorFile(UnitFile, [ofOnlyIfExists]) <> mrOk then exit;
|
if MainIDE.DoOpenEditorFile(UnitFile,-1,[ofOnlyIfExists]) <> mrOk then exit;
|
||||||
|
|
||||||
ActiveSrcEdit := SourceNoteBook.GetActiveSE;
|
ActiveSrcEdit := SourceNoteBook.GetActiveSE;
|
||||||
if ActiveSrcEdit=nil then exit;
|
if ActiveSrcEdit=nil then exit;
|
||||||
|
@ -85,12 +85,13 @@ const
|
|||||||
ecNewUnit = ecUserFirst + 202;
|
ecNewUnit = ecUserFirst + 202;
|
||||||
ecNewForm = ecUserFirst + 203;
|
ecNewForm = ecUserFirst + 203;
|
||||||
ecOpen = ecUserFirst + 204;
|
ecOpen = ecUserFirst + 204;
|
||||||
ecSave = ecUserFirst + 205;
|
ecRevert = ecUserFirst + 205;
|
||||||
ecSaveAs = ecUserFirst + 206;
|
ecSave = ecUserFirst + 206;
|
||||||
ecSaveAll = ecUserFirst + 207;
|
ecSaveAs = ecUserFirst + 207;
|
||||||
ecClose = ecUserFirst + 208;
|
ecSaveAll = ecUserFirst + 208;
|
||||||
ecCloseAll = ecUserFirst + 209;
|
ecClose = ecUserFirst + 209;
|
||||||
ecQuit = ecUserFirst + 210;
|
ecCloseAll = ecUserFirst + 210;
|
||||||
|
ecQuit = ecUserFirst + 211;
|
||||||
|
|
||||||
ecJumpToEditor = ecUserFirst + 300;
|
ecJumpToEditor = ecUserFirst + 300;
|
||||||
ecToggleFormUnit = ecUserFirst + 301;
|
ecToggleFormUnit = ecUserFirst + 301;
|
||||||
@ -451,6 +452,7 @@ begin
|
|||||||
ecNewUnit: Result:='new unit';
|
ecNewUnit: Result:='new unit';
|
||||||
ecNewForm: Result:='new form';
|
ecNewForm: Result:='new form';
|
||||||
ecOpen: Result:= 'open';
|
ecOpen: Result:= 'open';
|
||||||
|
ecRevert: Result:= 'revert';
|
||||||
ecSave: Result:= 'save';
|
ecSave: Result:= 'save';
|
||||||
ecSaveAs: Result:= 'save as';
|
ecSaveAs: Result:= 'save as';
|
||||||
ecSaveAll: Result:= 'save all';
|
ecSaveAll: Result:= 'save all';
|
||||||
@ -1209,6 +1211,7 @@ begin
|
|||||||
Add(C,'NewUnit',ecNewUnit,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'NewUnit',ecNewUnit,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
Add(C,'NewForm',ecNewForm,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'NewForm',ecNewForm,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
Add(C,'Open',ecOpen,VK_O,[ssCtrl],VK_UNKNOWN,[]);
|
Add(C,'Open',ecOpen,VK_O,[ssCtrl],VK_UNKNOWN,[]);
|
||||||
|
Add(C,'Revert',ecRevert,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
Add(C,'Save',ecSave,VK_S,[ssCtrl],VK_UNKNOWN,[]);
|
Add(C,'Save',ecSave,VK_S,[ssCtrl],VK_UNKNOWN,[]);
|
||||||
Add(C,'SaveAs',ecSaveAs,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
Add(C,'SaveAs',ecSaveAs,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||||
Add(C,'SaveAll',ecSaveAll,VK_S,[ssCtrl,ssShift],VK_UNKNOWN,[]);
|
Add(C,'SaveAll',ecSaveAll,VK_S,[ssCtrl,ssShift],VK_UNKNOWN,[]);
|
||||||
|
@ -95,6 +95,7 @@ ResourceString
|
|||||||
lisMenuNewUnit = 'New Unit';
|
lisMenuNewUnit = 'New Unit';
|
||||||
lisMenuNewForm = 'New Form';
|
lisMenuNewForm = 'New Form';
|
||||||
lisMenuOpen = 'Open';
|
lisMenuOpen = 'Open';
|
||||||
|
lisMenuRevert = 'Revert';
|
||||||
lisMenuOpenRecent = 'Open Recent';
|
lisMenuOpenRecent = 'Open Recent';
|
||||||
lisMenuSave = 'Save';
|
lisMenuSave = 'Save';
|
||||||
lisMenuSaveAs = 'Save As';
|
lisMenuSaveAs = 'Save As';
|
||||||
|
249
ide/main.pp
249
ide/main.pp
@ -73,6 +73,7 @@ type
|
|||||||
procedure mnuNewUnitClicked(Sender : TObject);
|
procedure mnuNewUnitClicked(Sender : TObject);
|
||||||
procedure mnuNewFormClicked(Sender : TObject);
|
procedure mnuNewFormClicked(Sender : TObject);
|
||||||
procedure mnuOpenClicked(Sender : TObject);
|
procedure mnuOpenClicked(Sender : TObject);
|
||||||
|
procedure mnuRevertClicked(Sender : TObject);
|
||||||
procedure mnuSaveClicked(Sender : TObject);
|
procedure mnuSaveClicked(Sender : TObject);
|
||||||
procedure mnuSaveAsClicked(Sender : TObject);
|
procedure mnuSaveAsClicked(Sender : TObject);
|
||||||
procedure mnuSaveAllClicked(Sender : TObject);
|
procedure mnuSaveAllClicked(Sender : TObject);
|
||||||
@ -304,9 +305,12 @@ type
|
|||||||
var NewUnitInfo: TUnitInfo; var Handled: boolean): TModalResult;
|
var NewUnitInfo: TUnitInfo; var Handled: boolean): TModalResult;
|
||||||
procedure DoRestoreBookMarks(AnUnitInfo: TUnitInfo; ASrcEdit:TSourceEditor);
|
procedure DoRestoreBookMarks(AnUnitInfo: TUnitInfo; ASrcEdit:TSourceEditor);
|
||||||
function DoOpenFileInSourceNotebook(AnUnitInfo: TUnitInfo;
|
function DoOpenFileInSourceNotebook(AnUnitInfo: TUnitInfo;
|
||||||
Flags: TOpenFlags): TModalResult;
|
PageIndex: integer; Flags: TOpenFlags): TModalResult;
|
||||||
function DoLoadLFM(AnUnitInfo: TUnitInfo; Flags: TOpenFlags): TModalResult;
|
function DoLoadLFM(AnUnitInfo: TUnitInfo; Flags: TOpenFlags): TModalResult;
|
||||||
|
|
||||||
|
// methods for 'close unit'
|
||||||
|
function CloseDesignerForm(AnUnitInfo: TUnitInfo): TModalResult;
|
||||||
|
|
||||||
// methods for 'save project'
|
// methods for 'save project'
|
||||||
procedure GetMainUnit(var MainUnitInfo: TUnitInfo;
|
procedure GetMainUnit(var MainUnitInfo: TUnitInfo;
|
||||||
var MainUnitSrcEdit: TSourceEditor; UpdateModified: boolean);
|
var MainUnitSrcEdit: TSourceEditor; UpdateModified: boolean);
|
||||||
@ -323,13 +327,13 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
// files/units
|
// files/units
|
||||||
function DoNewEditorUnit(NewUnitType:TNewUnitType;
|
function DoNewEditorFile(NewUnitType:TNewUnitType;
|
||||||
NewFilename: string):TModalResult;
|
NewFilename: string):TModalResult;
|
||||||
function DoSaveEditorUnit(PageIndex:integer;
|
function DoSaveEditorFile(PageIndex:integer;
|
||||||
Flags: TSaveFlags): TModalResult;
|
Flags: TSaveFlags): TModalResult;
|
||||||
function DoCloseEditorUnit(PageIndex:integer;
|
function DoCloseEditorFile(PageIndex:integer;
|
||||||
SaveFirst: boolean):TModalResult;
|
SaveFirst: boolean):TModalResult;
|
||||||
function DoOpenEditorFile(const AFileName:string;
|
function DoOpenEditorFile(AFileName:string; PageIndex: integer;
|
||||||
Flags: TOpenFlags): TModalResult; override;
|
Flags: TOpenFlags): TModalResult; override;
|
||||||
function DoOpenFileAtCursor(Sender: TObject): TModalResult;
|
function DoOpenFileAtCursor(Sender: TObject): TModalResult;
|
||||||
function DoSaveAll: TModalResult;
|
function DoSaveAll: TModalResult;
|
||||||
@ -1198,6 +1202,12 @@ begin
|
|||||||
itmFileOpen.OnClick := @mnuOpenClicked;
|
itmFileOpen.OnClick := @mnuOpenClicked;
|
||||||
mnuFile.Add(itmFileOpen);
|
mnuFile.Add(itmFileOpen);
|
||||||
|
|
||||||
|
itmFileRevert := TMenuItem.Create(Self);
|
||||||
|
itmFileRevert.Name:='itmFileRevert';
|
||||||
|
itmFileRevert.Caption := lisMenuRevert;
|
||||||
|
itmFileRevert.OnClick := @mnuRevertClicked;
|
||||||
|
mnuFile.Add(itmFileRevert);
|
||||||
|
|
||||||
itmFileRecentOpen := TMenuItem.Create(Self);
|
itmFileRecentOpen := TMenuItem.Create(Self);
|
||||||
itmFileRecentOpen.Name:='itmFileRecentOpen';
|
itmFileRecentOpen.Name:='itmFileRecentOpen';
|
||||||
itmFileRecentOpen.Caption := lisMenuOpenRecent;
|
itmFileRecentOpen.Caption := lisMenuOpenRecent;
|
||||||
@ -1763,12 +1773,12 @@ end;
|
|||||||
|
|
||||||
procedure TMainIDE.mnuNewUnitClicked(Sender : TObject);
|
procedure TMainIDE.mnuNewUnitClicked(Sender : TObject);
|
||||||
begin
|
begin
|
||||||
DoNewEditorUnit(nuUnit,'');
|
DoNewEditorFile(nuUnit,'');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.mnuNewFormClicked(Sender : TObject);
|
procedure TMainIDE.mnuNewFormClicked(Sender : TObject);
|
||||||
begin
|
begin
|
||||||
DoNewEditorUnit(nuForm,'');
|
DoNewEditorFile(nuForm,'');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.mnuOpenClicked(Sender : TObject);
|
procedure TMainIDE.mnuOpenClicked(Sender : TObject);
|
||||||
@ -1787,7 +1797,7 @@ begin
|
|||||||
For I := 0 to OpenDialog.Files.Count-1 do
|
For I := 0 to OpenDialog.Files.Count-1 do
|
||||||
Begin
|
Begin
|
||||||
AFilename:=ExpandFilename(OpenDialog.Files.Strings[i]);
|
AFilename:=ExpandFilename(OpenDialog.Files.Strings[i]);
|
||||||
if DoOpenEditorFile(AFilename,[])=mrOk then begin
|
if DoOpenEditorFile(AFilename,-1,[])=mrOk then begin
|
||||||
EnvironmentOptions.AddToRecentOpenFiles(AFilename);
|
EnvironmentOptions.AddToRecentOpenFiles(AFilename);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1799,13 +1809,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
end else if Sender is TMenuItem then begin
|
end else if Sender is TMenuItem then begin
|
||||||
AFileName:=ExpandFilename(TMenuItem(Sender).Caption);
|
AFileName:=ExpandFilename(TMenuItem(Sender).Caption);
|
||||||
if DoOpenEditorFile(AFilename,[])=mrOk then begin
|
if DoOpenEditorFile(AFilename,-1,[])=mrOk then begin
|
||||||
EnvironmentOptions.AddToRecentOpenFiles(AFilename);
|
EnvironmentOptions.AddToRecentOpenFiles(AFilename);
|
||||||
SaveEnvironment;
|
SaveEnvironment;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainIDE.mnuRevertClicked(Sender : TObject);
|
||||||
|
begin
|
||||||
|
if SourceNoteBook.NoteBook=nil then exit;
|
||||||
|
DoOpenEditorFile('',SourceNoteBook.NoteBook.PageIndex,[ofRevert]);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.mnuOpenFileAtCursorClicked(Sender : TObject);
|
procedure TMainIDE.mnuOpenFileAtCursorClicked(Sender : TObject);
|
||||||
begin
|
begin
|
||||||
if SourceNoteBook.NoteBook=nil then exit;
|
if SourceNoteBook.NoteBook=nil then exit;
|
||||||
@ -1820,13 +1836,13 @@ end;
|
|||||||
procedure TMainIDE.mnuSaveClicked(Sender : TObject);
|
procedure TMainIDE.mnuSaveClicked(Sender : TObject);
|
||||||
begin
|
begin
|
||||||
if SourceNoteBook.NoteBook=nil then exit;
|
if SourceNoteBook.NoteBook=nil then exit;
|
||||||
DoSaveEditorUnit(SourceNoteBook.NoteBook.PageIndex,[]);
|
DoSaveEditorFile(SourceNoteBook.NoteBook.PageIndex,[]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.mnuSaveAsClicked(Sender : TObject);
|
procedure TMainIDE.mnuSaveAsClicked(Sender : TObject);
|
||||||
begin
|
begin
|
||||||
if SourceNoteBook.NoteBook=nil then exit;
|
if SourceNoteBook.NoteBook=nil then exit;
|
||||||
DoSaveEditorUnit(SourceNoteBook.NoteBook.PageIndex,[sfSaveAs]);
|
DoSaveEditorFile(SourceNoteBook.NoteBook.PageIndex,[sfSaveAs]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.mnuSaveAllClicked(Sender : TObject);
|
procedure TMainIDE.mnuSaveAllClicked(Sender : TObject);
|
||||||
@ -1845,13 +1861,13 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
PageIndex:=SourceNoteBook.NoteBook.PageIndex;
|
PageIndex:=SourceNoteBook.NoteBook.PageIndex;
|
||||||
end;
|
end;
|
||||||
DoCloseEditorUnit(PageIndex,true);
|
DoCloseEditorFile(PageIndex,true);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.mnuCloseAllClicked(Sender : TObject);
|
procedure TMainIDE.mnuCloseAllClicked(Sender : TObject);
|
||||||
begin
|
begin
|
||||||
while (SourceNoteBook.NoteBook<>nil)
|
while (SourceNoteBook.NoteBook<>nil)
|
||||||
and (DoCloseEditorUnit(SourceNoteBook.NoteBook.PageIndex,true)=mrOk) do ;
|
and (DoCloseEditorFile(SourceNoteBook.NoteBook.PageIndex,true)=mrOk) do ;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TMainIDE.OnSrcNotebookFileNew(Sender : TObject);
|
Procedure TMainIDE.OnSrcNotebookFileNew(Sender : TObject);
|
||||||
@ -2958,9 +2974,9 @@ begin
|
|||||||
begin
|
begin
|
||||||
// create new file
|
// create new file
|
||||||
if FilenameIsPascalSource(AFilename) then
|
if FilenameIsPascalSource(AFilename) then
|
||||||
Result:=DoNewEditorUnit(nuUnit,AFilename)
|
Result:=DoNewEditorFile(nuUnit,AFilename)
|
||||||
else
|
else
|
||||||
Result:=DoNewEditorUnit(nuEmpty,AFilename);
|
Result:=DoNewEditorFile(nuEmpty,AFilename);
|
||||||
end else if ofOnlyIfExists in Flags then begin
|
end else if ofOnlyIfExists in Flags then begin
|
||||||
MessageDlg('File not found','File "'+AFilename+'" not found.'#13,
|
MessageDlg('File not found','File "'+AFilename+'" not found.'#13,
|
||||||
mtInformation,[mbCancel],0);
|
mtInformation,[mbCancel],0);
|
||||||
@ -3069,6 +3085,8 @@ var
|
|||||||
CInterface: TComponentInterface;
|
CInterface: TComponentInterface;
|
||||||
TempForm: TCustomForm;
|
TempForm: TCustomForm;
|
||||||
begin
|
begin
|
||||||
|
CloseDesignerForm(AnUnitInfo);
|
||||||
|
|
||||||
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename,'.lfm');
|
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename,'.lfm');
|
||||||
LFMBuf:=nil;
|
LFMBuf:=nil;
|
||||||
if FileExists(LFMFilename) then begin
|
if FileExists(LFMFilename) then begin
|
||||||
@ -3145,9 +3163,9 @@ begin
|
|||||||
FLastFormActivated:=TempForm;
|
FLastFormActivated:=TempForm;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{$IFDEF IDE_DEBUG}
|
{$IFDEF IDE_DEBUG}
|
||||||
writeln('[TMainIDE.DoLoadLFM] LFM end');
|
writeln('[TMainIDE.DoLoadLFM] LFM end');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
finally
|
finally
|
||||||
BinLFMStream.Free;
|
BinLFMStream.Free;
|
||||||
end;
|
end;
|
||||||
@ -3155,6 +3173,38 @@ writeln('[TMainIDE.DoLoadLFM] LFM end');
|
|||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{-------------------------------------------------------------------------------
|
||||||
|
function TMainIDE.CloseDesignerForm
|
||||||
|
|
||||||
|
Params: AnUnitInfo: TUnitInfo
|
||||||
|
Result: TModalResult;
|
||||||
|
|
||||||
|
Free the designer form of a unit.
|
||||||
|
-------------------------------------------------------------------------------}
|
||||||
|
function TMainIDE.CloseDesignerForm(AnUnitInfo: TUnitInfo): TModalResult;
|
||||||
|
var
|
||||||
|
AForm: TCustomForm;
|
||||||
|
i: integer;
|
||||||
|
OldDesigner: TDesigner;
|
||||||
|
begin
|
||||||
|
AForm:=TCustomForm(AnUnitInfo.Form);
|
||||||
|
if AForm<>nil then begin
|
||||||
|
if FLastFormActivated=AForm then
|
||||||
|
FLastFormActivated:=nil;
|
||||||
|
// unselect controls
|
||||||
|
for i:=AForm.ComponentCount-1 downto 0 do
|
||||||
|
TheControlSelection.Remove(
|
||||||
|
AForm.Components[i]);
|
||||||
|
TheControlSelection.Remove(AForm);
|
||||||
|
// free designer and design form
|
||||||
|
OldDesigner:=TDesigner(AForm.Designer);
|
||||||
|
FormEditor1.DeleteControl(AForm);
|
||||||
|
OldDesigner.Free;
|
||||||
|
AnUnitInfo.Form:=nil;
|
||||||
|
end;
|
||||||
|
Result:=mrOk;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMainIDE.GetMainUnit(var MainUnitInfo: TUnitInfo;
|
procedure TMainIDE.GetMainUnit(var MainUnitInfo: TUnitInfo;
|
||||||
var MainUnitSrcEdit: TSourceEditor; UpdateModified: boolean);
|
var MainUnitSrcEdit: TSourceEditor; UpdateModified: boolean);
|
||||||
begin
|
begin
|
||||||
@ -3390,19 +3440,32 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TMainIDE.DoOpenFileInSourceNotebook(AnUnitInfo: TUnitInfo;
|
function TMainIDE.DoOpenFileInSourceNotebook(AnUnitInfo: TUnitInfo;
|
||||||
Flags: TOpenFlags): TModalResult;
|
PageIndex: integer; Flags: TOpenFlags): TModalResult;
|
||||||
var NewSrcEdit: TSourceEditor;
|
var NewSrcEdit: TSourceEditor;
|
||||||
AFilename: string;
|
AFilename: string;
|
||||||
|
NewSrcEditorCreated: boolean;
|
||||||
begin
|
begin
|
||||||
AFilename:=AnUnitInfo.Filename;
|
AFilename:=AnUnitInfo.Filename;
|
||||||
|
|
||||||
// create a new source editor
|
// get syntax highlighter type
|
||||||
if not AnUnitInfo.CustomHighlighter then
|
if not AnUnitInfo.CustomHighlighter then
|
||||||
AnUnitInfo.SyntaxHighlighter:=
|
AnUnitInfo.SyntaxHighlighter:=
|
||||||
ExtensionToLazSyntaxHighlighter(ExtractFileExt(AFilename));
|
ExtensionToLazSyntaxHighlighter(ExtractFileExt(AFilename));
|
||||||
SourceNotebook.NewFile(CreateSrcEditPageName(AnUnitInfo.UnitName,
|
|
||||||
AFilename,-1),AnUnitInfo.Source);
|
if (not (ofRevert in Flags)) or (PageIndex<0) then begin
|
||||||
NewSrcEdit:=SourceNotebook.GetActiveSE;
|
// create a new source editor
|
||||||
|
SourceNotebook.NewFile(CreateSrcEditPageName(AnUnitInfo.UnitName,
|
||||||
|
AFilename,-1),AnUnitInfo.Source);
|
||||||
|
NewSrcEdit:=SourceNotebook.GetActiveSE;
|
||||||
|
NewSrcEditorCreated:=true;
|
||||||
|
end else begin
|
||||||
|
// revert code in existing source editor
|
||||||
|
NewSrcEdit:=SourceNotebook.FindSourceEditorWithPageIndex(PageIndex);
|
||||||
|
AnUnitInfo.Source.AssignTo(NewSrcEdit.EditorComponent.Lines);
|
||||||
|
NewSrcEdit.Modified:=false;
|
||||||
|
AnUnitInfo.Modified:=false;
|
||||||
|
NewSrcEditorCreated:=false;
|
||||||
|
end;
|
||||||
|
|
||||||
if ofProjectLoading in Flags then begin
|
if ofProjectLoading in Flags then begin
|
||||||
// reloading the project -> restore marks
|
// reloading the project -> restore marks
|
||||||
@ -3410,9 +3473,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// update editor indices in project
|
// update editor indices in project
|
||||||
if not (ofProjectLoading in Flags) then
|
if (not (ofProjectLoading in Flags)) and NewSrcEditorCreated then
|
||||||
Project1.InsertEditorIndex(SourceNotebook.NoteBook.PageIndex);
|
Project1.InsertEditorIndex(SourceNotebook.NoteBook.PageIndex);
|
||||||
AnUnitInfo.EditorIndex:=SourceNotebook.NoteBook.PageIndex;
|
AnUnitInfo.EditorIndex:=SourceNotebook.FindPageWithEditor(NewSrcEdit);
|
||||||
|
|
||||||
// restore source editor settings
|
// restore source editor settings
|
||||||
NewSrcEdit.SyntaxHighlighterType:=AnUnitInfo.SyntaxHighlighter;
|
NewSrcEdit.SyntaxHighlighterType:=AnUnitInfo.SyntaxHighlighter;
|
||||||
@ -3430,14 +3493,14 @@ begin
|
|||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMainIDE.DoNewEditorUnit(NewUnitType:TNewUnitType;
|
function TMainIDE.DoNewEditorFile(NewUnitType:TNewUnitType;
|
||||||
NewFilename: string):TModalResult;
|
NewFilename: string):TModalResult;
|
||||||
var NewUnitInfo:TUnitInfo;
|
var NewUnitInfo:TUnitInfo;
|
||||||
NewSrcEdit: TSourceEditor;
|
NewSrcEdit: TSourceEditor;
|
||||||
NewUnitName: string;
|
NewUnitName: string;
|
||||||
NewBuffer: TCodeBuffer;
|
NewBuffer: TCodeBuffer;
|
||||||
begin
|
begin
|
||||||
writeln('TMainIDE.DoNewEditorUnit A NewFilename=',NewFilename);
|
writeln('TMainIDE.DoNewEditorFile A NewFilename=',NewFilename);
|
||||||
SaveSourceEditorChangesToCodeCache(-1);
|
SaveSourceEditorChangesToCodeCache(-1);
|
||||||
Result:=CreateNewCodeBuffer(NewUnitType,NewFilename,NewBuffer,NewUnitName);
|
Result:=CreateNewCodeBuffer(NewUnitType,NewFilename,NewBuffer,NewUnitName);
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
@ -3495,7 +3558,7 @@ begin
|
|||||||
{$IFDEF IDE_MEM_CHECK}CheckHeap(IntToStr(GetMem_Cnt));{$ENDIF}
|
{$IFDEF IDE_MEM_CHECK}CheckHeap(IntToStr(GetMem_Cnt));{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMainIDE.DoSaveEditorUnit(PageIndex:integer;
|
function TMainIDE.DoSaveEditorFile(PageIndex:integer;
|
||||||
Flags: TSaveFlags):TModalResult;
|
Flags: TSaveFlags):TModalResult;
|
||||||
var ActiveSrcEdit:TSourceEditor;
|
var ActiveSrcEdit:TSourceEditor;
|
||||||
ActiveUnitInfo:TUnitInfo;
|
ActiveUnitInfo:TUnitInfo;
|
||||||
@ -3503,7 +3566,7 @@ var ActiveSrcEdit:TSourceEditor;
|
|||||||
ResourceCode, LFMCode: TCodeBuffer;
|
ResourceCode, LFMCode: TCodeBuffer;
|
||||||
begin
|
begin
|
||||||
{$IFDEF IDE_VERBOSE}
|
{$IFDEF IDE_VERBOSE}
|
||||||
writeln('TMainIDE.DoSaveEditorUnit A PageIndex=',PageIndex,' SaveAs=',sfSaveAs in Flags,' SaveToTestDir=',sfSaveToTestDir in Flags);
|
writeln('TMainIDE.DoSaveEditorFile A PageIndex=',PageIndex,' SaveAs=',sfSaveAs in Flags,' SaveToTestDir=',sfSaveToTestDir in Flags);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFDEF IDE_MEM_CHECK}CheckHeap(IntToStr(GetMem_Cnt));{$ENDIF}
|
{$IFDEF IDE_MEM_CHECK}CheckHeap(IntToStr(GetMem_Cnt));{$ENDIF}
|
||||||
Result:=mrCancel;
|
Result:=mrCancel;
|
||||||
@ -3599,20 +3662,19 @@ begin
|
|||||||
SourceNoteBook.UpdateStatusBar;
|
SourceNoteBook.UpdateStatusBar;
|
||||||
|
|
||||||
{$IFDEF IDE_VERBOSE}
|
{$IFDEF IDE_VERBOSE}
|
||||||
writeln('TMainIDE.DoSaveEditorUnit END');
|
writeln('TMainIDE.DoSaveEditorFile END');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMainIDE.DoCloseEditorUnit(PageIndex:integer;
|
function TMainIDE.DoCloseEditorFile(PageIndex:integer;
|
||||||
SaveFirst: boolean):TModalResult;
|
SaveFirst: boolean):TModalResult;
|
||||||
var ActiveSrcEdit: TSourceEditor;
|
var ActiveSrcEdit: TSourceEditor;
|
||||||
ActiveUnitInfo: TUnitInfo;
|
ActiveUnitInfo: TUnitInfo;
|
||||||
ACaption,AText: string;
|
ACaption,AText: string;
|
||||||
i:integer;
|
i:integer;
|
||||||
OldDesigner: TDesigner;
|
|
||||||
begin
|
begin
|
||||||
writeln('TMainIDE.DoCloseEditorUnit A PageIndex=',PageIndex);
|
writeln('TMainIDE.DoCloseEditorFile A PageIndex=',PageIndex);
|
||||||
Result:=mrCancel;
|
Result:=mrCancel;
|
||||||
GetUnitWithPageIndex(PageIndex,ActiveSrcEdit,ActiveUnitInfo);
|
GetUnitWithPageIndex(PageIndex,ActiveSrcEdit,ActiveUnitInfo);
|
||||||
if ActiveUnitInfo=nil then exit;
|
if ActiveUnitInfo=nil then exit;
|
||||||
@ -3638,28 +3700,15 @@ begin
|
|||||||
ACaption:='Source modified';
|
ACaption:='Source modified';
|
||||||
if Messagedlg(ACaption, AText, mtConfirmation, [mbYes, mbNo], 0)=mrYes then
|
if Messagedlg(ACaption, AText, mtConfirmation, [mbYes, mbNo], 0)=mrYes then
|
||||||
begin
|
begin
|
||||||
Result:=DoSaveEditorUnit(PageIndex,[]);
|
Result:=DoSaveEditorFile(PageIndex,[]);
|
||||||
if Result=mrAbort then exit;
|
if Result=mrAbort then exit;
|
||||||
end;
|
end;
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// close form
|
// close form
|
||||||
if ActiveUnitInfo.Form<>nil then begin
|
CloseDesignerForm(ActiveUnitInfo);
|
||||||
if FLastFormActivated=ActiveUnitInfo.Form then
|
|
||||||
FLastFormActivated:=nil;
|
|
||||||
// unselect controls
|
|
||||||
for i:=TWinControl(ActiveUnitInfo.Form).ComponentCount-1 downto 0 do
|
|
||||||
TheControlSelection.Remove(
|
|
||||||
TWinControl(ActiveUnitInfo.Form).Components[i]);
|
|
||||||
TheControlSelection.Remove(TControl(ActiveUnitInfo.Form));
|
|
||||||
// free designer and design form
|
|
||||||
OldDesigner:=TDesigner(TCustomForm(ActiveUnitInfo.Form).Designer);
|
|
||||||
FormEditor1.DeleteControl(ActiveUnitInfo.Form);
|
|
||||||
OldDesigner.Free;
|
|
||||||
ActiveUnitInfo.Form:=nil;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// close source editor
|
// close source editor
|
||||||
SourceNoteBook.CloseFile(PageIndex);
|
SourceNoteBook.CloseFile(PageIndex);
|
||||||
|
|
||||||
@ -3671,14 +3720,14 @@ begin
|
|||||||
Project1.RemoveUnit(i);
|
Project1.RemoveUnit(i);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
writeln('TMainIDE.DoCloseEditorUnit end');
|
writeln('TMainIDE.DoCloseEditorFile end');
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TMainIDE.DoOpenEditorFile(const AFileName:string;
|
function TMainIDE.DoOpenEditorFile(AFileName:string;
|
||||||
Flags: TOpenFlags):TModalResult;
|
PageIndex: integer; Flags: TOpenFlags):TModalResult;
|
||||||
var
|
var
|
||||||
i: integer;
|
UnitIndex: integer;
|
||||||
ReOpen, Handled:boolean;
|
ReOpen, Handled:boolean;
|
||||||
NewUnitInfo:TUnitInfo;
|
NewUnitInfo:TUnitInfo;
|
||||||
NewBuf: TCodeBuffer;
|
NewBuf: TCodeBuffer;
|
||||||
@ -3689,41 +3738,72 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFDEF IDE_MEM_CHECK}CheckHeap(IntToStr(GetMem_Cnt));{$ENDIF}
|
{$IFDEF IDE_MEM_CHECK}CheckHeap(IntToStr(GetMem_Cnt));{$ENDIF}
|
||||||
Result:=mrCancel;
|
Result:=mrCancel;
|
||||||
if ExtractFilenameOnly(AFilename)='' then exit;
|
|
||||||
|
|
||||||
|
if (not (ofRevert in Flags))
|
||||||
|
and (ExtractFilenameOnly(AFilename)='') then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
// check if this is a hidden unit:
|
||||||
// if this is a virtual (new, unsaved) project, the main unit is already
|
// if this is a virtual (new, unsaved) project, the main unit is already
|
||||||
// loaded and needs only to be shown in the sourceeditor/formeditor
|
// loaded and needs only to be shown in the sourceeditor/formeditor
|
||||||
if (Project1.IsVirtual)
|
if (not (ofRevert in Flags))
|
||||||
|
and (Project1.IsVirtual)
|
||||||
and (CompareFilenames(Project1.MainFilename,AFilename)=0)
|
and (CompareFilenames(Project1.MainFilename,AFilename)=0)
|
||||||
then begin
|
then begin
|
||||||
Result:=DoOpenMainUnit(ofProjectLoading in Flags);
|
Result:=DoOpenMainUnit(ofProjectLoading in Flags);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
// check if the project knows this file
|
// check if the project knows this file
|
||||||
i:=Project1.IndexOfFilename(AFilename);
|
if (not (ofRevert in Flags)) then begin
|
||||||
ReOpen:=(i>=0);
|
UnitIndex:=Project1.IndexOfFilename(AFilename);
|
||||||
if ReOpen then begin
|
ReOpen:=(UnitIndex>=0);
|
||||||
NewUnitInfo:=Project1.Units[i];
|
if ReOpen then begin
|
||||||
if (not (ofProjectLoading in Flags)) and NewUnitInfo.Loaded then begin
|
NewUnitInfo:=Project1.Units[UnitIndex];
|
||||||
// file already open -> change source notebook page
|
if (not (ofProjectLoading in Flags)) and NewUnitInfo.Loaded then begin
|
||||||
SourceNoteBook.NoteBook.PageIndex:=NewUnitInfo.EditorIndex;
|
// file already open -> change source notebook page
|
||||||
Result:=mrOk;
|
SourceNoteBook.NoteBook.PageIndex:=NewUnitInfo.EditorIndex;
|
||||||
|
Result:=mrOk;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end else begin
|
||||||
|
// revert
|
||||||
|
NewUnitInfo:=Project1.UnitWithEditorIndex(PageIndex);
|
||||||
|
UnitIndex:=Project1.IndexOf(NewUnitInfo);
|
||||||
|
AFilename:=NewUnitInfo.Filename;
|
||||||
|
if NewUnitInfo.IsVirtual then begin
|
||||||
|
if (not (ofQuiet in Flags)) then begin
|
||||||
|
MessageDlg('Revert failed','File "'+AFilename+'" is virtual.',
|
||||||
|
mtInformation,[mbCancel],0);
|
||||||
|
end;
|
||||||
|
Result:=mrCancel;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
ReOpen:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// check if file exists
|
// check if file exists
|
||||||
if (not FileExists(AFilename)) then begin
|
if (not FileExists(AFilename)) then begin
|
||||||
// file does not exists
|
// file does not exists
|
||||||
Result:=DoOpenNotExistingFile(AFilename,Flags);
|
if (ofRevert in Flags) then begin
|
||||||
exit;
|
// revert failed, due to missing file
|
||||||
|
if not (ofQuiet in Flags) then begin
|
||||||
|
MessageDlg('Revert failed','File "'+AFilename+'" not found.',
|
||||||
|
mtError,[mbCancel],0);
|
||||||
|
end;
|
||||||
|
Result:=mrCancel;
|
||||||
|
exit;
|
||||||
|
end else begin
|
||||||
|
Result:=DoOpenNotExistingFile(AFilename,Flags);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// load the source
|
// load the source
|
||||||
if ReOpen then begin
|
if ReOpen then begin
|
||||||
// project knows this file => all the meta data is known
|
// project knows this file => all the meta data is known
|
||||||
// -> just load the source
|
// -> just load the source
|
||||||
NewUnitInfo:=Project1.Units[i];
|
NewUnitInfo:=Project1.Units[UnitIndex];
|
||||||
Result:=DoLoadCodeBuffer(NewBuf,AFileName,
|
Result:=DoLoadCodeBuffer(NewBuf,AFileName,
|
||||||
[lbfCheckIfText,lbfUpdateFromDisk,lbfRevert]);
|
[lbfCheckIfText,lbfUpdateFromDisk,lbfRevert]);
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
@ -3746,7 +3826,7 @@ begin
|
|||||||
writeln('[TMainIDE.DoOpenEditorFile] B');
|
writeln('[TMainIDE.DoOpenEditorFile] B');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
// open file in source notebook
|
// open file in source notebook
|
||||||
Result:=DoOpenFileInSourceNoteBook(NewUnitInfo,Flags);
|
Result:=DoOpenFileInSourceNoteBook(NewUnitInfo,PageIndex,Flags);
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
|
|
||||||
{$IFDEF IDE_DEBUG}
|
{$IFDEF IDE_DEBUG}
|
||||||
@ -3758,6 +3838,9 @@ begin
|
|||||||
// this could be a unit -> try to load the lfm file
|
// this could be a unit -> try to load the lfm file
|
||||||
Result:=DoLoadLFM(NewUnitInfo,Flags);
|
Result:=DoLoadLFM(NewUnitInfo,Flags);
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
|
end else if NewUnitInfo.Form<>nil then begin
|
||||||
|
// close form (Note: e.g. close form on revert)
|
||||||
|
CloseDesignerForm(NewUnitInfo);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
@ -3785,7 +3868,7 @@ begin
|
|||||||
// open file in source notebook
|
// open file in source notebook
|
||||||
OpenFlags:=[];
|
OpenFlags:=[];
|
||||||
if ProjectLoading then Include(OpenFlags,ofProjectLoading);
|
if ProjectLoading then Include(OpenFlags,ofProjectLoading);
|
||||||
Result:=DoOpenFileInSourceNoteBook(MainUnitInfo,OpenFlags);
|
Result:=DoOpenFileInSourceNoteBook(MainUnitInfo,-1,OpenFlags);
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
|
|
||||||
// build a nice pagename for the sourcenotebook
|
// build a nice pagename for the sourcenotebook
|
||||||
@ -3864,7 +3947,7 @@ Begin
|
|||||||
if MainUnitIndex=i then
|
if MainUnitIndex=i then
|
||||||
Result:=DoOpenMainUnit(false)
|
Result:=DoOpenMainUnit(false)
|
||||||
else
|
else
|
||||||
Result:=DoOpenEditorFile(AnUnitInfo.Filename,[ofOnlyIfExists]);
|
Result:=DoOpenEditorFile(AnUnitInfo.Filename,-1,[ofOnlyIfExists]);
|
||||||
if Result=mrAbort then exit;
|
if Result=mrAbort then exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -3990,7 +4073,7 @@ begin
|
|||||||
if FindFile(FName,SPath) then begin
|
if FindFile(FName,SPath) then begin
|
||||||
result:=mrOk;
|
result:=mrOk;
|
||||||
InputHistories.FileDialogSettings.InitialDir:=ExtractFilePath(FName);
|
InputHistories.FileDialogSettings.InitialDir:=ExtractFilePath(FName);
|
||||||
if DoOpenEditorFile(FName,[])=mrOk then begin
|
if DoOpenEditorFile(FName,-1,[])=mrOk then begin
|
||||||
EnvironmentOptions.AddToRecentOpenFiles(FName);
|
EnvironmentOptions.AddToRecentOpenFiles(FName);
|
||||||
SaveEnvironment;
|
SaveEnvironment;
|
||||||
end;
|
end;
|
||||||
@ -4051,7 +4134,7 @@ writeln('TMainIDE.DoNewProject A');
|
|||||||
+';'+
|
+';'+
|
||||||
'$(LazarusDir)'+ds+'lcl'+ds+'interfaces'+ds+'$(LCLWidgetType)';
|
'$(LazarusDir)'+ds+'lcl'+ds+'interfaces'+ds+'$(LCLWidgetType)';
|
||||||
// create a first form unit
|
// create a first form unit
|
||||||
DoNewEditorUnit(nuForm,'');
|
DoNewEditorFile(nuForm,'');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ptProgram,ptCustomProgram:
|
ptProgram,ptCustomProgram:
|
||||||
@ -4094,7 +4177,7 @@ writeln('TMainIDE.DoSaveProject A SaveAs=',sfSaveAs in Flags,' SaveToTestDir=',s
|
|||||||
for i:=0 to Project1.UnitCount-1 do begin
|
for i:=0 to Project1.UnitCount-1 do begin
|
||||||
if (Project1.Units[i].Loaded) and (Project1.Units[i].IsVirtual)
|
if (Project1.Units[i].Loaded) and (Project1.Units[i].IsVirtual)
|
||||||
and (Project1.MainUnit<>i) then begin
|
and (Project1.MainUnit<>i) then begin
|
||||||
Result:=DoSaveEditorUnit(Project1.Units[i].EditorIndex,
|
Result:=DoSaveEditorFile(Project1.Units[i].EditorIndex,
|
||||||
[sfSaveAs,sfProjectSaving]+[sfSaveToTestDir]*Flags);
|
[sfSaveAs,sfProjectSaving]+[sfSaveToTestDir]*Flags);
|
||||||
if (Result=mrAbort) or (Result=mrCancel) then exit;
|
if (Result=mrAbort) or (Result=mrCancel) then exit;
|
||||||
end;
|
end;
|
||||||
@ -4135,7 +4218,7 @@ writeln('TMainIDE.DoSaveProject A SaveAs=',sfSaveAs in Flags,' SaveToTestDir=',s
|
|||||||
if MainUnitInfo<>nil then begin
|
if MainUnitInfo<>nil then begin
|
||||||
if MainUnitInfo.Loaded then begin
|
if MainUnitInfo.Loaded then begin
|
||||||
// loaded in source editor
|
// loaded in source editor
|
||||||
Result:=DoSaveEditorUnit(MainUnitInfo.EditorIndex,
|
Result:=DoSaveEditorFile(MainUnitInfo.EditorIndex,
|
||||||
[sfProjectSaving]+[sfSaveToTestDir]*Flags);
|
[sfProjectSaving]+[sfSaveToTestDir]*Flags);
|
||||||
if Result=mrAbort then exit;
|
if Result=mrAbort then exit;
|
||||||
end else begin
|
end else begin
|
||||||
@ -4164,7 +4247,7 @@ writeln('TMainIDE.DoSaveProject A SaveAs=',sfSaveAs in Flags,' SaveToTestDir=',s
|
|||||||
for i:=0 to SourceNoteBook.Notebook.Pages.Count-1 do begin
|
for i:=0 to SourceNoteBook.Notebook.Pages.Count-1 do begin
|
||||||
if (Project1.MainUnit<0)
|
if (Project1.MainUnit<0)
|
||||||
or (Project1.MainUnitInfo.EditorIndex<>i) then begin
|
or (Project1.MainUnitInfo.EditorIndex<>i) then begin
|
||||||
Result:=DoSaveEditorUnit(i,[sfProjectSaving]+[sfSaveToTestDir]*Flags);
|
Result:=DoSaveEditorFile(i,[sfProjectSaving]+[sfSaveToTestDir]*Flags);
|
||||||
if Result=mrAbort then exit;
|
if Result=mrAbort then exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -4180,7 +4263,7 @@ begin
|
|||||||
// close all loaded files
|
// close all loaded files
|
||||||
{$IFDEF IDE_MEM_CHECK}CheckHeap(IntToStr(GetMem_Cnt));{$ENDIF}
|
{$IFDEF IDE_MEM_CHECK}CheckHeap(IntToStr(GetMem_Cnt));{$ENDIF}
|
||||||
while SourceNotebook.NoteBook<>nil do begin
|
while SourceNotebook.NoteBook<>nil do begin
|
||||||
Result:=DoCloseEditorUnit(SourceNotebook.Notebook.Pages.Count-1,false);
|
Result:=DoCloseEditorFile(SourceNotebook.Notebook.Pages.Count-1,false);
|
||||||
if Result=mrAbort then exit;
|
if Result=mrAbort then exit;
|
||||||
end;
|
end;
|
||||||
{$IFDEF IDE_MEM_CHECK}CheckHeap(IntToStr(GetMem_Cnt));{$ENDIF}
|
{$IFDEF IDE_MEM_CHECK}CheckHeap(IntToStr(GetMem_Cnt));{$ENDIF}
|
||||||
@ -4291,7 +4374,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
if LowestEditorIndex>=0 then begin
|
if LowestEditorIndex>=0 then begin
|
||||||
// reopen file
|
// reopen file
|
||||||
Result:=DoOpenEditorFile(Project1.Units[LowestUnitIndex].Filename,
|
Result:=DoOpenEditorFile(Project1.Units[LowestUnitIndex].Filename,-1,
|
||||||
[ofProjectLoading,ofOnlyIfExists]);
|
[ofProjectLoading,ofOnlyIfExists]);
|
||||||
if Result=mrAbort then begin
|
if Result=mrAbort then begin
|
||||||
// mark all files, that are left to load as unloaded:
|
// mark all files, that are left to load as unloaded:
|
||||||
@ -5076,7 +5159,7 @@ begin
|
|||||||
if MacroName='save' then begin
|
if MacroName='save' then begin
|
||||||
Handled:=true;
|
Handled:=true;
|
||||||
if SourceNoteBook.NoteBook<>nil then
|
if SourceNoteBook.NoteBook<>nil then
|
||||||
Abort:=(DoSaveEditorUnit(SourceNoteBook.NoteBook.PageIndex,[])<>mrOk);
|
Abort:=(DoSaveEditorFile(SourceNoteBook.NoteBook.PageIndex,[])<>mrOk);
|
||||||
s:='';
|
s:='';
|
||||||
end else if MacroName='saveall' then begin
|
end else if MacroName='saveall' then begin
|
||||||
Handled:=true;
|
Handled:=true;
|
||||||
@ -5187,7 +5270,7 @@ begin
|
|||||||
// open the file in the source editor
|
// open the file in the source editor
|
||||||
Ext:=lowercase(ExtractFileExt(SearchedFilename));
|
Ext:=lowercase(ExtractFileExt(SearchedFilename));
|
||||||
if (not FilenameIsFormText(SearchedFilename)) and (Ext<>'.lpi') then begin
|
if (not FilenameIsFormText(SearchedFilename)) and (Ext<>'.lpi') then begin
|
||||||
Result:=(DoOpenEditorFile(SearchedFilename,[ofOnlyIfExists])=mrOk);
|
Result:=(DoOpenEditorFile(SearchedFilename,-1,[ofOnlyIfExists])=mrOk);
|
||||||
if Result then begin
|
if Result then begin
|
||||||
// set caret position
|
// set caret position
|
||||||
SourceNotebook.AddJumpPointClicked(Self);
|
SourceNotebook.AddJumpPointClicked(Self);
|
||||||
@ -5576,7 +5659,7 @@ begin
|
|||||||
// open all sources in editor
|
// open all sources in editor
|
||||||
for i:=0 to Manager.SourceChangeCache.BuffersToModifyCount-1 do begin
|
for i:=0 to Manager.SourceChangeCache.BuffersToModifyCount-1 do begin
|
||||||
if DoOpenEditorFile(Manager.SourceChangeCache.BuffersToModify[i].Filename,
|
if DoOpenEditorFile(Manager.SourceChangeCache.BuffersToModify[i].Filename,
|
||||||
[ofOnlyIfExists])<>mrOk then
|
-1,[ofOnlyIfExists])<>mrOk then
|
||||||
begin
|
begin
|
||||||
Abort:=true;
|
Abort:=true;
|
||||||
exit;
|
exit;
|
||||||
@ -5650,7 +5733,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
if NewSource<>ActiveUnitInfo.Source then begin
|
if NewSource<>ActiveUnitInfo.Source then begin
|
||||||
// jump to other file -> open it
|
// jump to other file -> open it
|
||||||
Result:=DoOpenEditorFile(NewSource.Filename,[ofOnlyIfExists]);
|
Result:=DoOpenEditorFile(NewSource.Filename,-1,[ofOnlyIfExists]);
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
GetUnitWithPageIndex(SourceNoteBook.NoteBook.PageIndex,NewSrcEdit,
|
GetUnitWithPageIndex(SourceNoteBook.NoteBook.PageIndex,NewSrcEdit,
|
||||||
NewUnitInfo);
|
NewUnitInfo);
|
||||||
@ -5723,7 +5806,7 @@ begin
|
|||||||
if CodeToolBoss.ErrorCode<>nil then begin
|
if CodeToolBoss.ErrorCode<>nil then begin
|
||||||
SourceNotebook.AddJumpPointClicked(Self);
|
SourceNotebook.AddJumpPointClicked(Self);
|
||||||
ErrorCaret:=Point(CodeToolBoss.ErrorColumn,CodeToolBoss.ErrorLine);
|
ErrorCaret:=Point(CodeToolBoss.ErrorColumn,CodeToolBoss.ErrorLine);
|
||||||
if DoOpenEditorFile(CodeToolBoss.ErrorCode.Filename,[ofOnlyIfExists])=mrOk
|
if DoOpenEditorFile(CodeToolBoss.ErrorCode.Filename,-1,[ofOnlyIfExists])=mrOk
|
||||||
then begin
|
then begin
|
||||||
ActiveSrcEdit:=SourceNoteBook.GetActiveSE;
|
ActiveSrcEdit:=SourceNoteBook.GetActiveSE;
|
||||||
with ActiveSrcEdit.EditorComponent do begin
|
with ActiveSrcEdit.EditorComponent do begin
|
||||||
@ -6453,6 +6536,7 @@ begin
|
|||||||
itmFileNewUnit.ShortCut:=CommandToShortCut(ecNewUnit);
|
itmFileNewUnit.ShortCut:=CommandToShortCut(ecNewUnit);
|
||||||
itmFileNewForm.ShortCut:=CommandToShortCut(ecNewForm);
|
itmFileNewForm.ShortCut:=CommandToShortCut(ecNewForm);
|
||||||
itmFileOpen.ShortCut:=CommandToShortCut(ecOpen);
|
itmFileOpen.ShortCut:=CommandToShortCut(ecOpen);
|
||||||
|
itmFileRevert.ShortCut:=CommandToShortCut(ecRevert);
|
||||||
//itmFileRecentOpen.ShortCut:=CommandToShortCut(ec);
|
//itmFileRecentOpen.ShortCut:=CommandToShortCut(ec);
|
||||||
itmFileSave.ShortCut:=CommandToShortCut(ecSave);
|
itmFileSave.ShortCut:=CommandToShortCut(ecSave);
|
||||||
itmFileSaveAs.ShortCut:=CommandToShortCut(ecSaveAs);
|
itmFileSaveAs.ShortCut:=CommandToShortCut(ecSaveAs);
|
||||||
@ -6568,6 +6652,9 @@ end.
|
|||||||
|
|
||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.324 2002/07/06 06:37:04 lazarus
|
||||||
|
MG: added Revert
|
||||||
|
|
||||||
Revision 1.323 2002/07/05 12:54:27 lazarus
|
Revision 1.323 2002/07/05 12:54:27 lazarus
|
||||||
MG: syntax highlighter is now set on open non existing file
|
MG: syntax highlighter is now set on open non existing file
|
||||||
|
|
||||||
|
@ -68,8 +68,10 @@ type
|
|||||||
|
|
||||||
TSaveFlag = (sfSaveAs, sfSaveToTestDir, sfProjectSaving);
|
TSaveFlag = (sfSaveAs, sfSaveToTestDir, sfProjectSaving);
|
||||||
TSaveFlags = set of TSaveFlag;
|
TSaveFlags = set of TSaveFlag;
|
||||||
TOpenFlag = (ofProjectLoading, ofOnlyIfExists);
|
TOpenFlag = (ofProjectLoading, ofOnlyIfExists, ofRevert, ofQuiet);
|
||||||
TOpenFlags = set of TOpenFlag;
|
TOpenFlags = set of TOpenFlag;
|
||||||
|
TRevertFlag = (rfQuiet);
|
||||||
|
TRevertFlags = set of TRevertFlag;
|
||||||
TLoadBufferFlag = (lbfUpdateFromDisk, lbfRevert, lbfCheckIfText);
|
TLoadBufferFlag = (lbfUpdateFromDisk, lbfRevert, lbfCheckIfText);
|
||||||
TLoadBufferFlags = set of TLoadBufferFlag;
|
TLoadBufferFlags = set of TLoadBufferFlag;
|
||||||
|
|
||||||
@ -110,6 +112,7 @@ type
|
|||||||
itmFileNewUnit : TMenuItem;
|
itmFileNewUnit : TMenuItem;
|
||||||
itmFileNewForm : TMenuItem;
|
itmFileNewForm : TMenuItem;
|
||||||
itmFileOpen: TMenuItem;
|
itmFileOpen: TMenuItem;
|
||||||
|
itmFileRevert: TMenuItem;
|
||||||
itmFileRecentOpen: TMenuItem;
|
itmFileRecentOpen: TMenuItem;
|
||||||
itmFileSave: TMenuItem;
|
itmFileSave: TMenuItem;
|
||||||
itmFileSaveAs: TMenuItem;
|
itmFileSaveAs: TMenuItem;
|
||||||
@ -210,7 +213,7 @@ type
|
|||||||
function GetTestUnitFilename(AnUnitInfo: TUnitInfo): string; virtual; abstract;
|
function GetTestUnitFilename(AnUnitInfo: TUnitInfo): string; virtual; abstract;
|
||||||
function GetRunCommandLine: string; virtual; abstract;
|
function GetRunCommandLine: string; virtual; abstract;
|
||||||
|
|
||||||
function DoOpenEditorFile(const AFileName:string;
|
function DoOpenEditorFile(AFileName:string; PageIndex: integer;
|
||||||
Flags: TOpenFlags): TModalResult; virtual; abstract;
|
Flags: TOpenFlags): TModalResult; virtual; abstract;
|
||||||
function DoInitProjectRun: TModalResult; virtual; abstract;
|
function DoInitProjectRun: TModalResult; virtual; abstract;
|
||||||
|
|
||||||
|
@ -531,7 +531,7 @@ begin
|
|||||||
if Assigned(fOnUnitNameChange) then
|
if Assigned(fOnUnitNameChange) then
|
||||||
fOnUnitNameChange(Self,fUnitName,NewUnitName,false,Allowed);
|
fOnUnitNameChange(Self,fUnitName,NewUnitName,false,Allowed);
|
||||||
// (ignore Allowed)
|
// (ignore Allowed)
|
||||||
if fSource<>nil then begin
|
if (fSource<>nil) then begin
|
||||||
CodeToolBoss.RenameSource(fSource,NewUnitName);
|
CodeToolBoss.RenameSource(fSource,NewUnitName);
|
||||||
end;
|
end;
|
||||||
fUnitName:=NewUnitName;
|
fUnitName:=NewUnitName;
|
||||||
@ -1458,6 +1458,9 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.66 2002/07/06 06:37:06 lazarus
|
||||||
|
MG: added Revert
|
||||||
|
|
||||||
Revision 1.65 2002/05/16 13:00:57 lazarus
|
Revision 1.65 2002/05/16 13:00:57 lazarus
|
||||||
MG: fixed changing syntax highlighter on save as
|
MG: fixed changing syntax highlighter on save as
|
||||||
|
|
||||||
|
@ -373,7 +373,6 @@ type
|
|||||||
var Command: TSynEditorCommand; var AChar: char; Data: pointer;
|
var Command: TSynEditorCommand; var AChar: char; Data: pointer;
|
||||||
var Handled: boolean);
|
var Handled: boolean);
|
||||||
function FindBookmark(BookmarkID: integer): TSourceEditor;
|
function FindBookmark(BookmarkID: integer): TSourceEditor;
|
||||||
function FindPageWithEditor(ASourceEditor: TSourceEditor):integer;
|
|
||||||
function GetEditors(Index:integer):TSourceEditor;
|
function GetEditors(Index:integer):TSourceEditor;
|
||||||
|
|
||||||
procedure KeyDown(var Key : Word; Shift : TShiftState); override;
|
procedure KeyDown(var Key : Word; Shift : TShiftState); override;
|
||||||
@ -387,6 +386,7 @@ type
|
|||||||
property Editors[Index:integer]:TSourceEditor read GetEditors;
|
property Editors[Index:integer]:TSourceEditor read GetEditors;
|
||||||
function EditorCount:integer;
|
function EditorCount:integer;
|
||||||
function FindSourceEditorWithPageIndex(PageIndex:integer):TSourceEditor;
|
function FindSourceEditorWithPageIndex(PageIndex:integer):TSourceEditor;
|
||||||
|
function FindPageWithEditor(ASourceEditor: TSourceEditor):integer;
|
||||||
Function GetActiveSE : TSourceEditor;
|
Function GetActiveSE : TSourceEditor;
|
||||||
procedure LockAllEditorsInSourceChangeCache;
|
procedure LockAllEditorsInSourceChangeCache;
|
||||||
procedure UnlockAllEditorsInSourceChangeCache;
|
procedure UnlockAllEditorsInSourceChangeCache;
|
||||||
|
Loading…
Reference in New Issue
Block a user