From d6e8a7c168bba3d1b4777d6e04f04392fb39eb36 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sat, 22 Jan 2022 02:20:58 +0100 Subject: [PATCH] Make Sci_PositionCR 64 bits in x64 build --- PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp | 6 +++--- PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp | 6 +++--- PowerEditor/src/ScintillaComponent/ScintillaEditView.h | 2 +- PowerEditor/src/ScintillaComponent/SmartHighlighter.cpp | 2 +- scintilla/include/Sci_Position.h | 6 ++++++ 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index c24abcb56..8273e892b 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -1115,7 +1115,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM if (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE) { Sci_CharacterRange cr = (*_ppEditView)->getSelection(); - int nbSelected = cr.cpMax - cr.cpMin; + INT_PTR nbSelected = cr.cpMax - cr.cpMin; _options._isInSelection = isCheckedOrNot(IDC_IN_SELECTION_CHECK)?1:0; int checkVal = _options._isInSelection?BST_CHECKED:BST_UNCHECKED; @@ -3433,8 +3433,8 @@ void FindReplaceDlg::clearMarks(const FindOption& opt) { Sci_CharacterRange cr = (*_ppEditView)->getSelection(); - int startPosition = cr.cpMin; - int endPosition = cr.cpMax; + INT_PTR startPosition = cr.cpMin; + INT_PTR endPosition = cr.cpMax; (*_ppEditView)->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE); (*_ppEditView)->execute(SCI_INDICATORCLEARRANGE, startPosition, endPosition - startPosition); diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp index e01c05b3a..e8d111711 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp @@ -387,7 +387,7 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa if (wParam == IMR_RECONVERTSTRING) { INT_PTR textLength; - int selectSize; + INT_PTR selectSize; char smallTextBuffer[128]; char * selectedStr = smallTextBuffer; RECONVERTSTRING * reconvert = (RECONVERTSTRING *)lParam; @@ -426,7 +426,7 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa { // convert the selection to Unicode, and get the number // of bytes required for the converted text - textLength = sizeof(WCHAR) * ::MultiByteToWideChar(codepage, 0, selectedStr, selectSize, NULL, 0); + textLength = sizeof(WCHAR) * ::MultiByteToWideChar(codepage, 0, selectedStr, (int)selectSize, NULL, 0); } else { @@ -436,7 +436,7 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa // dwCompStrOffset, and dwTargetStrOffset specify byte counts. textLength = ::MultiByteToWideChar( codepage, 0, - selectedStr, selectSize, + selectedStr, (int)selectSize, (LPWSTR)((LPSTR)reconvert + sizeof(RECONVERTSTRING)), reconvert->dwSize - sizeof(RECONVERTSTRING)); diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h index 5d2e92bbb..1e1c1a6f8 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h @@ -234,7 +234,7 @@ public: void insertGenericTextFrom(size_t position, const TCHAR *text2insert) const; void replaceSelWith(const char * replaceText); - int getSelectedTextCount() { + INT_PTR getSelectedTextCount() { Sci_CharacterRange range = getSelection(); return (range.cpMax - range.cpMin); }; diff --git a/PowerEditor/src/ScintillaComponent/SmartHighlighter.cpp b/PowerEditor/src/ScintillaComponent/SmartHighlighter.cpp index ef06e885b..363acb201 100644 --- a/PowerEditor/src/ScintillaComponent/SmartHighlighter.cpp +++ b/PowerEditor/src/ScintillaComponent/SmartHighlighter.cpp @@ -116,7 +116,7 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView, Scintil auto curPos = pHighlightView->execute(SCI_GETCURRENTPOS); auto range = pHighlightView->getSelection(); - int textlen = range.cpMax - range.cpMin; + INT_PTR textlen = range.cpMax - range.cpMin; // Determine mode for SmartHighlighting bool isWordOnly = true; diff --git a/scintilla/include/Sci_Position.h b/scintilla/include/Sci_Position.h index abd0f3408..c7dbeee63 100644 --- a/scintilla/include/Sci_Position.h +++ b/scintilla/include/Sci_Position.h @@ -15,10 +15,16 @@ typedef ptrdiff_t Sci_Position; // Unsigned variant used for ILexer::Lex and ILexer::Fold +// Definitions of common types typedef size_t Sci_PositionU; + // For Sci_CharacterRange which is defined as long to be compatible with Win32 CHARRANGE +#ifdef _WIN64 +typedef long long Sci_PositionCR; +#else typedef long Sci_PositionCR; +#endif #ifdef _WIN32 #define SCI_METHOD __stdcall