Commits

kankri  committed 812deb3

Add status bar symbol as an alternative file change notification.

  • Participants
  • Parent commits a142cb5

Comments (0)

Files changed (4)

File src/Dialogs.c

 //  Controls: 100 Radio Button
 //            101 Radio Button
 //            102 Radio Button
-//            103 Check Box
+//            103 Radio Button
+//            200 Check Box
 //
 extern int iFileWatchingMode;
 extern BOOL bResetFileWatching;
   switch(umsg)
   {
     case WM_INITDIALOG:
-      CheckRadioButton(hwnd,100,102,100+iFileWatchingMode);
+      CheckRadioButton(hwnd,100,103,100+iFileWatchingMode);
       if (bResetFileWatching)
-        CheckDlgButton(hwnd,103,BST_CHECKED);
+        CheckDlgButton(hwnd,200,BST_CHECKED);
       CenterDlgInParent(hwnd);
       return TRUE;
 
             iFileWatchingMode = 0;
           else if (IsDlgButtonChecked(hwnd,101) == BST_CHECKED)
             iFileWatchingMode = 1;
+          else if (IsDlgButtonChecked(hwnd,102) == BST_CHECKED)
+            iFileWatchingMode = 2;
           else
-            iFileWatchingMode = 2;
-          bResetFileWatching = (IsDlgButtonChecked(hwnd,103) == BST_CHECKED) ? TRUE : FALSE;
+            iFileWatchingMode = 3;
+          bResetFileWatching = (IsDlgButtonChecked(hwnd,200) == BST_CHECKED) ? TRUE : FALSE;
           EndDialog(hwnd,IDOK);
           break;
 

File src/Notepad2.c

 HWND      hwndNextCBChain = NULL;
 HWND      hDlgFindReplace = NULL;
 
+int g_bFileChange = 0;
+
 #define NUMTOOLBITMAPS  23
 #define NUMINITIALTOOLS 24
 
 int       iPrintZoom;
 RECT      pagesetupMargin;
 BOOL      bSaveBeforeRunningTools;
-int       iFileWatchingMode;
+int       iFileWatchingMode = 0;
 BOOL      bResetFileWatching;
 DWORD     dwFileCheckInverval;
 DWORD     dwAutoReloadTimeout;
             SetForegroundWindow(hwnd);
 
           if (PathFileExists(szCurFile)) {
-
+            if (iFileWatchingMode == 3) {
+              g_bFileChange = 1;
+              UpdateStatusbar();
+            } else {
             if ((iFileWatchingMode == 2 && !bModified && iEncoding == iOriginalEncoding) ||
                  MsgBox(MBYESNO,IDS_FILECHANGENOTIFY) == IDYES) {
 
                 }
               }
             }
+            }
           }
           else {
-
-            if (MsgBox(MBYESNO,IDS_FILECHANGENOTIFY2) == IDYES)
-              FileSave(TRUE,FALSE,FALSE,FALSE);
+            if (iFileWatchingMode == 3) {
+              g_bFileChange = 1;
+              UpdateStatusbar();
+            } else {
+              if (MsgBox(MBYESNO,IDS_FILECHANGENOTIFY2) == IDYES)
+                FileSave(TRUE,FALSE,FALSE,FALSE);
+            }
           }
 
           if (!bRunningWatch)
   HDWP hdwp;
 
   // Statusbar
-  int aWidth[6];
+  int aWidth[7];
 
   if (wParam == SIZE_MINIMIZED)
     return;
 
   // Statusbar width
   aWidth[0] = max(120,min(cx/3,StatusCalcPaneWidth(hwndStatus,L"Ln 9'999'999 : 9'999'999   Col 9'999'999 : 999   Sel 9'999'999")));
-  aWidth[1] = aWidth[0] + StatusCalcPaneWidth(hwndStatus,L"9'999'999 Bytes");
-  aWidth[2] = aWidth[1] + StatusCalcPaneWidth(hwndStatus,L"Unicode BE BOM");
-  aWidth[3] = aWidth[2] + StatusCalcPaneWidth(hwndStatus,L"CR+LF");
-  aWidth[4] = aWidth[3] + StatusCalcPaneWidth(hwndStatus,L"OVR");
-  aWidth[5] = -1;
+  aWidth[1] = aWidth[0] + StatusCalcPaneWidth(hwndStatus,L"*MOD*");
+  aWidth[2] = aWidth[1] + StatusCalcPaneWidth(hwndStatus,L"9'999'999 Bytes");
+  aWidth[3] = aWidth[2] + StatusCalcPaneWidth(hwndStatus,L"Unicode BE BOM");
+  aWidth[4] = aWidth[3] + StatusCalcPaneWidth(hwndStatus,L"CR+LF");
+  aWidth[5] = aWidth[4] + StatusCalcPaneWidth(hwndStatus,L"OVR");
+  aWidth[6] = -1;
 
   SendMessage(hwndStatus,SB_SETPARTS,COUNTOF(aWidth),(LPARAM)aWidth);
 
   if (bSaveBeforeRunningTools) bSaveBeforeRunningTools = 1;
 
   iFileWatchingMode = IniSectionGetInt(pIniSection,L"FileWatchingMode",0);
-  iFileWatchingMode = max(min(iFileWatchingMode,2),0);
+  iFileWatchingMode = max(min(iFileWatchingMode,3),0);
 
   bResetFileWatching = IniSectionGetInt(pIniSection,L"ResetFileWatching",1);
   if (bResetFileWatching) bResetFileWatching = 1;
   StatusSetText(hwndStatus,STATUS_EOLMODE,tchEOLMode);
   StatusSetText(hwndStatus,STATUS_OVRMODE,tchOvrMode);
   StatusSetText(hwndStatus,STATUS_LEXER,tchLexerName);
-
+  StatusSetText(hwndStatus, STATUS_FILECHANGE, g_bFileChange ? L"*MOD*" : L"");
   //InvalidateRect(hwndStatus,NULL,TRUE);
 
 }
   else
     fSuccess = EditSaveFile(hwndEdit,psz,*ienc,pbCancelDataLoss,bSaveCopy);
 
+  if (fSuccess) {
+    g_bFileChange = 0;
+    UpdateStatusbar();
+  }
+
   dwFileAttributes = GetFileAttributes(psz);
   bReadOnly = (dwFileAttributes != INVALID_FILE_ATTRIBUTES && dwFileAttributes & FILE_ATTRIBUTE_READONLY);
 

File src/Notepad2.h

 
 
 //==== Statusbar ==============================================================
-#define STATUS_DOCPOS    0
-#define STATUS_DOCSIZE   1
-#define STATUS_CODEPAGE  2
-#define STATUS_EOLMODE   3
-#define STATUS_OVRMODE   4
-#define STATUS_LEXER     5
-#define STATUS_HELP    255
+#define STATUS_DOCPOS      0
+#define STATUS_FILECHANGE  1
+#define STATUS_DOCSIZE     2
+#define STATUS_CODEPAGE    3
+#define STATUS_EOLMODE     4
+#define STATUS_OVRMODE     5
+#define STATUS_LEXER       6
+#define STATUS_HELP      255
 
 
 //==== Change Notifications ===================================================

File src/Notepad2.rc

     SCROLLBAR       IDC_RESIZEGRIP,7,117,10,10
 END
 
-IDD_CHANGENOTIFY DIALOGEX 0, 0, 184, 65
+IDD_CHANGENOTIFY DIALOGEX 0, 0, 184, 78
 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
     WS_SYSMENU
 CAPTION "File Change Notification"
 FONT 8, "MS Shell Dlg", 0, 0, 0x0
 BEGIN
     CONTROL         "&None.",100,"Button",BS_AUTORADIOBUTTON | WS_GROUP |
-                    WS_TABSTOP,7,7,35,10
-    CONTROL         "&Display message.",101,"Button",BS_AUTORADIOBUTTON |
-                    WS_TABSTOP,7,19,71,10
+                    WS_TABSTOP,7,7,100,10
+    CONTROL         "Display &status bar indicator.",103,"Button",
+                    BS_AUTORADIOBUTTON | WS_TABSTOP,7,19,100,10
+    CONTROL         "&Display message dialog.",101,"Button",
+                    BS_AUTORADIOBUTTON | WS_TABSTOP,7,31,100,10
     CONTROL         "&Auto-reload (unmodified).",102,"Button",
-                    BS_AUTORADIOBUTTON | WS_TABSTOP,7,31,99,10
-    CONTROL         "&Reset if a new file is opened.",103,"Button",
-                    BS_AUTOCHECKBOX | WS_TABSTOP,7,48,109,10
+                    BS_AUTORADIOBUTTON | WS_TABSTOP,7,43,100,10
+    CONTROL         "&Reset if a new file is opened.",200,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,7,60,100,10
     DEFPUSHBUTTON   "OK",IDOK,127,7,50,14
     PUSHBUTTON      "Cancel",IDCANCEL,127,24,50,14
 END