dont detect module name after line 50

This commit is contained in:
Basile Burg 2016-02-03 15:09:33 +01:00
parent 61e0925b22
commit 605a24c1ff
1 changed files with 14 additions and 18 deletions

View File

@ -59,7 +59,6 @@ type
fDoc: TCESynMemo; fDoc: TCESynMemo;
fProj: ICECommonProject; fProj: ICECommonProject;
fTokList: TLexTokenList; fTokList: TLexTokenList;
fErrList: TLexErrorList;
fModStart: boolean; fModStart: boolean;
fLastCommand: TSynEditorCommand; fLastCommand: TSynEditorCommand;
procedure pageBtnAddCLick(Sender: TObject); procedure pageBtnAddCLick(Sender: TObject);
@ -127,7 +126,6 @@ begin
AssignPng(pageControl.splitButton, 'splitter'); AssignPng(pageControl.splitButton, 'splitter');
fTokList := TLexTokenList.Create; fTokList := TLexTokenList.Create;
fErrList := TLexErrorList.Create;
// //
AssignPng(mnuedCopy.Bitmap, 'copy'); AssignPng(mnuedCopy.Bitmap, 'copy');
AssignPng(mnuedCut.Bitmap, 'cut'); AssignPng(mnuedCut.Bitmap, 'cut');
@ -153,7 +151,6 @@ begin
if (PageControl.Pages[i].Controls[0] is TCESynMemo) then if (PageControl.Pages[i].Controls[0] is TCESynMemo) then
PageControl.Pages[i].Controls[0].Free; PageControl.Pages[i].Controls[0].Free;
fTokList.Free; fTokList.Free;
fErrList.Free;
inherited; inherited;
end; end;
@ -501,15 +498,14 @@ begin
end else end else
editorStatus.Panels[3].Width:= 0; editorStatus.Panels[3].Width:= 0;
editorStatus.Panels[4].Text := fDoc.fileName; editorStatus.Panels[4].Text := fDoc.fileName;
if Visible and (pageControl.currentPage <> nil) and ((pageControl.currentPage.Caption = '') or if Visible and pageControl.currentPage.isNotNil and ((pageControl.currentPage.Caption = '') or
(pageControl.currentPage.Caption = '<new document>')) then (pageControl.currentPage.Caption = '<new document>')) then
begin begin
if fDoc.isDSource then if fDoc.isDSource and (fDoc.CaretY < 50) then
begin begin
lex(fDoc.Lines.Text, fTokList, @lexFindToken); lex(fDoc.Lines.Text, fTokList, @lexFindToken);
md := getModuleName(fTokList); md := getModuleName(fTokList);
fTokList.Clear; fTokList.Clear;
fErrList.Clear;
end; end;
if md.isEmpty then md := fDoc.fileName.extractFileName; if md.isEmpty then md := fDoc.fileName.extractFileName;
pageControl.currentPage.Caption := md; pageControl.currentPage.Caption := md;
@ -519,11 +515,13 @@ end;
procedure TCEEditorWidget.lexFindToken(const aToken: PLexToken; out doStop: boolean); procedure TCEEditorWidget.lexFindToken(const aToken: PLexToken; out doStop: boolean);
begin begin
if aToken^.kind = ltkKeyword then if (aToken^.kind = ltkKeyword) and (aToken^.data = 'module') then
if aToken^.data = 'module' then begin
fModStart := true; fModStart := true;
if fModStart then if aToken^.kind = ltkSymbol then exit;
if aToken^.data = ';' then begin end;
if fModStart and (aToken^.kind = ltkSymbol) and (aToken^.data = ';') then
begin
doStop := true; doStop := true;
fModStart := false; fModStart := false;
end; end;
@ -541,15 +539,13 @@ begin
if fDoc.Lines.Count = 0 then exit; if fDoc.Lines.Count = 0 then exit;
// //
md := ''; md := '';
if fDoc.isDSource then if fDoc.isDSource and (fDoc.CaretY < 50) then
begin begin
lex(fDoc.Lines.Text, fTokList, @lexFindToken); lex(fDoc.Lines.Text, fTokList, @lexFindToken);
md := getModuleName(fTokList); md := getModuleName(fTokList);
fTokList.Clear; fTokList.Clear;
fErrList.Clear;
end; end;
if md.isEmpty then if md.isEmpty then md := fDoc.fileName.extractFileName;
md := fDoc.fileName.extractFileName;
pageControl.currentPage.Caption := md; pageControl.currentPage.Caption := md;
end; end;
{$ENDREGION} {$ENDREGION}