ReactOS 0.4.17-dev-116-ga4b6fe9
dialog.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Notepad
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: Providing a Windows-compatible simple text editor for ReactOS
5 * COPYRIGHT: Copyright 1998,99 Marcel Baur <mbaur@g26.ethz.ch>
6 * Copyright 2002 Sylvain Petreolle <spetreolle@yahoo.fr>
7 * Copyright 2002 Andriy Palamarchuk
8 * Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
9 */
10
11#include "notepad.h"
12
13#include <assert.h>
14#include <commctrl.h>
15#include <strsafe.h>
16
18
19static const TCHAR helpfile[] = _T("notepad.hlp");
20static const TCHAR empty_str[] = _T("");
21static const TCHAR szDefaultExt[] = _T("txt");
22static const TCHAR txt_files[] = _T("*.txt");
23
24/* Status bar parts index */
25#define SBPART_CURPOS 0
26#define SBPART_EOLN 1
27#define SBPART_ENCODING 2
28
29/* Line endings - string resource ID mapping table */
30static UINT EolnToStrId[] = {
34};
35
36/* Encoding - string resource ID mapping table */
37static UINT EncToStrId[] = {
43};
44
46{
48 if (error != NO_ERROR)
49 {
50 LPTSTR lpMsgBuf = NULL;
52 TCHAR szFallback[42], *pszMessage = szFallback;
53
55
57 NULL,
58 error,
59 0,
60 (LPTSTR) &lpMsgBuf,
61 0,
62 NULL);
63
64 if (lpMsgBuf)
65 pszMessage = lpMsgBuf;
66 else
67 wsprintfW(szFallback, L"%d", error);
68
70 LocalFree(lpMsgBuf);
71 }
72}
73
79void UpdateWindowCaption(BOOL clearModifyAlert)
80{
81 TCHAR szCaption[MAX_STRING_LEN];
82 TCHAR szNotepad[MAX_STRING_LEN];
83 TCHAR szFilename[MAX_STRING_LEN];
84 BOOL isModified;
85
86 if (clearModifyAlert)
87 {
88 /* When a file is being opened or created, there is no need to have
89 * the edited flag shown when the file has not been edited yet. */
90 isModified = FALSE;
91 }
92 else
93 {
94 /* Check whether the user has modified the file or not. If we are
95 * in the same state as before, don't change the caption. */
96 isModified = !!SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0);
97 if (isModified == Globals.bWasModified)
98 return;
99 }
100
101 /* Remember the state for later calls */
102 Globals.bWasModified = isModified;
103
104 /* Load the name of the application */
105 LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, _countof(szNotepad));
106
107 /* Determine if the file has been saved or if this is a new file */
108 if (Globals.szFileTitle[0] != 0)
109 StringCchCopy(szFilename, _countof(szFilename), Globals.szFileTitle);
110 else
111 LoadString(Globals.hInstance, STRING_UNTITLED, szFilename, _countof(szFilename));
112
113 /* Update the window caption based upon whether the user has modified the file or not */
114 StringCbPrintf(szCaption, sizeof(szCaption), _T("%s%s - %s"),
115 (isModified ? _T("*") : _T("")), szFilename, szNotepad);
116
117 SetWindowText(Globals.hMainWnd, szCaption);
118}
119
121{
122 static HCURSOR s_hWaitCursor = NULL;
123 static HCURSOR s_hOldCursor = NULL;
124 static INT s_nLock = 0;
125
126 if (bBegin)
127 {
128 if (s_nLock++ == 0)
129 {
130 if (s_hWaitCursor == NULL)
131 s_hWaitCursor = LoadCursor(NULL, IDC_WAIT);
132 s_hOldCursor = SetCursor(s_hWaitCursor);
133 }
134 else
135 {
136 SetCursor(s_hWaitCursor);
137 }
138 }
139 else
140 {
141 if (--s_nLock == 0)
142 SetCursor(s_hOldCursor);
143 }
144}
145
146
148{
149 static const int defaultWidths[] = {120, 120, 120};
150 RECT rcStatusBar;
151 int parts[3];
152
153 GetClientRect(Globals.hStatusBar, &rcStatusBar);
154
155 parts[0] = rcStatusBar.right - (defaultWidths[1] + defaultWidths[2]);
156 parts[1] = rcStatusBar.right - defaultWidths[2];
157 parts[2] = -1; // the right edge of the status bar
158
159 parts[0] = max(parts[0], defaultWidths[0]);
160 parts[1] = max(parts[1], defaultWidths[0] + defaultWidths[1]);
161
163}
164
166{
167 WCHAR szText[128];
168
169 LoadStringW(Globals.hInstance, EolnToStrId[Globals.iEoln], szText, _countof(szText));
170
171 SendMessageW(Globals.hStatusBar, SB_SETTEXTW, SBPART_EOLN, (LPARAM)szText);
172}
173
175{
176 WCHAR szText[128] = L"";
177
178 if (Globals.encFile != ENCODING_AUTO)
179 {
180 LoadStringW(Globals.hInstance, EncToStrId[Globals.encFile], szText, _countof(szText));
181 }
182
184}
185
187{
191}
192
193int DIALOG_StringMsgBox(HWND hParent, int formatId, LPCTSTR szString, DWORD dwFlags)
194{
195 TCHAR szMessage[MAX_STRING_LEN];
196 TCHAR szResource[MAX_STRING_LEN];
197
198 /* Load and format szMessage */
199 LoadString(Globals.hInstance, formatId, szResource, _countof(szResource));
200 StringCchPrintf(szMessage, _countof(szMessage), szResource, szString);
201
202 /* Load szCaption */
204 LoadString(Globals.hInstance, STRING_ERROR, szResource, _countof(szResource));
205 else
206 LoadString(Globals.hInstance, STRING_NOTEPAD, szResource, _countof(szResource));
207
208 /* Display Modal Dialog */
209 // if (hParent == NULL)
210 // hParent = Globals.hMainWnd;
211 return MessageBox(hParent, szMessage, szResource, dwFlags);
212}
213
214static void AlertFileNotFound(LPCTSTR szFileName)
215{
217}
218
219static int AlertFileNotSaved(LPCTSTR szFileName)
220{
221 TCHAR szUntitled[MAX_STRING_LEN];
222
223 LoadString(Globals.hInstance, STRING_UNTITLED, szUntitled, _countof(szUntitled));
224
226 szFileName[0] ? szFileName : szUntitled,
228}
229
236{
237 return GetFileAttributes(szFilename) != INVALID_FILE_ATTRIBUTES;
238}
239
241{
242 LPCTSTR s;
243
244 s = _tcsrchr(szFilename, _T('\\'));
245 if (s)
246 szFilename = s;
247 return _tcsrchr(szFilename, _T('.')) != NULL;
248}
249
251{
252 BOOL bRet = FALSE;
255
257
258 /* Use OPEN_ALWAYS instead of CREATE_ALWAYS in order to succeed
259 * even if the file has HIDDEN or SYSTEM attributes */
263 {
266 return FALSE;
267 }
268
270 if (cchText <= 0)
271 {
272 bRet = TRUE;
273 }
274 else
275 {
276 HLOCAL hLocal = (HLOCAL)SendMessageW(Globals.hEdit, EM_GETHANDLE, 0, 0);
277 LPWSTR pszText = LocalLock(hLocal);
278 if (pszText)
279 {
280 bRet = WriteText(hFile, pszText, cchText, Globals.encFile, Globals.iEoln);
281 if (!bRet)
283
284 LocalUnlock(hLocal);
285 }
286 else
287 {
289 }
290 }
291
292 /* Truncate the file and close it */
295
296 if (bRet)
297 {
299 SetFileName(Globals.szFileName);
300 }
301
303 return bRet;
304}
305
312{
313 int nResult;
314
315 if (SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0))
316 {
317 /* prompt user to save changes */
318 nResult = AlertFileNotSaved(Globals.szFileName);
319 switch (nResult)
320 {
321 case IDYES:
322 if(!DIALOG_FileSave())
323 return FALSE;
324 break;
325
326 case IDNO:
327 break;
328
329 case IDCANCEL:
330 default:
331 return FALSE;
332 }
333 }
334
337
338 return TRUE;
339}
340
342{
344 TCHAR log[5];
345 HLOCAL hOldLocal, hNewLocal;
346
347 /* Close any files and prompt to save changes */
348 if (!DoCloseFile())
349 return;
350
352 SetWindowText(Globals.hEdit, NULL);
353
357 {
359 goto done;
360 }
361
362 /* To make loading file quicker, we use the internal handle of EDIT control */
363 hOldLocal = (HLOCAL)SendMessageW(Globals.hEdit, EM_GETHANDLE, 0, 0);
364 hNewLocal = ReadText(hFile, &Globals.encFile, &Globals.iEoln);
365 if (!hNewLocal)
366 {
368 goto done;
369 }
370 SendMessageW(Globals.hEdit, EM_SETHANDLE, (WPARAM)hNewLocal, 0);
371 LocalFree(hOldLocal);
372 /* No need of EM_SETMODIFY and EM_EMPTYUNDOBUFFER here. EM_SETHANDLE does instead. */
373
374 SetFocus(Globals.hEdit);
375
376 /* If the file starts with .LOG, add a time/date at the end and set cursor after
377 * See http://web.archive.org/web/20090627165105/http://support.microsoft.com/kb/260563
378 */
379 if (GetWindowText(Globals.hEdit, log, _countof(log)) && !_tcscmp(log, _T(".LOG")))
380 {
381 static const TCHAR lf[] = _T("\r\n");
386 }
387
388 SetFileName(szFileName);
392
393done:
397}
398
400{
401 /* Close any files and prompt to save changes */
402 if (!DoCloseFile())
403 return;
404
406
407 SetWindowText(Globals.hEdit, NULL);
409 Globals.iEoln = EOLN_CRLF;
410 Globals.encFile = ENCODING_DEFAULT;
411
414
416}
417
419{
420 TCHAR pszNotepadExe[MAX_PATH];
421
423
424 GetModuleFileName(NULL, pszNotepadExe, _countof(pszNotepadExe));
425 ShellExecute(NULL, NULL, pszNotepadExe, NULL, NULL, SW_SHOWNORMAL);
426
428}
429
431{
432 OPENFILENAME openfilename;
434
435 ZeroMemory(&openfilename, sizeof(openfilename));
436
437 if (Globals.szFileName[0] == 0)
439 else
440 _tcscpy(szPath, Globals.szFileName);
441
442 openfilename.lStructSize = sizeof(openfilename);
443 openfilename.hwndOwner = Globals.hMainWnd;
444 openfilename.hInstance = Globals.hInstance;
445 openfilename.lpstrFilter = Globals.szFilter;
446 openfilename.lpstrFile = szPath;
447 openfilename.nMaxFile = _countof(szPath);
449 openfilename.lpstrDefExt = szDefaultExt;
450
451 if (GetOpenFileName(&openfilename)) {
452 if (FileExists(openfilename.lpstrFile))
453 DoOpenFile(openfilename.lpstrFile);
454 else
455 AlertFileNotFound(openfilename.lpstrFile);
456 }
457}
458
460{
461 if (Globals.szFileName[0] == 0)
462 {
463 return DIALOG_FileSaveAs();
464 }
465 else if (DoSaveFile())
466 {
468 return TRUE;
469 }
470 return FALSE;
471}
472
473static UINT_PTR
476{
477 TCHAR szText[128];
478 HWND hCombo;
479
481
482 switch(msg)
483 {
484 case WM_INITDIALOG:
485 hCombo = GetDlgItem(hDlg, ID_ENCODING);
486
488 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
489
491 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
492
494 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
495
497 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
498
500 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
501
502 SendMessage(hCombo, CB_SETCURSEL, Globals.encFile, 0);
503
504 hCombo = GetDlgItem(hDlg, ID_EOLN);
505
507 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
508
509 LoadString(Globals.hInstance, STRING_LF, szText, _countof(szText));
510 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
511
512 LoadString(Globals.hInstance, STRING_CR, szText, _countof(szText));
513 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
514
515 SendMessage(hCombo, CB_SETCURSEL, Globals.iEoln, 0);
516 break;
517
518 case WM_NOTIFY:
519 if (((NMHDR *) lParam)->code == CDN_FILEOK)
520 {
521 hCombo = GetDlgItem(hDlg, ID_ENCODING);
522 if (hCombo)
523 Globals.encFile = (ENCODING) SendMessage(hCombo, CB_GETCURSEL, 0, 0);
524
525 hCombo = GetDlgItem(hDlg, ID_EOLN);
526 if (hCombo)
527 Globals.iEoln = (EOLN)SendMessage(hCombo, CB_GETCURSEL, 0, 0);
528 }
529 break;
530 }
531 return 0;
532}
533
535{
536 OPENFILENAME saveas;
538
539 ZeroMemory(&saveas, sizeof(saveas));
540
541 if (Globals.szFileName[0] == 0)
543 else
544 _tcscpy(szPath, Globals.szFileName);
545
546 saveas.lStructSize = sizeof(OPENFILENAME);
547 saveas.hwndOwner = Globals.hMainWnd;
548 saveas.hInstance = Globals.hInstance;
549 saveas.lpstrFilter = Globals.szFilter;
550 saveas.lpstrFile = szPath;
551 saveas.nMaxFile = _countof(szPath);
554 saveas.lpstrDefExt = szDefaultExt;
557
558 if (GetSaveFileName(&saveas))
559 {
560 /* HACK: Because in ROS, Save-As boxes don't check the validity
561 * of file names and thus, here, szPath can be invalid !! We only
562 * see its validity when we call DoSaveFile()... */
564 if (DoSaveFile())
565 {
568 return TRUE;
569 }
570 else
571 {
572 SetFileName(_T(""));
573 return FALSE;
574 }
575 }
576 else
577 {
578 return FALSE;
579 }
580}
581
583{
585}
586
588{
589 SendMessage(Globals.hEdit, EM_UNDO, 0, 0);
590}
591
593{
594 SendMessage(Globals.hEdit, WM_CUT, 0, 0);
595}
596
598{
599 SendMessage(Globals.hEdit, WM_COPY, 0, 0);
600}
601
603{
604 SendMessage(Globals.hEdit, WM_PASTE, 0, 0);
605}
606
608{
609 SendMessage(Globals.hEdit, WM_CLEAR, 0, 0);
610}
611
613{
614 SendMessage(Globals.hEdit, EM_SETSEL, 0, -1);
615}
616
618{
619 SYSTEMTIME st;
620 TCHAR szDate[MAX_STRING_LEN];
621 TCHAR szText[MAX_STRING_LEN * 2 + 2];
622
623 GetLocalTime(&st);
624
626 _tcscpy(szText, szDate);
627 _tcscat(szText, _T(" "));
629 _tcscat(szText, szDate);
630 SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)szText);
631}
632
634{
635 /* Check if status bar object already exists. */
636 if (Globals.bShowStatusBar && Globals.hStatusBar == NULL)
637 {
638 /* Try to create the status bar */
640 NULL,
643
644 if (Globals.hStatusBar == NULL)
645 {
647 return;
648 }
649
650 /* Load the string for formatting column/row text output */
652 }
653
654 /* Update layout of controls */
656
657 if (Globals.hStatusBar == NULL)
658 return;
659
660 /* Update visibility of status bar */
661 ShowWindow(Globals.hStatusBar, (Globals.bShowStatusBar ? SW_SHOWNOACTIVATE : SW_HIDE));
662
663 /* Update status bar contents */
665}
666
668{
669 DWORD dwStyle;
670 int iSize;
671 LPTSTR pTemp = NULL;
672 BOOL bModified = FALSE;
673
674 iSize = 0;
675
676 /* If the edit control already exists, try to save its content */
677 if (Globals.hEdit != NULL)
678 {
679 /* number of chars currently written into the editor. */
680 iSize = GetWindowTextLength(Globals.hEdit);
681 if (iSize)
682 {
683 /* Allocates temporary buffer. */
684 pTemp = HeapAlloc(GetProcessHeap(), 0, (iSize + 1) * sizeof(TCHAR));
685 if (!pTemp)
686 {
688 return;
689 }
690
691 /* Recover the text into the control. */
692 GetWindowText(Globals.hEdit, pTemp, iSize + 1);
693
694 if (SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0))
695 bModified = TRUE;
696 }
697
698 /* Restore original window procedure */
700
701 /* Destroy the edit control */
702 DestroyWindow(Globals.hEdit);
703 }
704
705 /* Update wrap status into the main menu and recover style flags */
706 dwStyle = (Globals.bWrapLongLines ? EDIT_STYLE_WRAP : EDIT_STYLE);
707
708 /* Create the new edit control */
711 NULL,
712 dwStyle,
718 NULL,
720 NULL);
721 if (Globals.hEdit == NULL)
722 {
723 if (pTemp)
724 {
725 HeapFree(GetProcessHeap(), 0, pTemp);
726 }
727
729 return;
730 }
731
733 SendMessage(Globals.hEdit, EM_LIMITTEXT, 0, 0);
734
735 /* If some text was previously saved, restore it. */
736 if (iSize != 0)
737 {
738 SetWindowText(Globals.hEdit, pTemp);
739 HeapFree(GetProcessHeap(), 0, pTemp);
740
741 if (bModified)
743 }
744
745 /* Sub-class a new window callback for row/column detection. */
746 Globals.EditProc = (WNDPROC)SetWindowLongPtr(Globals.hEdit,
749
750 /* Finally shows new edit control and set focus into it. */
751 ShowWindow(Globals.hEdit, SW_SHOW);
752 SetFocus(Globals.hEdit);
753
754 /* Re-arrange controls */
756}
757
759{
760 Globals.bWrapLongLines = !Globals.bWrapLongLines;
761
763
766}
767
769{
771 LOGFONT lf = Globals.lfFont;
772
773 ZeroMemory( &cf, sizeof(cf) );
774 cf.lStructSize = sizeof(cf);
775 cf.hwndOwner = Globals.hMainWnd;
776 cf.lpLogFont = &lf;
778
779 if (ChooseFont(&cf))
780 {
781 HFONT currfont = Globals.hFont;
782
783 Globals.hFont = CreateFontIndirect(&lf);
784 Globals.lfFont = lf;
786 if (currfont != NULL)
787 DeleteObject(currfont);
788 }
789}
790
792
794{
795 if (Globals.hFindReplaceDlg != NULL)
796 {
797 SetFocus(Globals.hFindReplaceDlg);
798 return;
799 }
800
801 if (!Globals.find.lpstrFindWhat)
802 {
803 ZeroMemory(&Globals.find, sizeof(Globals.find));
804 Globals.find.lStructSize = sizeof(Globals.find);
805 Globals.find.hwndOwner = Globals.hMainWnd;
806 Globals.find.lpstrFindWhat = Globals.szFindText;
807 Globals.find.wFindWhatLen = _countof(Globals.szFindText);
808 Globals.find.lpstrReplaceWith = Globals.szReplaceText;
809 Globals.find.wReplaceWithLen = _countof(Globals.szReplaceText);
810 Globals.find.Flags = FR_DOWN;
811 }
812
813 /* We only need to create the modal FindReplace dialog which will */
814 /* notify us of incoming events using hMainWnd Window Messages */
815
816 Globals.hFindReplaceDlg = pfnProc(&Globals.find);
817 assert(Globals.hFindReplaceDlg != NULL);
818}
819
821{
823}
824
826{
827 if (bDown)
828 Globals.find.Flags |= FR_DOWN;
829 else
830 Globals.find.Flags &= ~FR_DOWN;
831
832 if (Globals.find.lpstrFindWhat != NULL && *Globals.find.lpstrFindWhat)
834 else
836}
837
839{
841}
842
843typedef struct tagGOTO_DATA
844{
848
849static INT_PTR
852{
853 static PGOTO_DATA s_pGotoData;
854
855 switch (uMsg)
856 {
857 case WM_INITDIALOG:
858 s_pGotoData = (PGOTO_DATA)lParam;
859 SetDlgItemInt(hwndDialog, ID_LINENUMBER, s_pGotoData->iLine, FALSE);
860 return TRUE; /* Set focus */
861
862 case WM_COMMAND:
863 {
864 if (LOWORD(wParam) == IDOK)
865 {
867 if (iLine <= 0 || s_pGotoData->cLines < iLine) /* Out of range */
868 {
869 /* Show error message */
870 WCHAR title[128], text[256];
873 MessageBoxW(hwndDialog, text, title, MB_OK);
874
875 SendDlgItemMessageW(hwndDialog, ID_LINENUMBER, EM_SETSEL, 0, -1);
876 SetFocus(GetDlgItem(hwndDialog, ID_LINENUMBER));
877 break;
878 }
879 s_pGotoData->iLine = iLine;
880 EndDialog(hwndDialog, IDOK);
881 }
882 else if (LOWORD(wParam) == IDCANCEL)
883 {
884 EndDialog(hwndDialog, IDCANCEL);
885 }
886 break;
887 }
888 }
889
890 return 0;
891}
892
894{
895 GOTO_DATA GotoData;
896 DWORD dwStart = 0, dwEnd = 0;
897 INT ich, cch = GetWindowTextLength(Globals.hEdit);
898
899 /* Get the current line number and the total line number */
900 SendMessage(Globals.hEdit, EM_GETSEL, (WPARAM) &dwStart, (LPARAM) &dwEnd);
901 GotoData.iLine = (UINT)SendMessage(Globals.hEdit, EM_LINEFROMCHAR, dwStart, 0) + 1;
902 GotoData.cLines = (UINT)SendMessage(Globals.hEdit, EM_GETLINECOUNT, 0, 0);
903
904 /* Ask the user for line number */
909 (LPARAM)&GotoData) != IDOK)
910 {
911 return; /* Canceled */
912 }
913
914 --GotoData.iLine; /* Make it zero-based */
915
916 /* Get ich (the target character index) from line number */
917 if (GotoData.iLine <= 0)
918 ich = 0;
919 else if (GotoData.iLine >= GotoData.cLines)
920 ich = cch;
921 else
922 ich = (INT)SendMessage(Globals.hEdit, EM_LINEINDEX, GotoData.iLine, 0);
923
924 /* EM_LINEINDEX can return -1 on failure */
925 if (ich < 0)
926 ich = 0;
927
928 /* Move the caret */
929 SendMessage(Globals.hEdit, EM_SETSEL, ich, ich);
930 SendMessage(Globals.hEdit, EM_SCROLLCARET, 0, 0);
931}
932
934{
935 int line, ich, col;
937 DWORD dwStart, dwSize;
938
939 SendMessage(Globals.hEdit, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwSize);
940 line = (int)SendMessage(Globals.hEdit, EM_LINEFROMCHAR, (WPARAM)dwStart, 0);
941 ich = (int)SendMessage(Globals.hEdit, EM_LINEINDEX, (WPARAM)line, 0);
942
943 /* EM_LINEINDEX can return -1 on failure */
944 col = ((ich < 0) ? 0 : (dwStart - ich));
945
946 StringCchPrintf(buff, _countof(buff), Globals.szStatusBarLineCol, line + 1, col + 1);
948}
949
951{
952 Globals.bShowStatusBar = !Globals.bShowStatusBar;
954}
955
957{
959}
960
962{
963 TCHAR szNotepad[MAX_STRING_LEN];
964 TCHAR szNotepadAuthors[MAX_STRING_LEN];
965
966 LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, _countof(szNotepad));
967 LoadString(Globals.hInstance, STRING_NOTEPAD_AUTHORS, szNotepadAuthors, _countof(szNotepadAuthors));
968
969 ShellAbout(Globals.hMainWnd, szNotepad, szNotepadAuthors,
971}
std::map< E_STRING, PART_TEST > parts
Definition: LocaleTests.cpp:69
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
#define MAX_STRING_LEN
Definition: precomp.h:36
static VOID SetFileName(PCONSOLE_CHILDFRM_WND Info, PWSTR pFileName)
Definition: console.c:180
BOOL DIALOG_FileSaveAs(VOID)
Definition: dialog.c:534
VOID DoShowHideStatusBar(VOID)
Definition: dialog.c:633
VOID DIALOG_StatusBarAlignParts(VOID)
Definition: dialog.c:147
static BOOL DoSaveFile(VOID)
Definition: dialog.c:250
VOID DIALOG_Replace(VOID)
Definition: dialog.c:838
VOID DIALOG_HelpContents(VOID)
Definition: dialog.c:956
VOID DIALOG_StatusBarUpdateCaretPos(VOID)
Definition: dialog.c:933
VOID DIALOG_EditSelectAll(VOID)
Definition: dialog.c:612
VOID DIALOG_FileNew(VOID)
Definition: dialog.c:399
static VOID DIALOG_StatusBarUpdateEncoding(VOID)
Definition: dialog.c:174
static INT_PTR CALLBACK DIALOG_GoTo_DialogProc(HWND hwndDialog, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialog.c:851
BOOL HasFileExtension(LPCTSTR szFilename)
Definition: dialog.c:240
static VOID DIALOG_SearchDialog(FINDPROC pfnProc)
Definition: dialog.c:793
VOID WaitCursor(BOOL bBegin)
Definition: dialog.c:120
VOID DIALOG_FileExit(VOID)
Definition: dialog.c:582
VOID DIALOG_FileNewWindow(VOID)
Definition: dialog.c:418
VOID DIALOG_EditUndo(VOID)
Definition: dialog.c:587
static const TCHAR helpfile[]
Definition: dialog.c:19
VOID DIALOG_GoTo(VOID)
Definition: dialog.c:893
static VOID DIALOG_StatusBarUpdateLineEndings(VOID)
Definition: dialog.c:165
VOID DIALOG_ViewStatusBar(VOID)
Definition: dialog.c:950
static const TCHAR empty_str[]
Definition: dialog.c:20
VOID DIALOG_EditTimeDate(VOID)
Definition: dialog.c:617
static void AlertFileNotFound(LPCTSTR szFileName)
Definition: dialog.c:214
#define SBPART_EOLN
Definition: dialog.c:26
static VOID DIALOG_StatusBarUpdateAll(VOID)
Definition: dialog.c:186
VOID DIALOG_FileOpen(VOID)
Definition: dialog.c:430
LRESULT CALLBACK EDIT_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:294
VOID DoCreateEditWindow(VOID)
Definition: dialog.c:667
static const TCHAR txt_files[]
Definition: dialog.c:22
static int AlertFileNotSaved(LPCTSTR szFileName)
Definition: dialog.c:219
VOID DIALOG_SelectFont(VOID)
Definition: dialog.c:768
BOOL DIALOG_FileSave(VOID)
Definition: dialog.c:459
struct tagGOTO_DATA * PGOTO_DATA
VOID ShowLastError(VOID)
Definition: dialog.c:45
VOID DIALOG_Search(VOID)
Definition: dialog.c:820
HWND(WINAPI * FINDPROC)(LPFINDREPLACE lpfr)
Definition: dialog.c:791
VOID DIALOG_HelpAboutNotepad(VOID)
Definition: dialog.c:961
BOOL DoCloseFile(VOID)
Definition: dialog.c:311
static UINT EncToStrId[]
Definition: dialog.c:37
VOID DIALOG_EditCut(VOID)
Definition: dialog.c:592
static UINT EolnToStrId[]
Definition: dialog.c:30
#define SBPART_ENCODING
Definition: dialog.c:27
VOID DIALOG_EditWrap(VOID)
Definition: dialog.c:758
VOID DIALOG_SearchNext(BOOL bDown)
Definition: dialog.c:825
BOOL FileExists(LPCTSTR szFilename)
Definition: dialog.c:235
VOID DIALOG_EditPaste(VOID)
Definition: dialog.c:602
static UINT_PTR CALLBACK DIALOG_FileSaveAs_Hook(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: dialog.c:475
struct tagGOTO_DATA GOTO_DATA
static const TCHAR szDefaultExt[]
Definition: dialog.c:21
VOID DIALOG_EditCopy(VOID)
Definition: dialog.c:597
int DIALOG_StringMsgBox(HWND hParent, int formatId, LPCTSTR szString, DWORD dwFlags)
Definition: dialog.c:193
VOID DoOpenFile(LPCTSTR szFileName)
Definition: dialog.c:341
void UpdateWindowCaption(BOOL clearModifyAlert)
Definition: dialog.c:79
VOID DIALOG_EditDelete(VOID)
Definition: dialog.c:607
#define SBPART_CURPOS
Definition: dialog.c:25
VOID NOTEPAD_EnableSearchMenu()
Definition: main.c:20
BOOL NOTEPAD_FindNext(FINDREPLACE *pFindReplace, BOOL bReplace, BOOL bShowAlert)
Definition: main.c:132
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define ChooseFont
Definition: commdlg.h:662
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
#define GetSaveFileName
Definition: commdlg.h:666
#define OFN_EXPLORER
Definition: commdlg.h:104
#define CF_INITTOLOGFONTSTRUCT
Definition: commdlg.h:66
#define OFN_ENABLEHOOK
Definition: commdlg.h:99
#define CF_NOVERTFONTS
Definition: commdlg.h:86
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define CDN_FILEOK
Definition: commdlg.h:38
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_ENABLETEMPLATE
Definition: commdlg.h:102
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
#define GetOpenFileName
Definition: commdlg.h:665
#define FindText
Definition: commdlg.h:663
#define FR_DOWN
Definition: commdlg.h:127
#define ReplaceText
Definition: commdlg.h:669
#define CF_SCREENFONTS
Definition: commdlg.h:59
OPENFILENAMEA OPENFILENAME
Definition: commdlg.h:657
#define NO_ERROR
Definition: dderror.h:5
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define GENERIC_READ
Definition: compat.h:135
HANDLE HWND
Definition: compat.h:19
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define CALLBACK
Definition: compat.h:35
#define FILE_SHARE_READ
Definition: compat.h:136
BOOL WINAPI SetEndOfFile(HANDLE hFile)
Definition: fileinfo.c:988
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:272
const WCHAR * text
Definition: package.c:1794
#define assert(_expr)
Definition: assert.h:32
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define L(x)
Definition: resources.c:13
static unsigned char buff[32768]
Definition: fatten.c:17
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
GLdouble s
Definition: gl.h:2039
LPVOID NTAPI LocalLock(HLOCAL hMem)
Definition: heapmem.c:1616
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1805
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
int iLine
Definition: hpp.c:35
char TCHAR
Definition: tchar.h:1402
#define _tcscmp
Definition: tchar.h:1424
#define _tcscat
Definition: tchar.h:622
#define _tcscpy
Definition: tchar.h:623
#define _tcsrchr
Definition: tchar.h:1413
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
#define ZeroMemory
Definition: minwinbase.h:31
LONG_PTR LPARAM
Definition: minwindef.h:175
LONG_PTR LRESULT
Definition: minwindef.h:176
UINT_PTR WPARAM
Definition: minwindef.h:174
HANDLE HLOCAL
Definition: minwindef.h:199
#define error(str)
Definition: mkdosfs.c:1605
#define OPEN_ALWAYS
Definition: disk.h:70
LPCWSTR szPath
Definition: env.c:37
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
ENCODING
Definition: more.c:492
LPSTR LPTSTR
Definition: ms-dtyp.idl:131
LPCSTR LPCTSTR
Definition: ms-dtyp.idl:130
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
_In_ HANDLE hFile
Definition: mswsock.h:90
unsigned int UINT
Definition: ndis.h:50
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define EDIT_STYLE
Definition: notepad.h:33
#define EDIT_STYLE_WRAP
Definition: notepad.h:32
#define ENCODING_DEFAULT
Definition: notepad.h:49
@ ENCODING_AUTO
Definition: notepad.h:41
BOOL WriteText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENCODING encFile, EOLN iEoln)
Definition: text.c:436
HLOCAL ReadText(HANDLE hFile, ENCODING *pencFile, EOLN *piEoln)
Definition: text.c:161
EOLN
Definition: notepad.h:52
@ EOLN_CRLF
Definition: notepad.h:53
#define EDIT_CLASS
Definition: notepad.h:34
#define ID_ENCODING
Definition: notepad_res.h:15
#define STRING_NOTFOUND
Definition: notepad_res.h:75
#define CMD_GOTO
Definition: notepad_res.h:47
#define CMD_STATUSBAR_WND_ID
Definition: notepad_res.h:54
#define STRING_ERROR
Definition: notepad_res.h:64
#define ID_EOLN
Definition: notepad_res.h:16
#define ID_LINENUMBER
Definition: notepad_res.h:18
#define STRING_CR
Definition: notepad_res.h:87
#define STRING_UTF8
Definition: notepad_res.h:82
#define STRING_LF
Definition: notepad_res.h:86
#define STRING_ANSI
Definition: notepad_res.h:79
#define STRING_UTF8_BOM
Definition: notepad_res.h:83
#define DIALOG_GOTO
Definition: notepad_res.h:17
#define STRING_NOTEPAD_AUTHORS
Definition: notepad_res.h:101
#define STRING_NOTSAVED
Definition: notepad_res.h:73
#define STRING_LINE_NUMBER_OUT_OF_RANGE
Definition: notepad_res.h:92
#define STRING_LINE_COLUMN
Definition: notepad_res.h:89
#define STRING_UNICODE_BE
Definition: notepad_res.h:81
#define STRING_UNICODE
Definition: notepad_res.h:80
#define STRING_CRLF
Definition: notepad_res.h:85
#define DIALOG_ENCODING
Definition: notepad_res.h:14
#define STRING_UNTITLED
Definition: notepad_res.h:67
#define STRING_NOTEPAD
Definition: notepad_res.h:63
#define IDI_NPICON
Definition: notepad_res.h:19
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define GENERIC_WRITE
Definition: nt_native.h:90
#define LOCALE_USER_DEFAULT
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
#define MAKEINTRESOURCE(i)
Definition: ntverrsrc.c:25
#define LOWORD(l)
Definition: pedump.c:82
#define WS_CHILD
Definition: pedump.c:617
short WCHAR
Definition: pedump.c:58
#define INT
Definition: polytest.cpp:20
static char title[]
Definition: ps.c:92
#define CreateStatusWindow
Definition: commctrl.h:1938
#define CCS_BOTTOM
Definition: commctrl.h:2249
#define SB_SETTEXT
Definition: commctrl.h:1954
#define SB_SETPARTS
Definition: commctrl.h:1959
#define SB_SETTEXTW
Definition: commctrl.h:1947
#define SBARS_SIZEGRIP
Definition: commctrl.h:1928
#define EM_SCROLLCARET
Definition: richedit.h:81
#define WM_NOTIFY
Definition: richedit.h:61
#define LoadStringW
Definition: utils.h:64
#define log(outFile, fmt,...)
Definition: util.h:15
_In_ UINT _In_ UINT cch
Definition: shellapi.h:432
#define ShellExecute
Definition: shellapi.h:738
#define ShellAbout
Definition: shellapi.h:737
#define _countof(array)
Definition: sndvol32.h:70
#define StringCchCopy
Definition: strsafe.h:139
#define StringCchPrintf
Definition: strsafe.h:517
#define StringCbPrintf
Definition: strsafe.h:544
HINSTANCE hInstance
Definition: precomp.h:43
Definition: inflate.c:139
Definition: parser.c:49
UINT iLine
Definition: dialog.c:845
UINT cLines
Definition: dialog.c:846
LPCSTR lpstrDefExt
Definition: commdlg.h:345
LPCSTR lpTemplateName
Definition: commdlg.h:348
HWND hwndOwner
Definition: commdlg.h:330
HINSTANCE hInstance
Definition: commdlg.h:331
LPSTR lpstrFile
Definition: commdlg.h:336
DWORD Flags
Definition: commdlg.h:342
LPOFNHOOKPROC lpfnHook
Definition: commdlg.h:347
DWORD lStructSize
Definition: commdlg.h:329
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD nMaxFile
Definition: commdlg.h:337
LONG right
Definition: windef.h:108
#define max(a, b)
Definition: svc.c:63
#define SetWindowLongPtr
Definition: treelist.c:70
#define GWLP_WNDPROC
Definition: treelist.c:66
int32_t INT_PTR
Definition: typedefs.h:64
uint16_t * LPWSTR
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define _T(x)
Definition: vfdio.h:22
#define FormatMessage
Definition: winbase.h:3544
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define GetFileAttributes
Definition: winbase.h:3564
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:400
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:396
#define CreateFile
Definition: winbase.h:3498
#define GetModuleFileName
Definition: winbase.h:3580
HICON HCURSOR
Definition: windef.h:99
#define WINAPI
Definition: msvc.h:6
#define CreateFontIndirect
Definition: wingdi.h:4890
#define GetTimeFormat
Definition: winnls.h:1361
#define DATE_LONGDATE
Definition: winnls.h:210
#define GetDateFormat
Definition: winnls.h:1356
#define SW_SHOWNORMAL
Definition: winuser.h:781
#define CreateWindowEx
Definition: winuser.h:5921
#define SW_HIDE
Definition: winuser.h:779
#define WM_CLOSE
Definition: winuser.h:1649
#define EM_LIMITTEXT
Definition: winuser.h:2029
#define EM_LINEFROMCHAR
Definition: winuser.h:2030
#define WM_PASTE
Definition: winuser.h:1891
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define WinHelp
Definition: winuser.h:6030
#define IDCANCEL
Definition: winuser.h:842
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define GetWindowTextLength
Definition: winuser.h:5965
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define EM_GETSEL
Definition: winuser.h:2026
#define EM_GETMODIFY
Definition: winuser.h:2023
#define WM_SIZE
Definition: winuser.h:1639
#define EM_EMPTYUNDOBUFFER
Definition: winuser.h:2014
#define WM_COMMAND
Definition: winuser.h:1768
#define EM_REPLACESEL
Definition: winuser.h:2035
#define CB_SETCURSEL
Definition: winuser.h:1990
#define SW_SHOWNOACTIVATE
Definition: winuser.h:785
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define WM_CUT
Definition: winuser.h:1889
#define DialogBoxParam
Definition: winuser.h:5930
#define WM_INITDIALOG
Definition: winuser.h:1767
#define EM_LINEINDEX
Definition: winuser.h:2031
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_ICONMASK
Definition: winuser.h:830
#define EM_GETHANDLE
Definition: winuser.h:2018
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:841
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MB_ICONERROR
Definition: winuser.h:798
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetDlgItemInt(_In_ HWND, _In_ int, _In_ UINT, _In_ BOOL)
#define EM_SETHANDLE
Definition: winuser.h:2038
HWND WINAPI SetFocus(_In_opt_ HWND)
#define MF_ENABLED
Definition: winuser.h:128
#define WM_SETFONT
Definition: winuser.h:1678
#define EM_UNDO
Definition: winuser.h:2050
#define IDNO
Definition: winuser.h:847
#define CB_ADDSTRING
Definition: winuser.h:1965
_In_ int cchText
Definition: winuser.h:4619
#define LoadIcon
Definition: winuser.h:5979
#define SendMessage
Definition: winuser.h:6009
#define LoadCursor
Definition: winuser.h:5978
#define EM_SETSEL
Definition: winuser.h:2047
int WINAPI GetWindowTextLengthW(_In_ HWND)
#define MB_ICONEXCLAMATION
Definition: winuser.h:796
#define MB_OK
Definition: winuser.h:801
#define GetWindowText
Definition: winuser.h:5964
#define PostMessage
Definition: winuser.h:5998
#define CW_USEDEFAULT
Definition: winuser.h:225
#define HELP_INDEX
Definition: winuser.h:2446
#define LoadString
Definition: winuser.h:5985
#define MB_ICONQUESTION
Definition: winuser.h:800
#define MessageBox
Definition: winuser.h:5988
#define WM_COPY
Definition: winuser.h:1890
#define IDC_WAIT
Definition: winuser.h:697
#define SW_SHOW
Definition: winuser.h:786
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define SetWindowText
Definition: winuser.h:6023
#define WM_CLEAR
Definition: winuser.h:1892
UINT WINAPI GetDlgItemInt(_In_ HWND, _In_ int, _Out_opt_ PBOOL, _In_ BOOL)
#define EM_GETLINECOUNT
Definition: winuser.h:2021
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:3014
#define IDYES
Definition: winuser.h:846
#define CB_GETCURSEL
Definition: winuser.h:1972
BOOL WINAPI DestroyWindow(_In_ HWND)
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MB_YESNOCANCEL
Definition: winuser.h:829
#define EM_SETMODIFY
Definition: winuser.h:2042
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define MF_GRAYED
Definition: winuser.h:129