ReactOS 0.4.15-dev-5863-g1fe3ab7
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
54
56 NULL,
57 error,
58 0,
59 (LPTSTR) &lpMsgBuf,
60 0,
61 NULL);
62
64 LocalFree(lpMsgBuf);
65 }
66}
67
73void UpdateWindowCaption(BOOL clearModifyAlert)
74{
75 TCHAR szCaption[MAX_STRING_LEN];
76 TCHAR szNotepad[MAX_STRING_LEN];
77 TCHAR szFilename[MAX_STRING_LEN];
78 BOOL isModified;
79
80 if (clearModifyAlert)
81 {
82 /* When a file is being opened or created, there is no need to have
83 * the edited flag shown when the file has not been edited yet. */
84 isModified = FALSE;
85 }
86 else
87 {
88 /* Check whether the user has modified the file or not. If we are
89 * in the same state as before, don't change the caption. */
90 isModified = !!SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0);
91 if (isModified == Globals.bWasModified)
92 return;
93 }
94
95 /* Remember the state for later calls */
96 Globals.bWasModified = isModified;
97
98 /* Load the name of the application */
99 LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, _countof(szNotepad));
100
101 /* Determine if the file has been saved or if this is a new file */
102 if (Globals.szFileTitle[0] != 0)
103 StringCchCopy(szFilename, _countof(szFilename), Globals.szFileTitle);
104 else
105 LoadString(Globals.hInstance, STRING_UNTITLED, szFilename, _countof(szFilename));
106
107 /* Update the window caption based upon whether the user has modified the file or not */
108 StringCbPrintf(szCaption, sizeof(szCaption), _T("%s%s - %s"),
109 (isModified ? _T("*") : _T("")), szFilename, szNotepad);
110
111 SetWindowText(Globals.hMainWnd, szCaption);
112}
113
115{
116 static const int defaultWidths[] = {120, 120, 120};
117 RECT rcStatusBar;
118 int parts[3];
119
120 GetClientRect(Globals.hStatusBar, &rcStatusBar);
121
122 parts[0] = rcStatusBar.right - (defaultWidths[1] + defaultWidths[2]);
123 parts[1] = rcStatusBar.right - defaultWidths[2];
124 parts[2] = -1; // the right edge of the status bar
125
126 parts[0] = max(parts[0], defaultWidths[0]);
127 parts[1] = max(parts[1], defaultWidths[0] + defaultWidths[1]);
128
130}
131
133{
134 WCHAR szText[128];
135
136 LoadStringW(Globals.hInstance, EolnToStrId[Globals.iEoln], szText, _countof(szText));
137
138 SendMessageW(Globals.hStatusBar, SB_SETTEXTW, SBPART_EOLN, (LPARAM)szText);
139}
140
142{
143 WCHAR szText[128] = L"";
144
145 if (Globals.encFile != ENCODING_AUTO)
146 {
147 LoadStringW(Globals.hInstance, EncToStrId[Globals.encFile], szText, _countof(szText));
148 }
149
151}
152
154{
158}
159
160int DIALOG_StringMsgBox(HWND hParent, int formatId, LPCTSTR szString, DWORD dwFlags)
161{
162 TCHAR szMessage[MAX_STRING_LEN];
163 TCHAR szResource[MAX_STRING_LEN];
164
165 /* Load and format szMessage */
166 LoadString(Globals.hInstance, formatId, szResource, _countof(szResource));
167 _sntprintf(szMessage, _countof(szMessage), szResource, szString);
168
169 /* Load szCaption */
171 LoadString(Globals.hInstance, STRING_ERROR, szResource, _countof(szResource));
172 else
173 LoadString(Globals.hInstance, STRING_NOTEPAD, szResource, _countof(szResource));
174
175 /* Display Modal Dialog */
176 // if (hParent == NULL)
177 // hParent = Globals.hMainWnd;
178 return MessageBox(hParent, szMessage, szResource, dwFlags);
179}
180
181static void AlertFileNotFound(LPCTSTR szFileName)
182{
184}
185
186static int AlertFileNotSaved(LPCTSTR szFileName)
187{
188 TCHAR szUntitled[MAX_STRING_LEN];
189
190 LoadString(Globals.hInstance, STRING_UNTITLED, szUntitled, _countof(szUntitled));
191
193 szFileName[0] ? szFileName : szUntitled,
195}
196
203{
204 return GetFileAttributes(szFilename) != INVALID_FILE_ATTRIBUTES;
205}
206
208{
209 LPCTSTR s;
210
211 s = _tcsrchr(szFilename, _T('\\'));
212 if (s)
213 szFilename = s;
214 return _tcsrchr(szFilename, _T('.')) != NULL;
215}
216
218{
219 BOOL bRet = FALSE;
222
226 {
228 return FALSE;
229 }
230
232 if (cchText <= 0)
233 {
234 bRet = TRUE;
235 }
236 else
237 {
238 HLOCAL hLocal = (HLOCAL)SendMessageW(Globals.hEdit, EM_GETHANDLE, 0, 0);
239 LPWSTR pszText = LocalLock(hLocal);
240 if (pszText)
241 {
242 bRet = WriteText(hFile, pszText, cchText, Globals.encFile, Globals.iEoln);
243 if (!bRet)
245
246 LocalUnlock(hLocal);
247 }
248 else
249 {
251 }
252 }
253
255
256 if (bRet)
257 {
259 SetFileName(Globals.szFileName);
260 }
261
262 return bRet;
263}
264
271{
272 int nResult;
273
274 if (SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0))
275 {
276 /* prompt user to save changes */
277 nResult = AlertFileNotSaved(Globals.szFileName);
278 switch (nResult)
279 {
280 case IDYES:
281 if(!DIALOG_FileSave())
282 return FALSE;
283 break;
284
285 case IDNO:
286 break;
287
288 case IDCANCEL:
289 default:
290 return FALSE;
291 }
292 }
293
296
297 return TRUE;
298}
299
301{
303 TCHAR log[5];
304 HLOCAL hLocal;
305
306 /* Close any files and prompt to save changes */
307 if (!DoCloseFile())
308 return;
309
313 {
315 goto done;
316 }
317
318 /* To make loading file quicker, we use the internal handle of EDIT control */
319 hLocal = (HLOCAL)SendMessageW(Globals.hEdit, EM_GETHANDLE, 0, 0);
320 if (!ReadText(hFile, &hLocal, &Globals.encFile, &Globals.iEoln))
321 {
323 goto done;
324 }
325 SendMessageW(Globals.hEdit, EM_SETHANDLE, (WPARAM)hLocal, 0);
326 /* No need of EM_SETMODIFY and EM_EMPTYUNDOBUFFER here. EM_SETHANDLE does instead. */
327
328 SetFocus(Globals.hEdit);
329
330 /* If the file starts with .LOG, add a time/date at the end and set cursor after
331 * See http://web.archive.org/web/20090627165105/http://support.microsoft.com/kb/260563
332 */
333 if (GetWindowText(Globals.hEdit, log, _countof(log)) && !_tcscmp(log, _T(".LOG")))
334 {
335 static const TCHAR lf[] = _T("\r\n");
340 }
341
342 SetFileName(szFileName);
346
347done:
350}
351
353{
354 /* Close any files and prompt to save changes */
355 if (!DoCloseFile())
356 return;
357
358 SetWindowText(Globals.hEdit, NULL);
360 Globals.iEoln = EOLN_CRLF;
361 Globals.encFile = ENCODING_DEFAULT;
362
365}
366
368{
369 TCHAR pszNotepadExe[MAX_PATH];
370 GetModuleFileName(NULL, pszNotepadExe, _countof(pszNotepadExe));
371 ShellExecute(NULL, NULL, pszNotepadExe, NULL, NULL, SW_SHOWNORMAL);
372}
373
375{
376 OPENFILENAME openfilename;
378
379 ZeroMemory(&openfilename, sizeof(openfilename));
380
381 if (Globals.szFileName[0] == 0)
383 else
384 _tcscpy(szPath, Globals.szFileName);
385
386 openfilename.lStructSize = sizeof(openfilename);
387 openfilename.hwndOwner = Globals.hMainWnd;
388 openfilename.hInstance = Globals.hInstance;
389 openfilename.lpstrFilter = Globals.szFilter;
390 openfilename.lpstrFile = szPath;
391 openfilename.nMaxFile = _countof(szPath);
393 openfilename.lpstrDefExt = szDefaultExt;
394
395 if (GetOpenFileName(&openfilename)) {
396 if (FileExists(openfilename.lpstrFile))
397 DoOpenFile(openfilename.lpstrFile);
398 else
399 AlertFileNotFound(openfilename.lpstrFile);
400 }
401}
402
404{
405 if (Globals.szFileName[0] == 0)
406 {
407 return DIALOG_FileSaveAs();
408 }
409 else if (DoSaveFile())
410 {
412 return TRUE;
413 }
414 return FALSE;
415}
416
417static UINT_PTR
420{
421 TCHAR szText[128];
422 HWND hCombo;
423
425
426 switch(msg)
427 {
428 case WM_INITDIALOG:
429 hCombo = GetDlgItem(hDlg, ID_ENCODING);
430
432 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
433
435 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
436
438 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
439
441 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
442
444 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
445
446 SendMessage(hCombo, CB_SETCURSEL, Globals.encFile, 0);
447
448 hCombo = GetDlgItem(hDlg, ID_EOLN);
449
451 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
452
453 LoadString(Globals.hInstance, STRING_LF, szText, _countof(szText));
454 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
455
456 LoadString(Globals.hInstance, STRING_CR, szText, _countof(szText));
457 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
458
459 SendMessage(hCombo, CB_SETCURSEL, Globals.iEoln, 0);
460 break;
461
462 case WM_NOTIFY:
463 if (((NMHDR *) lParam)->code == CDN_FILEOK)
464 {
465 hCombo = GetDlgItem(hDlg, ID_ENCODING);
466 if (hCombo)
467 Globals.encFile = (ENCODING) SendMessage(hCombo, CB_GETCURSEL, 0, 0);
468
469 hCombo = GetDlgItem(hDlg, ID_EOLN);
470 if (hCombo)
471 Globals.iEoln = (EOLN)SendMessage(hCombo, CB_GETCURSEL, 0, 0);
472 }
473 break;
474 }
475 return 0;
476}
477
479{
480 OPENFILENAME saveas;
482
483 ZeroMemory(&saveas, sizeof(saveas));
484
485 if (Globals.szFileName[0] == 0)
487 else
488 _tcscpy(szPath, Globals.szFileName);
489
490 saveas.lStructSize = sizeof(OPENFILENAME);
491 saveas.hwndOwner = Globals.hMainWnd;
492 saveas.hInstance = Globals.hInstance;
493 saveas.lpstrFilter = Globals.szFilter;
494 saveas.lpstrFile = szPath;
495 saveas.nMaxFile = _countof(szPath);
498 saveas.lpstrDefExt = szDefaultExt;
501
502 if (GetSaveFileName(&saveas))
503 {
504 /* HACK: Because in ROS, Save-As boxes don't check the validity
505 * of file names and thus, here, szPath can be invalid !! We only
506 * see its validity when we call DoSaveFile()... */
508 if (DoSaveFile())
509 {
512 return TRUE;
513 }
514 else
515 {
516 SetFileName(_T(""));
517 return FALSE;
518 }
519 }
520 else
521 {
522 return FALSE;
523 }
524}
525
527{
529}
530
532{
533 SendMessage(Globals.hEdit, EM_UNDO, 0, 0);
534}
535
537{
538 SendMessage(Globals.hEdit, WM_CUT, 0, 0);
539}
540
542{
543 SendMessage(Globals.hEdit, WM_COPY, 0, 0);
544}
545
547{
548 SendMessage(Globals.hEdit, WM_PASTE, 0, 0);
549}
550
552{
553 SendMessage(Globals.hEdit, WM_CLEAR, 0, 0);
554}
555
557{
558 SendMessage(Globals.hEdit, EM_SETSEL, 0, -1);
559}
560
562{
563 SYSTEMTIME st;
564 TCHAR szDate[MAX_STRING_LEN];
565 TCHAR szText[MAX_STRING_LEN * 2 + 2];
566
567 GetLocalTime(&st);
568
570 _tcscpy(szText, szDate);
571 _tcscat(szText, _T(" "));
573 _tcscat(szText, szDate);
574 SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)szText);
575}
576
578{
579 /* Check if status bar object already exists. */
580 if (Globals.bShowStatusBar && Globals.hStatusBar == NULL)
581 {
582 /* Try to create the status bar */
584 NULL,
587
588 if (Globals.hStatusBar == NULL)
589 {
591 return;
592 }
593
594 /* Load the string for formatting column/row text output */
596 }
597
598 /* Update layout of controls */
600
601 if (Globals.hStatusBar == NULL)
602 return;
603
604 /* Update visibility of status bar */
605 ShowWindow(Globals.hStatusBar, (Globals.bShowStatusBar ? SW_SHOWNOACTIVATE : SW_HIDE));
606
607 /* Update status bar contents */
609}
610
612{
613 DWORD dwStyle;
614 int iSize;
615 LPTSTR pTemp = NULL;
616 BOOL bModified = FALSE;
617
618 iSize = 0;
619
620 /* If the edit control already exists, try to save its content */
621 if (Globals.hEdit != NULL)
622 {
623 /* number of chars currently written into the editor. */
624 iSize = GetWindowTextLength(Globals.hEdit);
625 if (iSize)
626 {
627 /* Allocates temporary buffer. */
628 pTemp = HeapAlloc(GetProcessHeap(), 0, (iSize + 1) * sizeof(TCHAR));
629 if (!pTemp)
630 {
632 return;
633 }
634
635 /* Recover the text into the control. */
636 GetWindowText(Globals.hEdit, pTemp, iSize + 1);
637
638 if (SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0))
639 bModified = TRUE;
640 }
641
642 /* Restore original window procedure */
644
645 /* Destroy the edit control */
646 DestroyWindow(Globals.hEdit);
647 }
648
649 /* Update wrap status into the main menu and recover style flags */
650 dwStyle = (Globals.bWrapLongLines ? EDIT_STYLE_WRAP : EDIT_STYLE);
651
652 /* Create the new edit control */
655 NULL,
656 dwStyle,
662 NULL,
664 NULL);
665 if (Globals.hEdit == NULL)
666 {
667 if (pTemp)
668 {
669 HeapFree(GetProcessHeap(), 0, pTemp);
670 }
671
673 return;
674 }
675
677 SendMessage(Globals.hEdit, EM_LIMITTEXT, 0, 0);
678
679 /* If some text was previously saved, restore it. */
680 if (iSize != 0)
681 {
682 SetWindowText(Globals.hEdit, pTemp);
683 HeapFree(GetProcessHeap(), 0, pTemp);
684
685 if (bModified)
687 }
688
689 /* Sub-class a new window callback for row/column detection. */
690 Globals.EditProc = (WNDPROC)SetWindowLongPtr(Globals.hEdit,
693
694 /* Finally shows new edit control and set focus into it. */
695 ShowWindow(Globals.hEdit, SW_SHOW);
696 SetFocus(Globals.hEdit);
697
698 /* Re-arrange controls */
700}
701
703{
704 Globals.bWrapLongLines = !Globals.bWrapLongLines;
705
707
710}
711
713{
715 LOGFONT lf = Globals.lfFont;
716
717 ZeroMemory( &cf, sizeof(cf) );
718 cf.lStructSize = sizeof(cf);
719 cf.hwndOwner = Globals.hMainWnd;
720 cf.lpLogFont = &lf;
722
723 if (ChooseFont(&cf))
724 {
725 HFONT currfont = Globals.hFont;
726
727 Globals.hFont = CreateFontIndirect(&lf);
728 Globals.lfFont = lf;
730 if (currfont != NULL)
731 DeleteObject(currfont);
732 }
733}
734
736
738{
739 if (Globals.hFindReplaceDlg != NULL)
740 {
741 SetFocus(Globals.hFindReplaceDlg);
742 return;
743 }
744
745 if (!Globals.find.lpstrFindWhat)
746 {
747 ZeroMemory(&Globals.find, sizeof(Globals.find));
748 Globals.find.lStructSize = sizeof(Globals.find);
749 Globals.find.hwndOwner = Globals.hMainWnd;
750 Globals.find.lpstrFindWhat = Globals.szFindText;
751 Globals.find.wFindWhatLen = _countof(Globals.szFindText);
752 Globals.find.lpstrReplaceWith = Globals.szReplaceText;
753 Globals.find.wReplaceWithLen = _countof(Globals.szReplaceText);
754 Globals.find.Flags = FR_DOWN;
755 }
756
757 /* We only need to create the modal FindReplace dialog which will */
758 /* notify us of incoming events using hMainWnd Window Messages */
759
760 Globals.hFindReplaceDlg = pfnProc(&Globals.find);
761 assert(Globals.hFindReplaceDlg != NULL);
762}
763
765{
767}
768
770{
771 if (bDown)
772 Globals.find.Flags |= FR_DOWN;
773 else
774 Globals.find.Flags &= ~FR_DOWN;
775
776 if (Globals.find.lpstrFindWhat != NULL)
778 else
780}
781
783{
785}
786
787typedef struct tagGOTO_DATA
788{
792
793static INT_PTR
796{
797 static PGOTO_DATA s_pGotoData;
798
799 switch (uMsg)
800 {
801 case WM_INITDIALOG:
802 s_pGotoData = (PGOTO_DATA)lParam;
803 SetDlgItemInt(hwndDialog, ID_LINENUMBER, s_pGotoData->iLine, FALSE);
804 return TRUE; /* Set focus */
805
806 case WM_COMMAND:
807 {
808 if (LOWORD(wParam) == IDOK)
809 {
811 if (iLine <= 0 || s_pGotoData->cLines < iLine) /* Out of range */
812 {
813 /* Show error message */
814 WCHAR title[128], text[256];
817 MessageBoxW(hwndDialog, text, title, MB_OK);
818
819 SendDlgItemMessageW(hwndDialog, ID_LINENUMBER, EM_SETSEL, 0, -1);
820 SetFocus(GetDlgItem(hwndDialog, ID_LINENUMBER));
821 break;
822 }
823 s_pGotoData->iLine = iLine;
824 EndDialog(hwndDialog, IDOK);
825 }
826 else if (LOWORD(wParam) == IDCANCEL)
827 {
828 EndDialog(hwndDialog, IDCANCEL);
829 }
830 break;
831 }
832 }
833
834 return 0;
835}
836
838{
839 GOTO_DATA GotoData;
840 DWORD dwStart = 0, dwEnd = 0;
841 INT ich, cch = GetWindowTextLength(Globals.hEdit);
842
843 /* Get the current line number and the total line number */
844 SendMessage(Globals.hEdit, EM_GETSEL, (WPARAM) &dwStart, (LPARAM) &dwEnd);
845 GotoData.iLine = (UINT)SendMessage(Globals.hEdit, EM_LINEFROMCHAR, dwStart, 0) + 1;
846 GotoData.cLines = (UINT)SendMessage(Globals.hEdit, EM_GETLINECOUNT, 0, 0);
847
848 /* Ask the user for line number */
853 (LPARAM)&GotoData) != IDOK)
854 {
855 return; /* Canceled */
856 }
857
858 --GotoData.iLine; /* Make it zero-based */
859
860 /* Get ich (the target character index) from line number */
861 if (GotoData.iLine <= 0)
862 ich = 0;
863 else if (GotoData.iLine >= GotoData.cLines)
864 ich = cch;
865 else
866 ich = (INT)SendMessage(Globals.hEdit, EM_LINEINDEX, GotoData.iLine, 0);
867
868 /* Move the caret */
869 SendMessage(Globals.hEdit, EM_SETSEL, ich, ich);
870 SendMessage(Globals.hEdit, EM_SCROLLCARET, 0, 0);
871}
872
874{
875 int line, col;
877 DWORD dwStart, dwSize;
878
879 SendMessage(Globals.hEdit, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwSize);
880 line = SendMessage(Globals.hEdit, EM_LINEFROMCHAR, (WPARAM)dwStart, 0);
881 col = dwStart - SendMessage(Globals.hEdit, EM_LINEINDEX, (WPARAM)line, 0);
882
883 _stprintf(buff, Globals.szStatusBarLineCol, line + 1, col + 1);
885}
886
888{
889 Globals.bShowStatusBar = !Globals.bShowStatusBar;
891}
892
894{
896}
897
899{
900 TCHAR szNotepad[MAX_STRING_LEN];
901 TCHAR szNotepadAuthors[MAX_STRING_LEN];
902
903 LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, _countof(szNotepad));
904 LoadString(Globals.hInstance, STRING_NOTEPAD_AUTHORS, szNotepadAuthors, _countof(szNotepadAuthors));
905
906 ShellAbout(Globals.hMainWnd, szNotepad, szNotepadAuthors,
908}
#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:478
VOID DoShowHideStatusBar(VOID)
Definition: dialog.c:577
VOID DIALOG_StatusBarAlignParts(VOID)
Definition: dialog.c:114
static BOOL DoSaveFile(VOID)
Definition: dialog.c:217
VOID DIALOG_Replace(VOID)
Definition: dialog.c:782
VOID DIALOG_HelpContents(VOID)
Definition: dialog.c:893
VOID DIALOG_StatusBarUpdateCaretPos(VOID)
Definition: dialog.c:873
VOID DIALOG_EditSelectAll(VOID)
Definition: dialog.c:556
VOID DIALOG_FileNew(VOID)
Definition: dialog.c:352
static VOID DIALOG_StatusBarUpdateEncoding(VOID)
Definition: dialog.c:141
static INT_PTR CALLBACK DIALOG_GoTo_DialogProc(HWND hwndDialog, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialog.c:795
BOOL HasFileExtension(LPCTSTR szFilename)
Definition: dialog.c:207
static VOID DIALOG_SearchDialog(FINDPROC pfnProc)
Definition: dialog.c:737
VOID DIALOG_FileExit(VOID)
Definition: dialog.c:526
VOID DIALOG_FileNewWindow(VOID)
Definition: dialog.c:367
VOID DIALOG_EditUndo(VOID)
Definition: dialog.c:531
static const TCHAR helpfile[]
Definition: dialog.c:19
VOID DIALOG_GoTo(VOID)
Definition: dialog.c:837
static VOID DIALOG_StatusBarUpdateLineEndings(VOID)
Definition: dialog.c:132
VOID DIALOG_ViewStatusBar(VOID)
Definition: dialog.c:887
static const TCHAR empty_str[]
Definition: dialog.c:20
VOID DIALOG_EditTimeDate(VOID)
Definition: dialog.c:561
static void AlertFileNotFound(LPCTSTR szFileName)
Definition: dialog.c:181
#define SBPART_EOLN
Definition: dialog.c:26
static VOID DIALOG_StatusBarUpdateAll(VOID)
Definition: dialog.c:153
VOID DIALOG_FileOpen(VOID)
Definition: dialog.c:374
LRESULT CALLBACK EDIT_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:293
VOID DoCreateEditWindow(VOID)
Definition: dialog.c:611
static const TCHAR txt_files[]
Definition: dialog.c:22
static int AlertFileNotSaved(LPCTSTR szFileName)
Definition: dialog.c:186
VOID DIALOG_SelectFont(VOID)
Definition: dialog.c:712
BOOL DIALOG_FileSave(VOID)
Definition: dialog.c:403
struct tagGOTO_DATA * PGOTO_DATA
VOID ShowLastError(VOID)
Definition: dialog.c:45
VOID DIALOG_Search(VOID)
Definition: dialog.c:764
HWND(WINAPI * FINDPROC)(LPFINDREPLACE lpfr)
Definition: dialog.c:735
VOID DIALOG_HelpAboutNotepad(VOID)
Definition: dialog.c:898
BOOL DoCloseFile(VOID)
Definition: dialog.c:270
static UINT EncToStrId[]
Definition: dialog.c:37
VOID DIALOG_EditCut(VOID)
Definition: dialog.c:536
static UINT EolnToStrId[]
Definition: dialog.c:30
#define SBPART_ENCODING
Definition: dialog.c:27
VOID DIALOG_EditWrap(VOID)
Definition: dialog.c:702
VOID DIALOG_SearchNext(BOOL bDown)
Definition: dialog.c:769
BOOL FileExists(LPCTSTR szFilename)
Definition: dialog.c:202
VOID DIALOG_EditPaste(VOID)
Definition: dialog.c:546
static UINT_PTR CALLBACK DIALOG_FileSaveAs_Hook(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: dialog.c:419
struct tagGOTO_DATA GOTO_DATA
static const TCHAR szDefaultExt[]
Definition: dialog.c:21
VOID DIALOG_EditCopy(VOID)
Definition: dialog.c:541
int DIALOG_StringMsgBox(HWND hParent, int formatId, LPCTSTR szString, DWORD dwFlags)
Definition: dialog.c:160
VOID DoOpenFile(LPCTSTR szFileName)
Definition: dialog.c:300
void UpdateWindowCaption(BOOL clearModifyAlert)
Definition: dialog.c:73
VOID DIALOG_EditDelete(VOID)
Definition: dialog.c:551
#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
HANDLE HWND
Definition: compat.h:19
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define GENERIC_READ
Definition: compat.h:135
#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
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
const WCHAR * text
Definition: package.c:1799
#define assert(x)
Definition: debug.h:53
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:1599
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1788
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
int iLine
Definition: hpp.c:35
#define _tcscmp
Definition: tchar.h:1424
#define _tcscat
Definition: tchar.h:622
#define _tcscpy
Definition: tchar.h:623
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
#define error(str)
Definition: mkdosfs.c:1605
#define _stprintf
Definition: utility.h:124
#define _tcsrchr
Definition: utility.h:116
#define CREATE_ALWAYS
Definition: disk.h:72
#define OPEN_ALWAYS
Definition: disk.h:70
LPCWSTR szPath
Definition: env.c:37
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
static const D3D_BLOB_PART parts[]
Definition: blob.c:76
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
ENCODING
Definition: more.c:492
__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
#define EDIT_STYLE
Definition: notepad.h:37
BOOL ReadText(HANDLE hFile, HLOCAL *phLocal, ENCODING *pencFile, EOLN *piEoln)
Definition: text.c:153
#define EDIT_STYLE_WRAP
Definition: notepad.h:36
#define ENCODING_DEFAULT
Definition: notepad.h:53
@ ENCODING_AUTO
Definition: notepad.h:45
BOOL WriteText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENCODING encFile, EOLN iEoln)
Definition: text.c:395
EOLN
Definition: notepad.h:56
@ EOLN_CRLF
Definition: notepad.h:57
#define EDIT_CLASS
Definition: notepad.h:38
#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:317
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define WS_CHILD
Definition: pedump.c:617
#define INT
Definition: polytest.cpp:20
static char title[]
Definition: ps.c:92
#define CreateStatusWindow
Definition: commctrl.h:1933
#define CCS_BOTTOM
Definition: commctrl.h:2244
#define SB_SETTEXT
Definition: commctrl.h:1949
#define SB_SETPARTS
Definition: commctrl.h:1954
#define SB_SETTEXTW
Definition: commctrl.h:1942
#define SBARS_SIZEGRIP
Definition: commctrl.h:1923
#define EM_SCROLLCARET
Definition: richedit.h:81
#define WM_NOTIFY
Definition: richedit.h:61
#define log(outFile, fmt,...)
Definition: util.h:15
#define ShellExecute
Definition: shellapi.h:690
#define ShellAbout
Definition: shellapi.h:689
#define _countof(array)
Definition: sndvol32.h:68
#define StringCchCopy
Definition: strsafe.h:139
#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:789
UINT cLines
Definition: dialog.c:790
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:308
#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
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:3666
#define ZeroMemory
Definition: winbase.h:1670
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
#define GetFileAttributes
Definition: winbase.h:3686
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:423
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:419
#define CreateFile
Definition: winbase.h:3620
#define GetModuleFileName
Definition: winbase.h:3702
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
HANDLE HLOCAL
Definition: windef.h:244
#define WINAPI
Definition: msvc.h:6
#define CreateFontIndirect
Definition: wingdi.h:4444
#define GetTimeFormat
Definition: winnls.h:1189
#define DATE_LONGDATE
Definition: winnls.h:197
#define GetDateFormat
Definition: winnls.h:1184
#define SW_SHOWNORMAL
Definition: winuser.h:764
#define CreateWindowEx
Definition: winuser.h:5745
#define SW_HIDE
Definition: winuser.h:762
#define WM_CLOSE
Definition: winuser.h:1611
#define EM_LIMITTEXT
Definition: winuser.h:1990
#define EM_LINEFROMCHAR
Definition: winuser.h:1991
#define WM_PASTE
Definition: winuser.h:1853
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define WinHelp
Definition: winuser.h:5854
#define IDCANCEL
Definition: winuser.h:825
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define GetWindowTextLength
Definition: winuser.h:5789
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define EM_GETSEL
Definition: winuser.h:1987
#define EM_GETMODIFY
Definition: winuser.h:1984
#define WM_SIZE
Definition: winuser.h:1601
#define EM_EMPTYUNDOBUFFER
Definition: winuser.h:1975
#define WM_COMMAND
Definition: winuser.h:1730
#define EM_REPLACESEL
Definition: winuser.h:1996
#define CB_SETCURSEL
Definition: winuser.h:1951
#define SW_SHOWNOACTIVATE
Definition: winuser.h:768
#define WM_CUT
Definition: winuser.h:1851
#define DialogBoxParam
Definition: winuser.h:5754
#define WM_INITDIALOG
Definition: winuser.h:1729
#define EM_LINEINDEX
Definition: winuser.h:1992
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_ICONMASK
Definition: winuser.h:813
#define EM_GETHANDLE
Definition: winuser.h:1979
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:824
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MB_ICONERROR
Definition: winuser.h:781
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetDlgItemInt(_In_ HWND, _In_ int, _In_ UINT, _In_ BOOL)
#define EM_SETHANDLE
Definition: winuser.h:1999
HWND WINAPI SetFocus(_In_opt_ HWND)
#define MF_ENABLED
Definition: winuser.h:128
#define WM_SETFONT
Definition: winuser.h:1640
#define EM_UNDO
Definition: winuser.h:2011
#define IDNO
Definition: winuser.h:830
#define CB_ADDSTRING
Definition: winuser.h:1926
_In_ int cchText
Definition: winuser.h:4455
#define LoadIcon
Definition: winuser.h:5803
#define SendMessage
Definition: winuser.h:5833
#define EM_SETSEL
Definition: winuser.h:2008
int WINAPI GetWindowTextLengthW(_In_ HWND)
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
#define MB_OK
Definition: winuser.h:784
#define GetWindowText
Definition: winuser.h:5788
#define PostMessage
Definition: winuser.h:5822
#define CW_USEDEFAULT
Definition: winuser.h:225
#define HELP_INDEX
Definition: winuser.h:2400
#define LoadString
Definition: winuser.h:5809
#define MB_ICONQUESTION
Definition: winuser.h:783
#define MessageBox
Definition: winuser.h:5812
#define WM_COPY
Definition: winuser.h:1852
#define SW_SHOW
Definition: winuser.h:769
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define SetWindowText
Definition: winuser.h:5847
#define WM_CLEAR
Definition: winuser.h:1854
UINT WINAPI GetDlgItemInt(_In_ HWND, _In_ int, _Out_opt_ PBOOL, _In_ BOOL)
#define EM_GETLINECOUNT
Definition: winuser.h:1982
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2896
#define IDYES
Definition: winuser.h:829
#define CB_GETCURSEL
Definition: winuser.h:1933
BOOL WINAPI DestroyWindow(_In_ HWND)
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define MB_YESNOCANCEL
Definition: winuser.h:812
#define EM_SETMODIFY
Definition: winuser.h:2003
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
char TCHAR
Definition: xmlstorage.h:189
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define _sntprintf
Definition: xmlstorage.h:201
CHAR * LPTSTR
Definition: xmlstorage.h:192