Browse Source

Added a panel to the Status Bar showing the amount of closed tabs if there are any.

Martijn Laan 1 năm trước cách đây
mục cha
commit
91d1fba75d
3 tập tin đã thay đổi với 41 bổ sung21 xóa
  1. 4 0
      Projects/CompForm.dfm
  2. 35 19
      Projects/CompForm.pas
  3. 2 2
      whatsnew.htm

+ 4 - 0
Projects/CompForm.dfm

@@ -159,6 +159,10 @@ object CompileForm: TCompileForm
         Text = 'Insert'
         Text = 'Insert'
         Width = 64
         Width = 64
       end
       end
+      item
+        Bevel = pbNone
+        Width = 100
+      end
       item
       item
         Bevel = pbNone
         Bevel = pbNone
         Style = psOwnerDraw
         Style = psOwnerDraw

+ 35 - 19
Projects/CompForm.pas

@@ -458,7 +458,7 @@ type
     procedure ParseDebugInfo(DebugInfo: Pointer);
     procedure ParseDebugInfo(DebugInfo: Pointer);
     procedure ReadMRUMainFilesList;
     procedure ReadMRUMainFilesList;
     procedure ReadMRUParametersList;
     procedure ReadMRUParametersList;
-    procedure ReopenTabOrTabs(const HiddenFileIndex: Integer);
+    procedure ReopenTabOrTabs(const HiddenFileIndex: Integer; const Activate: Boolean);
     procedure ResetAllMemosLineState;
     procedure ResetAllMemosLineState;
     procedure StartProcess;
     procedure StartProcess;
     function SaveFile(const AMemo: TCompScintFileEdit; const SaveAs: Boolean): Boolean;
     function SaveFile(const AMemo: TCompScintFileEdit; const SaveAs: Boolean): Boolean;
@@ -480,6 +480,7 @@ type
     procedure UpdateCompileStatusPanels(const AProgress, AProgressMax: Cardinal;
     procedure UpdateCompileStatusPanels(const AProgress, AProgressMax: Cardinal;
       const ASecondsRemaining: Integer; const ABytesCompressedPerSecond: Cardinal);
       const ASecondsRemaining: Integer; const ABytesCompressedPerSecond: Cardinal);
     procedure UpdateEditModePanel;
     procedure UpdateEditModePanel;
+    procedure UpdateHiddenFilesPanel;
     procedure UpdatePreprocMemos;
     procedure UpdatePreprocMemos;
     procedure UpdateLineMarkers(const AMemo: TCompScintFileEdit; const Line: Integer);
     procedure UpdateLineMarkers(const AMemo: TCompScintFileEdit; const Line: Integer);
     procedure UpdateMemosTabSetVisibility;
     procedure UpdateMemosTabSetVisibility;
@@ -549,9 +550,10 @@ const
   spCaretPos = 0;
   spCaretPos = 0;
   spModified = 1;
   spModified = 1;
   spEditMode = 2;
   spEditMode = 2;
-  spCompileIcon = 3;
-  spCompileProgress = 4;
-  spExtraStatus = 5;
+  spHiddenFilesCount = 3;
+  spCompileIcon = 4;
+  spCompileProgress = 5;
+  spExtraStatus = 6;
 
 
   { Output tab set indexes }
   { Output tab set indexes }
   tiCompilerOutput = 0;
   tiCompilerOutput = 0;
@@ -686,6 +688,7 @@ constructor TCompileForm.Create(AOwner: TComponent);
       end;
       end;
       SyncEditorOptions;
       SyncEditorOptions;
       UpdateNewMainFileButtons;
       UpdateNewMainFileButtons;
+      UpdateHiddenFilesPanel;
       UpdateTheme;
       UpdateTheme;
 
 
       { Window state }
       { Window state }
@@ -1030,6 +1033,7 @@ begin
     UpdateTargetMenu;
     UpdateTargetMenu;
   end;
   end;
   FHiddenFiles.Clear;
   FHiddenFiles.Clear;
+  UpdateHiddenFilesPanel;
   for Memo in FFileMemos do
   for Memo in FFileMemos do
     if Memo.Used then
     if Memo.Used then
       Memo.BreakPoints.Clear;
       Memo.BreakPoints.Clear;
@@ -1203,6 +1207,7 @@ begin
     if MainMemoAddToRecentDocs then
     if MainMemoAddToRecentDocs then
       AddFileToRecentDocs(AFilename);
       AddFileToRecentDocs(AFilename);
     LoadKnownIncludedAndHiddenFilesAndUpdateMemos(AFilename);
     LoadKnownIncludedAndHiddenFilesAndUpdateMemos(AFilename);
+    UpdateHiddenFilesPanel;
   end;
   end;
 end;
 end;
 
 
@@ -1523,6 +1528,7 @@ begin
           Form.FPreprocessorOutput := TrimRight(Data.PreprocessedScript);
           Form.FPreprocessorOutput := TrimRight(Data.PreprocessedScript);
           DecodeIncludedFilenames(Data.IncludedFilenames, Form.FIncludedFiles); { Also stores last write time }
           DecodeIncludedFilenames(Data.IncludedFilenames, Form.FIncludedFiles); { Also stores last write time }
           CleanHiddenFiles(Form.FIncludedFiles, Form.FHiddenFiles);
           CleanHiddenFiles(Form.FIncludedFiles, Form.FHiddenFiles);
+          Form.UpdateHiddenFilesPanel;
           Form.SaveKnownIncludedAndHiddenFiles(Filename);
           Form.SaveKnownIncludedAndHiddenFiles(Filename);
         end;
         end;
       iscbNotifySuccess:
       iscbNotifySuccess:
@@ -2334,6 +2340,7 @@ begin
   MemosTabSet.CloseButtons.Delete(Index);
   MemosTabSet.CloseButtons.Delete(Index);
   FActiveMemo.Visible := False;
   FActiveMemo.Visible := False;
   FHiddenFiles.Add((FActiveMemo as TCompScintFileEdit).Filename);
   FHiddenFiles.Add((FActiveMemo as TCompScintFileEdit).Filename);
+  UpdateHiddenFilesPanel;
   SaveKnownIncludedAndHiddenFiles(FMainMemo.Filename);
   SaveKnownIncludedAndHiddenFiles(FMainMemo.Filename);
 
 
   { Select next tab, except when we're already at the end }
   { Select next tab, except when we're already at the end }
@@ -2341,7 +2348,8 @@ begin
   VPreviousTabClick(Self);
   VPreviousTabClick(Self);
 end;
 end;
 
 
-procedure TCompileForm.ReopenTabOrTabs(const HiddenFileIndex: Integer);
+procedure TCompileForm.ReopenTabOrTabs(const HiddenFileIndex: Integer;
+  const Activate: Boolean);
 begin
 begin
   var ReopenFilename: String;
   var ReopenFilename: String;
   if HiddenFileIndex >= 0 then begin
   if HiddenFileIndex >= 0 then begin
@@ -2351,27 +2359,30 @@ begin
     ReopenFilename := FHiddenFiles[0];
     ReopenFilename := FHiddenFiles[0];
     FHiddenFiles.Clear;
     FHiddenFiles.Clear;
   end;
   end;
+  UpdateHiddenFilesPanel;
 
 
   UpdatePreprocMemos;
   UpdatePreprocMemos;
   SaveKnownIncludedAndHiddenFiles(FMainMemo.Filename);
   SaveKnownIncludedAndHiddenFiles(FMainMemo.Filename);
 
 
-  { Activate the memo }
-  for var Memo in FFileMemos do begin
-    if Memo.Used and (PathCompare(Memo.Filename, ReopenFilename) = 0) then begin
-      MemosTabSet.TabIndex := MemoToTabIndex(memo);
-      Break;
-    end;
+  { Activate the memo if requested }
+  if Activate then begin
+    for var Memo in FFileMemos do begin
+      if Memo.Used and (PathCompare(Memo.Filename, ReopenFilename) = 0) then begin
+        MemosTabSet.TabIndex := MemoToTabIndex(memo);
+        Break;
+      end;
+    end
   end;
   end;
 end;
 end;
 
 
 procedure TCompileForm.VReopenTabClick(Sender: TObject);
 procedure TCompileForm.VReopenTabClick(Sender: TObject);
 begin
 begin
-  ReopenTabOrTabs((Sender as TMenuItem).Tag);
+  ReopenTabOrTabs((Sender as TMenuItem).Tag, True);
 end;
 end;
 
 
 procedure TCompileForm.VReopenTabsClick(Sender: TObject);
 procedure TCompileForm.VReopenTabsClick(Sender: TObject);
 begin
 begin
-  ReopenTabOrTabs(-1);
+  ReopenTabOrTabs(-1, True);
 end;
 end;
 
 
 procedure TCompileForm.SyncZoom;
 procedure TCompileForm.SyncZoom;
@@ -3236,13 +3247,10 @@ procedure TCompileForm.MoveCaretAndActivateMemo(const AMemo: TCompScintFileEdit;
 var
 var
   Pos: Integer;
   Pos: Integer;
 begin
 begin
-  { Unhide file if needed }
+  { Reopen tab if needed }
   var HiddenFileIndex := FHiddenFiles.IndexOf(AMemo.Filename);
   var HiddenFileIndex := FHiddenFiles.IndexOf(AMemo.Filename);
-  if HiddenFileIndex <> -1 then begin
-    FHiddenFiles.Delete(HiddenFileIndex);
-    UpdatePreprocMemos;
-    SaveKnownIncludedAndHiddenFiles(FMainMemo.Filename);
-  end;
+  if HiddenFileIndex <> -1 then
+    ReopenTabOrTabs(HiddenFileIndex, False);
 
 
   { Move caret }
   { Move caret }
   if AlwaysResetColumn or (AMemo.CaretLine <> LineNumber) then
   if AlwaysResetColumn or (AMemo.CaretLine <> LineNumber) then
@@ -3324,6 +3332,14 @@ begin
     StatusBar.Panels[spEditMode].Text := InsertText[FActiveMemo.InsertMode];
     StatusBar.Panels[spEditMode].Text := InsertText[FActiveMemo.InsertMode];
 end;
 end;
 
 
+procedure TCompileForm.UpdateHiddenFilesPanel;
+begin
+  if FOptions.OpenIncludedFiles and (FHiddenFiles.Count > 0) then begin
+    StatusBar.Panels[spHiddenFilesCount].Text := Format('Tabs closed: %d', [FHiddenFiles.Count]);
+  end else
+    StatusBar.Panels[spHiddenFilesCount].Text := '';
+end;
+
 procedure TCompileForm.UpdateMemosTabSetVisibility;
 procedure TCompileForm.UpdateMemosTabSetVisibility;
 begin
 begin
   MemosTabSet.Visible := FPreprocessorOutputMemo.Used or FFileMemos[FirstIncludedFilesMemoIndex].Used;
   MemosTabSet.Visible := FPreprocessorOutputMemo.Used or FFileMemos[FirstIncludedFilesMemoIndex].Used;

+ 2 - 2
whatsnew.htm

@@ -50,8 +50,8 @@ For conditions of distribution and use, see <a href="https://jrsoftware.org/file
   <li>Compiler IDE changes:
   <li>Compiler IDE changes:
   <ul>
   <ul>
   <li>The Compiler IDE now opens up to 20 #include files in tabs, instead of up to 10.</li>
   <li>The Compiler IDE now opens up to 20 #include files in tabs, instead of up to 10.</li>
-  <li>Added new <i>Close Tab (Ctrl+F4)</i>, <i>Reopen Tab</i>, and  <i>Reopen All Tabs</i> menu items to the <i>View</i> menu, also available by right clicking the tab bar.</li>
-  <li>Selected and closeable tabs now show a close button.</li>
+  <li>Tabs for #include files can now be closed: Added new <i>Close Tab (Ctrl+F4)</i>, <i>Reopen Tab</i>, and  <i>Reopen All Tabs</i> menu items to the <i>View</i> menu, also available by right clicking the tab bar. Additionally the tab for a selected #include file now shows a close button.</li>
+  <li>Added a panel to the Status Bar showing the amount of closed tabs if there are any.</li>
   <li>Added new <i>[Files] Entries Designer</i> menu item to the <i>Tools</i> menu to design and insert extra entries to the [Files] section.</li>
   <li>Added new <i>[Files] Entries Designer</i> menu item to the <i>Tools</i> menu to design and insert extra entries to the [Files] section.</li>
   </ul>
   </ul>
   </li>
   </li>