From 2d276a7fd9a18609e0eedd36be03e8c91502da0a Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Mon, 6 Aug 2018 04:26:10 +0200 Subject: [PATCH 1/5] + add: make StatusBar section post-fix strings configurable + fix: bug in parsing CSV config string --- Build/Notepad3.ini | Bin 5620 -> 5744 bytes src/Helpers.c | 22 ++++++----- src/Notepad3.c | 92 ++++++++++++++++++++++++++++++--------------- src/Notepad3.rc | 9 ----- src/Styles.c | 8 ++-- src/TypeDefs.h | 15 ++++---- src/resource.h | 10 ----- 7 files changed, 85 insertions(+), 71 deletions(-) diff --git a/Build/Notepad3.ini b/Build/Notepad3.ini index 05f06bd814d937cb444b808318bde00f0ed54ae3..ab62cbc9d3f68c8fd4a92efe9865cc29722ea030 100644 GIT binary patch delta 108 zcmeyO{Xu7g4Hs_^Ln=c7Lk@!i5b8{x$R%nYz>v>S%uvFR#*oQS0hBFfuw~EzLj{It lhERqO1~&#>1`CE*?4pzPxsq8G7z`PVfTpExe#gbe4FJMv6(|4z delta 20 ccmeyM^F@1u4cFvVTw#;hxKlP4asT5209(=s4*&oF diff --git a/src/Helpers.c b/src/Helpers.c index f6350ed43..f3a8acb23 100644 --- a/src/Helpers.c +++ b/src/Helpers.c @@ -3019,22 +3019,24 @@ int ReadStrgsFromCSV(LPCWSTR wchCSVStrg, prefix_t sMatrix[], int const iCount, i StringCchCopyW(wchTmpBuff, COUNTOF(wchTmpBuff), wchCSVStrg); TrimString(wchTmpBuff); - // separate values - int const len = (int)StringCchLenW(wchTmpBuff, COUNTOF(wchTmpBuff)); - for (int i = 0; i < len; ++i) { - if (wchTmpBuff[i] == L',') { wchTmpBuff[i] = L'\0'; } - } - wchTmpBuff[len + 1] = L'\0'; // double zero at the end // fill default - for (int i = 0; i < iCount; ++i) { StringCchCopyW(sMatrix[i], (size_t)iLen, sDefault); } + for (int i = 0; i < iCount; ++i) { + if (sDefault && *sDefault) + StringCchCopyW(sMatrix[i], (size_t)iLen, sDefault); + else + sMatrix[i][0] = L'\0'; + } // insert values int n = 0; WCHAR* p = wchTmpBuff; - while (*p) { + while (p && *p) { + WCHAR* q = StrStrW(p, L","); + if (q > p) { *q = L'\0'; } if (n < iCount) { - StringCchCopyW(sMatrix[n++], (size_t)iLen, p); + if (*p != L',') { StringCchCopyW(sMatrix[n], (size_t)iLen, p); } } - p = StrEnd(p) + 1; + p = (q > p) ? (q + 1) : (p + 1); + ++n; } return n; } diff --git a/src/Notepad3.c b/src/Notepad3.c index e79263eda..2b4f76eb4 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -151,15 +151,13 @@ static WCHAR g_tchDefaultDir[MAX_PATH] = { L'\0' }; static WCHAR g_tchToolbarButtons[MIDSZ_BUFFER] = { L'\0' }; -static WCHAR g_tchStatusbarPrefixes[MIDSZ_BUFFER] = { L'\0' }; -static prefix_t g_mxStatusBarPrefix[STATUS_SECTOR_COUNT]; +static prefix_t g_mxSBPrefix[STATUS_SECTOR_COUNT]; +static prefix_t g_mxSBPostfix[STATUS_SECTOR_COUNT]; -static WCHAR g_tchStatusbarSections[SMALL_BUFFER] = { L'\0' }; static int g_iStatusbarSections[STATUS_SECTOR_COUNT] = SBS_INIT_MINUS; static bool g_iStatusbarVisible[STATUS_SECTOR_COUNT] = SBS_INIT_ZERO; static int g_vSBSOrder[STATUS_SECTOR_COUNT] = SBS_INIT_MINUS; -static WCHAR g_tchStatusbarWidthSpec[SMALL_BUFFER] = { L'\0' }; static int g_iStatusbarWidthSpec[STATUS_SECTOR_COUNT] = SBS_INIT_ZERO; @@ -6707,11 +6705,16 @@ void LoadSettings() LoadIniSection(L"Statusbar Settings", pIniSection, cchIniSection); // -------------------------------------------------------------------------- - IniSectionGetString(pIniSection, L"SectionPrefixes", STATUSBAR_EXTION_PREFIXES, g_tchStatusbarPrefixes, COUNTOF(g_tchStatusbarPrefixes)); - ReadStrgsFromCSV(g_tchStatusbarPrefixes, g_mxStatusBarPrefix, STATUS_SECTOR_COUNT, MICRO_BUFFER, L""); + WCHAR tchStatusBar[MIDSZ_BUFFER] = { L'\0' }; - IniSectionGetString(pIniSection, L"VisibleSections", STATUSBAR_DEFAULT_IDS, g_tchStatusbarSections, COUNTOF(g_tchStatusbarSections)); - ReadVectorFromString(g_tchStatusbarSections, g_iStatusbarSections, STATUS_SECTOR_COUNT, 0, (STATUS_SECTOR_COUNT - 1), -1); + IniSectionGetString(pIniSection, L"SectionPrefixes", STATUSBAR_SECTION_PREFIXES, tchStatusBar, COUNTOF(tchStatusBar)); + ReadStrgsFromCSV(tchStatusBar, g_mxSBPrefix, STATUS_SECTOR_COUNT, MICRO_BUFFER, L""); + + IniSectionGetString(pIniSection, L"SectionPostfixes", STATUSBAR_SECTION_POSTFIXES, tchStatusBar, COUNTOF(tchStatusBar)); + ReadStrgsFromCSV(tchStatusBar, g_mxSBPostfix, STATUS_SECTOR_COUNT, MICRO_BUFFER, L""); + + IniSectionGetString(pIniSection, L"VisibleSections", STATUSBAR_DEFAULT_IDS, tchStatusBar, COUNTOF(tchStatusBar)); + ReadVectorFromString(tchStatusBar, g_iStatusbarSections, STATUS_SECTOR_COUNT, 0, (STATUS_SECTOR_COUNT - 1), -1); for (int i = 0; i < STATUS_SECTOR_COUNT; ++i) { g_iStatusbarVisible[i] = false; @@ -6726,8 +6729,8 @@ void LoadSettings() } } - IniSectionGetString(pIniSection, L"SectionWidthSpecs", STATUSBAR_SECTION_WIDTH_SPECS, g_tchStatusbarWidthSpec, COUNTOF(g_tchStatusbarWidthSpec)); - ReadVectorFromString(g_tchStatusbarWidthSpec, g_iStatusbarWidthSpec, STATUS_SECTOR_COUNT, -4096, 4096, 0); + IniSectionGetString(pIniSection, L"SectionWidthSpecs", STATUSBAR_SECTION_WIDTH_SPECS, tchStatusBar, COUNTOF(tchStatusBar)); + ReadVectorFromString(tchStatusBar, g_iStatusbarWidthSpec, STATUS_SECTOR_COUNT, -4096, 4096, 0); // -------------------------------------------------------------------------- @@ -7977,7 +7980,8 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) if ((s_iLnFromPos != iLnFromPos) || (s_iLnCnt != iLnCnt)) { - FormatLngStringW(tchStatusBar[STATUS_DOCLINE], txtWidth, IDS_STATUS_DOCLINE, g_mxStatusBarPrefix[STATUS_DOCLINE], tchLn, tchLines); + StringCchPrintf(tchStatusBar[STATUS_DOCLINE], txtWidth, L"%s%s / %s%s", + g_mxSBPrefix[STATUS_DOCLINE], tchLn, tchLines, g_mxSBPostfix[STATUS_DOCLINE]); s_iLnFromPos = iLnFromPos; s_iLnCnt = iLnCnt; bIsUpdateNeeded = true; @@ -8001,11 +8005,13 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) if (bMarkLongLines) { StringCchPrintf(tchCols, COUNTOF(tchCols), L"%td", g_iLongLinesLimit); FormatNumberStr(tchCols); - FormatLngStringW(tchStatusBar[STATUS_DOCCOLUMN], txtWidth, IDS_STATUS_DOCCOLUMN2, g_mxStatusBarPrefix[STATUS_DOCCOLUMN], tchCol, tchCols); + StringCchPrintf(tchStatusBar[STATUS_DOCCOLUMN], txtWidth, L"%s%s / %s%s", + g_mxSBPrefix[STATUS_DOCCOLUMN], tchCol, tchCols, g_mxSBPostfix[STATUS_DOCCOLUMN]); } else { tchCols[0] = L'\0'; - FormatLngStringW(tchStatusBar[STATUS_DOCCOLUMN], txtWidth, IDS_STATUS_DOCCOLUMN, g_mxStatusBarPrefix[STATUS_DOCCOLUMN], tchCol); + StringCchPrintf(tchStatusBar[STATUS_DOCCOLUMN], txtWidth, L"%s%s%s", + g_mxSBPrefix[STATUS_DOCCOLUMN], tchCol, g_mxSBPostfix[STATUS_DOCCOLUMN]); } s_iCol = iCol; s_bmarkLongLines = bMarkLongLines; @@ -8041,9 +8047,10 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) tchSel[0] = L'-'; tchSel[1] = L'-'; tchSel[2] = L'\0'; tchSelB[0] = L'0'; tchSelB[1] = L'\0'; } - - FormatLngStringW(tchStatusBar[STATUS_SELECTION], txtWidth, IDS_STATUS_SELECTION, g_mxStatusBarPrefix[STATUS_SELECTION], tchSel); - FormatLngStringW(tchStatusBar[STATUS_SELCTBYTES], txtWidth, IDS_STATUS_SELCTBYTES, g_mxStatusBarPrefix[STATUS_SELCTBYTES], tchSelB); + StringCchPrintf(tchStatusBar[STATUS_SELECTION], txtWidth, L"%s%s%s", + g_mxSBPrefix[STATUS_SELECTION], tchSel, g_mxSBPostfix[STATUS_SELECTION]); + StringCchPrintf(tchStatusBar[STATUS_SELCTBYTES], txtWidth, L"%s%s%s", + g_mxSBPrefix[STATUS_SELCTBYTES], tchSelB, g_mxSBPostfix[STATUS_SELCTBYTES]); s_bIsSelCountable = bIsSelCountable; s_iSelStart = iSelStart; @@ -8077,8 +8084,8 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) StringCchPrintf(tchLinesSelected, COUNTOF(tchLinesSelected), L"%i", iLinesSelected); FormatNumberStr(tchLinesSelected); } - - FormatLngStringW(tchStatusBar[STATUS_SELCTLINES], txtWidth, IDS_STATUS_SELCTLINES, g_mxStatusBarPrefix[STATUS_SELCTLINES], tchLinesSelected); + StringCchPrintf(tchStatusBar[STATUS_SELCTLINES], txtWidth, L"%s%s%s", + g_mxSBPrefix[STATUS_SELCTLINES], tchLinesSelected, g_mxSBPostfix[STATUS_SELCTLINES]); s_bIsSelectionEmpty = bIsSelectionEmpty; s_iLinesSelected = iLinesSelected; @@ -8112,7 +8119,8 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) StringCchCopy(tchOcc, COUNTOF(tchOcc), L"--"); } - FormatLngStringW(tchStatusBar[STATUS_OCCURRENCE], txtWidth, IDS_STATUS_OCCURRENCE, g_mxStatusBarPrefix[STATUS_OCCURRENCE], tchOcc); + StringCchPrintf(tchStatusBar[STATUS_OCCURRENCE], txtWidth, L"%s%s%s", + g_mxSBPrefix[STATUS_OCCURRENCE], tchOcc, g_mxSBPostfix[STATUS_OCCURRENCE]); s_bMOVisible = g_bMarkOccurrencesMatchVisible; s_iMarkOccurrencesCount = g_iMarkOccurrencesCount; @@ -8127,7 +8135,10 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) DocPos const iTextLength = SciCall_GetTextLength(); if (s_iTextLength != iTextLength) { StrFormatByteSize(iTextLength, tchBytes, COUNTOF(tchBytes)); - FormatLngStringW(tchStatusBar[STATUS_DOCSIZE], txtWidth, IDS_STATUS_DOCSIZE, g_mxStatusBarPrefix[STATUS_DOCSIZE], tchBytes); + + StringCchPrintf(tchStatusBar[STATUS_DOCSIZE], txtWidth, L"%s%s%s", + g_mxSBPrefix[STATUS_DOCSIZE], tchBytes, g_mxSBPostfix[STATUS_DOCSIZE]); + s_iTextLength = iTextLength; bIsUpdateNeeded = true; } @@ -8136,7 +8147,10 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) int const iEncoding = Encoding_Current(CPI_GET); if (s_iEncoding != iEncoding) { Encoding_SetLabel(iEncoding); - StringCchPrintf(tchStatusBar[STATUS_CODEPAGE], txtWidth, L"%s%s", g_mxStatusBarPrefix[STATUS_CODEPAGE], Encoding_GetLabel(iEncoding)); + + StringCchPrintf(tchStatusBar[STATUS_CODEPAGE], txtWidth, L"%s%s%s", + g_mxSBPrefix[STATUS_CODEPAGE], Encoding_GetLabel(iEncoding), g_mxSBPostfix[STATUS_CODEPAGE]); + s_iEncoding = iEncoding; bIsUpdateNeeded = true; } @@ -8147,14 +8161,17 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) if (s_iEOLMode != g_iEOLMode) { if (g_iEOLMode == SC_EOL_CR) { - StringCchPrintf(tchStatusBar[STATUS_EOLMODE], txtWidth, L"%sCR", g_mxStatusBarPrefix[STATUS_EOLMODE]); + StringCchPrintf(tchStatusBar[STATUS_EOLMODE], txtWidth, L"%sCR%s", + g_mxSBPrefix[STATUS_EOLMODE], g_mxSBPostfix[STATUS_EOLMODE]); } else if (g_iEOLMode == SC_EOL_LF) { - StringCchPrintf(tchStatusBar[STATUS_EOLMODE], txtWidth, L"%sLF", g_mxStatusBarPrefix[STATUS_EOLMODE]); + StringCchPrintf(tchStatusBar[STATUS_EOLMODE], txtWidth, L"%sLF%s", + g_mxSBPrefix[STATUS_EOLMODE], g_mxSBPostfix[STATUS_EOLMODE]); } else { - StringCchPrintf(tchStatusBar[STATUS_EOLMODE], txtWidth, L"%sCR+LF", g_mxStatusBarPrefix[STATUS_EOLMODE]); + StringCchPrintf(tchStatusBar[STATUS_EOLMODE], txtWidth, L"%sCR+LF%s", + g_mxSBPrefix[STATUS_EOLMODE], g_mxSBPostfix[STATUS_EOLMODE]); } s_iEOLMode = g_iEOLMode; bIsUpdateNeeded = true; @@ -8166,10 +8183,12 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) if (s_bIsOVR != bIsOVR) { if (bIsOVR) { - StringCchPrintf(tchStatusBar[STATUS_OVRMODE], txtWidth, L"%sOVR", g_mxStatusBarPrefix[STATUS_OVRMODE]); + StringCchPrintf(tchStatusBar[STATUS_OVRMODE], txtWidth, L"%sOVR%s", + g_mxSBPrefix[STATUS_OVRMODE], g_mxSBPostfix[STATUS_OVRMODE]); } else { - StringCchPrintf(tchStatusBar[STATUS_OVRMODE], txtWidth, L"%sINS", g_mxStatusBarPrefix[STATUS_OVRMODE]); + StringCchPrintf(tchStatusBar[STATUS_OVRMODE], txtWidth, L"%sINS%s", + g_mxSBPrefix[STATUS_OVRMODE], g_mxSBPostfix[STATUS_OVRMODE]); } s_bIsOVR = bIsOVR; bIsUpdateNeeded = true; @@ -8181,9 +8200,11 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) if (s_bUse2ndDefault != bUse2ndDefault) { if (bUse2ndDefault) - StringCchPrintf(tchStatusBar[STATUS_2ND_DEF], txtWidth, L"%s2ND", g_mxStatusBarPrefix[STATUS_2ND_DEF]); + StringCchPrintf(tchStatusBar[STATUS_2ND_DEF], txtWidth, L"%s2ND%s", + g_mxSBPrefix[STATUS_2ND_DEF], g_mxSBPostfix[STATUS_2ND_DEF]); else - StringCchPrintf(tchStatusBar[STATUS_2ND_DEF], txtWidth, L"%sSTD", g_mxStatusBarPrefix[STATUS_2ND_DEF]); + StringCchPrintf(tchStatusBar[STATUS_2ND_DEF], txtWidth, L"%sSTD%s", + g_mxSBPrefix[STATUS_2ND_DEF], g_mxSBPostfix[STATUS_2ND_DEF]); s_bUse2ndDefault = bUse2ndDefault; bIsUpdateNeeded = true; @@ -8201,7 +8222,9 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) else Style_GetLexerDisplayName(Style_GetCurrentLexerPtr(), tchLexerName, MINI_BUFFER); - StringCchPrintf(tchStatusBar[STATUS_LEXER], txtWidth, L"%s%s", g_mxStatusBarPrefix[STATUS_LEXER], tchLexerName); + StringCchPrintf(tchStatusBar[STATUS_LEXER], txtWidth, L"%s%s%s", + g_mxSBPrefix[STATUS_LEXER], tchLexerName, g_mxSBPostfix[STATUS_LEXER]); + s_iCurLexer = iCurLexer; bIsUpdateNeeded = true; } @@ -8250,8 +8273,15 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) else StringCchCopy(tchReplOccs, COUNTOF(tchReplOccs), L"--"); - FormatLngStringW(tchFRStatus, COUNTOF(tchFRStatus), IDS_FR_STATUS_FMT, - tchLn, tchLines, tchCol, tchSel, tchOcc, tchReplOccs, FR_Status[g_FindReplaceMatchFoundState]); + const WCHAR* SBFMT = L" %s%s / %s %s%s %s%s %s%s %s%s ( %s ) "; + + StringCchPrintf(tchFRStatus, COUNTOF(tchFRStatus), SBFMT, + g_mxSBPrefix[STATUS_DOCLINE], tchLn, tchLines, + g_mxSBPrefix[STATUS_DOCCOLUMN], tchCol, + g_mxSBPrefix[STATUS_SELECTION], tchSel, + g_mxSBPrefix[STATUS_OCCURRENCE], tchOcc, + g_mxSBPrefix[STATUS_OCCREPLACE], tchReplOccs, + FR_Status[g_FindReplaceMatchFoundState]); SetWindowText(GetDlgItem(g_hwndDlgFindReplace, IDS_FR_STATUS_TEXT), tchFRStatus); } diff --git a/src/Notepad3.rc b/src/Notepad3.rc index 10fe59124..0dcfed460 100644 --- a/src/Notepad3.rc +++ b/src/Notepad3.rc @@ -312,15 +312,6 @@ END STRINGTABLE BEGIN IDS_WARN_PREF_LNG_NOT_AVAIL "Sorry, your prefered language (%s) is not available." - IDS_STATUS_DOCLINE "%s%s / %s" - IDS_STATUS_DOCCOLUMN "%s%s" - IDS_STATUS_DOCCOLUMN2 "%s%s / %s" - IDS_STATUS_SELECTION "%s%s" - IDS_STATUS_SELCTLINES "%s%s" - IDS_STATUS_SELCTBYTES "%s%s" - IDS_STATUS_OCCURRENCE "%s%s" - IDS_STATUS_DOCSIZE "%s%s [UTF-8]" - IDS_FR_STATUS_FMT " Ln %s / %s Col %s Sel %s Occ %s Repl %s ( %s ) " END diff --git a/src/Styles.c b/src/Styles.c index c774a7550..5d0771187 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -2718,7 +2718,7 @@ KEYWORDLIST KeyWords_D = { // Keywords 7 "", // --- - "" + "", "" }; @@ -2762,7 +2762,7 @@ KEYWORDLIST KeyWords_Go = { // Keywords 7 "", // --- - "" + "", "" }; @@ -2804,7 +2804,7 @@ KEYWORDLIST KeyWords_Awk = { "ARGC ARGIND ARGV FILENAME FNR FS NF NR OFMT OFS ORS RLENGTH RS RSTART SUBSEP TEXTDOMAIN " "BINMODE CONVFMT FIELDWIDTHS FPAT IGNORECASE LINT TEXTDOMAiN ENVIRON ERRNO PROCINFO RT", - "" + "", "", "", "", "", "" ,"" }; @@ -2961,7 +2961,7 @@ KEYWORDLIST KeyWords_Rust = { // Keywords 7 "", // 0 - "" }; + "", "" }; EDITLEXER lexRust = { SCLEX_RUST, IDS_LEX_RUST_SRC, L"Rust Source Code", L"rs; rust", L"", &KeyWords_Rust,{ diff --git a/src/TypeDefs.h b/src/TypeDefs.h index 1180b4a86..fd8f4d463 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -87,18 +87,19 @@ typedef WCHAR prefix_t[MICRO_BUFFER]; typedef enum { STATUS_DOCLINE = 0, STATUS_DOCCOLUMN, STATUS_SELECTION, STATUS_SELCTBYTES, STATUS_SELCTLINES, STATUS_OCCURRENCE, - STATUS_DOCSIZE, STATUS_CODEPAGE, STATUS_EOLMODE, STATUS_OVRMODE, STATUS_2ND_DEF, STATUS_LEXER, + STATUS_DOCSIZE, STATUS_CODEPAGE, STATUS_EOLMODE, STATUS_OVRMODE, STATUS_2ND_DEF, STATUS_LEXER, STATUS_OCCREPLACE, STATUS_SECTOR_COUNT, STATUS_HELP = 255 } STATUS_SECTOR_T; -#define SBS_INIT_ZERO { 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 } -#define SBS_INIT_ORDER { 0, 1, 2, 3, 4, 5, 6, 7. 8. 9, 10, 11 } +#define SBS_INIT_ZERO { 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 } +#define SBS_INIT_ORDER { 0, 1, 2, 3, 4, 5, 6, 7. 8. 9, 10, 11, 12 } -#define STATUSBAR_EXTION_PREFIXES L"Ln ,Col ,Sel ,Sb ,SLn ,Occ ,,,,,,," -#define STATUSBAR_DEFAULT_IDS L"0 1 2 4 5 6 7 8 9 10 11" -#define STATUSBAR_SECTION_WIDTH_SPECS L"30 20 20 20 20 20 0 0 0 0 0 0" +#define STATUSBAR_SECTION_PREFIXES L"Ln ,Col ,Sel ,Sb ,SLn ,Occ ,,,,,,,Repl ," +#define STATUSBAR_SECTION_POSTFIXES L",,, [UTF-8],,, [UTF-8],,,,,,," +#define STATUSBAR_DEFAULT_IDS L"0 1 2 4 5 6 7 8 9 10 11 12" +#define STATUSBAR_SECTION_WIDTH_SPECS L"30 20 20 20 20 20 0 0 0 0 0 0 0" #define STAUSBAR_RIGHT_MARGIN 20 // -------------------------------------------------------------------------- diff --git a/src/resource.h b/src/resource.h index 111943c13..174ac05ed 100644 --- a/src/resource.h +++ b/src/resource.h @@ -52,16 +52,6 @@ #define IDS_WARN_PREF_LNG_NOT_AVAIL 4000 -#define IDS_FR_STATUS_FMT 5000 -#define IDS_STATUS_DOCLINE 5001 -#define IDS_STATUS_DOCCOLUMN 5002 -#define IDS_STATUS_DOCCOLUMN2 5003 -#define IDS_STATUS_SELECTION 5004 -#define IDS_STATUS_SELCTLINES 5015 -#define IDS_STATUS_SELCTBYTES 5016 -#define IDS_STATUS_OCCURRENCE 5017 -#define IDS_STATUS_DOCSIZE 5018 - #include "../language/common_res.h" From 8b3b9f3efd79759b330345968a9f130189c02035 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Mon, 6 Aug 2018 19:27:46 +0200 Subject: [PATCH 2/5] + fix: bug in re-coding "ASCII as UTF-8" + add: Explicit call to force Google's "Compact Encoding Detection" (CED) --- language/common_res.h | 71 ++++++++++++++++--------------- language/np3_af_za/menu_af_za.rc | Bin 41516 -> 41746 bytes language/np3_de_de/menu_de_de.rc | Bin 43166 -> 43396 bytes language/np3_en_gb/menu_en_gb.rc | Bin 41522 -> 41676 bytes language/np3_en_us/menu_en_us.rc | Bin 41496 -> 41726 bytes language/np3_es_es/menu_es_es.rc | Bin 41588 -> 41818 bytes language/np3_fr_fr/menu_fr_fr.rc | Bin 44064 -> 44294 bytes language/np3_nl_nl/menu_nl_nl.rc | Bin 43060 -> 43290 bytes language/np3_zh_cn/menu_zh_cn.rc | Bin 39578 -> 39808 bytes src/Edit.c | 25 +++++++---- src/Encoding.c | 5 +-- src/Encoding.h | 1 + src/Notepad3.c | 52 +++++++++++++--------- src/SciCall.h | 5 ++- src/Styles.c | 4 +- 15 files changed, 91 insertions(+), 72 deletions(-) diff --git a/language/common_res.h b/language/common_res.h index 6cc9e116e..2a3a79994 100644 --- a/language/common_res.h +++ b/language/common_res.h @@ -281,41 +281,42 @@ #define CMD_RECODEANSI 20011 #define CMD_RECODEOEM 20012 #define CMD_RELOADASCIIASUTF8 20013 -#define CMD_RELOADNOFILEVARS 20014 -#define CMD_LEXDEFAULT 20015 -#define CMD_LEXHTML 20016 -#define CMD_LEXXML 20017 -#define CMD_TIMESTAMPS 20018 -#define CMD_WEBACTION1 20019 -#define CMD_WEBACTION2 20020 -#define CMD_FINDNEXTSEL 20021 -#define CMD_FINDPREVSEL 20022 -#define CMD_INCLINELIMIT 20023 -#define CMD_DECLINELIMIT 20024 -#define CMD_STRINGIFY 20025 -#define CMD_STRINGIFY2 20026 -#define CMD_EMBRACE 20027 -#define CMD_EMBRACE2 20028 -#define CMD_EMBRACE3 20029 -#define CMD_EMBRACE4 20030 -#define CMD_INCREASENUM 20031 -#define CMD_DECREASENUM 20032 -#define CMD_TOGGLETITLE 20033 -#define CMD_JUMP2SELSTART 20034 -#define CMD_JUMP2SELEND 20035 -#define CMD_COPYPATHNAME 20036 -#define CMD_COPYWINPOS 20037 -#define CMD_DEFAULTWINPOS 20038 -#define CMD_OPENINIFILE 20039 -#define CMD_CTRLENTER 20040 -#define CMD_OPEN_HYPERLINK 20041 -#define CMD_ALTUP 20042 -#define CMD_ALTDOWN 20043 -#define CMD_ALTLEFT 20044 -#define CMD_ALTRIGHT 20045 -#define CMD_TAB 20046 -#define CMD_BACKTAB 20047 -#define CMD_VK_INSERT 20048 +#define CMD_RELOADFORCEDETECTION 20014 +#define CMD_RELOADNOFILEVARS 20015 +#define CMD_LEXDEFAULT 20016 +#define CMD_LEXHTML 20017 +#define CMD_LEXXML 20018 +#define CMD_TIMESTAMPS 20019 +#define CMD_WEBACTION1 20020 +#define CMD_WEBACTION2 20021 +#define CMD_FINDNEXTSEL 20022 +#define CMD_FINDPREVSEL 20023 +#define CMD_INCLINELIMIT 20024 +#define CMD_DECLINELIMIT 20025 +#define CMD_STRINGIFY 20026 +#define CMD_STRINGIFY2 20027 +#define CMD_EMBRACE 20028 +#define CMD_EMBRACE2 20029 +#define CMD_EMBRACE3 20030 +#define CMD_EMBRACE4 20031 +#define CMD_INCREASENUM 20032 +#define CMD_DECREASENUM 20033 +#define CMD_TOGGLETITLE 20034 +#define CMD_JUMP2SELSTART 20035 +#define CMD_JUMP2SELEND 20036 +#define CMD_COPYPATHNAME 20037 +#define CMD_COPYWINPOS 20038 +#define CMD_DEFAULTWINPOS 20039 +#define CMD_OPENINIFILE 20040 +#define CMD_CTRLENTER 20041 +#define CMD_OPEN_HYPERLINK 20042 +#define CMD_ALTUP 20043 +#define CMD_ALTDOWN 20044 +#define CMD_ALTLEFT 20045 +#define CMD_ALTRIGHT 20046 +#define CMD_TAB 20047 +#define CMD_BACKTAB 20048 +#define CMD_VK_INSERT 20049 #define IDM_FILE_NEW 40000 #define IDM_FILE_OPEN 40001 diff --git a/language/np3_af_za/menu_af_za.rc b/language/np3_af_za/menu_af_za.rc index 133d9af5190795c93b6986fd80a4259bbe313dce..25cad6669bf8cee1a6583c1359e4b2d3ea5ffffe 100644 GIT binary patch delta 101 zcmZ2;glW<-rVW?GB;6SD8HyN^8B!S(7@UFZT!sRML?FLpvZAD@pbJpE1c-rrhD@Mr u-eiACX<;`8e}*8SYF7pqAPxay=gGd4Wha@$Ob*~;nVcmqwE2aYOE&-jkQpoh delta 22 ecmbPqjA_jgrVW?GCI@h_Ob(C`+I&vjr5gZj(+J7{ diff --git a/language/np3_de_de/menu_de_de.rc b/language/np3_de_de/menu_de_de.rc index c72a67e3ae699efab6dfe30af9b651e239254f49..f659aad9afa8cde69a3300dfe8a1ab6939747504 100644 GIT binary patch delta 120 zcmbPtk*Vb}(}o~%dpCxBh9ZV!hExUx24^5Um!W_m5y&qA@?9D7fUJCm6oyP7D;+4} z0#sK5#31=hpiJK6gA&4uJ`Da0jzBp#ARPoW#TCeQWe5RcXCUdx;6FJr$Z)fOc;7?- DTNoMd delta 14 VcmZp<%rx&J(}p1N%@z_q69F$X1;hXV diff --git a/language/np3_en_gb/menu_en_gb.rc b/language/np3_en_gb/menu_en_gb.rc index 47e12f7f6c93d243d55d0ac98fd93de167cf587a..f6c49033462245bef72c5ed0758b241797945d51 100644 GIT binary patch delta 98 zcmdmVgz3ytrVVnElMN=YOui?^rCP+0%8<^G$WX+P!jQ?32V^TSxB$gUfH)aQW-{b6 tTxjz?u8HyN^8B!S(7@UFZT!sRML?FL}L1A)XfUuwoP^JWkK_Zzz u`Mk-262g-|NO17GG59kC0rj{txBzj;IMKk^9RfT diff --git a/language/np3_fr_fr/menu_fr_fr.rc b/language/np3_fr_fr/menu_fr_fr.rc index 9c8530d8557ee1533c0935d958d590975be65151..2ef15ee2763211ff059668abc4dfc101d7be6a00 100644 GIT binary patch delta 120 zcmZ2*gQ@Kn(*_%HdpCxBh9ZV!hExUx24^5Um!W_m5y&qA@?9D7fUJCm6oyP7D;+4} z0#sK5#31=hpiJK6MsZ<99|nI0N1&V=kPZTx;tFKDGK2uJGm!LT@SmJ0SiIRr{K*sm DPaqmF delta 18 acmZp>#kAlC(*_&y$p<8qHoHh1ngRe!st3{l diff --git a/language/np3_nl_nl/menu_nl_nl.rc b/language/np3_nl_nl/menu_nl_nl.rc index fbab7a91043d0cae21710a263dd1fed85e78b70e..484427fef6497b327531bb3780cc86392dba07c5 100644 GIT binary patch delta 102 zcmdmTfoawyrVS$E_HGRM3`Gpd45 Date: Mon, 6 Aug 2018 19:39:36 +0200 Subject: [PATCH 3/5] + fix: some code cleanup --- src/Edit.c | 17 ++++++++++------- src/Encoding.c | 2 +- src/Encoding.h | 2 +- src/Notepad3.c | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index 9387ddc48..953825cdf 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -1024,27 +1024,30 @@ bool EditLoadFile( // if not skipped, analyze bytes bool bIsReliable = false; - int const iAnalyzedEncoding = (bSkipANSICPDetection && Encoding_IsNONE(g_CompEncDetection)) ? CPI_NONE : + + int const iAnalyzedEncoding = (bSkipANSICPDetection && !g_bForceCompEncDetection) ? CPI_NONE : Encoding_Analyze(lpData, cbNbytes4Analysis, &bIsReliable); - int const iFileEncWeak = Encoding_SrcWeak(CPI_GET); - int iForcedEncoding = Encoding_SrcCmdLn(CPI_GET); + int const iFileEncWeak = Encoding_SrcWeak(CPI_GET); + int iForcedEncoding = Encoding_SrcCmdLn(CPI_GET); - if (!Encoding_IsNONE(g_CompEncDetection) && !Encoding_IsNONE(iAnalyzedEncoding) && bIsReliable) { + if (g_bForceCompEncDetection && !Encoding_IsNONE(iAnalyzedEncoding) && bIsReliable) { iForcedEncoding = iAnalyzedEncoding; } // choose best encoding guess - int iPreferedEncoding = (bPreferOEM) ? g_DOSEncoding : (bUseDefaultForFileEncoding ? g_iDefaultNewFileEncoding : CPI_ANSI_DEFAULT); - + int iPreferedEncoding = CPI_NONE; if (!Encoding_IsNONE(iForcedEncoding)) iPreferedEncoding = iForcedEncoding; else if (iFileEncWeak != CPI_NONE) iPreferedEncoding = iFileEncWeak; else if (Encoding_IsUNICODE(iAnalyzedEncoding) && !bSkipUTFDetection) iPreferedEncoding = iAnalyzedEncoding; - else if (!Encoding_IsNONE(iAnalyzedEncoding) && bIsReliable) + else if (!Encoding_IsNONE(iAnalyzedEncoding)) iPreferedEncoding = iAnalyzedEncoding; + else + iPreferedEncoding = (bPreferOEM) ? g_DOSEncoding : + (bUseDefaultForFileEncoding ? g_iDefaultNewFileEncoding : CPI_ANSI_DEFAULT); bool bBOM = false; diff --git a/src/Encoding.c b/src/Encoding.c index 43469a833..833e5693c 100644 --- a/src/Encoding.c +++ b/src/Encoding.c @@ -280,7 +280,7 @@ int Encoding_CountOf() // int g_DOSEncoding = CPI_NONE; -int g_CompEncDetection = CPI_NONE; +bool g_bForceCompEncDetection = false; // Supported Encodings WCHAR wchANSI[16] = { L'\0' }; diff --git a/src/Encoding.h b/src/Encoding.h index a49c15abe..ed03e634d 100644 --- a/src/Encoding.h +++ b/src/Encoding.h @@ -35,7 +35,7 @@ #define _NP3_ENCODING_H_ extern int g_DOSEncoding; -extern int g_CompEncDetection; +extern bool g_bForceCompEncDetection; #define NCP_DEFAULT 1 #define NCP_UTF8 2 diff --git a/src/Notepad3.c b/src/Notepad3.c index 63e51b8a0..78fe5c20f 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -5271,13 +5271,13 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case CMD_RELOADFORCEDETECTION: { WCHAR tchCurFile2[MAX_PATH] = { L'\0' }; - g_CompEncDetection = CPI_GET; + g_bForceCompEncDetection = true; if (StringCchLenW(g_wchCurFile, COUNTOF(g_wchCurFile))) { bLoadASCIIasUTF8 = false; StringCchCopy(tchCurFile2, COUNTOF(tchCurFile2), g_wchCurFile); FileLoad(false, false, true, false, false, tchCurFile2); } - g_CompEncDetection = CPI_NONE; + g_bForceCompEncDetection = false; } break; From 5f8cf3aba0b46caefc5cd2c70777e32f2cbad8c9 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Mon, 6 Aug 2018 19:48:13 +0200 Subject: [PATCH 4/5] + add: new default Notepad3.ini for PortableApps package --- .../App/DefaultData/settings/Notepad3.ini | Bin 5620 -> 5744 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/np3portableapp/Notepad3Portable/App/DefaultData/settings/Notepad3.ini b/np3portableapp/Notepad3Portable/App/DefaultData/settings/Notepad3.ini index 05f06bd814d937cb444b808318bde00f0ed54ae3..ab62cbc9d3f68c8fd4a92efe9865cc29722ea030 100644 GIT binary patch delta 108 zcmeyO{Xu7g4Hs_^Ln=c7Lk@!i5b8{x$R%nYz>v>S%uvFR#*oQS0hBFfuw~EzLj{It lhERqO1~&#>1`CE*?4pzPxsq8G7z`PVfTpExe#gbe4FJMv6(|4z delta 20 ccmeyM^F@1u4cFvVTw#;hxKlP4asT5209(=s4*&oF From 961b1c3d3eb0b448a3d1808270086654e2ead6fa Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Mon, 6 Aug 2018 19:55:44 +0200 Subject: [PATCH 5/5] + fix: force ASCII to UTF-8, if requested --- src/Edit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Edit.c b/src/Edit.c index 953825cdf..e88ae8bf3 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -1029,8 +1029,8 @@ bool EditLoadFile( Encoding_Analyze(lpData, cbNbytes4Analysis, &bIsReliable); int const iFileEncWeak = Encoding_SrcWeak(CPI_GET); - int iForcedEncoding = Encoding_SrcCmdLn(CPI_GET); + int iForcedEncoding = bLoadASCIIasUTF8 ? CPI_UTF8 : Encoding_SrcCmdLn(CPI_GET); if (g_bForceCompEncDetection && !Encoding_IsNONE(iAnalyzedEncoding) && bIsReliable) { iForcedEncoding = iAnalyzedEncoding; }