aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32
diff options
context:
space:
mode:
Diffstat (limited to 'win32')
-rw-r--r--win32/ListBox.cxx12
-rw-r--r--win32/PlatWin.cxx24
-rw-r--r--win32/PlatWin.h5
-rw-r--r--win32/ScintRes.rc4
-rw-r--r--win32/ScintillaWin.cxx62
5 files changed, 67 insertions, 40 deletions
diff --git a/win32/ListBox.cxx b/win32/ListBox.cxx
index 0548ea5bc..b5ce7782f 100644
--- a/win32/ListBox.cxx
+++ b/win32/ListBox.cxx
@@ -195,8 +195,8 @@ class ListBoxX : public ListBox {
LRESULT NcHitTest(WPARAM, LPARAM) const;
void CentreItem(int n);
void AllocateBitMap();
- LRESULT PASCAL ListProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam);
- static LRESULT PASCAL ControlWndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam);
+ LRESULT CALLBACK ListProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam);
+ static LRESULT CALLBACK ControlWndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam);
static constexpr POINT ItemInset {0, 0}; // Padding around whole item
static constexpr POINT TextInset {2, 0}; // Padding around text
@@ -237,7 +237,7 @@ public:
void SetOptions(ListOptions options_) override;
void Draw(DRAWITEMSTRUCT *pDrawItem);
LRESULT WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam);
- static LRESULT PASCAL StaticWndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam);
+ static LRESULT CALLBACK StaticWndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam);
};
std::unique_ptr<ListBox> ListBox::Allocate() {
@@ -787,7 +787,7 @@ void ListBoxX::AllocateBitMap() {
graphics.pixmapLine->Init(graphics.bm.DC(), GetID());
}
-LRESULT PASCAL ListBoxX::ListProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) {
+LRESULT CALLBACK ListBoxX::ListProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) {
try {
switch (iMessage) {
case WM_ERASEBKGND:
@@ -831,7 +831,7 @@ LRESULT PASCAL ListBoxX::ListProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARA
return ::DefWindowProc(hWnd, iMessage, wParam, lParam);
}
-LRESULT PASCAL ListBoxX::ControlWndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) {
+LRESULT CALLBACK ListBoxX::ControlWndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) {
if (ListBoxX *lbx = static_cast<ListBoxX *>(PointerFromWindow(::GetParent(hWnd)))) {
return lbx->ListProc(hWnd, iMessage, wParam, lParam);
}
@@ -949,7 +949,7 @@ LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam
return 0;
}
-LRESULT PASCAL ListBoxX::StaticWndProc(
+LRESULT CALLBACK ListBoxX::StaticWndProc(
HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) {
if (iMessage == WM_CREATE) {
CREATESTRUCT *pCreate = static_cast<CREATESTRUCT *>(PtrFromLParam(lParam));
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index ff47c28ab..01b41f5cc 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -628,13 +628,14 @@ HCURSOR LoadReverseArrowCursor(UINT dpi) noexcept {
COLORREF strokeColour = RGB(0, 0, 1);
status = ::RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Accessibility", 0, KEY_QUERY_VALUE, &hKey);
if (status == ERROR_SUCCESS) {
+ constexpr DWORD customColour = 6;
if (std::optional<DWORD> cursorType = RegGetDWORD(hKey, L"CursorType")) {
switch (*cursorType) {
case 1: // black
case 4: // black
std::swap(fillColour, strokeColour);
break;
- case 6: // custom
+ case customColour: // custom
if (std::optional<DWORD> cursorColor = RegGetDWORD(hKey, L"CursorColor")) {
fillColour = *cursorColor;
}
@@ -696,6 +697,15 @@ void Menu::Show(Point pt, const Window &w) {
Destroy();
}
+namespace {
+
+bool assertionPopUps = true;
+
+constexpr int defaultFontSize = 8;
+constexpr size_t lengthDiagnostic = 2000;
+
+}
+
ColourRGBA ColourFromSys(int nIndex) noexcept {
const DWORD colourValue = ::GetSysColor(nIndex);
return ColourRGBA::FromRGB(colourValue);
@@ -714,7 +724,7 @@ const char *Platform::DefaultFont() {
}
int Platform::DefaultFontSize() {
- return 8;
+ return defaultFontSize;
}
unsigned int Platform::DoubleClickTime() {
@@ -729,7 +739,7 @@ void Platform::DebugDisplay(const char *s) noexcept {
#ifdef TRACE
void Platform::DebugPrintf(const char *format, ...) noexcept {
- char buffer[2000];
+ char buffer[lengthDiagnostic];
va_list pArguments;
va_start(pArguments, format);
vsnprintf(buffer, std::size(buffer), format, pArguments);
@@ -741,12 +751,6 @@ void Platform::DebugPrintf(const char *, ...) noexcept {
}
#endif
-namespace {
-
-bool assertionPopUps = true;
-
-}
-
bool Platform::ShowAssertionPopUps(bool assertionPopUps_) noexcept {
const bool ret = assertionPopUps;
assertionPopUps = assertionPopUps_;
@@ -754,7 +758,7 @@ bool Platform::ShowAssertionPopUps(bool assertionPopUps_) noexcept {
}
void Platform::Assert(const char *c, const char *file, int line) noexcept {
- char buffer[2000] {};
+ char buffer[lengthDiagnostic] {};
snprintf(buffer, std::size(buffer), "Assertion [%s] failed at %s %d%s", c, file, line, assertionPopUps ? "" : "\r\n");
if (assertionPopUps) {
const int idButton = ::MessageBoxA({}, buffer, "Assertion failure",
diff --git a/win32/PlatWin.h b/win32/PlatWin.h
index 2ffc4a5fb..3db343587 100644
--- a/win32/PlatWin.h
+++ b/win32/PlatWin.h
@@ -81,6 +81,11 @@ struct Painter {
explicit Painter(HWND hWnd_) noexcept : hWnd(hWnd_) {
::BeginPaint(hWnd, &ps);
}
+ // Deleted so Painter objects can not be copied.
+ Painter(const Painter &) = delete;
+ Painter(Painter &&) = delete;
+ Painter &operator=(const Painter &) = delete;
+ Painter &operator=(Painter &&) = delete;
~Painter() {
::EndPaint(hWnd, &ps);
}
diff --git a/win32/ScintRes.rc b/win32/ScintRes.rc
index 069195ea9..007b0ead9 100644
--- a/win32/ScintRes.rc
+++ b/win32/ScintRes.rc
@@ -4,8 +4,8 @@
#include <windows.h>
-#define VERSION_SCINTILLA "5.5.7"
-#define VERSION_WORDS 5, 5, 7, 0
+#define VERSION_SCINTILLA "5.6.0"
+#define VERSION_WORDS 5, 6, 0, 0
VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION_WORDS
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index fbec35f76..f59a5e28e 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -152,7 +152,7 @@ constexpr Point PointFromLParam(sptr_t lpoint) noexcept {
}
bool KeyboardIsKeyDown(int key) noexcept {
- return (::GetKeyState(key) & 0x80000000) != 0;
+ return ::GetKeyState(key) < 0;
}
// Bit 24 is the extended keyboard flag and the numeric keypad is non-extended
@@ -406,7 +406,8 @@ CLIPFORMAT RegisterClipboardType(LPCWSTR lpszFormat) noexcept {
// Registered clipboard format values are 0xC000 through 0xFFFF.
// RegisterClipboardFormatW returns 32-bit unsigned and CLIPFORMAT is 16-bit
// unsigned so choose the low 16-bits with &.
- return ::RegisterClipboardFormatW(lpszFormat) & 0xFFFF;
+ constexpr CLIPFORMAT LowBits = 0xFFFF;
+ return ::RegisterClipboardFormatW(lpszFormat) & LowBits;
}
RECT GetClientRect(HWND hwnd) noexcept {
@@ -572,12 +573,12 @@ class ScintillaWin :
sptr_t ptr, UINT iMessage, uptr_t wParam, sptr_t lParam);
static sptr_t DirectStatusFunction(
sptr_t ptr, UINT iMessage, uptr_t wParam, sptr_t lParam, int *pStatus);
- static LRESULT PASCAL SWndProc(
+ static LRESULT CALLBACK SWndProc(
HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam);
void CTPaint(HWND hWnd);
LRESULT CTProcessMessage(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam);
- static LRESULT PASCAL CTWndProc(
+ static LRESULT CALLBACK CTWndProc(
HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam);
enum : UINT_PTR { invalidTimerID, standardTimerID, idleTimerID, fineTimerStart };
@@ -856,7 +857,9 @@ bool ScintillaWin::UpdateRenderingParams(bool force) noexcept {
UINT clearTypeContrast = 0;
if (SUCCEEDED(hr) && monitorRenderingParams &&
::SystemParametersInfo(SPI_GETFONTSMOOTHINGCONTRAST, 0, &clearTypeContrast, 0) != 0) {
- if (clearTypeContrast >= 1000 && clearTypeContrast <= 2200) {
+ constexpr UINT minContrast = 1000;
+ constexpr UINT maxContrast = 2200;
+ if (clearTypeContrast >= minContrast && clearTypeContrast <= maxContrast) {
const FLOAT gamma = static_cast<FLOAT>(clearTypeContrast) / 1000.0f;
pIDWriteFactory->CreateCustomRenderingParams(gamma,
monitorRenderingParams->GetEnhancedContrast(),
@@ -1112,7 +1115,8 @@ namespace {
int InputCodePage() noexcept {
HKL inputLocale = ::GetKeyboardLayout(0);
const LANGID inputLang = LOWORD(inputLocale);
- char sCodePage[10];
+ constexpr size_t lengthCodePage = 10;
+ char sCodePage[lengthCodePage];
const int res = ::GetLocaleInfoA(MAKELCID(inputLang, SORT_DEFAULT),
LOCALE_IDEFAULTANSICODEPAGE, sCodePage, sizeof(sCodePage));
if (!res)
@@ -1750,7 +1754,7 @@ Window::Cursor ScintillaWin::ContextCursor(Point pt) {
// Display regular (drag) cursor over selection
if (PointInSelMargin(pt)) {
return GetMarginCursor(pt);
- } else if (!SelectionEmpty() && PointInSelection(pt)) {
+ } else if (dragDropEnabled && !SelectionEmpty() && PointInSelection(pt)) {
return Window::Cursor::arrow;
} else if (PointIsHotspot(pt)) {
return Window::Cursor::hand;
@@ -2813,10 +2817,10 @@ void CreateFoldMap(int codePage, FoldMap *foldingMap) {
if (DBCSIsLeadByte(codePage, ch1)) {
for (unsigned char byte2 = highByteLast; byte2 >= minTrailByte; byte2--) {
const char ch2 = byte2;
+ const DBCSPair pair{ ch1, ch2 };
+ const uint16_t index = DBCSIndex(ch1, ch2);
+ (*foldingMap)[index] = pair;
if (DBCSIsTrailByte(codePage, ch2)) {
- const DBCSPair pair{ ch1, ch2 };
- const uint16_t index = DBCSIndex(ch1, ch2);
- (*foldingMap)[index] = pair;
const std::string_view svBytes(pair.chars, 2);
const int lenUni = WideCharLenFromMultiByte(codePage, svBytes);
if (lenUni == 1) {
@@ -2848,36 +2852,41 @@ void CreateFoldMap(int codePage, FoldMap *foldingMap) {
class CaseFolderDBCS : public CaseFolderTable {
// Allocate the expandable storage here so that it does not need to be reallocated
// for each call to Fold.
- const FoldMap *foldingMap;
- UINT cp;
+ const FoldMap *foldingMap = nullptr;
+ UINT cp = 0;
public:
explicit CaseFolderDBCS(UINT cp_) : cp(cp_) {
- if (!DBCSHasFoldMap(cp)) {
- CreateFoldMap(cp, DBCSGetMutableFoldMap(cp));
- }
foldingMap = DBCSGetFoldMap(cp);
+ if (!foldingMap) {
+ FoldMap *pfm = DBCSCreateFoldMap(cp);
+ CreateFoldMap(cp, pfm);
+ foldingMap = pfm;
+ }
}
size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) override;
};
-size_t CaseFolderDBCS::Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) {
+size_t CaseFolderDBCS::Fold(char *folded, [[maybe_unused]] size_t sizeFolded, const char *mixed, size_t lenMixed) {
// This loop outputs the same length as input as for each char 1-byte -> 1-byte; 2-byte -> 2-byte
+ assert(lenMixed <= sizeFolded);
size_t lenOut = 0;
for (size_t i = 0; i < lenMixed; i++) {
- const ptrdiff_t lenLeft = lenMixed - i;
const char ch = mixed[i];
- if ((lenLeft >= 2) && DBCSIsLeadByte(cp, ch) && ((lenOut + 2) <= sizeFolded)) {
+ if (((i+1) < lenMixed) && DBCSIsLeadByte(cp, ch)) {
i++;
const char ch2 = mixed[i];
const uint16_t ind = DBCSIndex(ch, ch2);
const char *pair = foldingMap->at(ind).chars;
+ assert(pair[0]);
+ assert(pair[1]);
folded[lenOut++] = pair[0];
folded[lenOut++] = pair[1];
- } else if ((lenOut + 1) <= sizeFolded) {
+ } else {
const unsigned char uch = ch;
folded[lenOut++] = mapping[uch];
}
}
+ assert(lenOut == lenMixed);
return lenOut;
}
@@ -3712,6 +3721,10 @@ STDMETHODIMP_(ULONG) ScintillaWin::Release() {
/// Implement IDropTarget
STDMETHODIMP ScintillaWin::DragEnter(LPDATAOBJECT pIDataSource, DWORD grfKeyState,
POINTL, PDWORD pdwEffect) {
+ if (!dragDropEnabled) {
+ *pdwEffect = DROPEFFECT_NONE;
+ return S_OK;
+ }
if (!pIDataSource )
return E_POINTER;
FORMATETC fmtu = {CF_UNICODETEXT, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
@@ -3728,7 +3741,7 @@ STDMETHODIMP ScintillaWin::DragEnter(LPDATAOBJECT pIDataSource, DWORD grfKeyStat
STDMETHODIMP ScintillaWin::DragOver(DWORD grfKeyState, POINTL pt, PDWORD pdwEffect) {
try {
- if (!hasOKText || pdoc->IsReadOnly()) {
+ if (!dragDropEnabled || !hasOKText || pdoc->IsReadOnly()) {
*pdwEffect = DROPEFFECT_NONE;
return S_OK;
}
@@ -3762,6 +3775,11 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState,
try {
*pdwEffect = EffectFromState(grfKeyState);
+ if (!dragDropEnabled) {
+ *pdwEffect = DROPEFFECT_NONE;
+ return S_OK;
+ }
+
if (!pIDataSource)
return E_POINTER;
@@ -4001,7 +4019,7 @@ LRESULT ScintillaWin::CTProcessMessage(HWND hWnd, UINT iMessage, WPARAM wParam,
return ::DefWindowProc(hWnd, iMessage, wParam, lParam);
}
-LRESULT PASCAL ScintillaWin::CTWndProc(
+LRESULT CALLBACK ScintillaWin::CTWndProc(
HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) {
// Find C++ object associated with window.
ScintillaWin *sciThis = static_cast<ScintillaWin *>(PointerFromWindow(hWnd));
@@ -4043,7 +4061,7 @@ sptr_t DirectFunction(
}
-LRESULT PASCAL ScintillaWin::SWndProc(
+LRESULT CALLBACK ScintillaWin::SWndProc(
HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) {
//Platform::DebugPrintf("S W:%x M:%x WP:%x L:%x\n", hWnd, iMessage, wParam, lParam);