mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-07 20:00:53 +02:00
MG: added project bookmark support
git-svn-id: trunk@302 -
This commit is contained in:
parent
9df86b0fa9
commit
8bdc13024b
43
ide/main.pp
43
ide/main.pp
@ -1985,7 +1985,7 @@ end;
|
||||
function TMainIDE.DoOpenEditorFile(AFileName:string;
|
||||
ProjectLoading:boolean):TModalResult;
|
||||
var Ext,ACaption,AText:string;
|
||||
i,ProgramNameStart,ProgramNameEnd:integer;
|
||||
i,BookmarkID,ProgramNameStart,ProgramNameEnd:integer;
|
||||
ReOpen:boolean;
|
||||
NewUnitInfo:TUnitInfo;
|
||||
NewPageName, NewLFMFilename, NewProgramName, NewSource: string;
|
||||
@ -2035,7 +2035,7 @@ writeln('TMainIDE.DoOpenEditorFile "',AFilename,'"');
|
||||
if FileExists(ChangeFileExt(AFilename,'.lpi')) then begin
|
||||
AText:='The file "'+AFilename+'"'
|
||||
+' seems to be the program file of an existing lazarus project.'
|
||||
+' Open project?';
|
||||
+' Open project? Cancel will load the source.';
|
||||
ACaption:='Project info file detected';
|
||||
if Application.MessageBox(PChar(AText),PChar(ACaption)
|
||||
,MB_OKCANCEL)=mrOk then begin
|
||||
@ -2045,7 +2045,8 @@ writeln('TMainIDE.DoOpenEditorFile "',AFilename,'"');
|
||||
end else begin
|
||||
AText:='The file "'+AFilename+'"'
|
||||
+' seems to be a program. Close current project'
|
||||
+' and create a new lazarus project for this program?';
|
||||
+' and create a new lazarus project for this program?'
|
||||
+' Cancel will load the source.';
|
||||
ACaption:='Program detected';
|
||||
if Application.MessageBox(PChar(AText),PChar(ACaption)
|
||||
,MB_OKCANCEL)=mrOK then begin
|
||||
@ -2085,14 +2086,29 @@ writeln('TMainIDE.DoOpenEditorFile "',AFilename,'"');
|
||||
sl.Text:=NewUnitInfo.Source.Source;
|
||||
SourceNotebook.NewFile(NewPageName,sl);
|
||||
sl.Free;
|
||||
if not ProjectLoading then
|
||||
Project.InsertEditorIndex(SourceNotebook.NoteBook.PageIndex);
|
||||
NewUnitInfo.EditorIndex:=SourceNotebook.NoteBook.PageIndex;
|
||||
NewSrcEdit:=SourceNotebook.GetActiveSE;
|
||||
if not ProjectLoading then
|
||||
Project.InsertEditorIndex(SourceNotebook.NoteBook.PageIndex)
|
||||
else begin
|
||||
for BookmarkID:=0 to 9 do begin
|
||||
i:=Project.Bookmarks.IndexOfID(BookmarkID);
|
||||
if (i>=0) and (Project.Bookmarks[i].EditorIndex=NewUnitInfo.EditorIndex)
|
||||
then begin
|
||||
NewSrcEdit.EditorComponent.SetBookmark(BookmarkID,
|
||||
Project.Bookmarks[i].CursorPos.X,Project.Bookmarks[i].CursorPos.Y);
|
||||
while i>=0 do begin
|
||||
Project.Bookmarks.Delete(i);
|
||||
i:=Project.Bookmarks.IndexOfID(BookmarkID);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
NewUnitInfo.EditorIndex:=SourceNotebook.NoteBook.PageIndex;
|
||||
NewSrcEdit.SyntaxHighlighterType:=NewUnitInfo.SyntaxHighlighter;
|
||||
NewSrcEdit.EditorComponent.CaretXY:=NewUnitInfo.CursorPos;
|
||||
NewSrcEdit.EditorComponent.TopLine:=NewUnitInfo.TopLine;
|
||||
NewSrcEdit.EditorComponent.LeftChar:=1;
|
||||
|
||||
NewUnitInfo.Loaded:=true;
|
||||
// read form data
|
||||
if (NewUnitInfo.Unitname<>'') then begin
|
||||
@ -2366,7 +2382,7 @@ var MainUnitSrcEdit, ASrcEdit: TSourceEditor;
|
||||
MainUnitInfo, AnUnitInfo: TUnitInfo;
|
||||
SaveDialog: TSaveDialog;
|
||||
NewFilename, NewProgramFilename, NewPageName, AText, ACaption, Ext: string;
|
||||
i:integer;
|
||||
i, BookmarkID, BookmarkX, BookmarkY :integer;
|
||||
begin
|
||||
Result:=mrCancel;
|
||||
if ToolStatus<>itNone then begin
|
||||
@ -2402,6 +2418,7 @@ writeln('TMainIDE.DoSaveProject A');
|
||||
MainUnitInfo:=nil;
|
||||
|
||||
// save some information of the loaded files
|
||||
Project.Bookmarks.Clear;
|
||||
for i:=0 to Project.UnitCount-1 do begin
|
||||
AnUnitInfo:=Project.Units[i];
|
||||
if AnUnitInfo.Loaded then begin
|
||||
@ -2409,6 +2426,13 @@ writeln('TMainIDE.DoSaveProject A');
|
||||
AnUnitInfo.EditorIndex);
|
||||
AnUnitInfo.TopLine:=ASrcEdit.EditorComponent.TopLine;
|
||||
AnUnitInfo.CursorPos:=ASrcEdit.EditorComponent.CaretXY;
|
||||
for BookmarkID:=0 to 9 do begin
|
||||
if (ASrcEdit.EditorComponent.GetBookMark(BookmarkID,BookmarkX,BookmarkY))
|
||||
and (Project.Bookmarks.IndexOfID(BookmarkID)<0) then begin
|
||||
Project.Bookmarks.Add(TProjectBookmark.Create(BookmarkX,BookmarkX,
|
||||
AnUnitInfo.EditorIndex,BookmarkID));
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -2616,9 +2640,7 @@ writeln('TMainIDE.DoOpenProjectFile A "'+AFileName+'"');
|
||||
Project.Modified:=false;
|
||||
EnvironmentOptions.LastSavedProjectFile:=Project.ProjectInfoFile;
|
||||
EnvironmentOptions.Save(false);
|
||||
|
||||
writeln('TMainIDE.DoOpenProjectFile end ');
|
||||
|
||||
end;
|
||||
|
||||
function TMainIDE.DoCreateProjectForProgram(ProgramFilename
|
||||
@ -3463,6 +3485,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.104 2001/06/27 21:43:23 lazarus
|
||||
MG: added project bookmark support
|
||||
|
||||
Revision 1.103 2001/06/26 00:08:35 lazarus
|
||||
MG: added code for form icons from Rene E. Beszon
|
||||
|
||||
|
@ -42,6 +42,8 @@ type
|
||||
fEditorIndex: integer;
|
||||
fID: integer;
|
||||
public
|
||||
constructor Create;
|
||||
constructor Create(X,Y, AnEditorIndex, AnID: integer);
|
||||
property CursorPos: TPoint read fCursorPos write fCursorPos;
|
||||
property EditorIndex: integer read fEditorIndex write fEditorIndex;
|
||||
property ID:integer read fID write fID;
|
||||
@ -312,9 +314,24 @@ end;
|
||||
|
||||
{ TProjectBookmark }
|
||||
|
||||
constructor TProjectBookmark.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
end;
|
||||
|
||||
constructor TProjectBookmark.Create(X,Y, AnEditorIndex, AnID: integer);
|
||||
begin
|
||||
inherited Create;
|
||||
fCursorPos.X:=X;
|
||||
fCursorPos.Y:=Y;
|
||||
fEditorIndex:=AnEditorIndex;
|
||||
fID:=AnID;
|
||||
end;
|
||||
|
||||
procedure TProjectBookmark.SaveToXMLConfig(XMLConfig: TXMLConfig;
|
||||
Path: string);
|
||||
begin
|
||||
XMLConfig.SetValue(Path+'ID',ID);
|
||||
XMLConfig.SetValue(Path+'CursorPosX',CursorPos.X);
|
||||
XMLConfig.SetValue(Path+'CursorPosY',CursorPos.Y);
|
||||
XMLConfig.SetValue(Path+'EditorIndex',EditorIndex);
|
||||
@ -323,6 +340,7 @@ end;
|
||||
procedure TProjectBookmark.LoadFromXMLConfig(XMLConfig: TXMLConfig;
|
||||
Path: string);
|
||||
begin
|
||||
ID:=XMLConfig.GetValue(Path+'ID',-1);
|
||||
CursorPos.X:=XMLConfig.GetValue(Path+'CursorPosX',0);
|
||||
CursorPos.Y:=XMLConfig.GetValue(Path+'CursorPosY',0);
|
||||
EditorIndex:=XMLConfig.GetValue(Path+'EditorIndex',-1);
|
||||
@ -1398,6 +1416,9 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.25 2001/06/27 21:43:23 lazarus
|
||||
MG: added project bookmark support
|
||||
|
||||
Revision 1.24 2001/06/04 09:32:17 lazarus
|
||||
MG: fixed bugs and cleaned up messages
|
||||
|
||||
|
@ -231,7 +231,7 @@ type
|
||||
Procedure BookMarkToggle(Value : Integer);
|
||||
protected
|
||||
ccSelection : String;
|
||||
|
||||
|
||||
Function CreateNotebook : Boolean;
|
||||
Function DisplayPage(SE : TSourceEditor) : Boolean;
|
||||
Function NewSE(Pagenum : Integer) : TSourceEditor;
|
||||
@ -1099,6 +1099,7 @@ writeln('TSourceEditor.CreateEditor FEditorName="',NewName,'"');
|
||||
Name:=NewName;
|
||||
Parent := AParent;
|
||||
Align := alClient;
|
||||
BookMarkOptions.EnableKeys := false;
|
||||
OnStatusChange := @EditorStatusChanged;
|
||||
OnProcessUserCommand := @ProcessUserCommand;
|
||||
OnReplaceText := @OnReplace;
|
||||
@ -2036,8 +2037,8 @@ Begin
|
||||
if TempEditor <> nil then TempEditor.FindAgain;
|
||||
End;
|
||||
|
||||
|
||||
Procedure TSourceNotebook.BookMarkClicked(Sender : TObject);
|
||||
// popup menu toggle bookmark clicked
|
||||
var
|
||||
MenuItem : TMenuItem;
|
||||
Begin
|
||||
@ -2046,6 +2047,7 @@ Begin
|
||||
end;
|
||||
|
||||
Procedure TSourceNotebook.BookMarkGotoClicked(Sender : TObject);
|
||||
// popup menu goto bookmark clicked
|
||||
var
|
||||
MenuItem : TMenuItem;
|
||||
Begin
|
||||
@ -2336,7 +2338,8 @@ begin
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
function TSourceNotebook.FindPageWithEditor(ASourceEditor: TSourceEditor):integer;
|
||||
function TSourceNotebook.FindPageWithEditor(
|
||||
ASourceEditor: TSourceEditor):integer;
|
||||
var i:integer;
|
||||
begin
|
||||
if Notebook=nil then begin
|
||||
@ -2346,7 +2349,7 @@ begin
|
||||
while (Result>=0) do begin
|
||||
with Notebook.Page[Result] do
|
||||
for I := 0 to ControlCount-1 do
|
||||
if Controls[I]=TControl(ASourceEditor) then exit;
|
||||
if Controls[I]=ASourceEditor.EditorComponent then exit;
|
||||
dec(Result);
|
||||
end;
|
||||
end;
|
||||
@ -2391,7 +2394,7 @@ begin
|
||||
|
||||
ecJumpToEditor :
|
||||
Begin
|
||||
//This is NOT implemented yet
|
||||
// This is NOT implemented yet
|
||||
|
||||
end;
|
||||
|
||||
@ -2401,8 +2404,16 @@ begin
|
||||
|
||||
ecToggleFormUnit:
|
||||
ToggleFormUnitClicked(self);
|
||||
|
||||
ecGotoMarker0..ecGotoMarker9:
|
||||
BookMarkGoto(Command - ecGotoMarker0);
|
||||
|
||||
ecSetMarker0..ecSetMarker9:
|
||||
BookMarkToggle(Command - ecSetMarker0);
|
||||
|
||||
end; //case
|
||||
|
||||
writeln('******* ',ecGotoMarker4,',',Command);
|
||||
end;
|
||||
|
||||
Procedure TSourceNotebook.ReloadEditorOptions;
|
||||
|
@ -889,7 +889,6 @@ begin
|
||||
with Message do
|
||||
begin
|
||||
ShiftState := KeyDataToShiftState(KeyData);
|
||||
ShiftState := [];
|
||||
if not (csNoStdEvents in ControlStyle)
|
||||
then begin
|
||||
KeyUp(CharCode, ShiftState);
|
||||
@ -1960,6 +1959,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.34 2001/06/27 21:43:23 lazarus
|
||||
MG: added project bookmark support
|
||||
|
||||
Revision 1.33 2001/06/15 10:31:06 lazarus
|
||||
MG: set longstrings as default
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user