From 593b49c69542305cc998e11529a1f94c61051637 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sat, 25 Apr 2020 02:17:34 +0200 Subject: [PATCH] replace uses of important literal with an unique string const --- src/u_common.pas | 4 ++++ src/u_editor.pas | 8 ++++---- src/u_gdb.pas | 2 +- src/u_synmemo.pas | 6 +++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/u_common.pas b/src/u_common.pas index d7f25003..ea24a926 100644 --- a/src/u_common.pas +++ b/src/u_common.pas @@ -337,6 +337,10 @@ var // terminal used under posix consoleProgram: string; +const + // used as page caption and filename when a doc has never been saved + newdocPageCaption = ''; + implementation diff --git a/src/u_editor.pas b/src/u_editor.pas index 61a61ae3..354475d0 100644 --- a/src/u_editor.pas +++ b/src/u_editor.pas @@ -515,7 +515,7 @@ end; procedure TEditorWidget.docFocused(document: TDexedMemo); begin if fDoc.isNotNil and pageControl.currentPage.isNotNil and - (pageControl.currentPage.Caption = '') then + (pageControl.currentPage.Caption = newdocPageCaption) then updatePageCaption(pageControl.currentPage); if document = fDoc then exit; @@ -652,7 +652,7 @@ end; procedure TEditorWidget.pageBtnAddCLick(Sender: TObject); begin TDexedMemo.Create(nil); - pageControl.currentPage.Caption:=''; + pageControl.currentPage.Caption := newdocPageCaption; end; procedure TEditorWidget.setDetectModuleName(value: boolean); @@ -675,7 +675,7 @@ begin fDoc.hideCallTips; fDoc.hideDDocs; if (pageControl.currentPage.Caption = '') or - (pageControl.currentPage.Caption ='') then + (pageControl.currentPage.Caption = newdocPageCaption) then begin fKeyChanged := true; beginDelayedUpdate; @@ -842,7 +842,7 @@ end; procedure TEditorWidget.updatePageCaption(page: TDexedPage); var - txt: string = ''; + txt: string = newdocPageCaption; dc1: TDexedMemo = nil; dc2: TDexedMemo = nil; begin diff --git a/src/u_gdb.pas b/src/u_gdb.pas index eabb5e1a..ee81eb94 100644 --- a/src/u_gdb.pas +++ b/src/u_gdb.pas @@ -1525,7 +1525,7 @@ begin fDoc := document; if fGdbState = gsNone then updateDebugeeOptionsEditor; - if (fDoc.fileName <> '') then + if (fDoc.fileName <> newdocPageCaption) then begin fSynchronizingBreakpoints:= true; if fSynchronizedDocuments.IndexOf(document.fileName) = -1 then diff --git a/src/u_synmemo.pas b/src/u_synmemo.pas index 34fbff65..cdc3dd1b 100644 --- a/src/u_synmemo.pas +++ b/src/u_synmemo.pas @@ -1147,7 +1147,7 @@ begin Highlighter := fD2Highlighter; fTempFileName := GetTempDir(false) + 'temp_' + uniqueObjStr(self) + '.d'; - fFilename := ''; + fFilename := newdocPageCaption; fModified := false; TextBuffer.AddNotifyHandler(senrUndoRedoAdded, @changeNotify); @@ -3138,7 +3138,7 @@ begin if fFilename.length > 0 then result := fFilename.extractFileName else - result := ''; + result := newdocPageCaption; end; end; @@ -3437,7 +3437,7 @@ begin if fDiffDialogWillClose or fDisableFileDateCheck then exit; if fFilename.isNotEmpty and not fFilename.fileExists and - (fFilename <> '') then + (fFilename <> newdocPageCaption) then begin // cant use a dialog: dialog closed -> doc focused -> warn again, etc getMessageDisplay.message(fFilename + ' does not exist anymore', self, amcEdit, amkWarn);