https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d73b6cedf2482b68afc625aad2fae6451d47763d
commit d73b6cedf2482b68afc625aad2fae6451d47763d Author: Thamatip Chitpong <tangaming123...@outlook.com> AuthorDate: Mon Sep 5 23:21:27 2022 +0700 Commit: GitHub <nore...@github.com> CommitDate: Mon Sep 5 18:21:27 2022 +0200 [NOTEPAD] Improve UTF-8 encoding support and improve status bar (#4649) - Add write support for UTF-8 without BOM. - Add "UTF-8 with BOM" encoding to the "Save As" dialog. - Show line endings and encoding on the status bar (like Notepad in Windows 10). - Remove ignored WS_EX_STATICEDGE - Add grip to the status window. Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-ma...@reactos.org> --- base/applications/notepad/dialog.c | 87 +++++++++++++++++++++++++++++++-- base/applications/notepad/dialog.h | 1 + base/applications/notepad/lang/bg-BG.rc | 1 + base/applications/notepad/lang/cs-CZ.rc | 1 + base/applications/notepad/lang/da-DK.rc | 1 + base/applications/notepad/lang/de-DE.rc | 1 + base/applications/notepad/lang/el-GR.rc | 1 + base/applications/notepad/lang/en-US.rc | 1 + base/applications/notepad/lang/es-ES.rc | 1 + base/applications/notepad/lang/et-EE.rc | 1 + base/applications/notepad/lang/eu-ES.rc | 1 + base/applications/notepad/lang/fi-FI.rc | 1 + base/applications/notepad/lang/fr-FR.rc | 1 + base/applications/notepad/lang/he-IL.rc | 1 + base/applications/notepad/lang/hi-IN.rc | 1 + base/applications/notepad/lang/hr-HR.rc | 1 + base/applications/notepad/lang/hu-HU.rc | 1 + base/applications/notepad/lang/hy-AM.rc | 1 + base/applications/notepad/lang/id-ID.rc | 1 + base/applications/notepad/lang/it-IT.rc | 1 + base/applications/notepad/lang/ja-JP.rc | 1 + base/applications/notepad/lang/lt-LT.rc | 1 + base/applications/notepad/lang/ms-MY.rc | 1 + base/applications/notepad/lang/nl-NL.rc | 1 + base/applications/notepad/lang/no-NO.rc | 1 + base/applications/notepad/lang/pl-PL.rc | 1 + base/applications/notepad/lang/pt-BR.rc | 1 + base/applications/notepad/lang/pt-PT.rc | 1 + base/applications/notepad/lang/ro-RO.rc | 1 + base/applications/notepad/lang/ru-RU.rc | 1 + base/applications/notepad/lang/sk-SK.rc | 1 + base/applications/notepad/lang/sl-SI.rc | 1 + base/applications/notepad/lang/sq-AL.rc | 1 + base/applications/notepad/lang/sv-SE.rc | 1 + base/applications/notepad/lang/th-TH.rc | 1 + base/applications/notepad/lang/tr-TR.rc | 1 + base/applications/notepad/lang/uk-UA.rc | 1 + base/applications/notepad/lang/uz-UZ.rc | 1 + base/applications/notepad/lang/zh-CN.rc | 1 + base/applications/notepad/lang/zh-HK.rc | 1 + base/applications/notepad/lang/zh-TW.rc | 1 + base/applications/notepad/main.c | 9 +++- base/applications/notepad/main.h | 3 +- base/applications/notepad/notepad_res.h | 23 ++++----- base/applications/notepad/text.c | 20 ++++---- 45 files changed, 154 insertions(+), 28 deletions(-) diff --git a/base/applications/notepad/dialog.c b/base/applications/notepad/dialog.c index 1b10084e99b..6e45d05798e 100644 --- a/base/applications/notepad/dialog.c +++ b/base/applications/notepad/dialog.c @@ -33,6 +33,27 @@ static const TCHAR empty_str[] = _T(""); static const TCHAR szDefaultExt[] = _T("txt"); static const TCHAR txt_files[] = _T("*.txt"); +/* Status bar parts index */ +#define SBPART_CURPOS 0 +#define SBPART_EOLN 1 +#define SBPART_ENCODING 2 + +/* Line endings - string resource ID mapping table */ +static UINT EolnToStrId[] = { + STRING_CRLF, + STRING_LF, + STRING_CR +}; + +/* Encoding - string resource ID mapping table */ +static UINT EncToStrId[] = { + STRING_ANSI, + STRING_UNICODE, + STRING_UNICODE_BE, + STRING_UTF8, + STRING_UTF8_BOM +}; + static UINT_PTR CALLBACK DIALOG_PAGESETUP_Hook(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); VOID ShowLastError(VOID) @@ -104,6 +125,45 @@ void UpdateWindowCaption(BOOL clearModifyAlert) SetWindowText(Globals.hMainWnd, szCaption); } +VOID DIALOG_StatusBarAlignParts(VOID) +{ + static const int defaultWidths[] = {120, 120, 120}; + RECT rcStatusBar; + int parts[3]; + + GetClientRect(Globals.hStatusBar, &rcStatusBar); + + parts[0] = rcStatusBar.right - (defaultWidths[1] + defaultWidths[2]); + parts[1] = rcStatusBar.right - defaultWidths[2]; + parts[2] = -1; // the right edge of the status bar + + parts[0] = max(parts[0], defaultWidths[0]); + parts[1] = max(parts[1], defaultWidths[0] + defaultWidths[1]); + + SendMessageW(Globals.hStatusBar, SB_SETPARTS, (WPARAM)ARRAY_SIZE(parts), (LPARAM)parts); +} + +static VOID DIALOG_StatusBarUpdateLineEndings(VOID) +{ + WCHAR szText[128]; + + LoadStringW(Globals.hInstance, EolnToStrId[Globals.iEoln], szText, ARRAY_SIZE(szText)); + + SendMessageW(Globals.hStatusBar, SB_SETTEXTW, SBPART_EOLN, (LPARAM)szText); +} + +static VOID DIALOG_StatusBarUpdateEncoding(VOID) +{ + WCHAR szText[128] = L""; + + if (Globals.encFile != ENCODING_AUTO) + { + LoadStringW(Globals.hInstance, EncToStrId[Globals.encFile], szText, ARRAY_SIZE(szText)); + } + + SendMessageW(Globals.hStatusBar, SB_SETTEXTW, SBPART_ENCODING, (LPARAM)szText); +} + int DIALOG_StringMsgBox(HWND hParent, int formatId, LPCTSTR szString, DWORD dwFlags) { TCHAR szMessage[MAX_STRING_LEN]; @@ -403,6 +463,11 @@ VOID DoOpenFile(LPCTSTR szFileName) SetFileName(szFileName); UpdateWindowCaption(TRUE); NOTEPAD_EnableSearchMenu(); + + /* Update line endings and encoding on the status bar */ + DIALOG_StatusBarUpdateLineEndings(); + DIALOG_StatusBarUpdateEncoding(); + done: if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); @@ -497,6 +562,9 @@ DIALOG_FileSaveAs_Hook(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) LoadString(Globals.hInstance, STRING_UTF8, szText, ARRAY_SIZE(szText)); SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText); + LoadString(Globals.hInstance, STRING_UTF8_BOM, szText, ARRAY_SIZE(szText)); + SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText); + SendMessage(hCombo, CB_SETCURSEL, Globals.encFile, 0); hCombo = GetDlgItem(hDlg, ID_EOLN); @@ -562,6 +630,11 @@ BOOL DIALOG_FileSaveAs(VOID) if (DoSaveFile()) { UpdateWindowCaption(TRUE); + + /* Update line endings and encoding on the status bar */ + DIALOG_StatusBarUpdateLineEndings(); + DIALOG_StatusBarUpdateEncoding(); + return TRUE; } else @@ -852,7 +925,7 @@ VOID DoCreateStatusBar(VOID) if (Globals.hStatusBar == NULL) { /* Try to create the status bar */ - Globals.hStatusBar = CreateStatusWindow(WS_CHILD | WS_VISIBLE | WS_EX_STATICEDGE, + Globals.hStatusBar = CreateStatusWindow(WS_CHILD | WS_VISIBLE | CCS_BOTTOM | SBARS_SIZEGRIP, NULL, Globals.hMainWnd, CMD_STATUSBAR_WND_ID); @@ -865,9 +938,6 @@ VOID DoCreateStatusBar(VOID) /* Load the string for formatting column/row text output */ LoadString(Globals.hInstance, STRING_LINE_COLUMN, Globals.szStatusBarLineCol, MAX_PATH - 1); - - /* Set the status bar for single-text output */ - SendMessage(Globals.hStatusBar, SB_SIMPLE, (WPARAM)TRUE, (LPARAM)0); } /* Set status bar visiblity according to the settings. */ @@ -916,8 +986,15 @@ VOID DoCreateStatusBar(VOID) TRUE); } + /* Set the status bar for multiple-text output */ + DIALOG_StatusBarAlignParts(); + /* Update content with current row/column text */ DIALOG_StatusBarUpdateCaretPos(); + + /* Update line endings and encoding on the status bar */ + DIALOG_StatusBarUpdateLineEndings(); + DIALOG_StatusBarUpdateEncoding(); } VOID DoCreateEditWindow(VOID) @@ -1195,7 +1272,7 @@ VOID DIALOG_StatusBarUpdateCaretPos(VOID) col = dwStart - SendMessage(Globals.hEdit, EM_LINEINDEX, (WPARAM)line, 0); _stprintf(buff, Globals.szStatusBarLineCol, line + 1, col + 1); - SendMessage(Globals.hStatusBar, SB_SETTEXT, SB_SIMPLEID, (LPARAM)buff); + SendMessage(Globals.hStatusBar, SB_SETTEXT, SBPART_CURPOS, (LPARAM)buff); } VOID DIALOG_ViewStatusBar(VOID) diff --git a/base/applications/notepad/dialog.h b/base/applications/notepad/dialog.h index 98104dcc6e5..3d5572cfad7 100644 --- a/base/applications/notepad/dialog.h +++ b/base/applications/notepad/dialog.h @@ -46,6 +46,7 @@ VOID DIALOG_GoTo(VOID); VOID DIALOG_SelectFont(VOID); VOID DIALOG_ViewStatusBar(VOID); +VOID DIALOG_StatusBarAlignParts(VOID); VOID DIALOG_StatusBarUpdateCaretPos(VOID); VOID DIALOG_HelpContents(VOID); diff --git a/base/applications/notepad/lang/bg-BG.rc b/base/applications/notepad/lang/bg-BG.rc index d17e24ab300..5b900b511f3 100644 --- a/base/applications/notepad/lang/bg-BG.rc +++ b/base/applications/notepad/lang/bg-BG.rc @@ -160,6 +160,7 @@ BEGIN STRING_UNICODE "Уникод" STRING_UNICODE_BE "Уникод (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Уьиндоуьс (CR + LF)" STRING_LF "Юникс (LF)" STRING_CR "Мак (CR)" diff --git a/base/applications/notepad/lang/cs-CZ.rc b/base/applications/notepad/lang/cs-CZ.rc index 1338063e8e9..36fd1d28b52 100644 --- a/base/applications/notepad/lang/cs-CZ.rc +++ b/base/applications/notepad/lang/cs-CZ.rc @@ -161,6 +161,7 @@ paměti." STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/da-DK.rc b/base/applications/notepad/lang/da-DK.rc index f24b93562cb..8ab2d8f4c07 100644 --- a/base/applications/notepad/lang/da-DK.rc +++ b/base/applications/notepad/lang/da-DK.rc @@ -161,6 +161,7 @@ hukommelse, og prøv så igen." STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/de-DE.rc b/base/applications/notepad/lang/de-DE.rc index 12304456c6f..c1c491f3e03 100644 --- a/base/applications/notepad/lang/de-DE.rc +++ b/base/applications/notepad/lang/de-DE.rc @@ -162,6 +162,7 @@ um diese Funktion\nabzuschließen. Beenden Sie eine oder mehrere \ STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (Big-Endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/el-GR.rc b/base/applications/notepad/lang/el-GR.rc index c27cb97636a..32e23f3f00a 100644 --- a/base/applications/notepad/lang/el-GR.rc +++ b/base/applications/notepad/lang/el-GR.rc @@ -161,6 +161,7 @@ BEGIN STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/en-US.rc b/base/applications/notepad/lang/en-US.rc index 6f284bdbf21..242fb18c426 100644 --- a/base/applications/notepad/lang/en-US.rc +++ b/base/applications/notepad/lang/en-US.rc @@ -160,6 +160,7 @@ task.\nClose one or more applications to increase the amount of\nfree memory." STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/es-ES.rc b/base/applications/notepad/lang/es-ES.rc index a22083ca956..3700fe740cd 100644 --- a/base/applications/notepad/lang/es-ES.rc +++ b/base/applications/notepad/lang/es-ES.rc @@ -163,6 +163,7 @@ aumentar la cantidad\nde memoria libre." STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/et-EE.rc b/base/applications/notepad/lang/et-EE.rc index 3df808c417e..f5b3afa982b 100644 --- a/base/applications/notepad/lang/et-EE.rc +++ b/base/applications/notepad/lang/et-EE.rc @@ -168,6 +168,7 @@ käsu lõpetamiseks.\nSulge üks või enam rakendust, et suurendada\nvaba mälu STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/eu-ES.rc b/base/applications/notepad/lang/eu-ES.rc index 0923ac47c4d..bb082e9fbb6 100644 --- a/base/applications/notepad/lang/eu-ES.rc +++ b/base/applications/notepad/lang/eu-ES.rc @@ -161,6 +161,7 @@ memoria librearen\nkopurua handitzeko." STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/fi-FI.rc b/base/applications/notepad/lang/fi-FI.rc index a12be32822e..d13c7ce9337 100644 --- a/base/applications/notepad/lang/fi-FI.rc +++ b/base/applications/notepad/lang/fi-FI.rc @@ -161,6 +161,7 @@ muistia." STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/fr-FR.rc b/base/applications/notepad/lang/fr-FR.rc index 29bac1aa9c9..6fba3e8d9c0 100644 --- a/base/applications/notepad/lang/fr-FR.rc +++ b/base/applications/notepad/lang/fr-FR.rc @@ -161,6 +161,7 @@ de la mémoire." STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/he-IL.rc b/base/applications/notepad/lang/he-IL.rc index 63c3a2c2f46..f4929cf8d5f 100644 --- a/base/applications/notepad/lang/he-IL.rc +++ b/base/applications/notepad/lang/he-IL.rc @@ -163,6 +163,7 @@ task.\nClose one or more applications to increase the amount of\nfree memory." STRING_UNICODE "יוניקוד" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "חלונות (CR + LF)" STRING_LF "יוניקס (LF)" STRING_CR "מקינטוש (CR)" diff --git a/base/applications/notepad/lang/hi-IN.rc b/base/applications/notepad/lang/hi-IN.rc index abb0c2810fd..24ecb4b0094 100644 --- a/base/applications/notepad/lang/hi-IN.rc +++ b/base/applications/notepad/lang/hi-IN.rc @@ -167,6 +167,7 @@ BEGIN STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/hr-HR.rc b/base/applications/notepad/lang/hr-HR.rc index fa683dd091d..92eeafd4af5 100644 --- a/base/applications/notepad/lang/hr-HR.rc +++ b/base/applications/notepad/lang/hr-HR.rc @@ -167,6 +167,7 @@ zadatak.\nZatvorite jednu ili više aplikacija da povećate\nslobodnu memoriju." STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/hu-HU.rc b/base/applications/notepad/lang/hu-HU.rc index 48d1086851f..e23208079ff 100644 --- a/base/applications/notepad/lang/hu-HU.rc +++ b/base/applications/notepad/lang/hu-HU.rc @@ -161,6 +161,7 @@ Szeretné menteni a változásokat?" STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/hy-AM.rc b/base/applications/notepad/lang/hy-AM.rc index 7c82d538f26..d14af947fd7 100644 --- a/base/applications/notepad/lang/hy-AM.rc +++ b/base/applications/notepad/lang/hy-AM.rc @@ -160,6 +160,7 @@ Would you like to save the changes ?" STRING_UNICODE "Յունիկոդ" STRING_UNICODE_BE "Յունիկոդ (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Պատւոհաններ (CR + LF)" STRING_LF "Յունիքս (LF)" STRING_CR "Մակինտոշ (CR)" diff --git a/base/applications/notepad/lang/id-ID.rc b/base/applications/notepad/lang/id-ID.rc index 32f002e078a..594ddac068d 100644 --- a/base/applications/notepad/lang/id-ID.rc +++ b/base/applications/notepad/lang/id-ID.rc @@ -161,6 +161,7 @@ bebas." STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/it-IT.rc b/base/applications/notepad/lang/it-IT.rc index b239f11b7e8..d06b07dceb9 100644 --- a/base/applications/notepad/lang/it-IT.rc +++ b/base/applications/notepad/lang/it-IT.rc @@ -161,6 +161,7 @@ di memoria libera." STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/ja-JP.rc b/base/applications/notepad/lang/ja-JP.rc index ad1359f9aca..5b43cd0352e 100644 --- a/base/applications/notepad/lang/ja-JP.rc +++ b/base/applications/notepad/lang/ja-JP.rc @@ -161,6 +161,7 @@ BEGIN STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/lt-LT.rc b/base/applications/notepad/lang/lt-LT.rc index 494161c1eb3..040a66a6755 100644 --- a/base/applications/notepad/lang/lt-LT.rc +++ b/base/applications/notepad/lang/lt-LT.rc @@ -160,6 +160,7 @@ Ar norite išsaugoti pakeitimus?" STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/ms-MY.rc b/base/applications/notepad/lang/ms-MY.rc index 26787eeb4ef..9674fdef67d 100644 --- a/base/applications/notepad/lang/ms-MY.rc +++ b/base/applications/notepad/lang/ms-MY.rc @@ -162,6 +162,7 @@ tugas ini.\nTutup satu atau lebih aplikasi untuk menambah jumlah\ningatan kosong STRING_UNICODE "Unikod" STRING_UNICODE_BE "Unikod (endian besar)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/nl-NL.rc b/base/applications/notepad/lang/nl-NL.rc index d6c30f26403..a0ffe227096 100644 --- a/base/applications/notepad/lang/nl-NL.rc +++ b/base/applications/notepad/lang/nl-NL.rc @@ -160,6 +160,7 @@ Wilt u de wijzigingen opslaan?" STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/no-NO.rc b/base/applications/notepad/lang/no-NO.rc index ae83e8a270c..b58fdf6b475 100644 --- a/base/applications/notepad/lang/no-NO.rc +++ b/base/applications/notepad/lang/no-NO.rc @@ -161,6 +161,7 @@ minne." STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/pl-PL.rc b/base/applications/notepad/lang/pl-PL.rc index 70c29377898..708ead6edfb 100644 --- a/base/applications/notepad/lang/pl-PL.rc +++ b/base/applications/notepad/lang/pl-PL.rc @@ -155,6 +155,7 @@ BEGIN STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/pt-BR.rc b/base/applications/notepad/lang/pt-BR.rc index 1ba2f1788b5..08f8714b570 100644 --- a/base/applications/notepad/lang/pt-BR.rc +++ b/base/applications/notepad/lang/pt-BR.rc @@ -160,6 +160,7 @@ tarefa.\nFeche uma ou mais aplicações para aumentar a quantidade de memória l STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/pt-PT.rc b/base/applications/notepad/lang/pt-PT.rc index 5e597417040..857c587bcb2 100644 --- a/base/applications/notepad/lang/pt-PT.rc +++ b/base/applications/notepad/lang/pt-PT.rc @@ -160,6 +160,7 @@ tarefa.\nFeche uma ou mais aplicações para aumentar a quantidade de memória l STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/ro-RO.rc b/base/applications/notepad/lang/ro-RO.rc index a032dc0d67e..cfe4487fe18 100644 --- a/base/applications/notepad/lang/ro-RO.rc +++ b/base/applications/notepad/lang/ro-RO.rc @@ -165,6 +165,7 @@ Păstrați modificările aduse?" STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/ru-RU.rc b/base/applications/notepad/lang/ru-RU.rc index 4ebb9037727..c6c729b5fc9 100644 --- a/base/applications/notepad/lang/ru-RU.rc +++ b/base/applications/notepad/lang/ru-RU.rc @@ -160,6 +160,7 @@ BEGIN STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (Big Endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Macintosh (CR)" diff --git a/base/applications/notepad/lang/sk-SK.rc b/base/applications/notepad/lang/sk-SK.rc index 730ac82e4b9..7a272f3fb41 100644 --- a/base/applications/notepad/lang/sk-SK.rc +++ b/base/applications/notepad/lang/sk-SK.rc @@ -168,6 +168,7 @@ alebo viac aplikácií, aby sa uvoľnila pamäť a skúste to znova." STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (veľký indián)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/sl-SI.rc b/base/applications/notepad/lang/sl-SI.rc index a694e53c068..5dacaf8b8a9 100644 --- a/base/applications/notepad/lang/sl-SI.rc +++ b/base/applications/notepad/lang/sl-SI.rc @@ -160,6 +160,7 @@ operacijo.\nÈe ga želite sprostiti, konèajte enega ali veè programov in posk STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/sq-AL.rc b/base/applications/notepad/lang/sq-AL.rc index 542b5b93936..82c55454577 100644 --- a/base/applications/notepad/lang/sq-AL.rc +++ b/base/applications/notepad/lang/sq-AL.rc @@ -164,6 +164,7 @@ detyrë.\nMbyll nje ose me shume programe te rrisesh shumën e\nmemories." STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/sv-SE.rc b/base/applications/notepad/lang/sv-SE.rc index 6536306b1e7..49160f0fc62 100644 --- a/base/applications/notepad/lang/sv-SE.rc +++ b/base/applications/notepad/lang/sv-SE.rc @@ -160,6 +160,7 @@ den här åtgärden.\nAvsluta ett eller flera program för att frigöra mer minn STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/th-TH.rc b/base/applications/notepad/lang/th-TH.rc index ed6277314a8..ac24b8d2d5e 100644 --- a/base/applications/notepad/lang/th-TH.rc +++ b/base/applications/notepad/lang/th-TH.rc @@ -155,6 +155,7 @@ BEGIN STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 (มี BOM)" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/tr-TR.rc b/base/applications/notepad/lang/tr-TR.rc index 391b0e70d83..5a862b887c0 100644 --- a/base/applications/notepad/lang/tr-TR.rc +++ b/base/applications/notepad/lang/tr-TR.rc @@ -158,6 +158,7 @@ BEGIN STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (Büyük Sonlu)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/uk-UA.rc b/base/applications/notepad/lang/uk-UA.rc index 8c39417b9ec..a46758205ab 100644 --- a/base/applications/notepad/lang/uk-UA.rc +++ b/base/applications/notepad/lang/uk-UA.rc @@ -160,6 +160,7 @@ BEGIN STRING_UNICODE "Юнікод" STRING_UNICODE_BE "Юнікод (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/uz-UZ.rc b/base/applications/notepad/lang/uz-UZ.rc index e6857a5f546..abc5f6088ce 100644 --- a/base/applications/notepad/lang/uz-UZ.rc +++ b/base/applications/notepad/lang/uz-UZ.rc @@ -160,6 +160,7 @@ O‘zgarishlarni saqlashni istaysizmi?" STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Macintosh (CR)" diff --git a/base/applications/notepad/lang/zh-CN.rc b/base/applications/notepad/lang/zh-CN.rc index de8877d9f17..5b02a2fd733 100644 --- a/base/applications/notepad/lang/zh-CN.rc +++ b/base/applications/notepad/lang/zh-CN.rc @@ -168,6 +168,7 @@ BEGIN STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode(大端)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows(CR + LF)" STRING_LF "Unix(LF)" STRING_CR "Mac(CR)" diff --git a/base/applications/notepad/lang/zh-HK.rc b/base/applications/notepad/lang/zh-HK.rc index 6a47644ff58..c5e455fa877 100644 --- a/base/applications/notepad/lang/zh-HK.rc +++ b/base/applications/notepad/lang/zh-HK.rc @@ -168,6 +168,7 @@ BEGIN STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode(大端序)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/lang/zh-TW.rc b/base/applications/notepad/lang/zh-TW.rc index db550b17012..2cae1d75fd9 100644 --- a/base/applications/notepad/lang/zh-TW.rc +++ b/base/applications/notepad/lang/zh-TW.rc @@ -168,6 +168,7 @@ BEGIN STRING_UNICODE "Unicode" STRING_UNICODE_BE "Unicode (big endian)" STRING_UTF8 "UTF-8" + STRING_UTF8_BOM "UTF-8 with BOM" STRING_CRLF "Windows (CR + LF)" STRING_LF "Unix (LF)" STRING_CR "Mac (CR)" diff --git a/base/applications/notepad/main.c b/base/applications/notepad/main.c index 3fed529fb3e..42bf2493911 100644 --- a/base/applications/notepad/main.c +++ b/base/applications/notepad/main.c @@ -427,8 +427,13 @@ NOTEPAD_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) LOWORD(wParam), SWP_NOZORDER); - if (hdwp != NULL) - EndDeferWindowPos(hdwp); + if (hdwp == NULL) + break; + + EndDeferWindowPos(hdwp); + + /* Align status bar parts, only if the status bar resize operation succeeds */ + DIALOG_StatusBarAlignParts(); } else SetWindowPos(Globals.hEdit, diff --git a/base/applications/notepad/main.h b/base/applications/notepad/main.h index 349be218118..ce7fc850877 100644 --- a/base/applications/notepad/main.h +++ b/base/applications/notepad/main.h @@ -40,7 +40,8 @@ typedef enum ENCODING_ANSI = 0, ENCODING_UTF16LE = 1, ENCODING_UTF16BE = 2, - ENCODING_UTF8 = 3 + ENCODING_UTF8 = 3, + ENCODING_UTF8BOM = 4 } ENCODING; // #define MIN_ENCODING 0 diff --git a/base/applications/notepad/notepad_res.h b/base/applications/notepad/notepad_res.h index b53ff22cb57..7b463383dc8 100644 --- a/base/applications/notepad/notepad_res.h +++ b/base/applications/notepad/notepad_res.h @@ -88,17 +88,18 @@ #define STRING_OUT_OF_MEMORY 0x17C #define STRING_CANNOTFIND 0x17D -#define STRING_ANSI 0x17E -#define STRING_UNICODE 0x17F -#define STRING_UNICODE_BE 0x180 -#define STRING_UTF8 0x181 - -#define STRING_CRLF 0x182 -#define STRING_LF 0x183 -#define STRING_CR 0x184 - -#define STRING_LINE_COLUMN 0x186 -#define STRING_PRINTERROR 0x187 +#define STRING_ANSI 0x180 +#define STRING_UNICODE 0x181 +#define STRING_UNICODE_BE 0x182 +#define STRING_UTF8 0x183 +#define STRING_UTF8_BOM 0x184 + +#define STRING_CRLF 0x185 +#define STRING_LF 0x186 +#define STRING_CR 0x187 + +#define STRING_LINE_COLUMN 0x188 +#define STRING_PRINTERROR 0x189 #define STRING_TEXT_DOCUMENT 0x200 diff --git a/base/applications/notepad/text.c b/base/applications/notepad/text.c index 0afdde89b6c..6a83a89d64f 100644 --- a/base/applications/notepad/text.c +++ b/base/applications/notepad/text.c @@ -140,7 +140,7 @@ ReadText(HANDLE hFile, LPWSTR *ppszText, DWORD *pdwTextLen, ENCODING *pencFile, } else if ((dwSize >= 3) && (pBytes[0] == 0xEF) && (pBytes[1] == 0xBB) && (pBytes[2] == 0xBF)) { - encFile = ENCODING_UTF8; + encFile = ENCODING_UTF8BOM; dwPos += 3; } else @@ -166,10 +166,11 @@ ReadText(HANDLE hFile, LPWSTR *ppszText, DWORD *pdwTextLen, ENCODING *pencFile, case ENCODING_ANSI: case ENCODING_UTF8: - if (encFile == ENCODING_ANSI) - iCodePage = CP_ACP; - else if (encFile == ENCODING_UTF8) + case ENCODING_UTF8BOM: + if (encFile == ENCODING_UTF8 || encFile == ENCODING_UTF8BOM) iCodePage = CP_UTF8; + else + iCodePage = CP_ACP; if ((dwSize - dwPos) > 0) { @@ -312,10 +313,11 @@ static BOOL WriteEncodedText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENC case ENCODING_ANSI: case ENCODING_UTF8: - if (encFile == ENCODING_ANSI) - iCodePage = CP_ACP; - else if (encFile == ENCODING_UTF8) + case ENCODING_UTF8BOM: + if (encFile == ENCODING_UTF8 || encFile == ENCODING_UTF8BOM) iCodePage = CP_UTF8; + else + iCodePage = CP_ACP; iRequiredBytes = WideCharToMultiByte(iCodePage, 0, &pszText[dwPos], dwTextLen - dwPos, NULL, 0, NULL, NULL); if (iRequiredBytes <= 0) @@ -371,8 +373,8 @@ BOOL WriteText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENCODING encFile, LPCWSTR pszLF = L"\n"; DWORD dwPos, dwNext; - /* Write the proper byte order marks if not ANSI */ - if (encFile != ENCODING_ANSI) + /* Write the proper byte order marks if not ANSI or UTF-8 without BOM */ + if (encFile != ENCODING_ANSI && encFile != ENCODING_UTF8) { wcBom = 0xFEFF; if (!WriteEncodedText(hFile, &wcBom, 1, encFile))