mirror of https://gitlab.com/basile.b/dexed.git
editors, fix a mess with page caption and updates
This commit is contained in:
parent
495da4da2e
commit
8b880edddf
|
@ -61,6 +61,8 @@ type
|
||||||
fTokList: TLexTokenList;
|
fTokList: TLexTokenList;
|
||||||
fModStart: boolean;
|
fModStart: boolean;
|
||||||
fLastCommand: TSynEditorCommand;
|
fLastCommand: TSynEditorCommand;
|
||||||
|
procedure updateStatusBar;
|
||||||
|
procedure updatePageCaption;
|
||||||
procedure pageBtnAddCLick(Sender: TObject);
|
procedure pageBtnAddCLick(Sender: TObject);
|
||||||
procedure pageCloseBtnClick(Sender: TObject);
|
procedure pageCloseBtnClick(Sender: TObject);
|
||||||
procedure lexFindToken(const aToken: PLexToken; out doStop: boolean);
|
procedure lexFindToken(const aToken: PLexToken; out doStop: boolean);
|
||||||
|
@ -180,7 +182,6 @@ begin
|
||||||
//
|
//
|
||||||
fDoc := aDoc;
|
fDoc := aDoc;
|
||||||
focusedEditorChanged;
|
focusedEditorChanged;
|
||||||
beginDelayedUpdate;
|
|
||||||
updateImperative;
|
updateImperative;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -191,8 +192,8 @@ begin
|
||||||
aDoc.Parent := nil;
|
aDoc.Parent := nil;
|
||||||
if aDoc = fDoc then
|
if aDoc = fDoc then
|
||||||
fDoc := nil;
|
fDoc := nil;
|
||||||
updateImperative;
|
|
||||||
pageControl.deletePage(pageControl.pageIndex);
|
pageControl.deletePage(pageControl.pageIndex);
|
||||||
|
updateImperative;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEEditorWidget.docFocused(aDoc: TCESynMemo);
|
procedure TCEEditorWidget.docFocused(aDoc: TCESynMemo);
|
||||||
|
@ -200,7 +201,6 @@ begin
|
||||||
if aDoc = fDoc then exit;
|
if aDoc = fDoc then exit;
|
||||||
fDoc := aDoc;
|
fDoc := aDoc;
|
||||||
focusedEditorChanged;
|
focusedEditorChanged;
|
||||||
beginDelayedUpdate;
|
|
||||||
updateImperative;
|
updateImperative;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -209,7 +209,6 @@ begin
|
||||||
if fDoc <> aDoc then exit;
|
if fDoc <> aDoc then exit;
|
||||||
fKeyChanged := true;
|
fKeyChanged := true;
|
||||||
beginDelayedUpdate;
|
beginDelayedUpdate;
|
||||||
updateImperative;
|
|
||||||
end;
|
end;
|
||||||
{$ENDREGION}
|
{$ENDREGION}
|
||||||
|
|
||||||
|
@ -335,7 +334,8 @@ begin
|
||||||
fDoc.PopupMenu := mnuEditor;
|
fDoc.PopupMenu := mnuEditor;
|
||||||
fDoc.hideCallTips;
|
fDoc.hideCallTips;
|
||||||
fDoc.hideDDocs;
|
fDoc.hideDDocs;
|
||||||
if (pageControl.currentPage.Caption = '') then
|
if (pageControl.currentPage.Caption = '') or
|
||||||
|
(pageControl.currentPage.Caption ='<new document>') then
|
||||||
begin
|
begin
|
||||||
fKeyChanged := true;
|
fKeyChanged := true;
|
||||||
beginDelayedUpdate;
|
beginDelayedUpdate;
|
||||||
|
@ -414,7 +414,6 @@ end;
|
||||||
|
|
||||||
procedure TCEEditorWidget.memoMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
procedure TCEEditorWidget.memoMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||||
begin
|
begin
|
||||||
beginDelayedUpdate;
|
|
||||||
updateImperative;
|
updateImperative;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -471,19 +470,19 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEEditorWidget.updateImperative;
|
procedure TCEEditorWidget.updateStatusBar;
|
||||||
const
|
const
|
||||||
modstr: array[boolean] of string = ('...', 'MODIFIED');
|
modstr: array[boolean] of string = ('...', 'MODIFIED');
|
||||||
var
|
|
||||||
md: string = '';
|
|
||||||
begin
|
begin
|
||||||
if fDoc = nil then begin
|
if fDoc = nil then
|
||||||
|
begin
|
||||||
editorStatus.Panels[0].Text := '';
|
editorStatus.Panels[0].Text := '';
|
||||||
editorStatus.Panels[1].Text := '';
|
editorStatus.Panels[1].Text := '';
|
||||||
editorStatus.Panels[2].Text := '';
|
editorStatus.Panels[2].Text := '';
|
||||||
editorStatus.Panels[3].Text := '';
|
editorStatus.Panels[3].Text := '';
|
||||||
editorStatus.Panels[4].Text := '';
|
editorStatus.Panels[4].Text := '';
|
||||||
end else begin
|
end else
|
||||||
|
begin
|
||||||
editorStatus.Panels[0].Text := format('%d : %d | %d', [fDoc.CaretY, fDoc.CaretX, fDoc.SelEnd - fDoc.SelStart]);
|
editorStatus.Panels[0].Text := format('%d : %d | %d', [fDoc.CaretY, fDoc.CaretX, fDoc.SelEnd - fDoc.SelStart]);
|
||||||
editorStatus.Panels[1].Text := modstr[fDoc.modified];
|
editorStatus.Panels[1].Text := modstr[fDoc.modified];
|
||||||
if macRecorder.State = msRecording then
|
if macRecorder.State = msRecording then
|
||||||
|
@ -499,21 +498,46 @@ 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.isNotNil and ((pageControl.currentPage.Caption = '') or
|
|
||||||
(pageControl.currentPage.Caption = '<new document>')) then
|
|
||||||
begin
|
|
||||||
if fDoc.isDSource and (fDoc.CaretY < 50) then
|
|
||||||
begin
|
|
||||||
lex(fDoc.Lines.Text, fTokList, @lexFindToken);
|
|
||||||
md := getModuleName(fTokList);
|
|
||||||
fTokList.Clear;
|
|
||||||
end;
|
|
||||||
if md.isEmpty then md := fDoc.fileName.extractFileName;
|
|
||||||
pageControl.currentPage.Caption := md;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCEEditorWidget.updatePageCaption;
|
||||||
|
var
|
||||||
|
md: string = '';
|
||||||
|
begin
|
||||||
|
if fDoc.isDSource then
|
||||||
|
begin
|
||||||
|
lex(fDoc.Lines.Text, fTokList, @lexFindToken);
|
||||||
|
md := getModuleName(fTokList);
|
||||||
|
fTokList.Clear;
|
||||||
|
if md.isEmpty then
|
||||||
|
md := fDoc.fileName.extractFileName;
|
||||||
|
end
|
||||||
|
else if fDoc.fileName.fileExists then
|
||||||
|
md := fDoc.fileName.extractFileName
|
||||||
|
else
|
||||||
|
md := '<new document>';
|
||||||
|
pageControl.currentPage.Caption := md;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCEEditorWidget.updateImperative;
|
||||||
|
begin
|
||||||
|
updateStatusBar;
|
||||||
|
if fDoc.isNotNil then
|
||||||
|
updatePageCaption;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCEEditorWidget.updateDelayed;
|
||||||
|
begin
|
||||||
|
if fDoc = nil then
|
||||||
|
exit;
|
||||||
|
updateStatusBar;
|
||||||
|
if not fKeyChanged then
|
||||||
|
exit;
|
||||||
|
if fDoc.isNotNil then
|
||||||
|
updatePageCaption;
|
||||||
|
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) and (aToken^.data = 'module') then
|
if (aToken^.kind = ltkKeyword) and (aToken^.data = 'module') then
|
||||||
|
@ -527,32 +551,6 @@ begin
|
||||||
fModStart := false;
|
fModStart := false;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEEditorWidget.updateDelayed;
|
|
||||||
var
|
|
||||||
md: string;
|
|
||||||
begin
|
|
||||||
if fDoc = nil then exit;
|
|
||||||
updateImperative;
|
|
||||||
if not fKeyChanged then exit;
|
|
||||||
//
|
|
||||||
fKeyChanged := false;
|
|
||||||
if fDoc.Lines.Count = 0 then exit;
|
|
||||||
//
|
|
||||||
md := pageControl.currentPage.Caption;
|
|
||||||
if ((fDoc.CaretY < 50) or (md.isEmpty) or (md = '<new document>'))
|
|
||||||
or ((md = fDoc.fileName.extractFileName) and (fDoc.isDSource)) then
|
|
||||||
begin
|
|
||||||
if fDoc.isDSource then
|
|
||||||
begin
|
|
||||||
lex(fDoc.Lines.Text, fTokList, @lexFindToken);
|
|
||||||
md := getModuleName(fTokList);
|
|
||||||
fTokList.Clear;
|
|
||||||
end else
|
|
||||||
md := fDoc.fileName.extractFileName;
|
|
||||||
pageControl.currentPage.Caption := md;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
{$ENDREGION}
|
{$ENDREGION}
|
||||||
|
|
||||||
{$REGION Editor context menu ---------------------------------------------------}
|
{$REGION Editor context menu ---------------------------------------------------}
|
||||||
|
|
Loading…
Reference in New Issue