mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
Merge branch 'Dev_RC_fixes' into Dev_AccelKeys
This commit is contained in:
commit
80f823850a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -5,9 +5,17 @@
|
||||
// members to initialize or the initialization is complex or has comments.
|
||||
useInitializationList
|
||||
|
||||
// These may be interesting but its not clear without examining each instance closely
|
||||
// Would have to ensure that any_of/all_of has same early/late exits as current code and
|
||||
// produces same result on empty collections
|
||||
useStlAlgorithm
|
||||
|
||||
// Some non-explicit constructors are used for conversions or are private to lexers
|
||||
noExplicitConstructor
|
||||
|
||||
// Document is checking for a change by called methods and cppcheck isn't considering escape
|
||||
knownConditionTrueFalse:scintilla/src/Document.cxx
|
||||
|
||||
// ScintillaDocument is providing an API and there are no consumers of the API inside Scintilla
|
||||
unusedFunction:scintilla/qt/ScintillaEdit/ScintillaDocument.cpp
|
||||
|
||||
@ -32,6 +40,7 @@ variableScope:scintilla/lexers/LexLaTeX.cxx
|
||||
copyCtorAndEqOperator:scintilla/lexers/LexLaTeX.cxx
|
||||
variableScope:scintilla/lexers/LexMetapost.cxx
|
||||
variableScope:scintilla/lexers/LexModula.cxx
|
||||
variableScope:scintilla/lexers/LexMSSQL.cxx
|
||||
variableScope:scintilla/lexers/LexNimrod.cxx
|
||||
variableScope:scintilla/lexers/LexNsis.cxx
|
||||
variableScope:scintilla/lexers/LexOpal.cxx
|
||||
@ -42,6 +51,7 @@ uninitMemberVar:scintilla/lexers/LexRuby.cxx
|
||||
variableScope:scintilla/lexers/LexSpecman.cxx
|
||||
clarifyCalculation:scintilla/lexers/LexTADS3.cxx
|
||||
invalidscanf:scintilla/lexers/LexTCMD.cxx
|
||||
knownConditionTrueFalse:scintilla/lexers/LexTCMD.cxx
|
||||
variableScope:scintilla/lexers/LexTeX.cxx
|
||||
variableScope:scintilla/lexers/LexVHDL.cxx
|
||||
|
||||
|
||||
@ -571,6 +571,10 @@
|
||||
Released 2 October 2018.
|
||||
</li>
|
||||
<li>
|
||||
Improve efficiency of idle wrapping by wrapping in blocks as large as possible while
|
||||
still remaining responsive.
|
||||
</li>
|
||||
<li>
|
||||
C++ lexer fixes evaluation of "#elif".
|
||||
<a href="https://sourceforge.net/p/scintilla/bugs/2045/">Bug #2045</a>.
|
||||
</li>
|
||||
@ -578,6 +582,10 @@
|
||||
Markdown lexer fixes highlighting of non-ASCII characters in links.
|
||||
</li>
|
||||
<li>
|
||||
SCI_MARKERADD returns -1 for invalid lines as documented instead of 0.
|
||||
<a href="https://sourceforge.net/p/scintilla/bugs/2051/">Bug #2051</a>.
|
||||
</li>
|
||||
<li>
|
||||
SciTE on Win32 drops menukey feature, makes Del key work again in find and replace strips
|
||||
and disables F5 while command running.
|
||||
<a href="https://sourceforge.net/p/scintilla/bugs/2044/">Bug #2044</a>.
|
||||
|
||||
@ -602,11 +602,11 @@ public:
|
||||
const char *Find(int character) {
|
||||
const std::vector<int>::iterator it = std::lower_bound(characters.begin(), characters.end(), character);
|
||||
if (it == characters.end())
|
||||
return 0;
|
||||
return nullptr;
|
||||
else if (*it == character)
|
||||
return conversions[it - characters.begin()].conversion;
|
||||
else
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixed, size_t lenMixed) override {
|
||||
size_t lenConverted = 0;
|
||||
@ -614,7 +614,7 @@ public:
|
||||
unsigned char bytes[UTF8MaxBytes + 1]{};
|
||||
while (mixedPos < lenMixed) {
|
||||
const unsigned char leadByte = mixed[mixedPos];
|
||||
const char *caseConverted = 0;
|
||||
const char *caseConverted = nullptr;
|
||||
size_t lenMixedChar = 1;
|
||||
if (UTF8IsAscii(leadByte)) {
|
||||
caseConverted = Find(leadByte);
|
||||
@ -779,7 +779,7 @@ CaseConverter *ConverterForConversion(enum CaseConversion conversion) {
|
||||
case CaseConversionLower:
|
||||
return &caseConvLow;
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ const LexerModule *Catalogue::Find(int language) {
|
||||
return lm;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const LexerModule *Catalogue::Find(const char *languageName) {
|
||||
@ -45,7 +45,7 @@ const LexerModule *Catalogue::Find(const char *languageName) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Catalogue::AddLexerModule(LexerModule *plm) {
|
||||
|
||||
@ -138,7 +138,7 @@ class LineVector : public ILineVector {
|
||||
LineStartIndex<POS> startsUTF16;
|
||||
LineStartIndex<POS> startsUTF32;
|
||||
public:
|
||||
LineVector() : starts(256), perLine(0) {
|
||||
LineVector() : starts(256), perLine(nullptr) {
|
||||
Init();
|
||||
}
|
||||
// Deleted so LineVector objects can not be copied.
|
||||
@ -650,7 +650,7 @@ bool CellBuffer::SetStyleFor(Sci::Position position, Sci::Position lengthStyle,
|
||||
const char *CellBuffer::DeleteChars(Sci::Position position, Sci::Position deleteLength, bool &startSequence) {
|
||||
// InsertString and DeleteChars are the bottleneck though which all changes occur
|
||||
PLATFORM_ASSERT(deleteLength > 0);
|
||||
const char *data = 0;
|
||||
const char *data = nullptr;
|
||||
if (!readOnly) {
|
||||
if (collectingUndo) {
|
||||
// Save into the undo/redo stack, but only the characters - not the formatting
|
||||
@ -1148,7 +1148,7 @@ void CellBuffer::EndUndoAction() {
|
||||
|
||||
void CellBuffer::AddUndoAction(Sci::Position token, bool mayCoalesce) {
|
||||
bool startSequence;
|
||||
uh.AppendAction(containerAction, token, 0, 0, startSequence, mayCoalesce);
|
||||
uh.AppendAction(containerAction, token, nullptr, 0, startSequence, mayCoalesce);
|
||||
}
|
||||
|
||||
void CellBuffer::DeleteUndoHistory() {
|
||||
|
||||
@ -84,8 +84,31 @@ int LexInterface::LineEndTypesSupported() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ActionDuration::ActionDuration(double duration_, double minDuration_, double maxDuration_) noexcept :
|
||||
duration(duration_), minDuration(minDuration_), maxDuration(maxDuration_) {
|
||||
}
|
||||
|
||||
void ActionDuration::AddSample(size_t numberActions, double durationOfActions) noexcept {
|
||||
// Only adjust for multiple actions to avoid instability
|
||||
if (numberActions < 8)
|
||||
return;
|
||||
|
||||
// Alpha value for exponential smoothing.
|
||||
// Most recent value contributes 25% to smoothed value.
|
||||
const double alpha = 0.25;
|
||||
|
||||
const double durationOne = durationOfActions / numberActions;
|
||||
duration = std::clamp(alpha * durationOne + (1.0 - alpha) * duration,
|
||||
minDuration, maxDuration);
|
||||
}
|
||||
|
||||
double ActionDuration::Duration() const noexcept {
|
||||
return duration;
|
||||
}
|
||||
|
||||
Document::Document(int options) :
|
||||
cb((options & SC_DOCUMENTOPTION_STYLES_NONE) == 0, (options & SC_DOCUMENTOPTION_TEXT_LARGE) != 0) {
|
||||
cb((options & SC_DOCUMENTOPTION_STYLES_NONE) == 0, (options & SC_DOCUMENTOPTION_TEXT_LARGE) != 0),
|
||||
durationStyleOneLine(0.00001, 0.000001, 0.0001) {
|
||||
refCount = 0;
|
||||
#ifdef _WIN32
|
||||
eolMode = SC_EOL_CRLF;
|
||||
@ -106,7 +129,6 @@ Document::Document(int options) :
|
||||
useTabs = true;
|
||||
tabIndents = true;
|
||||
backspaceUnindents = false;
|
||||
durationStyleOneLine = 0.00001;
|
||||
|
||||
matchesValid = false;
|
||||
|
||||
@ -300,7 +322,7 @@ int Document::AddMark(Sci::Line line, int markerNum) {
|
||||
NotifyModified(mh);
|
||||
return prev;
|
||||
} else {
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2211,30 +2233,11 @@ void Document::EnsureStyledTo(Sci::Position pos) {
|
||||
}
|
||||
|
||||
void Document::StyleToAdjustingLineDuration(Sci::Position pos) {
|
||||
// Place bounds on the duration used to avoid glitches spiking it
|
||||
// and so causing slow styling or non-responsive scrolling
|
||||
const double minDurationOneLine = 0.000001;
|
||||
const double maxDurationOneLine = 0.0001;
|
||||
|
||||
// Alpha value for exponential smoothing.
|
||||
// Most recent value contributes 25% to smoothed value.
|
||||
const double alpha = 0.25;
|
||||
|
||||
const Sci::Line lineFirst = SciLineFromPosition(GetEndStyled());
|
||||
ElapsedPeriod epStyling;
|
||||
EnsureStyledTo(pos);
|
||||
const double durationStyling = epStyling.Duration();
|
||||
const Sci::Line lineLast = SciLineFromPosition(GetEndStyled());
|
||||
if (lineLast >= lineFirst + 8) {
|
||||
// Only adjust for styling multiple lines to avoid instability
|
||||
const double durationOneLine = durationStyling / (lineLast - lineFirst);
|
||||
durationStyleOneLine = alpha * durationOneLine + (1.0 - alpha) * durationStyleOneLine;
|
||||
if (durationStyleOneLine < minDurationOneLine) {
|
||||
durationStyleOneLine = minDurationOneLine;
|
||||
} else if (durationStyleOneLine > maxDurationOneLine) {
|
||||
durationStyleOneLine = maxDurationOneLine;
|
||||
}
|
||||
}
|
||||
durationStyleOneLine.AddSample(lineLast - lineFirst, epStyling.Duration());
|
||||
}
|
||||
|
||||
void Document::LexerChanged() {
|
||||
|
||||
@ -191,6 +191,26 @@ struct RegexError : public std::runtime_error {
|
||||
RegexError() : std::runtime_error("regex failure") {}
|
||||
};
|
||||
|
||||
/**
|
||||
* The ActionDuration class stores the average time taken for some action such as styling or
|
||||
* wrapping a line. It is used to decide how many repetitions of that action can be performed
|
||||
* on idle to maximize efficiency without affecting application responsiveness.
|
||||
* The duration changes if the time for the action changes. For example, if a simple lexer is
|
||||
* changed to a complex lexer. Changes are damped and clamped to avoid short periods of easy
|
||||
* or difficult processing moving the value too far leading to inefficiency or poor user
|
||||
* experience.
|
||||
*/
|
||||
|
||||
class ActionDuration {
|
||||
double duration;
|
||||
const double minDuration;
|
||||
const double maxDuration;
|
||||
public:
|
||||
ActionDuration(double duration_, double minDuration_, double maxDuration_) noexcept;
|
||||
void AddSample(size_t numberActions, double durationOfActions) noexcept;
|
||||
double Duration() const noexcept;
|
||||
};
|
||||
|
||||
/**
|
||||
*/
|
||||
class Document : PerLine, public IDocument, public ILoader {
|
||||
@ -261,7 +281,7 @@ public:
|
||||
bool useTabs;
|
||||
bool tabIndents;
|
||||
bool backspaceUnindents;
|
||||
double durationStyleOneLine;
|
||||
ActionDuration durationStyleOneLine;
|
||||
|
||||
std::unique_ptr<IDecorationList> decorations;
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <chrono>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
@ -54,6 +55,7 @@
|
||||
#include "MarginView.h"
|
||||
#include "EditView.h"
|
||||
#include "Editor.h"
|
||||
#include "ElapsedPeriod.h"
|
||||
|
||||
using namespace Scintilla;
|
||||
|
||||
@ -89,7 +91,7 @@ static bool IsLastStep(const DocModification &mh) {
|
||||
}
|
||||
|
||||
Timer::Timer() :
|
||||
ticking(false), ticksToWait(0), tickerID(0) {}
|
||||
ticking(false), ticksToWait(0), tickerID{} {}
|
||||
|
||||
Idler::Idler() :
|
||||
state(false), idlerID(0) {}
|
||||
@ -103,7 +105,7 @@ static inline bool IsAllSpacesOrTabs(const char *s, unsigned int len) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Editor::Editor() {
|
||||
Editor::Editor() : durationWrapOneLine(0.00001, 0.000001, 0.0001) {
|
||||
ctrlID = 0;
|
||||
|
||||
stylesValid = false;
|
||||
@ -1536,7 +1538,12 @@ bool Editor::WrapLines(WrapScope ws) {
|
||||
return false;
|
||||
}
|
||||
} else if (ws == WrapScope::wsIdle) {
|
||||
lineToWrapEnd = lineToWrap + LinesOnScreen() + 100;
|
||||
// Try to keep time taken by wrapping reasonable so interaction remains smooth.
|
||||
const double secondsAllowed = 0.01;
|
||||
const Sci::Line linesInAllowedTime = std::clamp<Sci::Line>(
|
||||
static_cast<Sci::Line>(secondsAllowed / durationWrapOneLine.Duration()),
|
||||
LinesOnScreen() + 50, 0x10000);
|
||||
lineToWrapEnd = lineToWrap + linesInAllowedTime;
|
||||
}
|
||||
const Sci::Line lineEndNeedWrap = std::min(wrapPending.end, pdoc->LinesTotal());
|
||||
lineToWrapEnd = std::min(lineToWrapEnd, lineEndNeedWrap);
|
||||
@ -1555,6 +1562,8 @@ bool Editor::WrapLines(WrapScope ws) {
|
||||
if (surface) {
|
||||
//Platform::DebugPrintf("Wraplines: scope=%0d need=%0d..%0d perform=%0d..%0d\n", ws, wrapPending.start, wrapPending.end, lineToWrap, lineToWrapEnd);
|
||||
|
||||
const Sci::Line linesBeingWrapped = lineToWrapEnd - lineToWrap;
|
||||
ElapsedPeriod epWrapping;
|
||||
while (lineToWrap < lineToWrapEnd) {
|
||||
if (WrapOneLine(surface, lineToWrap)) {
|
||||
wrapOccurred = true;
|
||||
@ -1562,6 +1571,7 @@ bool Editor::WrapLines(WrapScope ws) {
|
||||
wrapPending.Wrapped(lineToWrap);
|
||||
lineToWrap++;
|
||||
}
|
||||
durationWrapOneLine.AddSample(linesBeingWrapped, epWrapping.Duration());
|
||||
|
||||
goodTopLine = pcs->DisplayFromDoc(lineDocTop) + std::min(
|
||||
subLineTop, static_cast<Sci::Line>(pcs->GetHeight(lineDocTop)-1));
|
||||
@ -5057,7 +5067,8 @@ Sci::Position Editor::PositionAfterMaxStyling(Sci::Position posMax, bool scrolli
|
||||
// When scrolling, allow less time to ensure responsive
|
||||
const double secondsAllowed = scrolling ? 0.005 : 0.02;
|
||||
|
||||
const Sci::Line linesToStyle = std::clamp(static_cast<int>(secondsAllowed / pdoc->durationStyleOneLine),
|
||||
const Sci::Line linesToStyle = std::clamp(
|
||||
static_cast<int>(secondsAllowed / pdoc->durationStyleOneLine.Duration()),
|
||||
10, 0x10000);
|
||||
const Sci::Line stylingMaxLine = std::min(
|
||||
pdoc->SciLineFromPosition(pdoc->GetEndStyled()) + linesToStyle,
|
||||
|
||||
@ -250,6 +250,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
||||
|
||||
// Wrapping support
|
||||
WrapPending wrapPending;
|
||||
ActionDuration durationWrapOneLine;
|
||||
|
||||
bool convertPastes;
|
||||
|
||||
|
||||
@ -65,7 +65,7 @@ LexerLibrary::LexerLibrary(const char *moduleName_) {
|
||||
// Assign a buffer for the lexer name.
|
||||
char lexname[100] = "";
|
||||
GetLexerName(i, lexname, sizeof(lexname));
|
||||
ExternalLexerModule *lex = new ExternalLexerModule(SCLEX_AUTOMATIC, NULL, lexname, NULL);
|
||||
ExternalLexerModule *lex = new ExternalLexerModule(SCLEX_AUTOMATIC, nullptr, lexname, nullptr);
|
||||
// This is storing a second reference to lex in the Catalogue as well as in modules.
|
||||
// TODO: Should use std::shared_ptr or similar to ensure allocation safety.
|
||||
Catalogue::AddLexerModule(lex);
|
||||
|
||||
@ -60,7 +60,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
|
||||
const PRectangle rcSquiggle = PixelGridAlign(rc);
|
||||
|
||||
const int width = std::min(4000, static_cast<int>(rcSquiggle.Width()));
|
||||
RGBAImage image(width, 3, 1.0, 0);
|
||||
RGBAImage image(width, 3, 1.0, nullptr);
|
||||
enum { alphaFull = 0xff, alphaSide = 0x2f, alphaSide2=0x5f };
|
||||
for (int x = 0; x < width; x++) {
|
||||
if (x%2) {
|
||||
@ -165,7 +165,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
|
||||
IntegerRectangle ircBox(rcBox);
|
||||
// Cap width at 4000 to avoid large allocations when mistakes made
|
||||
const int width = std::min(ircBox.Width(), 4000);
|
||||
RGBAImage image(width, ircBox.Height(), 1.0, 0);
|
||||
RGBAImage image(width, ircBox.Height(), 1.0, nullptr);
|
||||
// Draw horizontal lines top and bottom
|
||||
for (int x=0; x<width; x++) {
|
||||
for (int y = 0; y<ircBox.Height(); y += ircBox.Height() - 1) {
|
||||
|
||||
@ -350,14 +350,14 @@ const char *LineAnnotation::Text(Sci::Line line) const {
|
||||
if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line])
|
||||
return annotations[line].get()+sizeof(AnnotationHeader);
|
||||
else
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const unsigned char *LineAnnotation::Styles(Sci::Line line) const {
|
||||
if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line] && MultipleStyles(line))
|
||||
return reinterpret_cast<unsigned char *>(annotations[line].get() + sizeof(AnnotationHeader) + Length(line));
|
||||
else
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static std::unique_ptr<char[]>AllocateAnnotation(int length, int style) {
|
||||
|
||||
@ -445,7 +445,7 @@ const char *RESearch::Compile(const char *pattern, Sci::Position length, bool ca
|
||||
|
||||
if (!pattern || !length) {
|
||||
if (sta)
|
||||
return 0;
|
||||
return nullptr;
|
||||
else
|
||||
return badpat("No previous regular expression");
|
||||
}
|
||||
@ -727,7 +727,7 @@ const char *RESearch::Compile(const char *pattern, Sci::Position length, bool ca
|
||||
return badpat((posix ? "Unmatched (" : "Unmatched \\("));
|
||||
*mp = END;
|
||||
sta = OKP;
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -443,12 +443,12 @@ int ScintillaBase::AutoCompleteGetCurrentText(char *buffer) const {
|
||||
const int item = ac.GetSelection();
|
||||
if (item != -1) {
|
||||
const std::string selected = ac.GetValue(item);
|
||||
if (buffer != NULL)
|
||||
if (buffer)
|
||||
memcpy(buffer, selected.c_str(), selected.length()+1);
|
||||
return static_cast<int>(selected.length());
|
||||
}
|
||||
}
|
||||
if (buffer != NULL)
|
||||
if (buffer)
|
||||
*buffer = '\0';
|
||||
return 0;
|
||||
}
|
||||
@ -571,7 +571,7 @@ public:
|
||||
}
|
||||
|
||||
LexState::LexState(Document *pdoc_) : LexInterface(pdoc_) {
|
||||
lexCurrent = 0;
|
||||
lexCurrent = nullptr;
|
||||
performingStyle = false;
|
||||
interfaceVersion = lvRelease4;
|
||||
lexLanguage = SCLEX_CONTAINER;
|
||||
@ -580,7 +580,7 @@ LexState::LexState(Document *pdoc_) : LexInterface(pdoc_) {
|
||||
LexState::~LexState() {
|
||||
if (instance) {
|
||||
instance->Release();
|
||||
instance = 0;
|
||||
instance = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -595,7 +595,7 @@ void LexState::SetLexerModule(const LexerModule *lex) {
|
||||
if (lex != lexCurrent) {
|
||||
if (instance) {
|
||||
instance->Release();
|
||||
instance = 0;
|
||||
instance = nullptr;
|
||||
}
|
||||
interfaceVersion = lvRelease4;
|
||||
lexCurrent = lex;
|
||||
@ -610,7 +610,7 @@ void LexState::SetLexerModule(const LexerModule *lex) {
|
||||
void LexState::SetLexer(uptr_t wParam) {
|
||||
lexLanguage = static_cast<int>(wParam);
|
||||
if (lexLanguage == SCLEX_CONTAINER) {
|
||||
SetLexerModule(0);
|
||||
SetLexerModule(nullptr);
|
||||
} else {
|
||||
const LexerModule *lex = Catalogue::Find(lexLanguage);
|
||||
if (!lex)
|
||||
@ -632,7 +632,7 @@ const char *LexState::DescribeWordListSets() {
|
||||
if (instance) {
|
||||
return instance->DescribeWordListSets();
|
||||
} else {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -653,7 +653,7 @@ void *LexState::PrivateCall(int operation, void *pointer) {
|
||||
if (pdoc && instance) {
|
||||
return instance->PrivateCall(operation, pointer);
|
||||
} else {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -661,7 +661,7 @@ const char *LexState::PropertyNames() {
|
||||
if (instance) {
|
||||
return instance->PropertyNames();
|
||||
} else {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -677,7 +677,7 @@ const char *LexState::DescribeProperty(const char *name) {
|
||||
if (instance) {
|
||||
return instance->DescribeProperty(name);
|
||||
} else {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -784,7 +784,7 @@ const char *LexState::NameOfStyle(int style) {
|
||||
if (instance) {
|
||||
return instance->NameOfStyle(style);
|
||||
} else {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -792,7 +792,7 @@ const char *LexState::TagsOfStyle(int style) {
|
||||
if (instance) {
|
||||
return instance->TagsOfStyle(style);
|
||||
} else {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -800,7 +800,7 @@ const char *LexState::DescriptionOfStyle(int style) {
|
||||
if (instance) {
|
||||
return instance->DescriptionOfStyle(style);
|
||||
} else {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -77,13 +77,13 @@ void FontMeasurements::ClearMeasurements() {
|
||||
|
||||
Style::Style() : FontSpecification() {
|
||||
Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
|
||||
Platform::DefaultFontSize() * SC_FONT_SIZE_MULTIPLIER, 0, SC_CHARSET_DEFAULT,
|
||||
Platform::DefaultFontSize() * SC_FONT_SIZE_MULTIPLIER, nullptr, SC_CHARSET_DEFAULT,
|
||||
SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
|
||||
}
|
||||
|
||||
Style::Style(const Style &source) : FontSpecification(), FontMeasurements() {
|
||||
Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
|
||||
0, 0, 0,
|
||||
0, nullptr, 0,
|
||||
SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
|
||||
fore = source.fore;
|
||||
back = source.back;
|
||||
@ -107,7 +107,7 @@ Style &Style::operator=(const Style &source) {
|
||||
if (this == &source)
|
||||
return * this;
|
||||
Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
|
||||
0, 0, SC_CHARSET_DEFAULT,
|
||||
0, nullptr, SC_CHARSET_DEFAULT,
|
||||
SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
|
||||
fore = source.fore;
|
||||
back = source.back;
|
||||
|
||||
@ -643,7 +643,7 @@ FontRealised *ViewStyle::Find(const FontSpecification &fs) {
|
||||
// Should always reach here since map was just set for all styles
|
||||
return it->second.get();
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ViewStyle::FindMaxAscentDescent() {
|
||||
|
||||
@ -75,8 +75,8 @@ ID2D1Factory *pD2DFactory = nullptr;
|
||||
IDWriteRenderingParams *defaultRenderingParams = nullptr;
|
||||
IDWriteRenderingParams *customClearTypeRenderingParams = nullptr;
|
||||
|
||||
static HMODULE hDLLD2D = NULL;
|
||||
static HMODULE hDLLDWrite = NULL;
|
||||
static HMODULE hDLLD2D {};
|
||||
static HMODULE hDLLDWrite {};
|
||||
|
||||
bool LoadD2D() {
|
||||
static bool triedLoadingD2D = false;
|
||||
@ -156,7 +156,7 @@ struct FormatAndMetrics {
|
||||
FormatAndMetrics(HFONT hfont_, int extraFontFlag_, int characterSet_) :
|
||||
technology(SCWIN_TECH_GDI), hfont(hfont_),
|
||||
#if defined(USE_D2D)
|
||||
pTextFormat(0),
|
||||
pTextFormat(nullptr),
|
||||
#endif
|
||||
extraFontFlag(extraFontFlag_), characterSet(characterSet_), yAscent(2), yDescent(1), yInternalLeading(0) {
|
||||
}
|
||||
@ -168,7 +168,7 @@ struct FormatAndMetrics {
|
||||
FLOAT yDescent_,
|
||||
FLOAT yInternalLeading_) :
|
||||
technology(SCWIN_TECH_DIRECTWRITE),
|
||||
hfont(0),
|
||||
hfont{},
|
||||
pTextFormat(pTextFormat_),
|
||||
extraFontFlag(extraFontFlag_),
|
||||
characterSet(characterSet_),
|
||||
@ -238,9 +238,9 @@ void SetWindowPointer(HWND hWnd, void *ptr) {
|
||||
}
|
||||
|
||||
CRITICAL_SECTION crPlatformLock;
|
||||
HINSTANCE hinstPlatformRes = 0;
|
||||
HINSTANCE hinstPlatformRes {};
|
||||
|
||||
HCURSOR reverseArrowCursor = NULL;
|
||||
HCURSOR reverseArrowCursor {};
|
||||
|
||||
FormatAndMetrics *FamFromFontID(void *fid) {
|
||||
return static_cast<FormatAndMetrics *>(fid);
|
||||
@ -332,7 +332,7 @@ public:
|
||||
FontCached *FontCached::first = nullptr;
|
||||
|
||||
FontCached::FontCached(const FontParameters &fp) :
|
||||
next(0), usage(0), size(1.0), hash(0) {
|
||||
next(nullptr), usage(0), size(1.0), hash(0) {
|
||||
SetLogFont(lf, fp.faceName, fp.characterSet, fp.size, fp.weight, fp.italic, fp.extraFontFlag);
|
||||
technology = fp.technology;
|
||||
hash = HashFont(fp);
|
||||
@ -414,7 +414,7 @@ void FontCached::Release() {
|
||||
}
|
||||
|
||||
FontID FontCached::FindOrCreate(const FontParameters &fp) {
|
||||
FontID ret = 0;
|
||||
FontID ret {};
|
||||
::EnterCriticalSection(&crPlatformLock);
|
||||
const int hashFind = HashFont(fp);
|
||||
for (FontCached *cur=first; cur; cur=cur->next) {
|
||||
@ -453,7 +453,7 @@ void FontCached::ReleaseId(FontID fid_) {
|
||||
::LeaveCriticalSection(&crPlatformLock);
|
||||
}
|
||||
|
||||
Font::Font() noexcept : fid(0) {
|
||||
Font::Font() noexcept : fid{} {
|
||||
}
|
||||
|
||||
Font::~Font() {
|
||||
@ -520,21 +520,22 @@ public:
|
||||
typedef VarBuffer<XYPOSITION, stackBufferLength> TextPositions;
|
||||
|
||||
class SurfaceGDI : public Surface {
|
||||
bool unicodeMode;
|
||||
HDC hdc;
|
||||
bool hdcOwned;
|
||||
HPEN pen;
|
||||
HPEN penOld;
|
||||
HBRUSH brush;
|
||||
HBRUSH brushOld;
|
||||
HFONT font;
|
||||
HFONT fontOld;
|
||||
HBITMAP bitmap;
|
||||
HBITMAP bitmapOld;
|
||||
int maxWidthMeasure;
|
||||
int maxLenText;
|
||||
bool unicodeMode=false;
|
||||
HDC hdc{};
|
||||
bool hdcOwned=false;
|
||||
HPEN pen{};
|
||||
HPEN penOld{};
|
||||
HBRUSH brush{};
|
||||
HBRUSH brushOld{};
|
||||
HFONT font{};
|
||||
HFONT fontOld{};
|
||||
HBITMAP bitmap{};
|
||||
HBITMAP bitmapOld{};
|
||||
int maxWidthMeasure = INT_MAX;
|
||||
// There appears to be a 16 bit string length limit in GDI on NT.
|
||||
int maxLenText = 65535;
|
||||
|
||||
int codePage;
|
||||
int codePage = 0;
|
||||
|
||||
void BrushColor(ColourDesired back);
|
||||
void SetFont(Font &font_);
|
||||
@ -595,18 +596,7 @@ public:
|
||||
void SetBidiR2L(bool bidiR2L_) override;
|
||||
};
|
||||
|
||||
SurfaceGDI::SurfaceGDI() :
|
||||
unicodeMode(false),
|
||||
hdc(0), hdcOwned(false),
|
||||
pen(0), penOld(0),
|
||||
brush(0), brushOld(0),
|
||||
font(0), fontOld(0),
|
||||
bitmap(0), bitmapOld(0) {
|
||||
maxWidthMeasure = INT_MAX;
|
||||
// There appears to be a 16 bit string length limit in GDI on NT.
|
||||
maxLenText = 65535;
|
||||
|
||||
codePage = 0;
|
||||
SurfaceGDI::SurfaceGDI() {
|
||||
}
|
||||
|
||||
SurfaceGDI::~SurfaceGDI() {
|
||||
@ -1235,7 +1225,7 @@ void SurfaceD2D::SetScale() {
|
||||
}
|
||||
|
||||
bool SurfaceD2D::Initialised() {
|
||||
return pRenderTarget != 0;
|
||||
return pRenderTarget != nullptr;
|
||||
}
|
||||
|
||||
HRESULT SurfaceD2D::FlushDrawing() {
|
||||
@ -1381,7 +1371,7 @@ void SurfaceD2D::Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesi
|
||||
if (pRenderTarget) {
|
||||
ID2D1Factory *pFactory = nullptr;
|
||||
pRenderTarget->GetFactory(&pFactory);
|
||||
ID2D1PathGeometry *geometry=0;
|
||||
ID2D1PathGeometry *geometry=nullptr;
|
||||
HRESULT hr = pFactory->CreatePathGeometry(&geometry);
|
||||
if (SUCCEEDED(hr)) {
|
||||
ID2D1GeometrySink *sink = nullptr;
|
||||
@ -2533,7 +2523,7 @@ class ListBoxX : public ListBox {
|
||||
static const Point ImageInset; // Padding around image
|
||||
|
||||
public:
|
||||
ListBoxX() : lineHeight(10), fontCopy(0), technology(0), lb(0), unicodeMode(false),
|
||||
ListBoxX() : lineHeight(10), fontCopy{}, technology(0), lb{}, unicodeMode(false),
|
||||
desiredVisibleRows(9), maxItemCharacters(0), aveCharWidth(8),
|
||||
parent(nullptr), ctrlID(0),
|
||||
delegate(nullptr),
|
||||
@ -3341,7 +3331,7 @@ bool ListBoxX_Unregister() {
|
||||
|
||||
}
|
||||
|
||||
Menu::Menu() noexcept : mid(0) {
|
||||
Menu::Menu() noexcept : mid{} {
|
||||
}
|
||||
|
||||
void Menu::CreatePopUp() {
|
||||
|
||||
@ -2599,6 +2599,21 @@ WININFO GetMyWindowPlacement(HWND hwnd, MONITORINFO* hMonitorInfo)
|
||||
wndpl.length = sizeof(WINDOWPLACEMENT);
|
||||
GetWindowPlacement(hwnd, &wndpl);
|
||||
|
||||
// corrections in case of aero snapped position
|
||||
if (SW_NORMAL == wndpl.showCmd) {
|
||||
RECT rc;
|
||||
GetWindowRect(hwnd, &rc);
|
||||
MONITORINFO mi;
|
||||
GetMonitorInfoFromRect(&rc, &mi);
|
||||
LONG const width = rc.right - rc.left;
|
||||
LONG const height = rc.bottom - rc.top;
|
||||
rc.left -= (mi.rcWork.left - mi.rcMonitor.left);
|
||||
rc.right = rc.left + width;
|
||||
rc.top -= (mi.rcWork.top - mi.rcMonitor.top);
|
||||
rc.bottom = rc.top + height;
|
||||
wndpl.rcNormalPosition = rc;
|
||||
}
|
||||
|
||||
WININFO wi;
|
||||
wi.x = wndpl.rcNormalPosition.left;
|
||||
wi.y = wndpl.rcNormalPosition.top;
|
||||
@ -2607,6 +2622,7 @@ WININFO GetMyWindowPlacement(HWND hwnd, MONITORINFO* hMonitorInfo)
|
||||
wi.max = IsZoomed(hwnd) || (wndpl.flags & WPF_RESTORETOMAXIMIZED);
|
||||
wi.zoom = SciCall_GetZoom();
|
||||
|
||||
// set monitor info too
|
||||
GetMonitorInfoFromRect(&(wndpl.rcNormalPosition), hMonitorInfo);
|
||||
|
||||
return wi;
|
||||
|
||||
@ -871,7 +871,7 @@ void EndWaitCursor()
|
||||
// _InitWindowPosition()
|
||||
//
|
||||
//
|
||||
static WININFO _InitDefaultWndPos(const int flagsPos)
|
||||
static WININFO _InitDefaultWndPos(const int flagsPos)
|
||||
{
|
||||
RECT rc;
|
||||
GetWindowRect(GetDesktopWindow(), &rc);
|
||||
@ -2001,9 +2001,6 @@ LRESULT MsgEndSession(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
// Terminate file watching
|
||||
InstallFileWatching(NULL);
|
||||
|
||||
// remember window position
|
||||
s_WinInfo = GetMyWindowPlacement(hwnd, NULL);
|
||||
|
||||
DragAcceptFiles(hwnd, true);
|
||||
#ifdef _EXTRA_DRAG_N_DROP_HANDLER_
|
||||
RevokeDragAndDrop(pDropTarget);
|
||||
@ -7095,10 +7092,12 @@ void SaveSettings(bool bSaveSettingsNow)
|
||||
|
||||
CreateIniFile();
|
||||
|
||||
if (!s_bSaveSettings && !bSaveSettingsNow) {
|
||||
if (!(s_bSaveSettings || bSaveSettingsNow)) {
|
||||
IniSetBool(L"Settings", L"SaveSettings", s_bSaveSettings);
|
||||
return;
|
||||
}
|
||||
// update window placement
|
||||
s_WinInfo = GetMyWindowPlacement(Globals.hwndMain, NULL);
|
||||
|
||||
WCHAR tchMsg[80];
|
||||
GetLngString(IDS_MUI_SAVINGSETTINGS, tchMsg, COUNTOF(tchMsg));
|
||||
@ -7261,7 +7260,6 @@ void SaveSettings(bool bSaveSettingsNow)
|
||||
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, CustomSchemesDlgPosX);
|
||||
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, CustomSchemesDlgPosY);
|
||||
|
||||
|
||||
SaveIniSection(L"Settings", pIniSection);
|
||||
|
||||
FreeMem(pIniSection);
|
||||
@ -7270,11 +7268,6 @@ void SaveSettings(bool bSaveSettingsNow)
|
||||
// Scintilla Styles
|
||||
Style_Save();
|
||||
|
||||
// update window placement
|
||||
if (bSaveSettingsNow) {
|
||||
s_WinInfo = GetMyWindowPlacement(Globals.hwndMain, NULL);
|
||||
}
|
||||
|
||||
int ResX = GetSystemMetrics(SM_CXSCREEN);
|
||||
int ResY = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user