diff --git a/scintilla/doc/ScintillaDoc.html b/scintilla/doc/ScintillaDoc.html index 348ab025f..40bb8f430 100644 --- a/scintilla/doc/ScintillaDoc.html +++ b/scintilla/doc/ScintillaDoc.html @@ -3214,8 +3214,8 @@ struct Sci_TextToFind {

SCI_SETCARETSTYLE(int caretStyle)
SCI_GETCARETSTYLE → int
The style of the caret can be set with SCI_SETCARETSTYLE to be a line caret - (CARETSTYLE_LINE=1) or a block caret (CARETSTYLE_BLOCK=2) for insert mode combined with - a bar caret (CARETSTYLE_OVERSTRIKE_BAR=0) or a block caret (CARETSTYLE_OVERSTRIKE_BLOCK=16) for overtype mode, + (CARETSTYLE_LINE=1) or a block caret (CARETSTYLE_BLOCK=2) for insert mode (lower 4-bits, CARETSTYLE_INS_MASK) combined with + a bar caret (CARETSTYLE_OVERSTRIKE_BAR=0) or a block caret (CARETSTYLE_OVERSTRIKE_BLOCK=16) for overtype mode (bit 4), or to not draw at all (CARETSTYLE_INVISIBLE=0). The default value for insert mode is the line caret (CARETSTYLE_LINE=1), for overtype mode is the bar caret (CARETSTYLE_OVERSTRIKE_BAR=0). You can determine the current caret style setting using SCI_GETCARETSTYLE.

diff --git a/scintilla/doc/ScintillaHistory.html b/scintilla/doc/ScintillaHistory.html index ad6ce07de..381dc4ecd 100644 --- a/scintilla/doc/ScintillaHistory.html +++ b/scintilla/doc/ScintillaHistory.html @@ -541,6 +541,7 @@ Jad Altahan Andrea Ricchi + Juarez Rudsatz

diff --git a/scintilla/include/Platform.h b/scintilla/include/Platform.h index c472da4da..2214f6073 100644 --- a/scintilla/include/Platform.h +++ b/scintilla/include/Platform.h @@ -112,6 +112,18 @@ public: return Point(static_cast(x_), static_cast(y_)); } + bool operator!=(Point other) const noexcept { + return (x != other.x) || (y != other.y); + } + + Point operator+(Point other) const noexcept { + return Point(x + other.x, y + other.y); + } + + Point operator-(Point other) const noexcept { + return Point(x - other.x, y - other.y); + } + // Other automatically defined methods (assignment, copy constructor, destructor) are fine }; diff --git a/scintilla/include/Scintilla.h b/scintilla/include/Scintilla.h index 6ff4c49c1..9c805c1e3 100644 --- a/scintilla/include/Scintilla.h +++ b/scintilla/include/Scintilla.h @@ -835,6 +835,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define CARETSTYLE_BLOCK 2 #define CARETSTYLE_OVERSTRIKE_BAR 0 #define CARETSTYLE_OVERSTRIKE_BLOCK 16 +#define CARETSTYLE_INS_MASK 0xF #define SCI_SETCARETSTYLE 2512 #define SCI_GETCARETSTYLE 2513 #define SCI_SETINDICATORCURRENT 2500 diff --git a/scintilla/include/Scintilla.iface b/scintilla/include/Scintilla.iface index 8fce94606..e19f3cfb2 100644 --- a/scintilla/include/Scintilla.iface +++ b/scintilla/include/Scintilla.iface @@ -2187,6 +2187,7 @@ val CARETSTYLE_LINE=1 val CARETSTYLE_BLOCK=2 val CARETSTYLE_OVERSTRIKE_BAR=0 val CARETSTYLE_OVERSTRIKE_BLOCK=16 +val CARETSTYLE_INS_MASK=0xF # Set the style of the caret to be drawn. set void SetCaretStyle=2512(int caretStyle,) diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx index d7a1fde2b..699d0c459 100644 --- a/scintilla/src/Editor.cxx +++ b/scintilla/src/Editor.cxx @@ -1150,13 +1150,9 @@ slop | strict | jumps | even | Caret can go to the margin | When Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &range, const XYScrollOptions options) { const PRectangle rcClient = GetTextRectangle(); - Point pt = LocationFromPosition(range.caret); - Point ptAnchor = LocationFromPosition(range.anchor); const Point ptOrigin = GetVisibleOriginInMain(); - pt.x += ptOrigin.x; - pt.y += ptOrigin.y; - ptAnchor.x += ptOrigin.x; - ptAnchor.y += ptOrigin.y; + const Point pt = LocationFromPosition(range.caret) + ptOrigin; + const Point ptAnchor = LocationFromPosition(range.anchor) + ptOrigin; const Point ptBottomCaret(pt.x, pt.y + vs.lineHeight - 1); XYScrollPosition newXY(xOffset, topLine); @@ -4176,9 +4172,10 @@ void Editor::GoToLine(Sci::Line lineNo) { } static bool Close(Point pt1, Point pt2, Point threshold) noexcept { - if (std::abs(pt1.x - pt2.x) > threshold.x) + const Point ptDifference = pt2 - pt1; + if (std::abs(ptDifference.x) > threshold.x) return false; - if (std::abs(pt1.y - pt2.y) > threshold.y) + if (std::abs(ptDifference.y) > threshold.y) return false; return true; } @@ -4268,9 +4265,8 @@ void Editor::DisplayCursor(Window::Cursor c) { } bool Editor::DragThreshold(Point ptStart, Point ptNow) { - const XYPOSITION xMove = ptStart.x - ptNow.x; - const XYPOSITION yMove = ptStart.y - ptNow.y; - const XYPOSITION distanceSquared = xMove * xMove + yMove * yMove; + const Point ptDiff = ptStart - ptNow; + const XYPOSITION distanceSquared = ptDiff.x * ptDiff.x + ptDiff.y * ptDiff.y; return distanceSquared > 16.0f; } @@ -4750,7 +4746,7 @@ Range Editor::GetHotSpotRange() const noexcept { } void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, int modifiers) { - if ((ptMouseLast.x != pt.x) || (ptMouseLast.y != pt.y)) { + if (ptMouseLast != pt) { DwellEnd(true); } diff --git a/scintilla/src/Editor.h b/scintilla/src/Editor.h index e86d5c41c..88bc88a77 100644 --- a/scintilla/src/Editor.h +++ b/scintilla/src/Editor.h @@ -260,7 +260,7 @@ protected: // ScintillaBase subclass needs access to much of Editor Editor(Editor &&) = delete; Editor &operator=(const Editor &) = delete; Editor &operator=(Editor &&) = delete; - ~Editor() override; + // ~Editor() in public section virtual void Initialise() = 0; virtual void Finalise(); @@ -599,6 +599,8 @@ protected: // ScintillaBase subclass needs access to much of Editor static sptr_t BytesResult(sptr_t lParam, const unsigned char *val, size_t len) noexcept; public: + ~Editor() override; + // Public so the COM thunks can access it. bool IsUnicodeMode() const noexcept; // Public so scintilla_send_message can use it. diff --git a/scintilla/src/ElapsedPeriod.h b/scintilla/src/ElapsedPeriod.h index 1e2c96eb4..6f8cdabdf 100644 --- a/scintilla/src/ElapsedPeriod.h +++ b/scintilla/src/ElapsedPeriod.h @@ -15,7 +15,7 @@ class ElapsedPeriod { std::chrono::high_resolution_clock::time_point tp; public: /// Capture the moment - ElapsedPeriod() : tp(std::chrono::high_resolution_clock::now()) { + ElapsedPeriod() noexcept : tp(std::chrono::high_resolution_clock::now()) { } /// Return duration as floating point seconds double Duration(bool reset=false) { diff --git a/scintilla/src/Indicator.h b/scintilla/src/Indicator.h index 7e9a00ce3..9e5fda221 100644 --- a/scintilla/src/Indicator.h +++ b/scintilla/src/Indicator.h @@ -13,9 +13,9 @@ namespace Scintilla { struct StyleAndColour { int style; ColourDesired fore; - StyleAndColour() : style(INDIC_PLAIN), fore(0, 0, 0) { + StyleAndColour() noexcept : style(INDIC_PLAIN), fore(0, 0, 0) { } - StyleAndColour(int style_, ColourDesired fore_ = ColourDesired(0, 0, 0)) : style(style_), fore(fore_) { + StyleAndColour(int style_, ColourDesired fore_ = ColourDesired(0, 0, 0)) noexcept : style(style_), fore(fore_) { } bool operator==(const StyleAndColour &other) const { return (style == other.style) && (fore == other.fore); @@ -33,9 +33,9 @@ public: int fillAlpha; int outlineAlpha; int attributes; - Indicator() : under(false), fillAlpha(30), outlineAlpha(50), attributes(0) { + Indicator() noexcept : under(false), fillAlpha(30), outlineAlpha(50), attributes(0) { } - Indicator(int style_, ColourDesired fore_=ColourDesired(0,0,0), bool under_=false, int fillAlpha_=30, int outlineAlpha_=50) : + Indicator(int style_, ColourDesired fore_=ColourDesired(0,0,0), bool under_=false, int fillAlpha_=30, int outlineAlpha_=50) noexcept : sacNormal(style_, fore_), sacHover(style_, fore_), under(under_), fillAlpha(fillAlpha_), outlineAlpha(outlineAlpha_), attributes(0) { } void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, const PRectangle &rcCharacter, DrawState drawState, int value) const; diff --git a/scintilla/src/KeyMap.h b/scintilla/src/KeyMap.h index b4299feec..6f30abf00 100644 --- a/scintilla/src/KeyMap.h +++ b/scintilla/src/KeyMap.h @@ -25,7 +25,7 @@ class KeyModifiers { public: int key; int modifiers; - KeyModifiers(int key_, int modifiers_) : key(key_), modifiers(modifiers_) { + KeyModifiers(int key_, int modifiers_) noexcept : key(key_), modifiers(modifiers_) { } bool operator<(const KeyModifiers &other) const { if (key == other.key) diff --git a/scintilla/src/PerLine.h b/scintilla/src/PerLine.h index bf0968f28..94dc17a20 100644 --- a/scintilla/src/PerLine.h +++ b/scintilla/src/PerLine.h @@ -17,7 +17,7 @@ namespace Scintilla { struct MarkerHandleNumber { int handle; int number; - MarkerHandleNumber(int handle_, int number_) : handle(handle_), number(number_) {} + MarkerHandleNumber(int handle_, int number_) noexcept : handle(handle_), number(number_) {} }; /** diff --git a/scintilla/src/ScintillaBase.cxx b/scintilla/src/ScintillaBase.cxx index acc9ebe88..f8d7c058b 100644 --- a/scintilla/src/ScintillaBase.cxx +++ b/scintilla/src/ScintillaBase.cxx @@ -276,9 +276,7 @@ void ScintillaBase::AutoCompleteStart(Sci::Position lenEntered, const char *list pt = PointMainCaret(); } if (wMargin.Created()) { - const Point ptOrigin = GetVisibleOriginInMain(); - pt.x += ptOrigin.x; - pt.y += ptOrigin.y; + pt = pt + GetVisibleOriginInMain(); } PRectangle rcac; rcac.left = pt.x - ac.lb->CaretFromEdge(); @@ -463,9 +461,7 @@ void ScintillaBase::CallTipShow(Point pt, const char *defn) { ct.SetForeBack(vs.styles[STYLE_CALLTIP].fore, vs.styles[STYLE_CALLTIP].back); } if (wMargin.Created()) { - const Point ptOrigin = GetVisibleOriginInMain(); - pt.x += ptOrigin.x; - pt.y += ptOrigin.y; + pt = pt + GetVisibleOriginInMain(); } PRectangle rc = ct.CallTipStart(sel.MainCaret(), pt, vs.lineHeight, diff --git a/scintilla/src/ScintillaBase.h b/scintilla/src/ScintillaBase.h index 1c08170eb..5ff050eb9 100644 --- a/scintilla/src/ScintillaBase.h +++ b/scintilla/src/ScintillaBase.h @@ -57,7 +57,7 @@ protected: ScintillaBase(ScintillaBase &&) = delete; ScintillaBase &operator=(const ScintillaBase &) = delete; ScintillaBase &operator=(ScintillaBase &&) = delete; - ~ScintillaBase() override; + // ~ScintillaBase() in public section void Initialise() override {} void Finalise() override; @@ -90,6 +90,8 @@ protected: void NotifyLexerChanged(Document *doc, void *userData) override; public: + ~ScintillaBase() override; + // Public so scintilla_send_message can use it sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override; }; diff --git a/scintilla/src/Selection.cxx b/scintilla/src/Selection.cxx index 4b3a17f63..a342cb3fb 100644 --- a/scintilla/src/Selection.cxx +++ b/scintilla/src/Selection.cxx @@ -177,7 +177,7 @@ void SelectionRange::MinimizeVirtualSpace() { } } -Selection::Selection() : mainRange(0), moveExtends(false), tentativeMain(false), selType(selStream) { +Selection::Selection() noexcept : mainRange(0), moveExtends(false), tentativeMain(false), selType(selStream) { AddSelection(SelectionRange(SelectionPosition(0))); } diff --git a/scintilla/src/Selection.h b/scintilla/src/Selection.h index 6530abf86..3fc1af545 100644 --- a/scintilla/src/Selection.h +++ b/scintilla/src/Selection.h @@ -14,7 +14,7 @@ class SelectionPosition { Sci::Position position; Sci::Position virtualSpace; public: - explicit SelectionPosition(Sci::Position position_=INVALID_POSITION, Sci::Position virtualSpace_=0) : position(position_), virtualSpace(virtualSpace_) { + explicit SelectionPosition(Sci::Position position_=INVALID_POSITION, Sci::Position virtualSpace_=0) noexcept : position(position_), virtualSpace(virtualSpace_) { PLATFORM_ASSERT(virtualSpace < 800000); if (virtualSpace < 0) virtualSpace = 0; @@ -84,15 +84,15 @@ struct SelectionRange { SelectionPosition caret; SelectionPosition anchor; - SelectionRange() : caret(), anchor() { + SelectionRange() noexcept : caret(), anchor() { } - explicit SelectionRange(SelectionPosition single) : caret(single), anchor(single) { + explicit SelectionRange(SelectionPosition single) noexcept : caret(single), anchor(single) { } - explicit SelectionRange(Sci::Position single) : caret(single), anchor(single) { + explicit SelectionRange(Sci::Position single) noexcept : caret(single), anchor(single) { } - SelectionRange(SelectionPosition caret_, SelectionPosition anchor_) : caret(caret_), anchor(anchor_) { + SelectionRange(SelectionPosition caret_, SelectionPosition anchor_) noexcept : caret(caret_), anchor(anchor_) { } - SelectionRange(Sci::Position caret_, Sci::Position anchor_) : caret(caret_), anchor(anchor_) { + SelectionRange(Sci::Position caret_, Sci::Position anchor_) noexcept : caret(caret_), anchor(anchor_) { } bool Empty() const { return anchor == caret; @@ -141,7 +141,7 @@ public: enum selTypes { noSel, selStream, selRectangle, selLines, selThin }; selTypes selType; - Selection(); + Selection() noexcept; ~Selection(); bool IsRectangular() const; Sci::Position MainCaret() const; diff --git a/scintilla/src/ViewStyle.cxx b/scintilla/src/ViewStyle.cxx index fc3a8489c..e650b1062 100644 --- a/scintilla/src/ViewStyle.cxx +++ b/scintilla/src/ViewStyle.cxx @@ -27,8 +27,6 @@ #include "Style.h" #include "ViewStyle.h" -#define CARETSTYLE_INS_MASK 0xF - using namespace Scintilla; MarginStyle::MarginStyle(int style_, int width_, int mask_) : diff --git a/scintilla/src/ViewStyle.h b/scintilla/src/ViewStyle.h index 1caaa5847..c9fb3ac37 100644 --- a/scintilla/src/ViewStyle.h +++ b/scintilla/src/ViewStyle.h @@ -74,9 +74,9 @@ constexpr int GetFontSizeZoomed(int size, int zoomLevel) noexcept { class ColourOptional : public ColourDesired { public: bool isSet; - ColourOptional(ColourDesired colour_=ColourDesired(0,0,0), bool isSet_=false) : ColourDesired(colour_), isSet(isSet_) { + ColourOptional(ColourDesired colour_=ColourDesired(0,0,0), bool isSet_=false) noexcept : ColourDesired(colour_), isSet(isSet_) { } - ColourOptional(uptr_t wParam, sptr_t lParam) : ColourDesired(static_cast(lParam)), isSet(wParam != 0) { + ColourOptional(uptr_t wParam, sptr_t lParam) noexcept : ColourDesired(static_cast(lParam)), isSet(wParam != 0) { } }; @@ -88,10 +88,10 @@ struct ForeBackColours { struct EdgeProperties { int column; ColourDesired colour; - EdgeProperties(int column_ = 0, ColourDesired colour_ = ColourDesired(0)) : + EdgeProperties(int column_ = 0, ColourDesired colour_ = ColourDesired(0)) noexcept : column(column_), colour(colour_) { } - EdgeProperties(uptr_t wParam, sptr_t lParam) : + EdgeProperties(uptr_t wParam, sptr_t lParam) noexcept : column(static_cast(wParam)), colour(static_cast(lParam)) { } }; diff --git a/scintilla/win32/PlatWin.cxx b/scintilla/win32/PlatWin.cxx index 35fcb899a..810cf8787 100644 --- a/scintilla/win32/PlatWin.cxx +++ b/scintilla/win32/PlatWin.cxx @@ -2797,9 +2797,7 @@ void ListBoxX::ResizeToCursor() { PRectangle rc = GetPosition(); POINT ptw; ::GetCursorPos(&ptw); - Point pt = Point::FromInts(ptw.x, ptw.y); - pt.x += dragOffset.x; - pt.y += dragOffset.y; + const Point pt = Point::FromInts(ptw.x, ptw.y) + dragOffset; switch (resizeHit) { case HTLEFT: diff --git a/scintilla/win32/ScintillaWin.cxx b/scintilla/win32/ScintillaWin.cxx index 8caec3ee1..672e47891 100644 --- a/scintilla/win32/ScintillaWin.cxx +++ b/scintilla/win32/ScintillaWin.cxx @@ -373,7 +373,7 @@ class ScintillaWin : #endif explicit ScintillaWin(HWND hwnd); - ~ScintillaWin() override; + // ~ScintillaWin() in public section void Init(); void Finalise() noexcept override; @@ -477,6 +477,7 @@ class ScintillaWin : sptr_t GetText(uptr_t wParam, sptr_t lParam); public: + ~ScintillaWin() override; // Deleted so ScintillaWin objects can not be copied. ScintillaWin(const ScintillaWin &) = delete; ScintillaWin(ScintillaWin &&) = delete; diff --git a/src/Edit.c b/src/Edit.c index 75bd404db..b64a75cc9 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -1052,37 +1052,45 @@ bool EditLoadFile( return false; } - bool bNfoDizDetected = false; - if (Settings.LoadNFOasOEM) - { - if (lpszExt && !(StringCchCompareXI(lpszExt, L".nfo") && StringCchCompareXI(lpszExt, L".diz"))) - bNfoDizDetected = true; - } + // -------------------------------------------------------------------------- + // Encoding Detection + // -------------------------------------------------------------------------- + + cpi_enc_t iPreferredEncoding = Settings.LoadASCIIasUTF8 ? CPI_UTF8 : CPI_ANSI_DEFAULT; + + // --- 1st check for force encodings --- + + bool const bNfoDizDetected = (lpszExt && !(StringCchCompareXI(lpszExt, L".nfo") && StringCchCompareXI(lpszExt, L".diz"))); + + cpi_enc_t iForcedEncoding = Globals.bForceReLoadAsUTF8 ? CPI_UTF8 : + ((Settings.LoadNFOasOEM && bNfoDizDetected) ? Globals.DOSEncoding : Encoding_SrcCmdLn(CPI_GET)); + + + // --- 2nd Use Encoding Analysis if applicable size_t const cbNbytes4Analysis = (cbData < 200000L) ? cbData : 200000L; - cpi_enc_t iPreferedEncoding = (bNfoDizDetected) ? Globals.DOSEncoding : - ((Settings.UseDefaultForFileEncoding || (cbNbytes4Analysis == 0)) ? Settings.DefaultEncoding : CPI_ANSI_DEFAULT); - - // -------------------------------------------------------------------------- - float confidence = 0.0f; - cpi_enc_t iAnalyzedEncoding = Encoding_AnalyzeText(lpData, cbNbytes4Analysis, &confidence, iPreferedEncoding); + cpi_enc_t iAnalyzedEncoding = iForcedEncoding; - bool const bIsReliable = (confidence >= Settings2.AnalyzeReliableConfidenceLevel); + if (Encoding_IsNONE(iForcedEncoding) || bForceEncDetection) + { + iAnalyzedEncoding = Encoding_AnalyzeText(lpData, cbNbytes4Analysis, &confidence, iPreferredEncoding); - if (Flags.bDevDebugMode) { + if (Flags.bDevDebugMode) { #if 1 - SetAdditionalTitleInfo(Encoding_GetTitleInfoW()); + SetAdditionalTitleInfo(Encoding_GetTitleInfoW()); #else - DocPos const iPos = SciCall_PositionFromLine(SciCall_GetFirstVisibleLine()); - int const iXOff = SciCall_GetXOffset(); - SciCall_SetXOffset(0); - SciCall_CallTipShow(iPos, Encoding_GetTitleInfoA()); - SciCall_SetXOffset(iXOff); - Globals.CallTipType = CT_ENC_INFO; + DocPos const iPos = SciCall_PositionFromLine(SciCall_GetFirstVisibleLine()); + int const iXOff = SciCall_GetXOffset(); + SciCall_SetXOffset(0); + SciCall_CallTipShow(iPos, Encoding_GetTitleInfoA()); + SciCall_SetXOffset(iXOff); + Globals.CallTipType = CT_ENC_INFO; #endif + } } + bool const bIsReliable = (confidence >= Settings2.AnalyzeReliableConfidenceLevel); // ------------------------------------------------------ @@ -1091,7 +1099,7 @@ bool EditLoadFile( bool const bIsUnicode = Encoding_IsUTF8(iAnalyzedEncoding) || Encoding_IsUNICODE(iAnalyzedEncoding); if (iAnalyzedEncoding == CPI_ASCII_7BIT) { - iAnalyzedEncoding = Settings.LoadASCIIasUTF8 ? CPI_UTF8 : iPreferedEncoding; // stay on preferred + iAnalyzedEncoding = Settings.LoadASCIIasUTF8 ? CPI_UTF8 : iPreferredEncoding; // stay on preferred } else { if ((bSkipUTFDetection && bIsUnicode) || (bSkipANSICPDetection && !bIsUnicode)) { @@ -1101,32 +1109,32 @@ bool EditLoadFile( } // -------------------------------------------------------------------------- - cpi_enc_t iForcedEncoding = Globals.bForceLoadASCIIasUTF8 ? CPI_UTF8 : Encoding_SrcCmdLn(CPI_GET); - if (Encoding_IsNONE(iForcedEncoding) && bNfoDizDetected) { - iForcedEncoding = Globals.DOSEncoding; - } if (bForceEncDetection && !Encoding_IsNONE(iAnalyzedEncoding)) { iForcedEncoding = iAnalyzedEncoding; // no bIsReliable check (forced unreliable detection) } // -------------------------------------------------------------------------- + // --- 3rd Unicode Checks + bool const bIsForced = !Encoding_IsNONE(iForcedEncoding); bool const bIsUnicodeForced = Encoding_IsUNICODE(iForcedEncoding); // choose best encoding guess cpi_enc_t const iFileEncWeak = Encoding_SrcWeak(CPI_GET); + // remap Preferred Encoding + if (bIsForced) { - iPreferedEncoding = iForcedEncoding; + iPreferredEncoding = iForcedEncoding; } else if (!Encoding_IsNONE(iFileEncWeak)) { - iPreferedEncoding = iFileEncWeak; + iPreferredEncoding = iFileEncWeak; } else if (!Encoding_IsNONE(iAnalyzedEncoding) && (bIsReliable || !Settings.UseReliableCEDonly)) { - iPreferedEncoding = iAnalyzedEncoding; + iPreferredEncoding = iAnalyzedEncoding; } - else if (Encoding_IsNONE(iPreferedEncoding)) { - iPreferedEncoding = CPI_ANSI_DEFAULT; + else if (Encoding_IsNONE(iPreferredEncoding)) { + iPreferredEncoding = Settings.LoadASCIIasUTF8 ? CPI_UTF8 : CPI_ANSI_DEFAULT; } // -------------------------------------------------------------------------- @@ -1141,7 +1149,7 @@ bool EditLoadFile( if (cbData == 0) { FileVars_Init(NULL,0,&Globals.fvCurFile); status->iEOLMode = Settings.DefaultEOLMode; - status->iEncoding = bIsForced ? iForcedEncoding : (Settings.LoadASCIIasUTF8 ? CPI_UTF8 : iPreferedEncoding); + status->iEncoding = bIsForced ? iForcedEncoding : (Settings.LoadASCIIasUTF8 ? CPI_UTF8 : iPreferredEncoding); EditSetNewText(hwnd,"",0); SciCall_SetEOLMode(Settings.DefaultEOLMode); FreeMem(lpData); @@ -1204,7 +1212,7 @@ bool EditLoadFile( bool const bValidUTF8 = IsValidUTF8(lpData, cbData); bool const bForcedUTF8 = Encoding_IsUTF8(iForcedEncoding) || (FileVars_IsUTF8(&Globals.fvCurFile) && !Settings.NoEncodingTags); bool const bAnalysisUTF8 = Encoding_IsUTF8(iAnalyzedEncoding) && bIsReliable; - bool const bSoftHintUTF8 = Encoding_IsUTF8(iAnalyzedEncoding) && Encoding_IsUTF8(iPreferedEncoding); // non-reliable analysis = soft-hint + bool const bSoftHintUTF8 = Encoding_IsUTF8(iAnalyzedEncoding) && Encoding_IsUTF8(iPreferredEncoding); // non-reliable analysis = soft-hint bool const bRejectUTF8 = !bValidUTF8 || (!bIsUTF8Sig && bSkipUTFDetection); @@ -1232,7 +1240,7 @@ bool EditLoadFile( status->iEncoding = FileVars_GetEncoding(&Globals.fvCurFile); if (Encoding_IsNONE(status->iEncoding)) { - status->iEncoding = ((Globals.fvCurFile.mask & FV_ENCODING) ? CPI_ANSI_DEFAULT : iPreferedEncoding); + status->iEncoding = ((Globals.fvCurFile.mask & FV_ENCODING) ? CPI_ANSI_DEFAULT : iPreferredEncoding); } } @@ -1273,7 +1281,7 @@ bool EditLoadFile( } } else { - status->iEncoding = Encoding_IsValid(iForcedEncoding) ? iForcedEncoding : iPreferedEncoding; + status->iEncoding = Encoding_IsValid(iForcedEncoding) ? iForcedEncoding : iPreferredEncoding; EditSetNewText(hwnd,"",0); EditSetNewText(hwnd,lpData,cbData); EditDetectEOLMode(lpData, cbData, status); diff --git a/src/Notepad3.c b/src/Notepad3.c index 383be4ee8..ce7f8dc43 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -441,7 +441,7 @@ static void _InitGlobals() Globals.iAvailLngCount = 1; Globals.iWrapCol = 0; Globals.bCodeFoldingAvailable = false; - Globals.bForceLoadASCIIasUTF8 = false; + Globals.bForceReLoadAsUTF8 = false; Globals.DOSEncoding = CPI_NONE; Globals.bZeroBasedColumnIndex = false; Globals.bZeroBasedCharacterCount = false; @@ -5488,10 +5488,10 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { if (StringCchLenW(Globals.CurrentFile,COUNTOF(Globals.CurrentFile))) { - Globals.bForceLoadASCIIasUTF8 = true; + Globals.bForceReLoadAsUTF8 = true; StringCchCopy(tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer),Globals.CurrentFile); FileLoad(false, false, true, true, true, false, tchMaxPathBuffer); - Globals.bForceLoadASCIIasUTF8 = false; + Globals.bForceReLoadAsUTF8 = false; } } break; @@ -5501,7 +5501,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { if (StringCchLenW(Globals.CurrentFile, COUNTOF(Globals.CurrentFile))) { - Globals.bForceLoadASCIIasUTF8 = false; + Globals.bForceReLoadAsUTF8 = false; StringCchCopy(tchMaxPathBuffer, COUNTOF(tchMaxPathBuffer), Globals.CurrentFile); FileLoad(false, false, true, false, false, true, tchMaxPathBuffer); } diff --git a/src/Styles.c b/src/Styles.c index f04de01ed..3119bfdb3 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -249,8 +249,10 @@ bool Style_InsertThemesMenu(HMENU hMenuBar) HMENU hmenuThemes = CreatePopupMenu(); int const pos = GetMenuItemCount(hMenuBar) - 1; + GetLngString(IDM_THEMES_DEFAULT, Theme_Files[0].szName, COUNTOF(Theme_Files[0].szName)); AppendMenu(hmenuThemes, MF_ENABLED | MF_STRING, Theme_Files[0].rid, Theme_Files[0].szName); - + + GetLngString(IDM_THEMES_FILE_ITEM, Theme_Files[1].szName, COUNTOF(Theme_Files[1].szName)); AppendMenu(hmenuThemes, MF_ENABLED | MF_STRING, Theme_Files[1].rid, Theme_Files[1].szName); for (unsigned i = 2; i < ThemeItems_CountOf(); ++i) diff --git a/src/TypeDefs.h b/src/TypeDefs.h index 22c9b8540..41c949689 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -302,7 +302,7 @@ typedef struct _globals_t int iWrapCol; bool bCodeFoldingAvailable; - bool bForceLoadASCIIasUTF8; + bool bForceReLoadAsUTF8; bool bZeroBasedColumnIndex; bool bZeroBasedCharacterCount; int iReplacedOccurrences;