From 2354703593c3985a6f983a7f7c251700749eb722 Mon Sep 17 00:00:00 2001 From: "METANEOCORTEX\\Kotti" Date: Thu, 23 Feb 2023 01:56:33 +0100 Subject: [PATCH] +fix: minor changes for Unicode Point display --- Build/Notepad3.ini | 2 +- Readme.md | 4 ++-- src/Notepad3.c | 11 ++++++----- src/TypeDefs.h | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Build/Notepad3.ini b/Build/Notepad3.ini index 9cbbe19f4..1977240ca 100644 --- a/Build/Notepad3.ini +++ b/Build/Notepad3.ini @@ -69,7 +69,7 @@ SettingsVersion=5 ;HyperlinkShellExURLCmdLnArgs="${URL}" (use ${URL} as place holder for clicked Hyperlink URL string) ;HyperlinkFileProtocolVerb="" (ShellExecuteEx()::lpVerb (""=default, "edit", "explore", "find", "open", "print", "properties", "runas") [Statusbar Settings] -;VisibleSections=0 1 12 14 2 4 5 6 7 8 9 10 11 +;VisibleSections=0 1 12 15 14 2 4 5 6 7 8 9 10 11 ;SectionPrefixes=Ln ,Col ,Sel ,Sb ,SLn ,Occ ,,,,,,,Ch ,Repl ,Eval ,U+, ;SectionPostfixes=,,,,,,,,,,,,,,,, ;SectionWidthSpecs=30 20 20 20 20 20 0 0 0 0 0 0 20 20 20 diff --git a/Readme.md b/Readme.md index 92e12d15f..c643e8c3d 100644 --- a/Readme.md +++ b/Readme.md @@ -490,7 +490,7 @@ If used, this setting also defines the field ordering. - Section 12 = Character Count (per line) - Section 13 = Replaced Occurrences - Section 14 = TinyExpr Evaluation -- Section 15 = Unicode point display of current (caret pos) character. +- Section 15 = Unicode point display (UTF-16 encoding) of current (caret pos) character. #### `SectionPrefixes=Ln ,Col ,Sel ,Sb ,SLn ,Occ ,,,,,,,Ch ,Repl ,Eval ,U+,` (internal default) @@ -502,7 +502,7 @@ This parameter is used to redefines the displayed Prefixes in the sections of th This parameter is used to redefines the displayed Postfixes in the sections of the Status Bar - A “,” (comma) is used as separator. Spaces are **NOT** ignored. -#### `SectionWidthSpecs=30 20 20 20 20 20 0 0 0 0 0 0 20 20 20` (internal default) +#### `SectionWidthSpecs=30 20 20 20 20 20 20 0 0 0 0 0 0 20 20 20` (internal default) This parameter is used to define the relative width of each field of the Status Bar - 0 = space optimized fit to text (dynamically adapted to width changes) diff --git a/src/Notepad3.c b/src/Notepad3.c index 03862424f..7f82d592e 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -10062,18 +10062,19 @@ static void _UpdateStatusbarDelayed(bool bForceRedraw) if (g_iStatusbarVisible[STATUS_UNICODEPT]) { - static WCHAR tchChr[32] = { L'\0' }; - static unsigned s_wChr = L'\0'; - int const len = sizeof(int) / sizeof(WCHAR); + static WCHAR tchChr[32] = { L'\0' }; + static UINT64 s_wChr = L'\0'; + static int const len = sizeof(UINT64) / sizeof(WCHAR); DocPos const iPosAfter = SciCall_PositionAfter(iPos); + int const chrLen = (int)(iPosAfter - iPos); char chChrs[8] = { '\0' }; struct Sci_TextRangeFull tr = { { iPos, iPosAfter }, chChrs }; SciCall_GetTextRangeFull(&tr); - unsigned wChr = L'\0'; - MultiByteToWideChar(Encoding_SciCP, 0, chChrs, (int)strlen(chChrs), (LPWSTR)&wChr, len); + UINT64 wChr = L'\0'; + MultiByteToWideChar(Encoding_SciCP, 0, chChrs, chrLen, (LPWSTR)&wChr, len); if (bForceRedraw || (s_wChr != wChr)) { if (wChr <= 0xFFFF) diff --git a/src/TypeDefs.h b/src/TypeDefs.h index 371c17b36..120150773 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -237,7 +237,7 @@ typedef enum STATUS_SECTOR_T { #define SBS_INIT_ZERO { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } #define SBS_INIT_MINUS { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 } -#define STATUSBAR_DEFAULT_IDS L"0 1 12 16 14 2 4 5 6 7 8 9 10 11" +#define STATUSBAR_DEFAULT_IDS L"0 1 12 15 14 2 4 5 6 7 8 9 10 11" #define STATUSBAR_SECTION_WIDTH_SPECS L"30 20 20 20 20 20 20 0 0 0 0 0 0 20 20 20" #define STAUSBAR_RIGHT_MARGIN 20