MG: fixes for open lpi files and improved jump points

git-svn-id: trunk@1608 -
This commit is contained in:
lazarus 2002-04-15 10:56:08 +00:00
parent 029bb35f4a
commit 1b493c7b2a
4 changed files with 84 additions and 30 deletions

View File

@ -2787,12 +2787,13 @@ var
PreReadBuf: TCodeBuffer; PreReadBuf: TCodeBuffer;
begin begin
Handled:=false; Handled:=false;
Ext:=lowercase(ExtractFilename(AFilename)); Ext:=lowercase(ExtractFileExt(AFilename));
if (not (ofProjectLoading in Flags)) and (ToolStatus=itNone) if (not (ofProjectLoading in Flags)) and (ToolStatus=itNone)
and (Ext='.lpi') then begin and (Ext='.lpi') then begin
// this is a project info file -> load whole project // this is a project info file -> load whole project
Result:=DoOpenProjectFile(AFilename); Result:=DoOpenProjectFile(AFilename);
Handled:=true;
exit; exit;
end; end;
@ -3226,7 +3227,7 @@ begin
NewSrcEdit.EditorComponent.TopLine:=AnUnitInfo.TopLine; NewSrcEdit.EditorComponent.TopLine:=AnUnitInfo.TopLine;
NewSrcEdit.EditorComponent.LeftChar:=1; NewSrcEdit.EditorComponent.LeftChar:=1;
NewSrcEdit.ReadOnly:=AnUnitInfo.ReadOnly; NewSrcEdit.ReadOnly:=AnUnitInfo.ReadOnly;
// mark unit as loaded // mark unit as loaded
AnUnitInfo.Loaded:=true; AnUnitInfo.Loaded:=true;
@ -3478,8 +3479,8 @@ var
NewUnitInfo:TUnitInfo; NewUnitInfo:TUnitInfo;
NewBuf: TCodeBuffer; NewBuf: TCodeBuffer;
begin begin
writeln(''); writeln('');
writeln('*** TMainIDE.DoOpenEditorFile START "',AFilename,'"'); writeln('*** TMainIDE.DoOpenEditorFile START "',AFilename,'"');
{$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 ExtractFilenameOnly(AFilename)='' then exit;
@ -3533,19 +3534,19 @@ writeln('*** TMainIDE.DoOpenEditorFile START "',AFilename,'"');
end; end;
// check readonly // check readonly
NewUnitInfo.ReadOnly:=NewUnitInfo.ReadOnly NewUnitInfo.ReadOnly:=NewUnitInfo.ReadOnly
or (not FileIsWritable(NewUnitInfo.Filename)); or (not FileIsWritable(NewUnitInfo.Filename));
{$IFDEF IDE_DEBUG} {$IFDEF IDE_DEBUG}
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,Flags);
if Result<>mrOk then exit; if Result<>mrOk then exit;
{$IFDEF IDE_DEBUG} {$IFDEF IDE_DEBUG}
writeln('[TMainIDE.DoOpenEditorFile] C'); writeln('[TMainIDE.DoOpenEditorFile] C');
{$ENDIF} {$ENDIF}
// read form data // read form data
if FilenameIsPascalUnit(AFilename) then begin if FilenameIsPascalUnit(AFilename) then begin
@ -3555,7 +3556,7 @@ writeln('[TMainIDE.DoOpenEditorFile] C');
end; end;
Result:=mrOk; Result:=mrOk;
writeln('TMainIDE.DoOpenEditorFile END "',AFilename,'"'); writeln('TMainIDE.DoOpenEditorFile END "',AFilename,'"');
{$IFDEF IDE_MEM_CHECK}CheckHeap(IntToStr(GetMem_Cnt));{$ENDIF} {$IFDEF IDE_MEM_CHECK}CheckHeap(IntToStr(GetMem_Cnt));{$ENDIF}
end; end;
@ -3563,7 +3564,7 @@ function TMainIDE.DoOpenMainUnit(ProjectLoading: boolean): TModalResult;
var MainUnitInfo: TUnitInfo; var MainUnitInfo: TUnitInfo;
OpenFlags: TOpenFlags; OpenFlags: TOpenFlags;
begin begin
writeln('[TMainIDE.DoOpenMainUnit] A'); writeln('[TMainIDE.DoOpenMainUnit] A');
Result:=mrCancel; Result:=mrCancel;
if Project1.MainUnit<0 then exit; if Project1.MainUnit<0 then exit;
MainUnitInfo:=Project1.MainUnitInfo; MainUnitInfo:=Project1.MainUnitInfo;
@ -3584,7 +3585,7 @@ writeln('[TMainIDE.DoOpenMainUnit] A');
// build a nice pagename for the sourcenotebook // build a nice pagename for the sourcenotebook
Result:=mrOk; Result:=mrOk;
writeln('[TMainIDE.DoOpenMainUnit] END'); writeln('[TMainIDE.DoOpenMainUnit] END');
end; end;
function TMainIDE.DoViewUnitsAndForms(OnlyForms: boolean): TModalResult; function TMainIDE.DoViewUnitsAndForms(OnlyForms: boolean): TModalResult;
@ -5443,6 +5444,7 @@ begin
// syntax error -> show error and jump // syntax error -> show error and jump
// show error in message view // show error in message view
DoArrangeSourceEditorAndMessageView; DoArrangeSourceEditorAndMessageView;
MessagesView.ClearTillLastSeparator;
MessagesView.AddSeparator; MessagesView.AddSeparator;
if CodeToolBoss.ErrorCode<>nil then begin if CodeToolBoss.ErrorCode<>nil then begin
MessagesView.Add(Project1.RemoveProjectPathFromFilename( MessagesView.Add(Project1.RemoveProjectPathFromFilename(
@ -5452,11 +5454,12 @@ begin
+') Error: '+CodeToolBoss.ErrorMessage); +') Error: '+CodeToolBoss.ErrorMessage);
end else end else
MessagesView.Add(CodeToolBoss.ErrorMessage); MessagesView.Add(CodeToolBoss.ErrorMessage);
// jump to error in source editor // jump to error in source editor
if CodeToolBoss.ErrorCode<>nil then begin if CodeToolBoss.ErrorCode<>nil then begin
SourceNotebook.AddJumpPointClicked(Self); SourceNotebook.AddJumpPointClicked(Self);
if DoOpenEditorFile(CodeToolBoss.ErrorCode.Filename,[ofOnlyIfExists])=mrOk then if DoOpenEditorFile(CodeToolBoss.ErrorCode.Filename,[ofOnlyIfExists])=mrOk
begin then begin
ActiveSrcEdit:=SourceNoteBook.GetActiveSE; ActiveSrcEdit:=SourceNoteBook.GetActiveSE;
with ActiveSrcEdit.EditorComponent do begin with ActiveSrcEdit.EditorComponent do begin
SetFocus; SetFocus;
@ -5677,7 +5680,7 @@ begin
ACaretXY,ATopLine); ACaretXY,ATopLine);
if DeleteForwardHistory then Project1.JumpHistory.DeleteForwardHistory; if DeleteForwardHistory then Project1.JumpHistory.DeleteForwardHistory;
Project1.JumpHistory.InsertSmart(Project1.JumpHistory.HistoryIndex+1, Project1.JumpHistory.InsertSmart(Project1.JumpHistory.HistoryIndex+1,
NewJumpPoint); NewJumpPoint);
if Project1.JumpHistory.HistoryIndex=Project1.JumpHistory.Count-2 then if Project1.JumpHistory.HistoryIndex=Project1.JumpHistory.Count-2 then
Project1.JumpHistory.HistoryIndex:=Project1.JumpHistory.Count-1; Project1.JumpHistory.HistoryIndex:=Project1.JumpHistory.Count-1;
//writeln('[TMainIDE.OnSrcNoteBookAddJumpPoint] END Line=',ACaretXY.Y,',DeleteForwardHistory=',DeleteForwardHistory,' Count=',Project1.JumpHistory.Count,',HistoryIndex=',Project1.JumpHistory.HistoryIndex); //writeln('[TMainIDE.OnSrcNoteBookAddJumpPoint] END Line=',ACaretXY.Y,',DeleteForwardHistory=',DeleteForwardHistory,' Count=',Project1.JumpHistory.Count,',HistoryIndex=',Project1.JumpHistory.HistoryIndex);
@ -6218,6 +6221,9 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.278 2002/04/15 10:56:05 lazarus
MG: fixes for open lpi files and improved jump points
Revision 1.277 2002/04/12 16:36:07 lazarus Revision 1.277 2002/04/12 16:36:07 lazarus
MG: FPC unitlinks are now saved MG: FPC unitlinks are now saved

View File

@ -43,10 +43,11 @@ type
Function GetSelectedLineIndex : Integer; Function GetSelectedLineIndex : Integer;
public public
constructor Create(AOwner : TComponent); override; constructor Create(AOwner : TComponent); override;
Procedure Add(const Texts : String); procedure Add(const Texts : String);
Procedure AddSeparator; procedure AddSeparator;
procedure ClearTillLastSeparator;
function MsgCount: integer; function MsgCount: integer;
Procedure Clear; procedure Clear;
property Message : String read GetMessage; property Message : String read GetMessage;
property SelectedMessageIndex : Integer read GetSelectedLineIndex; property SelectedMessageIndex : Integer read GetSelectedLineIndex;
property OnSelectionChanged : TNotifyEvent read FOnSelectionChanged write FOnSelectionChanged; property OnSelectionChanged : TNotifyEvent read FOnSelectionChanged write FOnSelectionChanged;
@ -58,6 +59,8 @@ var
implementation implementation
const SeparatorLine = '----------------------------';
{ TMessagesView } { TMessagesView }
@ -96,8 +99,22 @@ end;
Procedure TMessagesView.AddSeparator; Procedure TMessagesView.AddSeparator;
begin begin
if MsgCount>0 then Add(SeparatorLine);
Add('----------------------------'); end;
procedure TMessagesView.ClearTillLastSeparator;
var LastSeparator: integer;
begin
with MessageView do begin
LastSeparator:=Items.Count-1;
while (LastSeparator>=0) and (Items[LastSeparator]<>SeparatorLine) do
dec(LastSeparator);
if LastSeparator>=0 then begin
while (Items.Count>LastSeparator) do begin
Items.Delete(Items.Count-1);
end;
end;
end;
end; end;
function TMessagesView.MsgCount: integer; function TMessagesView.MsgCount: integer;

View File

@ -797,15 +797,23 @@ end;
procedure TProjectJumpHistory.InsertSmart(Index: integer; procedure TProjectJumpHistory.InsertSmart(Index: integer;
APosition: TProjectJumpHistoryPosition); APosition: TProjectJumpHistoryPosition);
// insert if item after or in front of Index is not equal to APosition // insert if item after or in front of Index is not similar to APosition
// else replace the similar with the new updated version
begin begin
if Index<0 then Index:=Count; if Index<0 then Index:=Count;
if (Index<=Count) if (Index<=Count) then begin
and ((Index<1) or (not Items[Index-1].IsSimilar(APosition))) if (Index>0) and Items[Index-1].IsSimilar(APosition) then begin
and ((Index=Count) or (not Items[Index].IsSimilar(APosition))) then Items[Index-1]:=APosition;
Insert(Index,APosition) APosition.Free;
else end else if (Index<Count) and Items[Index].IsSimilar(APosition) then begin
Items[Index]:=APosition;
APosition.Free;
end else begin
Insert(Index,APosition);
end;
end else begin
APosition.Free; APosition.Free;
end;
end; end;
procedure TProjectJumpHistory.DeleteForwardHistory; procedure TProjectJumpHistory.DeleteForwardHistory;

View File

@ -153,6 +153,8 @@ type
ErrorMsgs : TStrings; ErrorMsgs : TStrings;
Procedure ReParent(AParent : TWinControl); Procedure ReParent(AParent : TWinControl);
Procedure ProcessCommand(Sender: TObject;
var Command: TSynEditorCommand; var AChar: char; Data: pointer);
Procedure ProcessUserCommand(Sender: TObject; Procedure ProcessUserCommand(Sender: TObject;
var Command: TSynEditorCommand; var AChar: char; Data: pointer); var Command: TSynEditorCommand; var AChar: char; Data: pointer);
Procedure UserCommandProcessed(Sender: TObject; Procedure UserCommandProcessed(Sender: TObject;
@ -716,6 +718,20 @@ begin
FEditor.ReadOnly:=NewValue; FEditor.ReadOnly:=NewValue;
end; end;
Procedure TSourceEditor.ProcessCommand(Sender: TObject;
var Command: TSynEditorCommand; var AChar: char; Data: pointer);
begin
case Command of
ecSelEditorTop, ecSelEditorBottom, ecEditorTop, ecEditorBottom:
begin
if FaOwner<>nil then
TSourceNotebook(FaOwner).AddJumpPointClicked(Self);
end;
end;
end;
Procedure TSourceEditor.ProcessUserCommand(Sender: TObject; Procedure TSourceEditor.ProcessUserCommand(Sender: TObject;
var Command: TSynEditorCommand; var AChar: char; Data: pointer); var Command: TSynEditorCommand; var AChar: char; Data: pointer);
var var
@ -726,6 +742,7 @@ var
Begin Begin
Handled:=true; Handled:=true;
case Command of case Command of
ecIdentCompletion : ecIdentCompletion :
if TCustomSynEdit(Sender).ReadOnly=false then begin if TCustomSynEdit(Sender).ReadOnly=false then begin
CurrentCompletionType:=ctIdentCompletion; CurrentCompletionType:=ctIdentCompletion;
@ -816,9 +833,13 @@ var Handled: boolean;
begin begin
Handled:=true; Handled:=true;
case Command of case Command of
ecNone: ;
ecUndo: ecUndo:
if (FEditor.Modified=false) and (CodeBuffer<>nil) then if (FEditor.Modified=false) and (CodeBuffer<>nil) then
CodeBuffer.Assign(FEditor.Lines); CodeBuffer.Assign(FEditor.Lines);
else else
begin begin
Handled:=false; Handled:=false;
@ -1152,6 +1173,7 @@ writeln('TSourceEditor.CreateEditor A ');
Align := alClient; Align := alClient;
BookMarkOptions.EnableKeys := false; BookMarkOptions.EnableKeys := false;
OnStatusChange := @EditorStatusChanged; OnStatusChange := @EditorStatusChanged;
OnProcessCommand := @ProcessCommand;
OnProcessUserCommand := @ProcessUserCommand; OnProcessUserCommand := @ProcessUserCommand;
OnCommandProcessed := @UserCommandProcessed; OnCommandProcessed := @UserCommandProcessed;
OnReplaceText := @OnReplace; OnReplaceText := @OnReplace;
@ -3027,7 +3049,7 @@ begin
if Assigned(FOnProcessUserCommand) then begin if Assigned(FOnProcessUserCommand) then begin
Handled:=false; Handled:=false;
FOnProcessUserCommand(Self,Command,Handled); FOnProcessUserCommand(Self,Command,Handled);
if Handled then begin if Handled or (Command=ecNone) then begin
FProcessingCommand:=false; FProcessingCommand:=false;
exit; exit;
end; end;
@ -3035,6 +3057,7 @@ begin
Handled:=true; Handled:=true;
case Command of case Command of
ecNextEditor: ecNextEditor:
NextEditor; NextEditor;