Commitng source with new editor.

Shane

git-svn-id: trunk@155 -
This commit is contained in:
lazarus 2001-01-31 13:03:33 +00:00
parent 1b047e0f9b
commit f74fc3c637
14 changed files with 3521 additions and 354 deletions

2
.gitattributes vendored
View File

@ -55,6 +55,7 @@ examples/testallform.pp svneol=native#text/pascal
examples/testtools.inc svneol=native#text/pascal examples/testtools.inc svneol=native#text/pascal
examples/toolbar.pp svneol=native#text/pascal examples/toolbar.pp svneol=native#text/pascal
examples/trackbar.pp svneol=native#text/pascal examples/trackbar.pp svneol=native#text/pascal
ide/codetemplatedialog.pp svneol=native#text/pascal
ide/compiler.pp svneol=native#text/pascal ide/compiler.pp svneol=native#text/pascal
ide/compileroptions.pp svneol=native#text/pascal ide/compileroptions.pp svneol=native#text/pascal
ide/compreg.pp svneol=native#text/pascal ide/compreg.pp svneol=native#text/pascal
@ -62,6 +63,7 @@ ide/customformeditor.pp svneol=native#text/pascal
ide/dlgmessage.lfm svneol=native#text/plain ide/dlgmessage.lfm svneol=native#text/plain
ide/dlgmessage.lrs svneol=native#text/pascal ide/dlgmessage.lrs svneol=native#text/pascal
ide/dlgmessage.pp svneol=native#text/pascal ide/dlgmessage.pp svneol=native#text/pascal
ide/editoroptions.pp svneol=native#text/pascal
ide/find_dlg.pp svneol=native#text/pascal ide/find_dlg.pp svneol=native#text/pascal
ide/formeditor.pp svneol=native#text/pascal ide/formeditor.pp svneol=native#text/pascal
ide/global.inc svneol=native#text/pascal ide/global.inc svneol=native#text/pascal

View File

@ -860,27 +860,33 @@ begin
end; end;
procedure TCustomSynEdit.DoCopyToClipboard(const SText: string); procedure TCustomSynEdit.DoCopyToClipboard(const SText: string);
{$IFNDEF SYN_LAZARUS}
var var
{$IFNDEF SYN_LAZARUS}
Mem: HGLOBAL; Mem: HGLOBAL;
P: PChar; P: PChar;
{$ENDIF}
SLen: integer; SLen: integer;
Failed: boolean; Failed: boolean;
{$ENDIF}
begin begin
{$IFNDEF SYN_LAZARUS}
if SText <> '' then begin if SText <> '' then begin
Failed := TRUE; // assume the worst. Failed := TRUE; // assume the worst.
SLen := Length(SText); SLen := Length(SText);
// Open and Close are the only TClipboard methods we use because TClipboard // Open and Close are the only TClipboard methods we use because TClipboard
// is very hard (impossible) to work with if you want to put more than one // is very hard (impossible) to work with if you want to put more than one
// format on it at a time. // format on it at a time.
{$IFNDEF SYN_LAZARUS}
Clipboard.Open; Clipboard.Open;
{$ENDIF}
try try
// Clear anything already on the clipboard. // Clear anything already on the clipboard.
EmptyClipboard; EmptyClipboard;
// Put it on the clipboard as normal text format so it can be pasted into // Put it on the clipboard as normal text format so it can be pasted into
// things like notepad or Delphi. // things like notepad or Delphi.
{$IFDEF SYN_LAZARUS}
if SLen>0 then
ClipBoard.SetTextBuf(PChar(SText));
Failed:=not ClipBoard.HasFormat(CF_TEXT);
{$ELSE}
Mem := GlobalAlloc(GMEM_MOVEABLE or GMEM_DDESHARE, SLen + 1); Mem := GlobalAlloc(GMEM_MOVEABLE or GMEM_DDESHARE, SLen + 1);
if Mem <> 0 then begin if Mem <> 0 then begin
P := GlobalLock(Mem); P := GlobalLock(Mem);
@ -916,13 +922,15 @@ begin
// Don't free Mem! It belongs to the clipboard now, and it will free it // Don't free Mem! It belongs to the clipboard now, and it will free it
// when it is done with it. // when it is done with it.
end; end;
{$ENDIF}
finally finally
{$IFNDEF SYN_LAZARUS}
Clipboard.Close; Clipboard.Close;
{$ENDIF}
if Failed then if Failed then
raise ESynEditError.Create('Clipboard copy operation failed'); raise ESynEditError.Create('Clipboard copy operation failed');
end; end;
end; end;
{$ENDIF}
end; end;
procedure TCustomSynEdit.CopyToClipboard; procedure TCustomSynEdit.CopyToClipboard;
@ -1085,7 +1093,6 @@ destructor TCustomSynEdit.Destroy;
var var
i: integer; i: integer;
begin begin
writeln('[TCustomSynEdit.Destroy]');
Highlighter := nil; Highlighter := nil;
// free listeners while other fields are still valid // free listeners while other fields are still valid
if Assigned(fHookedCommandHandlers) then begin if Assigned(fHookedCommandHandlers) then begin
@ -1113,7 +1120,6 @@ writeln('[TCustomSynEdit.Destroy]');
fFontDummy.Free; fFontDummy.Free;
Lines.Free; Lines.Free;
inherited Destroy; inherited Destroy;
writeln('[TCustomSynEdit.Destroy] end');
end; end;
function TCustomSynEdit.GetBlockBegin: TPoint; function TCustomSynEdit.GetBlockBegin: TPoint;
@ -1443,7 +1449,6 @@ procedure TCustomSynEdit.InvalidateLines(FirstLine, LastLine: integer);
var var
rcInval: TRect; rcInval: TRect;
begin begin
writeln('[TCustomSynEdit.InvalidateLines] ',FirstLine,' ',LastLine);
if Visible and HandleAllocated then if Visible and HandleAllocated then
if (FirstLine = -1) and (LastLine = -1) then begin if (FirstLine = -1) and (LastLine = -1) then begin
rcInval := ClientRect; rcInval := ClientRect;
@ -1464,8 +1469,6 @@ writeln('[TCustomSynEdit.InvalidateLines] ',FirstLine,' ',LastLine);
if sfLinesChanging in fStateFlags then if sfLinesChanging in fStateFlags then
UnionRect(fInvalidateRect, fInvalidateRect, rcInval) UnionRect(fInvalidateRect, fInvalidateRect, rcInval)
else else
writeln('[TCustomSynEdit.InvalidateLines] InvalidateRect ',rcInval.Left,' ',rcInval.Top
,' ',rcInval.Right,' ',rcInval.Bottom);
InvalidateRect(Handle, @rcInval, FALSE); InvalidateRect(Handle, @rcInval, FALSE);
end; end;
end; end;
@ -1608,7 +1611,8 @@ begin
if (fMouseDownX < fGutterWidth) then if (fMouseDownX < fGutterWidth) then
Include(fStateFlags, sfPossibleGutterClick); Include(fStateFlags, sfPossibleGutterClick);
{$IFDEF SYN_LAZARUS} {$IFDEF SYN_LAZARUS}
SetFocus; LCLLinux.SetFocus(Handle);
ShowCaret;
{$ELSE} {$ELSE}
Windows.SetFocus(Handle); Windows.SetFocus(Handle);
{$ENDIF} {$ENDIF}
@ -1699,6 +1703,7 @@ end;
procedure TCustomSynEdit.MouseUp(Button: TMouseButton; Shift: TShiftState; procedure TCustomSynEdit.MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); X, Y: Integer);
begin begin
writeln('TCustomSynEdit.MouseUp x=',x,' y=',y);
inherited MouseUp(Button, Shift, X, Y); inherited MouseUp(Button, Shift, X, Y);
fScrollTimer.Enabled := False; fScrollTimer.Enabled := False;
if (Button = mbRight) and (Shift = [ssRight]) and Assigned(PopupMenu) then if (Button = mbRight) and (Shift = [ssRight]) and Assigned(PopupMenu) then
@ -1830,7 +1835,6 @@ var
end; end;
begin begin
writeln('[TCustomSynEdit.PaintGutter]');
if (FirstLine = 1) and (LastLine = 0) then if (FirstLine = 1) and (LastLine = 0) then
LastLine := 1; LastLine := 1;
// Changed to use fTextDrawer.BeginDrawing and fTextDrawer.EndDrawing only // Changed to use fTextDrawer.BeginDrawing and fTextDrawer.EndDrawing only
@ -1926,7 +1930,6 @@ writeln('[TCustomSynEdit.PaintGutter]');
FreeMem(aGutterOffs); FreeMem(aGutterOffs);
end; end;
end; end;
writeln('[TCustomSynEdit.PaintGutter] end');
end; end;
procedure TCustomSynEdit.PaintTextLines(AClip: TRect; FirstLine, LastLine, procedure TCustomSynEdit.PaintTextLines(AClip: TRect; FirstLine, LastLine,
@ -2383,7 +2386,6 @@ var
{ end local procedures } { end local procedures }
begin begin
writeln('[TCustomSynEdit.PaintTextLines]');
colEditorBG := Color; colEditorBG := Color;
if Assigned(Highlighter) and Assigned(Highlighter.WhitespaceAttribute) then if Assigned(Highlighter) and Assigned(Highlighter.WhitespaceAttribute) then
begin begin
@ -2447,7 +2449,6 @@ writeln('[TCustomSynEdit.PaintTextLines]');
{$ENDIF} {$ENDIF}
end; end;
end; end;
writeln('[TCustomSynEdit.PaintTextLines] end');
end; end;
procedure TCustomSynEdit.Update; procedure TCustomSynEdit.Update;
@ -2457,19 +2458,19 @@ begin
end; end;
procedure TCustomSynEdit.PasteFromClipboard; procedure TCustomSynEdit.PasteFromClipboard;
{$IFNDEF SYN_LAZARUS}
var var
StartOfBlock: TPoint; StartOfBlock: TPoint;
EndOfBlock: TPoint; EndOfBlock: TPoint;
{$IFNDEF SYN_LAZARUS}
PasteMode: TSynSelectionMode; PasteMode: TSynSelectionMode;
Mem: HGLOBAL; Mem: HGLOBAL;
P: PChar; P: PChar;
DummyTag: Integer; DummyTag: Integer;
{$ENDIF} {$ENDIF}
begin begin
{$IFNDEF SYN_LAZARUS}
BeginUndoBlock; //mh 2000-11-20 BeginUndoBlock; //mh 2000-11-20
try try
{$IFNDEF SYN_LAZARUS}
// Check for our special format first. // Check for our special format first.
if Clipboard.HasFormat(SynEditClipboardFormat) then begin if Clipboard.HasFormat(SynEditClipboardFormat) then begin
Clipboard.Open; Clipboard.Open;
@ -2521,7 +2522,7 @@ begin
Clipboard.Close; Clipboard.Close;
end; end;
// If our special format isn't there, check for regular text format. // If our special format isn't there, check for regular text format.
end else if Clipboard.HasFormat(CF_TEXT) then begin end else {$ENDIF} if Clipboard.HasFormat(CF_TEXT) then begin
// Normal text is much easier... // Normal text is much easier...
if SelAvail then begin if SelAvail then begin
// fUndoList.AddChange(crSelDelete, fBlockBegin, fBlockEnd, SelText, // fUndoList.AddChange(crSelDelete, fBlockBegin, fBlockEnd, SelText,
@ -2544,7 +2545,6 @@ begin
EnsureCursorPosVisible; EnsureCursorPosVisible;
// Selection should have changed... // Selection should have changed...
StatusChanged([scSelection]); StatusChanged([scSelection]);
{$ENDIF}
end; end;
procedure TCustomSynEdit.SelectAll; procedure TCustomSynEdit.SelectAll;
@ -2734,7 +2734,8 @@ begin
fGutterWidth := Value; fGutterWidth := Value;
fTextOffset := fGutterWidth + 2 - (LeftChar - 1) * fCharWidth; fTextOffset := fGutterWidth + 2 - (LeftChar - 1) * fCharWidth;
if HandleAllocated then begin if HandleAllocated then begin
fCharsInWindow := (ClientWidth - fGutterWidth - 2) div fCharWidth; fCharsInWindow := (ClientWidth - fGutterWidth -
{$IFDEF SYN_LAZARUS}2 - 15{$ELSE}2{$ENDIF}) div fCharWidth;
UpdateScrollBars; UpdateScrollBars;
Invalidate; Invalidate;
end; end;
@ -4647,13 +4648,11 @@ begin
// vertical caret movement or selection // vertical caret movement or selection
ecUp, ecSelUp: ecUp, ecSelUp:
begin begin
writeln('[TCustomSynEdit.ExecuteCommand] ecUp,ecSelUp');
MoveCaretVert(-1, Command = ecSelUp); MoveCaretVert(-1, Command = ecSelUp);
Update; Update;
end; end;
ecDown, ecSelDown: ecDown, ecSelDown:
begin begin
writeln('[TCustomSynEdit.ExecuteCommand] ecDown,ecSelDown');
MoveCaretVert(1, Command = ecSelDown); MoveCaretVert(1, Command = ecSelDown);
Update; Update;
end; end;
@ -4722,7 +4721,6 @@ writeln('[TCustomSynEdit.ExecuteCommand] ecDown,ecSelDown');
{begin} //mh 2000-10-30 {begin} //mh 2000-10-30
ecDeleteLastChar: ecDeleteLastChar:
if not ReadOnly then begin if not ReadOnly then begin
writeln('[TCustomSynEdit.ExecuteCommand] ecDeleteLastChar');
if SelAvail then if SelAvail then
SetSelectedTextEmpty SetSelectedTextEmpty
else begin else begin
@ -4790,7 +4788,6 @@ writeln('[TCustomSynEdit.ExecuteCommand] ecDeleteLastChar');
end; end;
ecDeleteChar: ecDeleteChar:
if not ReadOnly then begin if not ReadOnly then begin
writeln('[TCustomSynEdit.ExecuteCommand] ecDeleteChar');
if SelAvail then if SelAvail then
SetSelectedTextEmpty SetSelectedTextEmpty
else begin else begin
@ -4826,7 +4823,6 @@ writeln('[TCustomSynEdit.ExecuteCommand] ecDeleteChar');
end; end;
ecDeleteWord, ecDeleteEOL: ecDeleteWord, ecDeleteEOL:
if not ReadOnly then begin if not ReadOnly then begin
writeln('[TCustomSynEdit.ExecuteCommand] ecDeleteWord,ecDeleteEOL');
Len := Length(LineText); Len := Length(LineText);
if Command = ecDeleteWord then begin if Command = ecDeleteWord then begin
if CaretX > Len + 1 then if CaretX > Len + 1 then
@ -4851,7 +4847,6 @@ writeln('[TCustomSynEdit.ExecuteCommand] ecDeleteWord,ecDeleteEOL');
end; end;
ecDeleteLastWord, ecDeleteBOL: ecDeleteLastWord, ecDeleteBOL:
if not ReadOnly then begin if not ReadOnly then begin
writeln('[TCustomSynEdit.ExecuteCommand] ecDeleteLastWord');
if Command = ecDeleteLastWord then if Command = ecDeleteLastWord then
WP := PrevWordPos WP := PrevWordPos
else else
@ -4875,7 +4870,6 @@ writeln('[TCustomSynEdit.ExecuteCommand] ecDeleteLastWord');
ecDeleteLine: ecDeleteLine:
if not ReadOnly and not ((Lines.Count = 1) and (Length(Lines[0]) = 0)) if not ReadOnly and not ((Lines.Count = 1) and (Length(Lines[0]) = 0))
then begin then begin
writeln('[TCustomSynEdit.ExecuteCommand] ecDeleteLastLine');
if SelAvail then if SelAvail then
SetBlockBegin(CaretXY); SetBlockBegin(CaretXY);
if Lines.Count = 1 then begin if Lines.Count = 1 then begin
@ -4897,7 +4891,6 @@ writeln('[TCustomSynEdit.ExecuteCommand] ecDeleteLastLine');
ecInsertLine, ecInsertLine,
ecLineBreak: ecLineBreak:
if not ReadOnly then begin if not ReadOnly then begin
writeln('[TCustomSynEdit.ExecuteCommand] ecLineBreak');
if SelAvail then begin if SelAvail then begin
fUndoList.AddChange(crDelete, fBlockBegin, fBlockEnd, SelText, fUndoList.AddChange(crDelete, fBlockBegin, fBlockEnd, SelText,
SelectionMode); SelectionMode);
@ -5002,7 +4995,6 @@ writeln('[TCustomSynEdit.ExecuteCommand] ecLineBreak');
FindMatchingBracket; FindMatchingBracket;
ecChar: ecChar:
if not ReadOnly and (AChar >= #32) and (AChar <> #127) then begin if not ReadOnly and (AChar >= #32) and (AChar <> #127) then begin
writeln('[TCustomSynEdit.ExecuteCommand] ecChar ''',AChar,'''');
if SelAvail then begin if SelAvail then begin
BeginUndoBlock; BeginUndoBlock;
try try
@ -5111,7 +5103,6 @@ writeln('[TCustomSynEdit.ExecuteCommand] ecChar ''',AChar,'''');
end; end;
ecScrollUp: ecScrollUp:
begin begin
writeln('[TCustomSynEdit.ExecuteCommand] ecScrollUp');
TopLine := TopLine - 1; TopLine := TopLine - 1;
if CaretY > TopLine + LinesInWindow - 1 then if CaretY > TopLine + LinesInWindow - 1 then
CaretY := TopLine + LinesInWindow - 1; CaretY := TopLine + LinesInWindow - 1;
@ -5119,7 +5110,6 @@ writeln('[TCustomSynEdit.ExecuteCommand] ecScrollUp');
end; end;
ecScrollDown: ecScrollDown:
begin begin
writeln('[TCustomSynEdit.ExecuteCommand] ecScrollDown');
TopLine := TopLine + 1; TopLine := TopLine + 1;
if CaretY < TopLine then if CaretY < TopLine then
CaretY := TopLine; CaretY := TopLine;
@ -5788,8 +5778,10 @@ end;
procedure TCustomSynEdit.SizeOrFontChanged(bFont: boolean); procedure TCustomSynEdit.SizeOrFontChanged(bFont: boolean);
begin begin
if HandleAllocated then begin if HandleAllocated then begin
fCharsInWindow := (ClientWidth - fGutterWidth - 2) div fCharWidth; fCharsInWindow := (ClientWidth - fGutterWidth -
fLinesInWindow := ClientHeight div fTextHeight; {$IFDEF SYN_LAZARUS}15{$ELSE}2{$ENDIF}) div fCharWidth;
fLinesInWindow := (ClientHeight {$IFDEF SYN_LAZARUS}-13{$ENDIF})
div fTextHeight;
if bFont then begin if bFont then begin
if Gutter.ShowLineNumbers then if Gutter.ShowLineNumbers then
GutterChanged(Self) GutterChanged(Self)
@ -6048,7 +6040,6 @@ end;
procedure TCustomSynEdit.DestroyWnd; procedure TCustomSynEdit.DestroyWnd;
begin begin
writeln('[TCustomSynEdit.DestroyWnd]');
if (eoDropFiles in fOptions) and not (csDesigning in ComponentState) then if (eoDropFiles in fOptions) and not (csDesigning in ComponentState) then
{$IFDEF SYN_LAZARUS} {$IFDEF SYN_LAZARUS}
// ToDo DragAcceptFiles // ToDo DragAcceptFiles
@ -6056,9 +6047,7 @@ writeln('[TCustomSynEdit.DestroyWnd]');
{$ELSE} {$ELSE}
DragAcceptFiles(Handle, FALSE); DragAcceptFiles(Handle, FALSE);
{$ENDIF} {$ENDIF}
writeln('[TCustomSynEdit.DestroyWnd] B');
inherited DestroyWnd; inherited DestroyWnd;
writeln('[TCustomSynEdit.DestroyWnd] C');
end; end;
procedure TCustomSynEdit.DoBlockIndent; procedure TCustomSynEdit.DoBlockIndent;

View File

@ -430,6 +430,8 @@ begin
if sCompl <> '' then //mg 2000-11-07 if sCompl <> '' then //mg 2000-11-07
SaveEntry; SaveEntry;
end; end;
//Mattias
fParsed:=true;
end; end;
function TCustomSynAutoComplete.RemoveEditor(AEditor: TCustomSynEdit): boolean; function TCustomSynAutoComplete.RemoveEditor(AEditor: TCustomSynEdit): boolean;

187
ide/codetemplatedialog.pp Normal file
View File

@ -0,0 +1,187 @@
{
Author: Mattias Gaertner
Abstract:
A dialog for adding and editing code templates
ToDo:
-check if token already exists
}
unit CodeTemplateDialog;
{$mode objfpc}
interface
uses
Classes, SysUtils, LCLLinux, LResources, Forms, Buttons, Controls,
SynEditAutoComplete, StdCtrls, SynEditKeyCmds;
type
TCodeTemplateEditForm = class(TForm)
TokenLabel:TLabel;
TokenEdit:TEdit;
CommentLabel:TLabel;
CommentEdit:TEdit;
OkButton:TButton;
CancelButton:TButton;
procedure OkButtonClick(Sender:TObject);
public
constructor Create(AOwner:TComponent); override;
SynAutoComplete:TSynAutoComplete;
TemplateIndex:integer;
end;
function AddCodeTemplate(ASynAutoComplete:TSynAutoComplete;
var Token,Comment:ansistring):TModalResult;
function EditCodeTemplate(ASynAutoComplete:TSynAutoComplete;
Index:integer):TModalResult;
implementation
function AddCodeTemplate(ASynAutoComplete:TSynAutoComplete;
var Token,Comment:ansistring):TModalResult;
var
CodeTemplateEditForm:TCodeTemplateEditForm;
begin
Result:=mrCancel;
CodeTemplateEditForm:=TCodeTemplateEditForm.Create(Application);
try
CodeTemplateEditForm.SynAutoComplete:=ASynAutoComplete;
CodeTemplateEditForm.TemplateIndex:=ASynAutoComplete.Completions.Count;
CodeTemplateEditForm.Caption:='Add code template';
CodeTemplateEditForm.OkButton.Caption:='Add';
CodeTemplateEditForm.TokenEdit.Text:=Token;
CodeTemplateEditForm.CommentEdit.Text:=Comment;
Result:=CodeTemplateEditForm.ShowModal;
if Result=mrOk then begin
Token:=CodeTemplateEditForm.TokenEdit.Text;
Comment:=CodeTemplateEditForm.CommentEdit.Text;
end;
finally
CodeTemplateEditForm.Free;
end;
end;
function EditCodeTemplate(ASynAutoComplete:TSynAutoComplete;
Index:integer):TModalResult;
var
CodeTemplateEditForm:TCodeTemplateEditForm;
begin
Result:=mrCancel;
if (Index<0) or (Index>=ASynAutoComplete.Completions.Count) then exit;
CodeTemplateEditForm:=TCodeTemplateEditForm.Create(Application);
try
CodeTemplateEditForm.SynAutoComplete:=ASynAutoComplete;
CodeTemplateEditForm.TemplateIndex:=Index;
CodeTemplateEditForm.Caption:='Edit code template';
CodeTemplateEditForm.OkButton.Caption:='Change';
CodeTemplateEditForm.TokenEdit.Text:=ASynAutoComplete.Completions[Index];
CodeTemplateEditForm.CommentEdit.Text:=
ASynAutoComplete.CompletionComments[Index];
Result:=CodeTemplateEditForm.ShowModal;
if Result=mrOk then begin
ASynAutoComplete.Completions[Index]:=
CodeTemplateEditForm.TokenEdit.Text;
ASynAutoComplete.CompletionComments[Index]:=
CodeTemplateEditForm.CommentEdit.Text;
end;
finally
CodeTemplateEditForm.Free;
end;
end;
{ TCodeTemplateEditForm }
constructor TCodeTemplateEditForm.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
if LazarusResources.Find(ClassName)=nil then begin
Width:=300;
Height:=140;
TokenLabel:=TLabel.Create(Self);
with TokenLabel do begin
Name:='TokenLabel';
Parent:=Self;
Caption:='Token:';
Left:=12;
Top:=6;
Width:=Self.ClientWidth-Left-Left;
Show;
end;
TokenEdit:=TEdit.Create(Self);
with TokenEdit do begin
Name:='TokenEdit';
Parent:=Self;
Left:=10;
Top:=TokenLabel.Top+TokenLabel.Height+2;
Width:=Self.ClientWidth-Left-Left-4;
Text:='';
Show;
end;
CommentLabel:=TLabel.Create(Self);
with CommentLabel do begin
Name:='CommentLabel';
Parent:=Self;
Caption:='Comment:';
Left:=12;
Top:=TokenEdit.Top+TokenEdit.Height+23;
Width:=Self.ClientWidth-Left-Left;
Show;
end;
CommentEdit:=TEdit.Create(Self);
with CommentEdit do begin
Name:='CommentEdit';
Parent:=Self;
Left:=10;
Top:=CommentLabel.Top+CommentLabel.Height+2;
Width:=Self.ClientWidth-Left-Left-4;
Text:='';
Show;
end;
OkButton:=TButton.Create(Self);
with OkButton do begin
Name:='OkButton';
Parent:=Self;
Caption:='Ok';
OnClick:=@OkButtonClick;
Left:=50;
Top:=Self.ClientHeight-Height-12;
Width:=80;
Show;
end;
CancelButton:=TButton.Create(Self);
with CancelButton do begin
Name:='CancelButton';
Parent:=Self;
Caption:='Cancel';
ModalResult:=mrCancel;
Width:=80;
Left:=Self.ClientWidth-50-Width;
Top:=Self.ClientHeight-Height-12;
Show;
end;
end;
end;
procedure TCodeTemplateEditForm.OkButtonClick(Sender:TObject);
var a:integer;
AText,ACaption:AnsiString;
begin
a:=SynAutoComplete.Completions.IndexOf(TokenEdit.Text);
if (a<0) or (a=TemplateIndex) then
ModalResult:=mrOk
else begin
AText:=' A token '''+TokenEdit.Text+''' already exists! ';
ACaption:='Error';
Application.MessageBox(PChar(AText),PChar(ACaption),0);
end;
end;
end.

2722
ide/editoroptions.pp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -5,88 +5,14 @@
******************************************************************************) ******************************************************************************)
constructor TUnitInfo.Create;
begin
inherited Create;
Source := TStringList.Create;
Fpage := -1;
FName := '';
FFormName := '';
end;
destructor TUnitInfo.Destroy;
begin
Source.Destroy;
inherited destroy;
end;
procedure TUnitInfo.SetFormName(Value : String);
var
I : Integer;
Texts : String;
TempNum : Integer;
Replace : Boolean;
TempEdit : TmwCustomEdit;
begin
end;
function TUnitInfo.GetFormName : String;
begin
Result := FFormName;
end;
procedure TUnitInfo.SetPage(Value : Integer);
begin
FPage := Value;
end;
function TUnitInfo.GetPage : Integer;
begin
Result := FPage;
end;
{This function returns the index line number where the class definition starts}
function TUnitInfo.FindStartClass(cName: String; LineStart: Integer) : Integer;
var
I : Integer;
Texts : String;
begin
for I := LineStart to Source.Count-1 do
begin
Texts := Source.Strings[i];
if (pos(cName, Texts) > 0)
and (pos('class', Texts) > 0)
then begin
//validate it but for now, just break;
Result := i;
Break;
end;
end;
end;
procedure TUnitInfo.AddProcedureLine(value : String);
var
TempEdit : TmwCustomEdit;
num,i : Integer;
begin
end;
procedure TUnitInfo.AddControlLine(value : String); //adds the "Edit1 : TEdit" line
var
TempEdit : TmwCustomEdit;
I : Integer;
Texts : String;
SpaceCount : Integer;
Num : Integer;
END_Found,PROC_Found, PUBLIC_Found, PRIVATE_Found : Boolean;
begin
end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.3 2001/01/31 13:03:33 lazarus
Commitng source with new editor.
Shane
Revision 1.2 2000/12/19 18:43:12 lazarus Revision 1.2 2000/12/19 18:43:12 lazarus
Removed IDEEDITOR. This causes the PROJECT class to not function. Removed IDEEDITOR. This causes the PROJECT class to not function.
Saving projects no longer works. Saving projects no longer works.

View File

@ -22,48 +22,12 @@ unit global;
{$mode objfpc} {$mode objfpc}
interface interface
uses
Classes,sysutils;
type
TPRojFlags = (pfProject, pfForm, pfSource, pfNone);
TUnitInfo = class(TObject)
private
FName : String;
FFormName : String;
FFileName : String;
FFlags : TProjFlags;
FSource : TStringList;
FPage : Integer;
// FForm : TDesignerForm;
Procedure SetFormName(Value : String);
Function GetFormName : String;
Procedure SetPage(Value : Integer);
Function GetPage : Integer;
public
constructor Create;
destructor Destroy; override;
Procedure AddControlLine(value : String); //adds the "Edit1 : TEdit" line
Procedure AddProcedureLine(value : String); //adds the "Procedure TFomr.Button1Click(sender: TObject);" line
Function FindStartClass(cName: String; LineStart: Integer) : Integer;
Property Name : String read FName write FName;
Property FormName: String read GetFormName write SetFormName;
Property Source : TStringList read FSource write FSource;
Property Page : Integer read GetPage write SetPage;
Property FileName : String read FFileName write FFilename;
Property Flags : TProjFlags read FFlags write FFLags;
// property Form : TDesignerForm read fform write fform;
end;
var
ActivePage : Integer;
implementation implementation
uses
mwCustomEdit;
{$I global.inc} {$I global.inc}
@ -73,6 +37,10 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.5 2001/01/31 13:03:33 lazarus
Commitng source with new editor.
Shane
Revision 1.4 2000/12/19 18:43:12 lazarus Revision 1.4 2000/12/19 18:43:12 lazarus
Removed IDEEDITOR. This causes the PROJECT class to not function. Removed IDEEDITOR. This causes the PROJECT class to not function.
Saving projects no longer works. Saving projects no longer works.

133
ide/lazarus.dci Normal file
View File

@ -0,0 +1,133 @@
[arrayd | array declaration (var)]
array[0..|] of ;
[arrayc | array declaration (const)]
array[0..|] of = ();
[cases | case statement]
case | of
: ;
: ;
end;
[casee | case statement (with else)]
case | of
: ;
: ;
else ;
end;
[classf | class declaration (all parts)]
T| = class(T)
private
protected
public
published
end;
[classd | class declaration (no parts)]
T| = class(T)
end;
[classc | class declaration (with Create/Destroy overrides)]
T| = class(T)
private
protected
public
constructor Create; override;
destructor Destroy; override;
published
end;
[fors | for (no begin/end)]
for | := to do
[forb | for statement]
for | := to do
begin
end;
[function | function declaration]
function |(): ;
begin
end;
[ifs | if (no begin/end)]
if | then
[ifb | if statement]
if | then
begin
end;
[ife | if then (no begin/end) else (no begin/end)]
if | then
else
[ifeb | if then else]
if | then
begin
end
else
begin
end;
[procedure | procedure declaration]
procedure |();
begin
end;
[trye | try except]
try
|
except
end;
[tryf | try finally]
try
|
finally
end;
[trycf | try finally (with Create/Free)]
|variable := typename.Create;
try
finally
variable.Free;
end;
[whileb | while statement]
while | do
begin
end;
[whiles | while (no begin)]
while | do
[withb | with statement]
with | do
begin
end;
[withs | with (no begin)]
with | do

View File

@ -34,8 +34,9 @@ uses
compileroptions, compileroptions,
dlgMessage, dlgMessage,
viewunit_dlg, //dialog used to list the units in a project viewunit_dlg, //dialog used to list the units in a project
viewform_dlg; //dialog to display the forms in the project viewform_dlg, //dialog to display the forms in the project
editoroptions,
codetemplatedialog;
var var
SplashForm: TSplashForm; SplashForm: TSplashForm;
@ -56,6 +57,7 @@ begin
Application.CreateForm(TViewUnits1, ViewUnits1); Application.CreateForm(TViewUnits1, ViewUnits1);
Application.CreateForm(TfrmCompilerOptions, frmCompilerOptions); Application.CreateForm(TfrmCompilerOptions, frmCompilerOptions);
Application.CreateForm(TViewForms1, ViewForms1); Application.CreateForm(TViewForms1, ViewForms1);
Application.CreateForm(TEditorOptionsForm,EditorOptionsForm );
SplashForm.StartTimer; SplashForm.StartTimer;
Application.Run; Application.Run;
end. end.
@ -63,6 +65,10 @@ end.
{ {
$Log$ $Log$
Revision 1.12 2001/01/31 13:03:33 lazarus
Commitng source with new editor.
Shane
Revision 1.11 2001/01/16 23:30:45 lazarus Revision 1.11 2001/01/16 23:30:45 lazarus
trying to determine what's crashing LAzarus on load. trying to determine what's crashing LAzarus on load.
Shane Shane

View File

@ -33,7 +33,7 @@ uses
Spin, project,sysutils, Spin, project,sysutils,
compileroptions, Controls, graphics, extctrls, Dialogs, dlgMEssage, compileroptions, Controls, graphics, extctrls, Dialogs, dlgMEssage,
process, idecomp, Find_dlg, FormEditor, AbstractFormEditor, process, idecomp, Find_dlg, FormEditor, AbstractFormEditor,
CustomFormEditor,ObjectInspector, ControlSelection, PropEdits, UnitEditor, CustomFormEditor,ObjectInspector, ControlSelection, PropEdits, UnitEditor, EditorOptions,CodeTemplateDialog,
CompReg; CompReg;
const const
@ -147,6 +147,8 @@ type
procedure mnuSearchFindClicked(Sender : TObject); procedure mnuSearchFindClicked(Sender : TObject);
procedure mnuSearchFindAgainClicked(Sender : TObject); procedure mnuSearchFindAgainClicked(Sender : TObject);
procedure mnuEnvironmentOptionsClicked(Sender : TObject);
Procedure OpenFileDownArrowClicked(Sender : TObject); Procedure OpenFileDownArrowClicked(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);
@ -173,7 +175,6 @@ type
procedure ButtonCLick(Sender : TObject); procedure ButtonCLick(Sender : TObject);
procedure ToolButtonCLick(Sender : TObject); procedure ToolButtonCLick(Sender : TObject);
// Procedure Paint; override; // Procedure Paint; override;
Function ReturnFormName(Source : TStringList) : String;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
@ -980,6 +981,8 @@ begin
itmEnvironmentOptions := TMenuItem.Create(nil); itmEnvironmentOptions := TMenuItem.Create(nil);
itmEnvironmentOptions.Caption := 'Options'; itmEnvironmentOptions.Caption := 'Options';
itmEnvironmentOptions.OnCLick := @mnuEnvironmentOptionsClicked;
mnuEnvironment.Add(itmEnvironmentOptions); mnuEnvironment.Add(itmEnvironmentOptions);
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -1036,26 +1039,17 @@ Begin
{what now???} {what now???}
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{Fills the View Units dialog and the View Forms dialog} {Fills the View Units dialog and the View Forms dialog}
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
Procedure TMainIDE.UpdateViewDialogs; Procedure TMainIDE.UpdateViewDialogs;
Var
I : Integer;
//SList : TUnitInfo;
Begin Begin
ViewUnits1.Listbox1.Items.Clear; ViewUnits1.Listbox1.Items.Clear;
ViewForms1.Listbox1.Items.Clear; ViewForms1.Listbox1.Items.Clear;
{
For I := 0 to Project.UnitList.Count -1 do
Begin
SList := TUnitInfo(Project.UnitList.Items[I]);
ViewUnits1.Listbox1.Items.Add(SList.Name);
if SList.FormName <> '' then
ViewForms1.Listbox1.Items.Add(SList.FormName);
end;
}
End; End;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -1247,6 +1241,9 @@ begin
FormEditor1.AddSelected(TComponent(CInterface.Control)); FormEditor1.AddSelected(TComponent(CInterface.Control));
end; end;
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
{----------------OpenFileDownArrowClicked--------------------------------------} {----------------OpenFileDownArrowClicked--------------------------------------}
@ -1399,9 +1396,16 @@ procedure TMainIDE.mnuQuitClicked(Sender : TObject);
var var
I : Integer; I : Integer;
begin begin
//if there is a project loaded, check if it should be saved
//free the unitlist objects
if Project.UnitList.Count > 0 then
For I := 0 to Project.UnitList.Count -1 do
Begin
end;
//if there is a project loaded, check if it should be saved //if there is a project loaded, check if it should be saved
Project.Free; Project.Free;
Close; Close;
end; end;
@ -1465,8 +1469,82 @@ End;
{------------------------------------------------------------} {------------------------------------------------------------}
Procedure TMainIDE.mnuNewProjectClicked(Sender : TObject); Procedure TMainIDE.mnuNewProjectClicked(Sender : TObject);
var
Proj_Info : TUnitInfo;
tempSource : TStrings;
Begin Begin
Assert(False, 'Trace:New Project Clicked'); Assert(False, 'Trace:New Project Clicked');
//See if a project is loaded
If Project.ProjectFile <> '' then
Begin
//save and close the project
end;
//Create a new project
Project.ProjectFile := 'Project1.lpr';
Project.MainUnit := 'Unit1';
Project.Title := 'Project1';
TempSource := TStringList.Create;
TempSource.Add('Program Project1;');
TempSource.Add('');
tempSource.Add('{$mode objfpc}');
TempSource.Add('');
TempSource.Add('uses forms,');
TempSource.Add(' Unit1 in ''Unit1.pp'' {Form1}');
TempSource.Add('');
TempSource.Add('begin');
TempSource.Add(' Application.Initialize;');
TempSource.Add(' Application.CreateForm(TForm1, Form1);');
TempSource.Add(' Application.Run;');
TempSource.Add('end.');
SourceNotebook.NewFile('Project1',TempSource,True);
Proj_Info := TUnitInfo.Create;
with Proj_Info do
Begin
UnitName := 'Project1';
//??
end;
Project.AddUnit(Proj_Info);
//create first form file
TempSource.Clear;
TempSource.Add('unit Unit1;');
TempSource.Add('');
tempSource.Add('{$mode objfpc}');
TempSource.Add('interface');
TempSource.Add('uses Classes, Graphics, Controls, Forms, Dialogs;');
TempSource.Add('');
TempSource.Add('type');
TempSource.Add(' TForm1 = class(TFORM)');
TempSource.Add(' private');
TempSource.Add(' { private declarations }');
TempSource.Add(' public');
TempSource.Add(' { public declarations }');
TempSource.Add(' end;');
TempSource.Add('');
TempSource.Add('var');
TempSource.Add(' Form1 : TForm1;');
TempSource.Add('');
TempSource.Add('implementation');
TempSource.Add('');
TempSource.Add('end.');
SourceNotebook.NewFile('Unit1',TempSource,True);
Proj_Info := TUnitInfo.Create;
with Proj_Info do
Begin
UnitName := 'Unit1';
//??
end;
Project.AddUnit(Proj_Info);
Project.ProjectInfoFile := 'Project1.cfg';
end; end;
Procedure TMainIDE.mnuOpenProjectClicked(Sender : TObject); Procedure TMainIDE.mnuOpenProjectClicked(Sender : TObject);
@ -1477,6 +1555,7 @@ end;
Procedure TMainIDE.mnuSaveProjectClicked(Sender : TObject); Procedure TMainIDE.mnuSaveProjectClicked(Sender : TObject);
Begin Begin
Assert(False, 'Trace:Save Project Clicked'); Assert(False, 'Trace:Save Project Clicked');
Project.WriteProject;
end; end;
procedure TMainIDE.mnuSaveProjectAsClicked(Sender : TObject); procedure TMainIDE.mnuSaveProjectAsClicked(Sender : TObject);
@ -1551,127 +1630,11 @@ begin
//frmProjectOptions.Show; //frmProjectOptions.Show;
end; end;
Function TMainIDE.ReturnFormName(Source : TStringlist) : String; procedure TMainIDE.mnuEnvironmentOptionsClicked(Sender : TObject);
Var
I : Integer;
Num,Num2 : Integer;
Found : Boolean;
Texts : String;
Temp : String;
Temp2 : String;
Begin Begin
//Assert(False, 'Trace:************************************************'); EditorOptionsForm.ShowModal;
//Assert(False, 'Trace:************************************************'); End;
//Assert(False, 'Trace:************************************************');
//Assert(False, 'Trace:************************************************');
//Assert(False, 'Trace:************************************************');
//move to TUnitInfo
//parse file for the first class(TForm) I guess
Found := False;
for I := 0 to Source.Count-1 do
Begin
Num := pos(uppercase('class(TForm)'),uppercase(Source.Strings[I]));
if Num <> 0 then
Begin
Temp := Source.Strings[i];
//pull out class name
Texts := '';
for Num2 := 1 to length(Temp) do
Begin
if (Temp[num2] in ['a'..'z']) or (Temp[num2] in ['A'..'Z']) or (Temp[num2] in ['0'..'1'])then
Texts := Texts + Temp[num2]
else
if Length(Texts) <> 0 then Break;
end;
temp := Texts;
// Assert(False, 'Trace:*******************');
// Assert(False, 'Trace:Temp := '+Temp);
Found := True;
Break;
end;
end;
if Found then
Begin
{Temp now holds TFORM1 or whatever the name of the class is}
{Search for the var statement from the I line down}
Texts := '';
Num := I;
for I := Num to Source.Count-1 do
Begin
Found := False;
Num := pos('VAR',uppercase(Source.Strings[I]));
if Num <> 0 then
Begin
Temp2 := Source.Strings[I];
//Check around the VAR to see either spaces or begin/end of line
if (Length(Temp2) = 3) then
Begin
Found := True;
// Assert(False, 'Trace:1');
Num := I;
Break;
end;
//var in the beginning of a sentence
if (Num = 1) and ( not ( (Temp2[4] in CapLetters) or (Temp2[4] in SmallLetters) or (Temp2[4] in Numbers))) then
Begin
Found := True;
Num := I;
// Assert(False, 'Trace:2');
Break;
end;
if ((Num+2) = length(Temp2)) and not ( (Temp2[Num-1] in CapLetters) or (Temp2[Num-1] in SmallLetters) or (Temp2[Num-1] in Numbers)) then
Begin
Found := True;
Num := I;
// Assert(False, 'Trace:3');
Break;
end;
if not ( (Temp2[Num-1] in CapLetters) or (Temp2[Num-1] in SmallLetters) or (Temp2[Num-1] in Numbers)) and not ( (Temp2[Num+3] in CapLetters) or (Temp2[Num+3] in SmallLetters) or (Temp2[Num+3] in Numbers)) then
Begin
Found := True;
Num := I;
// Assert(False, 'Trace:4');
Break;
end;
end;
end;
end;
Assert(False, 'Trace:Length of temp2 is '+inttostr(Length(Temp2)));
if Found then
begin
for I := Num to Source.Count-1 do
Begin
Found := False;
Num := pos(uppercase(temp),uppercase(Source.Strings[I]));
if num <> 0 then
begin
num2 := pos(':', Source.Strings[i]);
if num2 <> 0 then
Begin
Temp2 := Source.Strings[i];
for num := 1 to num2 do
Begin
if (Temp2[num] in ['a'..'z']) or (Temp2[num] in ['A'..'Z']) or (Temp2[num] in ['0'..'1'])then
Texts := Texts + Temp2[num]
else
if Length(Texts) <> 0 then Break;
end;
break;
end;
end;
end;
end;
result := Texts;
end;
Procedure TMainIDE.MessageViewDblClick(Sender : TObject); Procedure TMainIDE.MessageViewDblClick(Sender : TObject);
Begin Begin
@ -1691,6 +1654,10 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.52 2001/01/31 13:03:33 lazarus
Commitng source with new editor.
Shane
Revision 1.51 2001/01/31 06:25:35 lazarus Revision 1.51 2001/01/31 06:25:35 lazarus
Removed global unit. Removed global unit.
Removed and commented all references to TUnitInfo. Removed and commented all references to TUnitInfo.

View File

@ -390,10 +390,12 @@ end;
procedure TProject.AddUnit(AUnit: TUnitInfo); procedure TProject.AddUnit(AUnit: TUnitInfo);
begin begin
if (AUnit <> nil) then UnitList.Add(AUnit); if (AUnit <> nil) then UnitList.Add(AUnit);
{ TODO: { TODO:
Add the unit to the .lpr file. Add the unit to the .lpr file.
Add an AutoCreate method call to the .lpr file for the unit. Add an AutoCreate method call to the .lpr file for the unit.
} }
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -446,7 +448,7 @@ begin
if (ProjectInfoFile = '') then exit; if (ProjectInfoFile = '') then exit;
confPath := GetPrimaryConfigPath + '/' + ProjectInfoFile; confPath := GetPrimaryConfigPath + '/' + ProjectInfoFile;
Writeln('[TPRoject] confPath = '+ConfPath);
// See if config path exists and if not create it // See if config path exists and if not create it
if (not DirectoryExists(GetPrimaryConfigPath)) then if (not DirectoryExists(GetPrimaryConfigPath)) then
begin begin
@ -474,6 +476,10 @@ end;
end. end.
{ {
$Log$ $Log$
Revision 1.6 2001/01/31 13:03:33 lazarus
Commitng source with new editor.
Shane
Revision 1.5 2001/01/31 06:28:41 lazarus Revision 1.5 2001/01/31 06:28:41 lazarus
Removed global unit. Removed global unit.
Renamed TProjectUnitInfo to TUnitInfo. Renamed TProjectUnitInfo to TUnitInfo.

View File

@ -23,7 +23,7 @@
} }
//{$DEFINE NEW_EDITOR} //{$DEFINE NEW_EDITOR}
//{$DEFINE NEW_EDITOR_SYNEDIT} {$DEFINE NEW_EDITOR_SYNEDIT}
unit UnitEditor; unit UnitEditor;
{$mode objfpc} {$mode objfpc}
@ -31,9 +31,10 @@ unit UnitEditor;
interface interface
uses uses
classes, Controls, forms,buttons,sysutils,Dialogs,FormEditor, classes, Controls, forms,buttons,comctrls,sysutils,Dialogs,FormEditor,
{$ifdef NEW_EDITOR_SYNEDIT} {$ifdef NEW_EDITOR_SYNEDIT}
synedit,SysHighlighterpas, SynEdit, SynEditHighlighter, SynHighlighterPas, SynEditAutoComplete,
SynEditKeyCmds,
{$else} {$else}
mwcustomedit,mwPasSyn, mwcustomedit,mwPasSyn,
{$endif} {$endif}
@ -60,8 +61,8 @@ type
//FAOwner is normally a TSourceNotebook. This is set in the Create constructor. //FAOwner is normally a TSourceNotebook. This is set in the Create constructor.
FAOwner : TComponent; FAOwner : TComponent;
{$ifdef NEW_EDITOR_SYNEDIT} {$ifdef NEW_EDITOR_SYNEDIT}
FHighlighter: TSynPasSyn; FEditor : TSynEdit;
FEditor : TSynEditor FSynAutoComplete: TSynAutoComplete;
{$else} {$else}
FHighlighter: TmwPasSyn; FHighlighter: TmwPasSyn;
FEditor : TmwCustomEdit; FEditor : TmwCustomEdit;
@ -81,6 +82,9 @@ type
// Used GetModified like this -> Result := FEditor.Modified // Used GetModified like this -> Result := FEditor.Modified
FModified : Boolean; FModified : Boolean;
// Used GetReadolny like this -> Result := FEditor.Readonly
FReadOnly : Boolean;
//created during the constructor. This is the popup you see when right-clicking on the editor //created during the constructor. This is the popup you see when right-clicking on the editor
FPopUpMenu : TPopupMenu; FPopUpMenu : TPopupMenu;
@ -96,6 +100,8 @@ type
FOnBeforeClose : TNotifyEvent; FOnBeforeClose : TNotifyEvent;
FOnBeforeOpen : TNotifyEvent; FOnBeforeOpen : TNotifyEvent;
FOnBeforeSave : TNotifyEvent; FOnBeforeSave : TNotifyEvent;
FOnEditorChange: TNotifyEvent;
FVisible : Boolean;
Procedure BuildPopupMenu; Procedure BuildPopupMenu;
Function GetSource : TStrings; Function GetSource : TStrings;
@ -106,6 +112,8 @@ type
Procedure SetCurrentCursorYLine(num : Integer); Procedure SetCurrentCursorYLine(num : Integer);
Function GetAncestor : String; Function GetAncestor : String;
Function GetModified : Boolean; Function GetModified : Boolean;
Function GetInsertMode : Boolean;
Function GetReadonly : Boolean;
Function TextUnderCursor : String; Function TextUnderCursor : String;
Function GotoMethod(Value : String) : Integer; Function GotoMethod(Value : String) : Integer;
Function GotoMethodDeclaration(Value : String) : Integer; Function GotoMethodDeclaration(Value : String) : Integer;
@ -121,15 +129,22 @@ type
Procedure BookMarkGotoClicked(Sender : TObject); Procedure BookMarkGotoClicked(Sender : TObject);
Procedure ReadOnlyClicked(Sender : TObject); Procedure ReadOnlyClicked(Sender : TObject);
Procedure ToggleBreakpointClicked(Sender : TObject); Procedure ToggleBreakpointClicked(Sender : TObject);
Procedure ToggleLineNumbersClicked(Sender : TObject);
Procedure OpenAtCursorClicked(Sender : TObject); Procedure OpenAtCursorClicked(Sender : TObject);
Procedure BookMarkToggle(Value : Integer); Procedure BookMarkToggle(Value : Integer);
Procedure BookMarkGoto(Value : Integer); Procedure BookMarkGoto(Value : Integer);
Procedure EditorKeyDown(Sender : TObject; var Key: Word; Shift : TShiftState); Procedure EditorKeyDown(Sender : TObject; var Key: Word; Shift : TShiftState);
Procedure EditorKeyUp(Sender : TObject; var Key: Word; Shift : TShiftState); Procedure EditorKeyUp(Sender : TObject; var Key: Word; Shift : TShiftState);
property Editor : TmwCustomEdit read FEditor; Procedure FocusEditor; //called by TSourceNotebook whne the Notebook page changes so the editor is focused
Procedure EditorStatusChanged(Sender: TObject; Changes: TSynStatusChanges);
property Editor : TmwCustomEdit read FEditor;
property Visible : Boolean read FVisible write FVisible default False;
public public
constructor Create(AOwner : TComponent; AParent : TWinControl); constructor Create(AOwner : TComponent; AParent : TWinControl);
destructor Destroy; override; destructor Destroy; override;
@ -148,9 +163,11 @@ type
property CurrentCursorYLine : Integer read GetCurrentCursorYLine write SetCurrentCursorYLine; property CurrentCursorYLine : Integer read GetCurrentCursorYLine write SetCurrentCursorYLine;
property Owner : TComponent read FAOwner; property Owner : TComponent read FAOwner;
property Source : TStrings read GetSource write SetSource; property Source : TStrings read GetSource write SetSource;
property UnitName : String read FUnitName; property UnitName : String read FUnitName write FUnitname;
property FileName : String read FFileName write FFilename; property FileName : String read FFileName write FFilename;
property Modified : Boolean read GetModified; property Modified : Boolean read GetModified;
property ReadOnly : Boolean read GetReadOnly;
property InsertMode : Boolean read GetInsertmode;
property OnAfterClose : TNotifyEvent read FOnAfterClose write FOnAfterClose; property OnAfterClose : TNotifyEvent read FOnAfterClose write FOnAfterClose;
property OnBeforeClose : TNotifyEvent read FOnBeforeClose write FOnBeforeClose; property OnBeforeClose : TNotifyEvent read FOnBeforeClose write FOnBeforeClose;
@ -158,12 +175,16 @@ type
property OnBeforeOpen : TNotifyEvent read FOnBeforeOpen write FOnBeforeOpen; property OnBeforeOpen : TNotifyEvent read FOnBeforeOpen write FOnBeforeOpen;
property OnAfterSave : TNotifyEvent read FOnAfterSave write FOnAfterSave; property OnAfterSave : TNotifyEvent read FOnAfterSave write FOnAfterSave;
property OnBeforeSave : TNotifyEvent read FOnBeforeSave write FOnBeforeSave; property OnBeforeSave : TNotifyEvent read FOnBeforeSave write FOnBeforeSave;
property OnEditorChange: TNotifyEvent read FOnEditorChange write FOnEditorChange;
end; end;
TSourceNotebook = class(TFORM) TSourceNotebook = class(TFORM)
private private
Notebook1 : TNotebook; Notebook1 : TNotebook;
StatusBar : TStatusBar;
FEmpty : Boolean; FEmpty : Boolean;
FFormEditor : TFormEditor; FFormEditor : TFormEditor;
FSourceEditorList : TList; FSourceEditorList : TList;
@ -174,20 +195,27 @@ type
FOnSaveFile : TNotifyFileEvent; FOnSaveFile : TNotifyFileEvent;
FMainIDE : TComponent; FMainIDE : TComponent;
Function GetEmpty : Boolean; //look at the # of pages Function GetEmpty : Boolean; //look at the # of pages
Procedure NoteBookPageChanged(Sender : TObject);
protected protected
Function CreateNotebook : Boolean; Function CreateNotebook : Boolean;
Function GetActiveSE : TSourceEditor; Function GetActiveSE : TSourceEditor;
Function DisplayPage(SE : TSourceEditor) : Boolean; Function DisplayPage(SE : TSourceEditor) : Boolean;
Function NewSE(Pagenum : Integer) : TSourceEditor; Function NewSE(Pagenum : Integer) : TSourceEditor;
Procedure EditorChanged(sender : TObject);
procedure UpdateStatusBar;
Bookmarks : TImageList; Bookmarks : TImageList;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
Function ActiveUnitName : String; Function ActiveUnitName : String;
Function ActiveFileName : String; Function ActiveFileName : String;
Function CreateUnitFromForm(AForm : TForm) : TSourceEditor;
Function GetSourceForUnit(UnitName : String) : TStrings;
Function SetSourceForUnit(UnitName : String; NewSource : TStrings) : Boolean;
Procedure DisplayFormforActivePage; Procedure DisplayFormforActivePage;
Procedure DisplayCodeforControl(Control : TObject); Procedure DisplayCodeforControl(Control : TObject);
Function CreateUnitFromForm(AForm : TForm) : TSourceEditor; Procedure DisplayCodefromUnitName(UnitName : String);
procedure CloseClicked(Sender : TObject); procedure CloseClicked(Sender : TObject);
Procedure NewClicked(Sender: TObject); Procedure NewClicked(Sender: TObject);
@ -196,10 +224,12 @@ type
procedure SaveAllClicked(Sender : TObject); procedure SaveAllClicked(Sender : TObject);
procedure SaveAsClicked(Sender : TObject); procedure SaveAsClicked(Sender : TObject);
Procedure OpenFile(FileName: String); Procedure NewFile(UnitName: String; Source : TStrings; aVisible : Boolean);
Procedure OpenFile(FileName: String; aVisible : Boolean);
Procedure ToggleBookmark(Value : Integer); Procedure ToggleBookmark(Value : Integer);
Procedure GoToBookmark(Value: Integer); Procedure GotoBookmark(Value: Integer);
property OnCloseFile : TNotifyFileEvent read FOnCloseFile write FOnCloseFile; property OnCloseFile : TNotifyFileEvent read FOnCloseFile write FOnCloseFile;
property OnOpenFile : TNotifyFileEvent read FOnOPenFile write FOnOPenFile; property OnOpenFile : TNotifyFileEvent read FOnOPenFile write FOnOPenFile;
@ -214,6 +244,9 @@ implementation
uses uses
LCLLinux,TypInfo,LResources,Main; LCLLinux,TypInfo,LResources,Main;
var
Editor_Num : Integer;
aHighlighter: TSynPasSyn;
{ TSourceEditor } { TSourceEditor }
@ -236,7 +269,6 @@ end;
destructor TSourceEditor.destroy; destructor TSourceEditor.destroy;
begin begin
FHighlighter.free;
FEditor.Free; FEditor.Free;
FSource.free; FSource.free;
inherited; inherited;
@ -320,6 +352,12 @@ Begin
//SubMenuItem.OnClick := @ToggleBreakpoint; //SubMenuItem.OnClick := @ToggleBreakpoint;
MenuItem.Add(SubMenuItem); MenuItem.Add(SubMenuItem);
FPopupMenu.Items.Add(Seperator);
MenuItem := TMenuItem.Create(FAOwner);
MenuItem.Caption := 'Line Numbers';
menuItem.OnClick := @ToggleLineNumbersClicked;
FPopupMenu.Items.Add(MenuItem);
end; end;
{------------------------------G O T O M E T H O D ---------------------------------} {------------------------------G O T O M E T H O D ---------------------------------}
@ -462,6 +500,8 @@ Begin
End; End;
{------------------------------BOOKMARK GOTO ---------------------------------} {------------------------------BOOKMARK GOTO ---------------------------------}
Procedure TSourceEditor.BookMarkGoto(Value : Integer); Procedure TSourceEditor.BookMarkGoto(Value : Integer);
Begin Begin
@ -484,22 +524,22 @@ Begin
Found := False; Found := False;
//check the current directory //check the current directory
Found := True; Found := True;
if FileExists(Lowercase(Texts)) then TSOurceNotebook(FAOwner).OpenFile(Lowercase(Texts)) if FileExists(Lowercase(Texts)) then TSOurceNotebook(FAOwner).OpenFile(Lowercase(Texts), True)
else else
if FileExists(Lowercase(Texts)+'.pp') then TSOurceNotebook(FAOwner).OpenFile(Lowercase(Texts)+'.pp') if FileExists(Lowercase(Texts)+'.pp') then TSOurceNotebook(FAOwner).OpenFile(Lowercase(Texts)+'.pp', True)
else else
if FileExists(Lowercase(Texts)+'.pas') then TSOurceNotebook(FAOwner).OpenFile(Lowercase(Texts)+'.pas') if FileExists(Lowercase(Texts)+'.pas') then TSOurceNotebook(FAOwner).OpenFile(Lowercase(Texts)+'.pas', True)
else else
Found := False; Found := False;
// check the default LCL directory if not Found // check the default LCL directory if not Found
Found := True; Found := True;
AppDir := ExtractFilePath(Application.Exename); AppDir := ExtractFilePath(Application.Exename);
if FileExists(AppDir+'lcl'+AppDir[Length(AppDir)]+Lowercase(Texts)) then TSOurceNotebook(FAOwner).OpenFile(AppDir+'lcl'+AppDir[Length(AppDir)]+Lowercase(Texts)) if FileExists(AppDir+'lcl'+AppDir[Length(AppDir)]+Lowercase(Texts)) then TSOurceNotebook(FAOwner).OpenFile(AppDir+'lcl'+AppDir[Length(AppDir)]+Lowercase(Texts), True)
else else
if FileExists(AppDir+'lcl'+AppDir[Length(AppDir)]+Lowercase(Texts)+'.pp') then TSOurceNotebook(FAOwner).OpenFile(AppDir+'lcl'+AppDir[Length(AppDir)]+Lowercase(Texts)+'.pp') if FileExists(AppDir+'lcl'+AppDir[Length(AppDir)]+Lowercase(Texts)+'.pp') then TSOurceNotebook(FAOwner).OpenFile(AppDir+'lcl'+AppDir[Length(AppDir)]+Lowercase(Texts)+'.pp', True)
else else
if FileExists(AppDir+'lcl'+AppDir[Length(AppDir)]+Lowercase(Texts)+'.pas') then TSOurceNotebook(FAOwner).OpenFile(AppDir+'lcl'+AppDir[Length(AppDir)]+Lowercase(Texts)+'.pas') if FileExists(AppDir+'lcl'+AppDir[Length(AppDir)]+Lowercase(Texts)+'.pas') then TSOurceNotebook(FAOwner).OpenFile(AppDir+'lcl'+AppDir[Length(AppDir)]+Lowercase(Texts)+'.pas', True)
else else
Found := False; Found := False;
@ -518,11 +558,11 @@ Begin
if tempDir[Length(TempDir)] <> DirDelimiter then if tempDir[Length(TempDir)] <> DirDelimiter then
TempDir := TempDir + DirDelimiter; TempDir := TempDir + DirDelimiter;
Found := True; Found := True;
if FileExists(TempDir+Lowercase(Texts)) then TSOurceNotebook(FAOwner).OpenFile(TempDir+Lowercase(Texts)) if FileExists(TempDir+Lowercase(Texts)) then TSOurceNotebook(FAOwner).OpenFile(TempDir+Lowercase(Texts), True)
else else
if FileExists(TempDir+Lowercase(Texts)+'.pp') then TSOurceNotebook(FAOwner).OpenFile(TempDir+Lowercase(Texts)+'.pp') if FileExists(TempDir+Lowercase(Texts)+'.pp') then TSOurceNotebook(FAOwner).OpenFile(TempDir+Lowercase(Texts)+'.pp', True)
else else
if FileExists(TempDir+Lowercase(Texts)+'.pas') then TSOurceNotebook(FAOwner).OpenFile(TempDir+Lowercase(Texts)+'.pas') if FileExists(TempDir+Lowercase(Texts)+'.pas') then TSOurceNotebook(FAOwner).OpenFile(TempDir+Lowercase(Texts)+'.pas', True)
else else
Found := False; Found := False;
Num := pos(';',SearchDir); Num := pos(';',SearchDir);
@ -535,6 +575,17 @@ Begin
end; end;
Procedure TSourceEditor.ToggleLineNumbersClicked(Sender : TObject);
var
MenuITem : TMenuItem;
begin
MenuItem := TMenuITem(Sender);
MenuItem.Checked := not(MenuItem.Checked);
FEditor.Gutter.ShowLineNumbers := MenuItem.Checked;
End;
Procedure TSourceEditor.ReadOnlyClicked(Sender : TObject); Procedure TSourceEditor.ReadOnlyClicked(Sender : TObject);
var var
MenuItem : TMenuItem; MenuItem : TMenuItem;
@ -544,6 +595,16 @@ Begin
//set the statusbar text; //set the statusbar text;
end; end;
Procedure TSourceEditor.FocusEditor;
Begin
FEditor.SetFocus;
end;
Function TSourceEditor.GetReadOnly : Boolean;
Begin
Result := FEditor.ReadOnly;
End;
Procedure TSourceEditor.ToggleBreakpointClicked(Sender : TObject); Procedure TSourceEditor.ToggleBreakpointClicked(Sender : TObject);
Begin Begin
@ -611,6 +672,13 @@ Begin
end; end;
Procedure TSourceEditor.EditorStatusChanged(Sender: TObject; Changes: TSynStatusChanges);
Begin
If Assigned(OnEditorChange) then
OnEditorChange(sender);
end;
Procedure TSourceEditor.CreateEditor(AOwner : TComponent; AParent: TWinControl); Procedure TSourceEditor.CreateEditor(AOwner : TComponent; AParent: TWinControl);
Begin Begin
if assigned(FEditor) then if assigned(FEditor) then
@ -619,38 +687,32 @@ if assigned(FEditor) then
FEditor.Free; FEditor.Free;
end; end;
FEditor := TmwCustomEdit.Create(FAOwner); {SynEdit}
with FEditor do
begin FSynAutoComplete:=TSynAutoComplete.Create(FAOwner);
with FSynAutoComplete do begin
AutoCompleteList.LoadFromFile('lazarus.dci');
end;
FEditor:=TSynEdit.Create(FAOwner);
with FEditor do
begin
Name:='SynEdit'+Inttostr(Editor_num);
inc(Editor_num);
Parent := AParent; Parent := AParent;
Top := 25; SetBounds(0,25,TWinControl(FAOwner).ClientWidth - 10,TWinControl(FAOwner).ClientHeight -10);
Left := 0;
Width := TWinControl(FAOwner).ClientWidth - 10;//clientwidth;//500;
Height :=TWinControl(FAOwner).ClientHeight -10;//clientheight;//250;
Align := alClient; Align := alClient;
{$IFDEF NEW_EDITOR} Highlighter:=aHighlighter;
Gutter.Color := clBtnface; Gutter.Color:=clBlue;
Gutter.ShowLineNumbers := True; AddKey(ecAutoCompletion, word('J'), [ssCtrl], 0, []);
{$ELSE} OnKeyDown := @EditorKeyDown;
GutterColor := clBtnface; OnKeyUp := @EditorKeyUp;
{$ENDIF} OnStatusChange := @EditorStatusChanged;
Color := clWindow; Show;
Visible := True; end;
Font.Name := 'courier'; FSynAutoComplete.AddEditor(FEditor);
Font.Size := 12; {SynEdit}
if FHighlighter = nil
then begin
FHighlighter := TmwPasSyn.Create(FAOwner);
with TmwPasSyn(FHighLighter) do
begin
CommentAttri.Foreground := clNavy;
NumberAttri.Foreground := clRed;
KeyAttri.Foreground := clGreen;
end;
end;
OnKeyDown := @EditorKeyDown;
OnKeyUp := @EditorKeyUp;
end;
FEditor.Lines.Assign(FSource); FEditor.Lines.Assign(FSource);
end; end;
@ -690,7 +752,7 @@ For I := 0 to TempSource.Count-1 do
//if I => FSource.Count then I didn't find the line... //if I => FSource.Count then I didn't find the line...
If I < TempSource.Count then If I < TempSource.Count-1 then
Begin Begin
//alphabetical //alphabetical
inc(i); inc(i);
@ -818,6 +880,12 @@ Begin
Result := FEditor.Modified; Result := FEditor.Modified;
end; end;
Function TSourceEditor.GetInsertMode : Boolean;
Begin
Result := FEditor.Insertmode;
end;
//Get's the ancestor of the FControl. //Get's the ancestor of the FControl.
//For example the ancestor of a TForm1 = class(xxxx) is the xxxx //For example the ancestor of a TForm1 = class(xxxx) is the xxxx
Function TSourceEditor.GetAncestor : String; Function TSourceEditor.GetAncestor : String;
@ -842,8 +910,6 @@ Begin
nmAncestor := GetAncestor; nmAncestor := GetAncestor;
//figure out what the unit name should be...
FUnitName:='Unit1'; //just assigning it to this for now
nmForm := FControl.Name; nmForm := FControl.Name;
with TempSource do with TempSource do
@ -921,20 +987,22 @@ Begin
FOnBeforeClose(Self); FOnBeforeClose(Self);
end; end;
FSource.Clear; // FSource.Clear;
Visible := False;
If Assigned(FOnAfterClose) then FOnAfterClose(Self); If Assigned(FOnAfterClose) then FOnAfterClose(Self);
end; end;
Function TSourceEditor.Open : Boolean; Function TSourceEditor.Open : Boolean;
Begin Begin
Writeln('[TSourceEditor] Open');
Result := True; Result := True;
If Assigned(FOnBeforeOpen) then FOnBeforeOpen(Self); If Assigned(FOnBeforeOpen) then FOnBeforeOpen(Self);
try try
FEditor.Lines.LoadFromFile(FileName); FEditor.Lines.LoadFromFile(FileName);
FUnitName := Filename;
FModified := False; FModified := False;
FUnitName := ExtractFileName(Filename);
//see if this is a form file //see if this is a form file
CreateFormfromUnit; CreateFormfromUnit;
except except
@ -943,6 +1011,7 @@ Begin
if Result then if Result then
If Assigned(FOnAfterOpen) then FOnAfterOpen(Self); If Assigned(FOnAfterOpen) then FOnAfterOpen(Self);
Writeln('[TSourceEditor] Open Done');
end; end;
@ -972,6 +1041,8 @@ Begin
Result := (FControl <> nil); Result := (FControl <> nil);
end; end;
{------------------------------------------------------------------------} {------------------------------------------------------------------------}
{ TSourceNotebook } { TSourceNotebook }
@ -1029,18 +1100,59 @@ begin
LoadResource('default',Pixmap1); LoadResource('default',Pixmap1);
Bookmarks.Add(Pixmap1,nil); Bookmarks.Add(Pixmap1,nil);
end; end;
aHighlighter:=TSynPasSyn.Create(AOwner);
with aHighlighter do begin
CommentAttri.ForeGround:=clBlue;
CommentAttri.Style:=[fsBold,fsItalic];
AsmAttri.ForeGround:=clGreen;
IdentifierAttri.Style:=[fsBold];
NumberAttri.ForeGround:=clGreen;
//SpaceAttri.Background:=clWhite;
StringAttri.ForeGround:=clRed;
SymbolAttri.ForeGround:=clBlack;
end;
StatusBar := TStatusBar.Create(self);
with Statusbar do
begin
Parent := Self;
Name := 'StatusBar';
Visible := True;
SimpleText := 'This is a test';
Panels.Add; //x,y coord
Panels.Add; //Readonly/Modified
Panels.Add; //Unitname
Panels.Add; //OVR/INS
Panels[0].Text := '';
Panels[0].Width := 100;
Panels[0].Bevel := pbLowered;
Panels[1].Text := '';
Panels[1].Bevel := pbLowered;
Panels[1].Width := 150;
Panels[2].Text := '';
Panels[2].Bevel := pbLowered;
Panels[2].Width := 100;
Panels[3].Text := 'INS';
Panels[3].Bevel := pbLowered;
Panels[3].Width := 50;
SimplePanel := False;
end;
end; end;
destructor TSourceNotebook.Destroy; destructor TSourceNotebook.Destroy;
begin begin
FSourceEditorList.Free; FSourceEditorList.Free;
aHighlighter.Free;
inherited Destroy; inherited Destroy;
end; end;
Function TSourceNotebook.CreateNotebook : Boolean; Function TSourceNotebook.CreateNotebook : Boolean;
Begin Begin
Writeln('TSourceNotebook] CreateNotebook');
Result := False; Result := False;
if not assigned(Notebook1) then if not assigned(Notebook1) then
Begin Begin
@ -1054,13 +1166,16 @@ Begin
Top :=2; Top :=2;
Width := ClientWidth; Width := ClientWidth;
Height := ClientHeight-Notebook1.top; Height := ClientHeight-Notebook1.top;
Pages.Strings[0] := 'NewUnit.pp'; Pages.Strings[0] := 'Unit1';
PageIndex := 0; // Set it to the first page PageIndex := 0; // Set it to the first page
OnPageChanged := @NoteBookPageChanged;
Show; Show;
end; //with end; //with
Show; //used to display the code form Show; //used to display the code form
end; end;
Writeln('TSourceNotebook] CreateNotebook done');
End; End;
Function TSourceNotebook.CreateUnitFromForm(AForm : TForm): TSourceEditor; Function TSourceNotebook.CreateUnitFromForm(AForm : TForm): TSourceEditor;
@ -1069,6 +1184,7 @@ Var
Notebook_Just_Created : Boolean; Notebook_Just_Created : Boolean;
PageIndex : Integer; PageIndex : Integer;
begin begin
Notebook_Just_Created := (not assigned(Notebook1)) or Notebook_Just_Created := (not assigned(Notebook1)) or
(Notebook1.Pages.Count = 0); (Notebook1.Pages.Count = 0);
@ -1085,19 +1201,40 @@ begin
Show; Show;
end; end;
Procedure TSourceNotebook.EditorChanged(sender : TObject);
Begin
Writeln('EditorChanged');
UpdateStatusBar;
Writeln('EditorChanged done');
End;
Function TSourceNotebook.NewSe(PageNum : Integer) : TSourceEditor; Function TSourceNotebook.NewSe(PageNum : Integer) : TSourceEditor;
var
UnitIndex,I:integer;
Begin Begin
if CreateNotebook then Pagenum := 0; if CreateNotebook then Pagenum := 0;
if Pagenum = -1 then //add a new page if Pagenum = -1 then begin //add a new page
Pagenum := Notebook1.Pages.Add('title'); UnitIndex:=0;
repeat
inc(UnitIndex);
I:=FSourceEditorList.Count-1;
while (I>=0)
and (lowercase(TSourceEditor(FSourceEditorList[I]).UnitName)
<>'unit'+IntToStr(UnitIndex)) do dec(I);
until I<0;
Pagenum := Notebook1.Pages.Add('unit'+IntToStr(UnitIndex));
end;
Result := TSourceEditor.Create(Self,Notebook1.Page[PageNum]); Result := TSourceEditor.Create(Self,Notebook1.Page[PageNum]);
Result.FUnitName:=Notebook1.Pages[PageNum];
Notebook1.Pageindex := Pagenum; Notebook1.Pageindex := Pagenum;
FSourceEditorList.Add(Result); FSourceEditorList.Add(Result);
Writeln('Assigning bookmark images'); Result.Editor.BookMarkOptions.BookmarkImages := Bookmarks;
Result.Editor.BookmarkImages := Bookmarks; Result.OnEditorChange := @EditorChanged;
end; end;
@ -1119,6 +1256,22 @@ Begin
End; End;
Procedure TSourceNotebook.DisplayCodefromUnitName(UnitName : String);
Var
I,X : Integer;
Begin
X := FSourceEditorList.Count;
if X = 0 then Exit;
I := 0;
while (I < X) and (Uppercase(TSourceEditor(FSourceEditorList.Items[I]).Unitname) <> Uppercase(Unitname)) do
Begin
inc(i);
end;
if I < X then
DisplayPage(TSourceEditor(FSOurceEditorList.Items[I]));
end;
Procedure TSourceNotebook.DisplayFormforActivePage; Procedure TSourceNotebook.DisplayFormforActivePage;
Begin Begin
Writeln('DisplayFormForActivePage'); Writeln('DisplayFormForActivePage');
@ -1183,6 +1336,7 @@ Begin
with Notebook1.Page[Notebook1.Pageindex] do with Notebook1.Page[Notebook1.Pageindex] do
Begin Begin
if ControlCount = 0 then Exit;
for I := 0 to ControlCount-1 do for I := 0 to ControlCount-1 do
if Controls[I] is TmwCustomEdit then if Controls[I] is TmwCustomEdit then
Begin Begin
@ -1211,21 +1365,28 @@ 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 if (sender is TMenuItem) and (TMenuItem(sender).name <> 'FileOpen') then //the down arrow next to open was selected
OpenFile(TMenuItem(sender).Caption) OpenFile(TMenuItem(sender).Caption,True)
else else
Begin 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
Writeln('create a new editor');
TempEditor := NewSE(-1); TempEditor := NewSE(-1);
Writeln('Done create a new editor');
TempEditor.Filename := FOpenDialog.Filename; TempEditor.Filename := FOpenDialog.Filename;
if (TempEditor.Open) then if (TempEditor.Open) then
Begin Begin
if assigned(FOnOPenFile) then FOnOpenFile(TObject(TempEditor),FOpenDialog.Filename); Writeln('1');
if assigned(FOnOpenFile) then FOnOpenFile(TObject(TempEditor),FOpenDialog.Filename);
Writeln('2');
Notebook1.Pages.Strings[Notebook1.Pageindex] := TempEditor.UnitName; Notebook1.Pages.Strings[Notebook1.Pageindex] := TempEditor.UnitName;
Writeln('3');
end; end;
end; end;
end; end;
TempEditor.Visible := True;
UpdateStatusBar;
end; end;
@ -1243,8 +1404,19 @@ Begin
GetActiveSE.BookMarkGoto(Value); GetActiveSE.BookMarkGoto(Value);
End; End;
Procedure TSourceNotebook.NewFile(UnitName: String; Source : TStrings; aVisible : Boolean);
Var
TempEditor : TSourceEditor;
Begin
//create a new page
TempEditor := NewSE(-1);
TempEditor.Unitname := Unitname;
TempEditor.Source := Source;
if Visible then Notebook1.Pages.Strings[Notebook1.Pageindex] := TempEditor.UnitName;
TempEditor.Visible := aVisible;
end;
Procedure TSourceNotebook.OpenFile(FileName: String); Procedure TSourceNotebook.OpenFile(FileName: String; aVisible : Boolean);
Var Var
TempEditor : TSourceEditor; TempEditor : TSourceEditor;
Begin Begin
@ -1257,7 +1429,8 @@ Begin
if (TempEditor.OPen) then if (TempEditor.OPen) then
Begin Begin
if assigned(FOnOPenFile) then FOnOpenFile(TObject(TempEditor),FOpenDialog.Filename); if assigned(FOnOPenFile) then FOnOpenFile(TObject(TempEditor),FOpenDialog.Filename);
Notebook1.Pages.Strings[Notebook1.Pageindex] := ExtractFileName(TempEditor.UnitName); if Visible then Notebook1.Pages.Strings[Notebook1.Pageindex] := ExtractFileName(TempEditor.UnitName);
TempEditor.Visible := aVisible;
end; end;
end; end;
@ -1272,6 +1445,9 @@ Begin
TempEditor := NewSE(-1); TempEditor := NewSE(-1);
TempEditor.CreateNewUnit; TempEditor.CreateNewUnit;
Notebook1.Pages.Strings[Notebook1.Pageindex] := TempEditor.UnitName; Notebook1.Pages.Strings[Notebook1.Pageindex] := TempEditor.UnitName;
TempEditor.Visible := True;
UpdateStatusBar;
End; End;
Procedure TSourceNotebook.SaveClicked(Sender: TObject); Procedure TSourceNotebook.SaveClicked(Sender: TObject);
@ -1284,6 +1460,8 @@ if ActiveFileName <> '' then
else else
SaveAsClicked(Sender); SaveAsClicked(Sender);
UpdateStatusBar;
end; end;
Function TSourceNotebook.ActiveUnitName : String; Function TSourceNotebook.ActiveUnitName : String;
@ -1308,9 +1486,11 @@ if (GetActiveSE.Modified) then
Notebook1.Pages.Delete(Notebook1.Pageindex); Notebook1.Pages.Delete(Notebook1.Pageindex);
if Notebook1.Pages.Count = 0 then if Notebook1.Pages.Count = 0 then
Hide; Hide;
UpdateStatusBar;
end; end;
@ -1342,6 +1522,8 @@ Begin
For I := 0 to FSourceEditorList.Count-1 do For I := 0 to FSourceEditorList.Count-1 do
Begin Begin
TempEditor := TSourceEditor(FSourceEditorList.Items[i]); TempEditor := TSourceEditor(FSourceEditorList.Items[i]);
if TempEditor.Visible then
Begin
FSaveDialog.Title := 'Save '+TempEditor.UnitName+' as :'; FSaveDialog.Title := 'Save '+TempEditor.UnitName+' as :';
if TempEditor.FileName <> '' then if TempEditor.FileName <> '' then
FSaveDialog.Filename := TempEditor.FileName FSaveDialog.Filename := TempEditor.FileName
@ -1357,10 +1539,84 @@ Begin
else else
Break; Break;
end; end;
end;
end;
Function TSourceNotebook.GetSourceForUnit(UnitName : String) : TStrings;
Var
I : Integer;
TempEditor : TSourceEditor;
begin
For I := 0 to FSourceEditorList.Count-1 do
Begin
TempEditor := TSourceEditor(FSourceEditorList.Items[i]);
if Uppercase(TempEditor.UnitName) = Uppercase(Unitname) then
Break;
End;
if Uppercase(TempEditor.UnitName) = Uppercase(Unitname) then
Result := TempEditor.Source
else
Result := nil;
End;
Function TSourceNotebook.SetSourceForUnit(UnitName : String; NewSource : TStrings) : Boolean;
Var
I : Integer;
TempEditor : TSourceEditor;
begin
Result := False;
For I := 0 to FSourceEditorList.Count-1 do
Begin
TempEditor := TSourceEditor(FSourceEditorList.Items[i]);
if Uppercase(TempEditor.UnitName) = Uppercase(Unitname) then
Break;
End;
if Uppercase(TempEditor.UnitName) = Uppercase(Unitname) then
Begin
TempEditor.Source := NewSource;
Result := True;
end;
End;
Procedure TSourceNotebook.UpdateStatusBar;
var
tempEditor : TSourceEditor;
begin
TempEditor := GetActiveSE;
if TempEditor = nil then Exit;
Writeln('Updating status bar...');
Statusbar.Panels[2].Text := GetActiveSE.Unitname;
If GetActiveSE.Modified then StatusBar.Panels[1].Text := 'Modified'
else
StatusBar.Panels[1].Text := '';
If GetActiveSE.ReadOnly then
if StatusBar.Panels[1].Text <> '' then StatusBar.Panels[1].Text := StatusBar.Panels[1].Text + '/ReadOnly'
else
StatusBar.Panels[1].Text := 'Readonly';
Statusbar.Panels[0].Text := Inttostr(GetActiveSE.CurrentCursorXLine) + ','+ Inttostr(GetActiveSE.CurrentCursorYLine);
if GetActiveSE.InsertMode then
Statusbar.Panels[3].Text := 'INS' else
Statusbar.Panels[3].Text := 'OVR';
End;
Procedure TSourceNotebook.NoteBookPageChanged(Sender : TObject);
Begin
GetActiveSE.FocusEditor;
UpdateStatusBar;
end; end;
initialization initialization
Editor_Num := 0;
{$I designer/bookmark.lrs} {$I designer/bookmark.lrs}

View File

@ -57,6 +57,8 @@ end;
Procedure TStatusBar.DrawBevel(xLeft, PanelNum : Integer ); Procedure TStatusBar.DrawBevel(xLeft, PanelNum : Integer );
Begin Begin
Canvas.Brush.Color := color;
Canvas.FillRect(Rect(XLeft,Top,XLeft +Panels[PanelNum].Width,Top+Height));
if Panels[PanelNum].Bevel = pbRaised then if Panels[PanelNum].Bevel = pbRaised then
Begin Begin

View File

@ -28,5 +28,6 @@ end;
procedure TStatusPanels.Update(Item: TCollectionItem); procedure TStatusPanels.Update(Item: TCollectionItem);
begin begin
FStatusBar.Invalidate;
end; end;