mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-29 16:54:43 +02:00
parent
cb7bbef4fe
commit
b1bc06ec23
@ -325,7 +325,7 @@ generic_string purgeMenuItemString(const TCHAR * menuItemStr, bool keepAmpersand
|
||||
}
|
||||
|
||||
|
||||
const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT codepage, int lenMbcs, int *pLenWc, int *pBytesNotProcessed)
|
||||
const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, size_t codepage, int lenMbcs, int *pLenWc, int *pBytesNotProcessed)
|
||||
{
|
||||
// Do not process NULL pointer
|
||||
if (!mbcs2Convert)
|
||||
@ -338,36 +338,37 @@ const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT c
|
||||
return _wideCharStr;
|
||||
}
|
||||
|
||||
UINT cp = static_cast<UINT>(codepage);
|
||||
int bytesNotProcessed = 0;
|
||||
int lenWc = 0;
|
||||
|
||||
// If length not specified, simply convert without checking
|
||||
if (lenMbcs == -1)
|
||||
{
|
||||
lenWc = MultiByteToWideChar(codepage, 0, mbcs2Convert, lenMbcs, NULL, 0);
|
||||
lenWc = MultiByteToWideChar(cp, 0, mbcs2Convert, lenMbcs, NULL, 0);
|
||||
}
|
||||
// Otherwise, test if we are cutting a multi-byte character at end of buffer
|
||||
else if (lenMbcs != -1 && codepage == CP_UTF8) // For UTF-8, we know how to test it
|
||||
else if (lenMbcs != -1 && cp == CP_UTF8) // For UTF-8, we know how to test it
|
||||
{
|
||||
int indexOfLastChar = Utf8::characterStart(mbcs2Convert, lenMbcs-1); // get index of last character
|
||||
if (indexOfLastChar != 0 && !Utf8::isValid(mbcs2Convert+indexOfLastChar, lenMbcs-indexOfLastChar)) // if it is not valid we do not process it right now (unless its the only character in string, to ensure that we always progress, e.g. that bytesNotProcessed < lenMbcs)
|
||||
{
|
||||
bytesNotProcessed = lenMbcs-indexOfLastChar;
|
||||
}
|
||||
lenWc = MultiByteToWideChar(codepage, 0, mbcs2Convert, lenMbcs-bytesNotProcessed, NULL, 0);
|
||||
lenWc = MultiByteToWideChar(cp, 0, mbcs2Convert, lenMbcs-bytesNotProcessed, NULL, 0);
|
||||
}
|
||||
else // For other encodings, ask system if there are any invalid characters; note that it will not correctly know if last character is cut when there are invalid characters inside the text
|
||||
{
|
||||
lenWc = MultiByteToWideChar(codepage, (lenMbcs == -1) ? 0 : MB_ERR_INVALID_CHARS, mbcs2Convert, lenMbcs, NULL, 0);
|
||||
lenWc = MultiByteToWideChar(cp, (lenMbcs == -1) ? 0 : MB_ERR_INVALID_CHARS, mbcs2Convert, lenMbcs, NULL, 0);
|
||||
if (lenWc == 0 && GetLastError() == ERROR_NO_UNICODE_TRANSLATION)
|
||||
{
|
||||
// Test without last byte
|
||||
if (lenMbcs > 1) lenWc = MultiByteToWideChar(codepage, MB_ERR_INVALID_CHARS, mbcs2Convert, lenMbcs-1, NULL, 0);
|
||||
if (lenMbcs > 1) lenWc = MultiByteToWideChar(cp, MB_ERR_INVALID_CHARS, mbcs2Convert, lenMbcs-1, NULL, 0);
|
||||
if (lenWc == 0) // don't have to check that the error is still ERROR_NO_UNICODE_TRANSLATION, since only the length parameter changed
|
||||
{
|
||||
// TODO: should warn user about incorrect loading due to invalid characters
|
||||
// We still load the file, but the system will either strip or replace invalid characters (including the last character, if cut in half)
|
||||
lenWc = MultiByteToWideChar(codepage, 0, mbcs2Convert, lenMbcs, NULL, 0);
|
||||
lenWc = MultiByteToWideChar(cp, 0, mbcs2Convert, lenMbcs, NULL, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -380,7 +381,7 @@ const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT c
|
||||
if (lenWc > 0)
|
||||
{
|
||||
_wideCharStr.sizeTo(lenWc);
|
||||
MultiByteToWideChar(codepage, 0, mbcs2Convert, lenMbcs-bytesNotProcessed, _wideCharStr, lenWc);
|
||||
MultiByteToWideChar(cp, 0, mbcs2Convert, lenMbcs-bytesNotProcessed, _wideCharStr, lenWc);
|
||||
}
|
||||
else
|
||||
_wideCharStr.empty();
|
||||
@ -396,21 +397,21 @@ const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT c
|
||||
|
||||
// "mstart" and "mend" are pointers to indexes in mbcs2Convert,
|
||||
// which are converted to the corresponding indexes in the returned wchar_t string.
|
||||
const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT codepage, int *mstart, int *mend)
|
||||
const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, size_t codepage, INT_PTR* mstart, INT_PTR* mend)
|
||||
{
|
||||
// Do not process NULL pointer
|
||||
if (!mbcs2Convert) return NULL;
|
||||
|
||||
int len = MultiByteToWideChar(codepage, 0, mbcs2Convert, -1, NULL, 0);
|
||||
UINT cp = static_cast<UINT>(codepage);
|
||||
int len = MultiByteToWideChar(cp, 0, mbcs2Convert, -1, NULL, 0);
|
||||
if (len > 0)
|
||||
{
|
||||
_wideCharStr.sizeTo(len);
|
||||
len = MultiByteToWideChar(codepage, 0, mbcs2Convert, -1, _wideCharStr, len);
|
||||
len = MultiByteToWideChar(cp, 0, mbcs2Convert, -1, _wideCharStr, len);
|
||||
|
||||
if ((size_t)*mstart < strlen(mbcs2Convert) && (size_t)*mend <= strlen(mbcs2Convert))
|
||||
{
|
||||
*mstart = MultiByteToWideChar(codepage, 0, mbcs2Convert, *mstart, _wideCharStr, 0);
|
||||
*mend = MultiByteToWideChar(codepage, 0, mbcs2Convert, *mend, _wideCharStr, 0);
|
||||
*mstart = MultiByteToWideChar(cp, 0, mbcs2Convert, static_cast<int>(*mstart), _wideCharStr, 0);
|
||||
*mend = MultiByteToWideChar(cp, 0, mbcs2Convert, static_cast<int>(*mend), _wideCharStr, 0);
|
||||
if (*mstart >= len || *mend >= len)
|
||||
{
|
||||
*mstart = 0;
|
||||
@ -428,16 +429,16 @@ const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT c
|
||||
}
|
||||
|
||||
|
||||
const char* WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UINT codepage, int lenWc, int *pLenMbcs)
|
||||
const char* WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, size_t codepage, int lenWc, int *pLenMbcs)
|
||||
{
|
||||
if (nullptr == wcharStr2Convert)
|
||||
return nullptr;
|
||||
|
||||
int lenMbcs = WideCharToMultiByte(codepage, 0, wcharStr2Convert, lenWc, NULL, 0, NULL, NULL);
|
||||
UINT cp = static_cast<UINT>(codepage);
|
||||
int lenMbcs = WideCharToMultiByte(cp, 0, wcharStr2Convert, lenWc, NULL, 0, NULL, NULL);
|
||||
if (lenMbcs > 0)
|
||||
{
|
||||
_multiByteStr.sizeTo(lenMbcs);
|
||||
WideCharToMultiByte(codepage, 0, wcharStr2Convert, lenWc, _multiByteStr, lenMbcs, NULL, NULL);
|
||||
WideCharToMultiByte(cp, 0, wcharStr2Convert, lenWc, _multiByteStr, lenMbcs, NULL, NULL);
|
||||
}
|
||||
else
|
||||
_multiByteStr.empty();
|
||||
@ -448,21 +449,21 @@ const char* WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UIN
|
||||
}
|
||||
|
||||
|
||||
const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UINT codepage, long *mstart, long *mend)
|
||||
const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, size_t codepage, long *mstart, long *mend)
|
||||
{
|
||||
if (nullptr == wcharStr2Convert)
|
||||
return nullptr;
|
||||
|
||||
int len = WideCharToMultiByte(codepage, 0, wcharStr2Convert, -1, NULL, 0, NULL, NULL);
|
||||
UINT cp = static_cast<UINT>(codepage);
|
||||
int len = WideCharToMultiByte(cp, 0, wcharStr2Convert, -1, NULL, 0, NULL, NULL);
|
||||
if (len > 0)
|
||||
{
|
||||
_multiByteStr.sizeTo(len);
|
||||
len = WideCharToMultiByte(codepage, 0, wcharStr2Convert, -1, _multiByteStr, len, NULL, NULL); // not needed?
|
||||
len = WideCharToMultiByte(cp, 0, wcharStr2Convert, -1, _multiByteStr, len, NULL, NULL); // not needed?
|
||||
|
||||
if (*mstart < lstrlenW(wcharStr2Convert) && *mend < lstrlenW(wcharStr2Convert))
|
||||
{
|
||||
*mstart = WideCharToMultiByte(codepage, 0, wcharStr2Convert, *mstart, NULL, 0, NULL, NULL);
|
||||
*mend = WideCharToMultiByte(codepage, 0, wcharStr2Convert, *mend, NULL, 0, NULL, NULL);
|
||||
*mstart = WideCharToMultiByte(cp, 0, wcharStr2Convert, *mstart, NULL, 0, NULL, NULL);
|
||||
*mend = WideCharToMultiByte(cp, 0, wcharStr2Convert, *mend, NULL, 0, NULL, NULL);
|
||||
if (*mstart >= len || *mend >= len)
|
||||
{
|
||||
*mstart = 0;
|
||||
|
@ -94,12 +94,12 @@ public:
|
||||
return instance;
|
||||
}
|
||||
|
||||
const wchar_t * char2wchar(const char *mbStr, UINT codepage, int lenIn=-1, int *pLenOut=NULL, int *pBytesNotProcessed=NULL);
|
||||
const wchar_t * char2wchar(const char *mbcs2Convert, UINT codepage, int *mstart, int *mend);
|
||||
const char * wchar2char(const wchar_t *wcStr, UINT codepage, int lenIn = -1, int *pLenOut = NULL);
|
||||
const char * wchar2char(const wchar_t *wcStr, UINT codepage, long *mstart, long *mend);
|
||||
const wchar_t * char2wchar(const char *mbStr, size_t codepage, int lenIn=-1, int *pLenOut=NULL, int *pBytesNotProcessed=NULL);
|
||||
const wchar_t * char2wchar(const char *mbcs2Convert, size_t codepage, INT_PTR* mstart, INT_PTR* mend);
|
||||
const char * wchar2char(const wchar_t *wcStr, size_t codepage, int lenIn = -1, int *pLenOut = NULL);
|
||||
const char * wchar2char(const wchar_t *wcStr, size_t codepage, long *mstart, long *mend);
|
||||
|
||||
const char * encode(UINT fromCodepage, UINT toCodepage, const char *txt2Encode, int lenIn=-1, int *pLenOut=NULL, int *pBytesNotProcessed=NULL)
|
||||
const char * encode(UINT fromCodepage, UINT toCodepage, const char *txt2Encode, int lenIn = -1, int *pLenOut=NULL, int *pBytesNotProcessed=NULL)
|
||||
{
|
||||
int lenWc = 0;
|
||||
const wchar_t * strW = char2wchar(txt2Encode, fromCodepage, lenIn, &lenWc, pBytesNotProcessed);
|
||||
|
@ -308,7 +308,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
||||
_mainEditView.performGlobalStyles();
|
||||
_subEditView.performGlobalStyles();
|
||||
|
||||
_zoomOriginalValue = static_cast<int32_t>(_pEditView->execute(SCI_GETZOOM));
|
||||
_zoomOriginalValue = _pEditView->execute(SCI_GETZOOM);
|
||||
_mainEditView.execute(SCI_SETZOOM, svp._zoom);
|
||||
_subEditView.execute(SCI_SETZOOM, svp._zoom2);
|
||||
|
||||
@ -1061,11 +1061,11 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const
|
||||
|
||||
_invisibleEditView.execute(SCI_SETTARGETRANGE, startPos, endPos);
|
||||
|
||||
int posFound = static_cast<int32_t>(_invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(htmlHeaderRegExpr), reinterpret_cast<LPARAM>(htmlHeaderRegExpr)));
|
||||
auto posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(htmlHeaderRegExpr), reinterpret_cast<LPARAM>(htmlHeaderRegExpr));
|
||||
|
||||
if (posFound < 0)
|
||||
{
|
||||
posFound = static_cast<int32_t>(_invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(htmlHeaderRegExpr2), reinterpret_cast<LPARAM>(htmlHeaderRegExpr2)));
|
||||
posFound = _invisibleEditView.execute(SCI_SEARCHINTARGET, strlen(htmlHeaderRegExpr2), reinterpret_cast<LPARAM>(htmlHeaderRegExpr2));
|
||||
if (posFound < 0)
|
||||
return -1;
|
||||
}
|
||||
@ -1093,8 +1093,8 @@ int Notepad_plus::getHtmlXmlEncoding(const TCHAR *fileName) const
|
||||
|
||||
void Notepad_plus::setCodePageForInvisibleView(Buffer const *pBuffer)
|
||||
{
|
||||
int detectedCp = static_cast<int>(_invisibleEditView.execute(SCI_GETCODEPAGE));
|
||||
int cp2set = SC_CP_UTF8;
|
||||
INT_PTR detectedCp = _invisibleEditView.execute(SCI_GETCODEPAGE);
|
||||
INT_PTR cp2set = SC_CP_UTF8;
|
||||
if (pBuffer->getUnicodeMode() == uni8Bit)
|
||||
{
|
||||
cp2set = (detectedCp == SC_CP_UTF8 ? CP_ACP : detectedCp);
|
||||
@ -1186,17 +1186,17 @@ bool Notepad_plus::replaceInOpenedFiles()
|
||||
|
||||
void Notepad_plus::wsTabConvert(spaceTab whichWay)
|
||||
{
|
||||
int tabWidth = static_cast<int32_t>(_pEditView->execute(SCI_GETTABWIDTH));
|
||||
int currentPos = static_cast<int32_t>(_pEditView->execute(SCI_GETCURRENTPOS));
|
||||
int lastLine = _pEditView->lastZeroBasedLineNumber();
|
||||
int docLength = static_cast<int32_t>(_pEditView->execute(SCI_GETLENGTH) + 1);
|
||||
INT_PTR tabWidth = _pEditView->execute(SCI_GETTABWIDTH);
|
||||
INT_PTR currentPos = _pEditView->execute(SCI_GETCURRENTPOS);
|
||||
INT_PTR lastLine = _pEditView->lastZeroBasedLineNumber();
|
||||
INT_PTR docLength = _pEditView->execute(SCI_GETLENGTH) + 1;
|
||||
if (docLength < 2)
|
||||
return;
|
||||
|
||||
int count = 0;
|
||||
int column = 0;
|
||||
int newCurrentPos = 0;
|
||||
int tabStop = static_cast<int32_t>(tabWidth - 1); // remember, counting from zero !
|
||||
INT_PTR count = 0;
|
||||
INT_PTR column = 0;
|
||||
INT_PTR newCurrentPos = 0;
|
||||
INT_PTR tabStop = static_cast<int32_t>(tabWidth - 1); // remember, counting from zero !
|
||||
bool onlyLeading = false;
|
||||
vector<int> bookmarks;
|
||||
vector<int> folding;
|
||||
@ -1249,7 +1249,7 @@ void Notepad_plus::wsTabConvert(spaceTab whichWay)
|
||||
{
|
||||
if (source[i] == '\t')
|
||||
{
|
||||
int insertTabs = tabWidth - (column % tabWidth);
|
||||
INT_PTR insertTabs = tabWidth - (column % tabWidth);
|
||||
for (int j = 0; j < insertTabs; ++j)
|
||||
{
|
||||
*dest++ = ' ';
|
||||
@ -2399,9 +2399,9 @@ generic_string Notepad_plus::getLangDesc(LangType langType, bool getName)
|
||||
|
||||
void Notepad_plus::copyMarkedLines()
|
||||
{
|
||||
int lastLine = _pEditView->lastZeroBasedLineNumber();
|
||||
INT_PTR lastLine = _pEditView->lastZeroBasedLineNumber();
|
||||
generic_string globalStr = TEXT("");
|
||||
for (int i = lastLine ; i >= 0 ; i--)
|
||||
for (INT_PTR i = lastLine ; i >= 0 ; i--)
|
||||
{
|
||||
if (bookmarkPresent(i))
|
||||
{
|
||||
@ -2418,11 +2418,11 @@ void Notepad_plus::cutMarkedLines()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mark_mutex);
|
||||
|
||||
int lastLine = _pEditView->lastZeroBasedLineNumber();
|
||||
INT_PTR lastLine = _pEditView->lastZeroBasedLineNumber();
|
||||
generic_string globalStr = TEXT("");
|
||||
|
||||
_pEditView->execute(SCI_BEGINUNDOACTION);
|
||||
for (int i = lastLine ; i >= 0 ; i--)
|
||||
for (INT_PTR i = lastLine ; i >= 0 ; i--)
|
||||
{
|
||||
if (bookmarkPresent(i))
|
||||
{
|
||||
@ -2440,10 +2440,10 @@ void Notepad_plus::deleteMarkedLines(bool isMarked)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mark_mutex);
|
||||
|
||||
int lastLine = _pEditView->lastZeroBasedLineNumber();
|
||||
INT_PTR lastLine = _pEditView->lastZeroBasedLineNumber();
|
||||
|
||||
_pEditView->execute(SCI_BEGINUNDOACTION);
|
||||
for (int i = lastLine ; i >= 0 ; i--)
|
||||
for (INT_PTR i = lastLine ; i >= 0 ; i--)
|
||||
{
|
||||
if (bookmarkPresent(i) == isMarked)
|
||||
deleteMarkedline(i);
|
||||
@ -2461,7 +2461,7 @@ void Notepad_plus::pasteToMarkedLines()
|
||||
BOOL canPaste = ::IsClipboardFormatAvailable(clipFormat);
|
||||
if (!canPaste)
|
||||
return;
|
||||
int lastLine = _pEditView->lastZeroBasedLineNumber();
|
||||
INT_PTR lastLine = _pEditView->lastZeroBasedLineNumber();
|
||||
|
||||
::OpenClipboard(_pPublicInterface->getHSelf());
|
||||
HANDLE clipboardData = ::GetClipboardData(clipFormat);
|
||||
@ -2475,7 +2475,7 @@ void Notepad_plus::pasteToMarkedLines()
|
||||
::CloseClipboard();
|
||||
|
||||
_pEditView->execute(SCI_BEGINUNDOACTION);
|
||||
for (int i = lastLine ; i >= 0 ; i--)
|
||||
for (INT_PTR i = lastLine ; i >= 0 ; i--)
|
||||
{
|
||||
if (bookmarkPresent(i))
|
||||
{
|
||||
@ -2485,7 +2485,7 @@ void Notepad_plus::pasteToMarkedLines()
|
||||
_pEditView->execute(SCI_ENDUNDOACTION);
|
||||
}
|
||||
|
||||
void Notepad_plus::deleteMarkedline(int ln)
|
||||
void Notepad_plus::deleteMarkedline(size_t ln)
|
||||
{
|
||||
int lineLen = static_cast<int32_t>(_pEditView->execute(SCI_LINELENGTH, ln));
|
||||
int lineBegin = static_cast<int32_t>(_pEditView->execute(SCI_POSITIONFROMLINE, ln));
|
||||
@ -2497,7 +2497,7 @@ void Notepad_plus::deleteMarkedline(int ln)
|
||||
|
||||
void Notepad_plus::inverseMarks()
|
||||
{
|
||||
int lastLine = _pEditView->lastZeroBasedLineNumber();
|
||||
INT_PTR lastLine = _pEditView->lastZeroBasedLineNumber();
|
||||
for (int i = 0 ; i <= lastLine ; ++i)
|
||||
{
|
||||
if (bookmarkPresent(i))
|
||||
@ -2511,7 +2511,7 @@ void Notepad_plus::inverseMarks()
|
||||
}
|
||||
}
|
||||
|
||||
void Notepad_plus::replaceMarkedline(int ln, const TCHAR *str)
|
||||
void Notepad_plus::replaceMarkedline(size_t ln, const TCHAR *str)
|
||||
{
|
||||
int lineBegin = static_cast<int32_t>(_pEditView->execute(SCI_POSITIONFROMLINE, ln));
|
||||
int lineEnd = static_cast<int32_t>(_pEditView->execute(SCI_GETLINEENDPOSITION, ln));
|
||||
@ -2519,7 +2519,7 @@ void Notepad_plus::replaceMarkedline(int ln, const TCHAR *str)
|
||||
_pEditView->replaceTarget(str, lineBegin, lineEnd);
|
||||
}
|
||||
|
||||
generic_string Notepad_plus::getMarkedLine(int ln)
|
||||
generic_string Notepad_plus::getMarkedLine(size_t ln)
|
||||
{
|
||||
auto lineLen = _pEditView->execute(SCI_LINELENGTH, ln);
|
||||
auto lineBegin = _pEditView->execute(SCI_POSITIONFROMLINE, ln);
|
||||
@ -2993,8 +2993,8 @@ void Notepad_plus::addHotSpot(ScintillaEditView* view)
|
||||
pView->execute(SCI_INDICSETFLAGS, URL_INDIC, SC_INDICFLAG_VALUEFORE);
|
||||
}
|
||||
|
||||
int startPos = 0;
|
||||
int endPos = -1;
|
||||
INT_PTR startPos = 0;
|
||||
INT_PTR endPos = -1;
|
||||
pView->getVisibleStartAndEndPosition(&startPos, &endPos);
|
||||
if (startPos >= endPos) return;
|
||||
pView->execute(SCI_SETINDICATORCURRENT, URL_INDIC);
|
||||
@ -3011,7 +3011,7 @@ void Notepad_plus::addHotSpot(ScintillaEditView* view)
|
||||
char *encodedText = new char[endPos - startPos + 1];
|
||||
pView->getText(encodedText, startPos, endPos);
|
||||
TCHAR *wideText = new TCHAR[endPos - startPos + 1];
|
||||
int wideTextLen = MultiByteToWideChar(cp, 0, encodedText, endPos - startPos + 1, (LPWSTR) wideText, endPos - startPos + 1) - 1;
|
||||
int wideTextLen = MultiByteToWideChar(cp, 0, encodedText, static_cast<int>(endPos - startPos + 1), (LPWSTR) wideText, static_cast<int>(endPos - startPos + 1)) - 1;
|
||||
delete[] encodedText;
|
||||
if (wideTextLen > 0)
|
||||
{
|
||||
@ -3098,7 +3098,7 @@ void Notepad_plus::maintainIndentation(TCHAR ch)
|
||||
int eolMode = static_cast<int32_t>((_pEditView->execute(SCI_GETEOLMODE)));
|
||||
int curLine = static_cast<int32_t>((_pEditView->getCurrentLineNumber()));
|
||||
int prevLine = curLine - 1;
|
||||
int indentAmountPrevLine = 0;
|
||||
INT_PTR indentAmountPrevLine = 0;
|
||||
int tabWidth = static_cast<int32_t>(_pEditView->execute(SCI_GETTABWIDTH));
|
||||
|
||||
LangType type = _pEditView->getCurrentBuffer()->getLangType();
|
||||
@ -3747,17 +3747,17 @@ void Notepad_plus::updateStatusBar()
|
||||
|
||||
TCHAR strSel[64];
|
||||
|
||||
int numSelections = static_cast<int>(_pEditView->execute(SCI_GETSELECTIONS));
|
||||
size_t numSelections = _pEditView->execute(SCI_GETSELECTIONS);
|
||||
if (numSelections == 1)
|
||||
{
|
||||
if (_pEditView->execute(SCI_GETSELECTIONEMPTY))
|
||||
{
|
||||
int currPos = static_cast<int>(_pEditView->execute(SCI_GETCURRENTPOS));
|
||||
size_t currPos = _pEditView->execute(SCI_GETCURRENTPOS);
|
||||
wsprintf(strSel, TEXT("Pos : %s"), commafyInt(currPos + 1).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::pair<int, int> oneSelCharsAndLines = _pEditView->getSelectedCharsAndLinesCount();
|
||||
const std::pair<size_t, size_t> oneSelCharsAndLines = _pEditView->getSelectedCharsAndLinesCount();
|
||||
wsprintf(strSel, TEXT("Sel : %s | %s"),
|
||||
commafyInt(oneSelCharsAndLines.first).c_str(),
|
||||
commafyInt(oneSelCharsAndLines.second).c_str());
|
||||
@ -3765,16 +3765,16 @@ void Notepad_plus::updateStatusBar()
|
||||
}
|
||||
else if (_pEditView->execute(SCI_SELECTIONISRECTANGLE))
|
||||
{
|
||||
const std::pair<int, int> rectSelCharsAndLines = _pEditView->getSelectedCharsAndLinesCount();
|
||||
const std::pair<size_t, size_t> rectSelCharsAndLines = _pEditView->getSelectedCharsAndLinesCount();
|
||||
|
||||
bool sameCharCountOnEveryLine = true;
|
||||
int maxLineCharCount = 0;
|
||||
size_t maxLineCharCount = 0;
|
||||
|
||||
for (int sel = 0; sel < numSelections; ++sel)
|
||||
for (size_t sel = 0; sel < numSelections; ++sel)
|
||||
{
|
||||
int start = static_cast<int>(_pEditView->execute(SCI_GETSELECTIONNSTART, sel));
|
||||
int end = static_cast<int>(_pEditView->execute(SCI_GETSELECTIONNEND, sel));
|
||||
int lineCharCount = static_cast<int>(_pEditView->execute(SCI_COUNTCHARACTERS, start, end));
|
||||
size_t start = _pEditView->execute(SCI_GETSELECTIONNSTART, sel);
|
||||
size_t end = _pEditView->execute(SCI_GETSELECTIONNEND, sel);
|
||||
size_t lineCharCount = _pEditView->execute(SCI_COUNTCHARACTERS, start, end);
|
||||
|
||||
if (sel == 0)
|
||||
{
|
||||
@ -3802,7 +3802,7 @@ void Notepad_plus::updateStatusBar()
|
||||
else // multiple stream selections
|
||||
{
|
||||
const int maxSelsToProcessLineCount = 99; // limit the number of selections to process, for performance reasons
|
||||
const std::pair<int, int> multipleSelCharsAndLines = _pEditView->getSelectedCharsAndLinesCount(maxSelsToProcessLineCount);
|
||||
const std::pair<size_t, size_t> multipleSelCharsAndLines = _pEditView->getSelectedCharsAndLinesCount(maxSelsToProcessLineCount);
|
||||
|
||||
wsprintf(strSel, TEXT("Sel %s : %s | %s"),
|
||||
commafyInt(numSelections).c_str(),
|
||||
@ -5042,8 +5042,8 @@ void Notepad_plus::saveScintillasZoom()
|
||||
{
|
||||
NppParameters& nppParam = NppParameters::getInstance();
|
||||
ScintillaViewParams & svp = (ScintillaViewParams &)nppParam.getSVP();
|
||||
svp._zoom = static_cast<int>(_mainEditView.execute(SCI_GETZOOM));
|
||||
svp._zoom2 = static_cast<int>(_subEditView.execute(SCI_GETZOOM));
|
||||
svp._zoom = _mainEditView.execute(SCI_GETZOOM);
|
||||
svp._zoom2 = _subEditView.execute(SCI_GETZOOM);
|
||||
}
|
||||
|
||||
bool Notepad_plus::addCurrentMacro()
|
||||
@ -5147,8 +5147,8 @@ bool Notepad_plus::goToPreviousIndicator(int indicID2Search, bool isWrap) const
|
||||
auto docLen = _pEditView->getCurrentDocLen();
|
||||
|
||||
bool isInIndicator = _pEditView->execute(SCI_INDICATORVALUEAT, indicID2Search, position) != 0;
|
||||
auto posStart = _pEditView->execute(SCI_INDICATORSTART, indicID2Search, position);
|
||||
auto posEnd = _pEditView->execute(SCI_INDICATOREND, indicID2Search, position);
|
||||
size_t posStart = _pEditView->execute(SCI_INDICATORSTART, indicID2Search, position);
|
||||
size_t posEnd = _pEditView->execute(SCI_INDICATOREND, indicID2Search, position);
|
||||
|
||||
// pre-condition
|
||||
if ((posStart == 0) && (posEnd == docLen - 1))
|
||||
@ -5196,12 +5196,12 @@ bool Notepad_plus::goToPreviousIndicator(int indicID2Search, bool isWrap) const
|
||||
|
||||
bool Notepad_plus::goToNextIndicator(int indicID2Search, bool isWrap) const
|
||||
{
|
||||
auto position = _pEditView->execute(SCI_GETCURRENTPOS);
|
||||
int docLen = _pEditView->getCurrentDocLen();
|
||||
size_t position = _pEditView->execute(SCI_GETCURRENTPOS);
|
||||
size_t docLen = _pEditView->getCurrentDocLen();
|
||||
|
||||
bool isInIndicator = _pEditView->execute(SCI_INDICATORVALUEAT, indicID2Search, position) != 0;
|
||||
auto posStart = _pEditView->execute(SCI_INDICATORSTART, indicID2Search, position);
|
||||
auto posEnd = _pEditView->execute(SCI_INDICATOREND, indicID2Search, position);
|
||||
size_t posStart = _pEditView->execute(SCI_INDICATORSTART, indicID2Search, position);
|
||||
size_t posEnd = _pEditView->execute(SCI_INDICATOREND, indicID2Search, position);
|
||||
|
||||
// pre-condition
|
||||
if ((posStart == 0) && (posEnd == docLen - 1))
|
||||
@ -6113,7 +6113,7 @@ std::vector<generic_string> Notepad_plus::loadCommandlineParams(const TCHAR * co
|
||||
generic_string udl = pCmdParams->_udlName;
|
||||
int lineNumber = pCmdParams->_line2go;
|
||||
int columnNumber = pCmdParams->_column2go;
|
||||
int positionNumber = pCmdParams->_pos2go;
|
||||
size_t positionNumber = pCmdParams->_pos2go;
|
||||
bool recursive = pCmdParams->_isRecursive;
|
||||
bool readOnly = pCmdParams->_isReadOnly;
|
||||
bool openFoldersAsWorkspace = pCmdParams->_openFoldersAsWorkspace;
|
||||
@ -6160,7 +6160,7 @@ std::vector<generic_string> Notepad_plus::loadCommandlineParams(const TCHAR * co
|
||||
// make sure not jumping into the middle of a multibyte character
|
||||
// or into the middle of a CR/LF pair for Windows files
|
||||
auto before = _pEditView->execute(SCI_POSITIONBEFORE, positionNumber);
|
||||
positionNumber = static_cast<int>(_pEditView->execute(SCI_POSITIONAFTER, before));
|
||||
positionNumber = _pEditView->execute(SCI_POSITIONAFTER, before);
|
||||
}
|
||||
_pEditView->execute(SCI_GOTOPOS, positionNumber);
|
||||
}
|
||||
@ -7901,10 +7901,10 @@ bool Notepad_plus::undoStreamComment(bool tryBlockComment)
|
||||
//-- First, search all start_comment and end_comment before and after the selectionStart and selectionEnd position.
|
||||
const int iSelStart=0, iSelEnd=1;
|
||||
const size_t N_CMNT = 2;
|
||||
int posStartCommentBefore[N_CMNT], posEndCommentBefore[N_CMNT], posStartCommentAfter[N_CMNT], posEndCommentAfter[N_CMNT];
|
||||
INT_PTR posStartCommentBefore[N_CMNT], posEndCommentBefore[N_CMNT], posStartCommentAfter[N_CMNT], posEndCommentAfter[N_CMNT];
|
||||
bool blnStartCommentBefore[N_CMNT], blnEndCommentBefore[N_CMNT], blnStartCommentAfter[N_CMNT], blnEndCommentAfter[N_CMNT];
|
||||
int posStartComment, posEndComment;
|
||||
int selectionStartMove, selectionEndMove;
|
||||
INT_PTR posStartComment, posEndComment;
|
||||
INT_PTR selectionStartMove, selectionEndMove;
|
||||
int flags;
|
||||
|
||||
//-- Directly use Scintilla-Functions
|
||||
@ -7973,8 +7973,8 @@ bool Notepad_plus::undoStreamComment(bool tryBlockComment)
|
||||
//-- Ok, there are valid start-comment and valid end-comment around the caret-position.
|
||||
// Now, un-comment stream-comment:
|
||||
retVal = true;
|
||||
int startCommentLength = static_cast<int32_t>(start_comment_length);
|
||||
int endCommentLength = static_cast<int32_t>(end_comment_length);
|
||||
INT_PTR startCommentLength = start_comment_length;
|
||||
INT_PTR endCommentLength = end_comment_length;
|
||||
|
||||
//-- First delete end-comment, so that posStartCommentBefore does not change!
|
||||
//-- Get character before end-comment to decide, if there is a white character before the end-comment, which will be removed too!
|
||||
@ -8005,20 +8005,20 @@ bool Notepad_plus::undoStreamComment(bool tryBlockComment)
|
||||
if (selectionStart > posStartComment)
|
||||
{
|
||||
if (selectionStart >= posStartComment+startCommentLength)
|
||||
selectionStartMove = -static_cast<int>(startCommentLength);
|
||||
selectionStartMove = -startCommentLength;
|
||||
else
|
||||
selectionStartMove = -static_cast<int>(selectionStart - posStartComment);
|
||||
selectionStartMove = -selectionStart - posStartComment;
|
||||
}
|
||||
else
|
||||
selectionStartMove = 0;
|
||||
|
||||
// selectionEnd
|
||||
if (selectionEnd >= posEndComment+endCommentLength)
|
||||
selectionEndMove = -static_cast<int>(startCommentLength+endCommentLength);
|
||||
selectionEndMove = -startCommentLength+endCommentLength;
|
||||
else if (selectionEnd <= posEndComment)
|
||||
selectionEndMove = -static_cast<int>(startCommentLength);
|
||||
selectionEndMove = -startCommentLength;
|
||||
else
|
||||
selectionEndMove = -static_cast<int>(startCommentLength + (selectionEnd - posEndComment));
|
||||
selectionEndMove = -startCommentLength + (selectionEnd - posEndComment);
|
||||
|
||||
//-- Reset selection of text without deleted stream-comment-string
|
||||
if (move_caret)
|
||||
|
@ -372,7 +372,7 @@ private:
|
||||
bool _isUDDocked = false;
|
||||
|
||||
trayIconControler* _pTrayIco = nullptr;
|
||||
int _zoomOriginalValue = 0;
|
||||
INT_PTR _zoomOriginalValue = 0;
|
||||
|
||||
Accelerator _accelerator;
|
||||
ScintillaAccelerator _scintaccelerator;
|
||||
@ -509,16 +509,16 @@ private:
|
||||
_pEditView->execute(SCI_MARKERADD, lineno, MARK_BOOKMARK);
|
||||
}
|
||||
|
||||
void bookmarkDelete(int lineno) const {
|
||||
void bookmarkDelete(size_t lineno) const {
|
||||
if (lineno == -1)
|
||||
lineno = static_cast<int32_t>(_pEditView->getCurrentLineNumber());
|
||||
while (bookmarkPresent(lineno))
|
||||
_pEditView->execute(SCI_MARKERDELETE, lineno, MARK_BOOKMARK);
|
||||
}
|
||||
|
||||
bool bookmarkPresent(int lineno) const {
|
||||
bool bookmarkPresent(INT_PTR lineno) const {
|
||||
if (lineno == -1)
|
||||
lineno = static_cast<int32_t>(_pEditView->getCurrentLineNumber());
|
||||
lineno = _pEditView->getCurrentLineNumber();
|
||||
LRESULT state = _pEditView->execute(SCI_MARKERGET, lineno);
|
||||
return ((state & (1 << MARK_BOOKMARK)) != 0);
|
||||
}
|
||||
@ -542,10 +542,10 @@ private:
|
||||
void cutMarkedLines();
|
||||
void deleteMarkedLines(bool isMarked);
|
||||
void pasteToMarkedLines();
|
||||
void deleteMarkedline(int ln);
|
||||
void deleteMarkedline(size_t ln);
|
||||
void inverseMarks();
|
||||
void replaceMarkedline(int ln, const TCHAR *str);
|
||||
generic_string getMarkedLine(int ln);
|
||||
void replaceMarkedline(size_t ln, const TCHAR *str);
|
||||
generic_string getMarkedLine(size_t ln);
|
||||
void findMatchingBracePos(int & braceAtCaret, int & braceOpposite);
|
||||
bool braceMatch();
|
||||
|
||||
|
@ -881,20 +881,21 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
TCHAR str[strSize];
|
||||
TCHAR strLine[strSize];
|
||||
size_t lineNumber;
|
||||
int col;
|
||||
int i;
|
||||
INT_PTR col;
|
||||
int hasSlash;
|
||||
TCHAR *pTchar = reinterpret_cast<TCHAR *>(lParam);
|
||||
|
||||
_pEditView->getGenericSelectedText(str, strSize); // this is either the selected text, or the word under the cursor if there is no selection
|
||||
hasSlash = FALSE;
|
||||
for (i = 0; str[i] != 0; i++) if (CharacterIs(str[i], TEXT("\\/"))) hasSlash = TRUE;
|
||||
for (int i = 0; str[i] != 0; i++)
|
||||
if (CharacterIs(str[i], TEXT("\\/")))
|
||||
hasSlash = TRUE;
|
||||
|
||||
if (hasSlash == FALSE)
|
||||
{
|
||||
// it's not a full file name so try to find the beginning and ending of it
|
||||
int start;
|
||||
int end;
|
||||
INT_PTR start;
|
||||
INT_PTR end;
|
||||
const TCHAR *delimiters;
|
||||
|
||||
lineNumber = _pEditView->getCurrentLineNumber();
|
||||
@ -904,7 +905,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
// find the start
|
||||
start = col;
|
||||
delimiters = TEXT(" \t[(\"<>");
|
||||
while ((start > 0) && (CharacterIs(strLine[start], delimiters) == FALSE)) start--;
|
||||
while ((start > 0) && (CharacterIs(strLine[start], delimiters) == FALSE))
|
||||
start--;
|
||||
|
||||
if (CharacterIs(strLine[start], delimiters)) start++;
|
||||
|
||||
// find the end
|
||||
@ -912,7 +915,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
delimiters = TEXT(" \t:()[]<>\"\r\n");
|
||||
while ((strLine[end] != 0) && (CharacterIs(strLine[end], delimiters) == FALSE)) end++;
|
||||
|
||||
lstrcpyn(str, &strLine[start], end - start + 1);
|
||||
lstrcpyn(str, &strLine[start], static_cast<int>(end - start + 1));
|
||||
}
|
||||
|
||||
if (lstrlen(str) >= int(wParam)) //buffer too small
|
||||
|
@ -359,7 +359,7 @@ void Notepad_plus::command(int id)
|
||||
|
||||
case IDM_EDIT_COPY_LINK:
|
||||
{
|
||||
int startPos = 0, endPos = 0, curPos = 0;
|
||||
size_t startPos = 0, endPos = 0, curPos = 0;
|
||||
if (_pEditView->getIndicatorRange(URL_INDIC, &startPos, &endPos, &curPos))
|
||||
{
|
||||
_pEditView->execute(SCI_SETSEL, startPos, endPos);
|
||||
@ -673,7 +673,7 @@ void Notepad_plus::command(int id)
|
||||
hasLineSelection = selStart != selEnd;
|
||||
if (hasLineSelection)
|
||||
{
|
||||
const pair<int, int> lineRange = _pEditView->getSelectionLinesRange();
|
||||
const pair<size_t, size_t> lineRange = _pEditView->getSelectionLinesRange();
|
||||
// One single line selection is not allowed.
|
||||
if (lineRange.first == lineRange.second)
|
||||
{
|
||||
@ -1427,8 +1427,8 @@ void Notepad_plus::command(int id)
|
||||
if (range.cpMin == range.cpMax)
|
||||
{
|
||||
auto caretPos = _pEditView->execute(SCI_GETCURRENTPOS, 0, 0);
|
||||
range.cpMin = static_cast<int>(_pEditView->execute(SCI_WORDSTARTPOSITION, caretPos, true));
|
||||
range.cpMax = static_cast<int>(_pEditView->execute(SCI_WORDENDPOSITION, caretPos, true));
|
||||
range.cpMin = static_cast<Sci_PositionCR>(_pEditView->execute(SCI_WORDSTARTPOSITION, caretPos, true));
|
||||
range.cpMax = static_cast<Sci_PositionCR>(_pEditView->execute(SCI_WORDENDPOSITION, caretPos, true));
|
||||
}
|
||||
if (range.cpMax > range.cpMin)
|
||||
{
|
||||
@ -1705,11 +1705,11 @@ void Notepad_plus::command(int id)
|
||||
case IDM_EDIT_RMV_TAB:
|
||||
{
|
||||
bool forwards = id == IDM_EDIT_INS_TAB;
|
||||
int selStartPos = static_cast<int>(_pEditView->execute(SCI_GETSELECTIONSTART));
|
||||
int lineNumber = static_cast<int>(_pEditView->execute(SCI_LINEFROMPOSITION, selStartPos));
|
||||
int numSelections = static_cast<int>(_pEditView->execute(SCI_GETSELECTIONS));
|
||||
int selEndPos = static_cast<int>(_pEditView->execute(SCI_GETSELECTIONEND));
|
||||
int selEndLineNumber = static_cast<int>(_pEditView->execute(SCI_LINEFROMPOSITION, selEndPos));
|
||||
size_t selStartPos = _pEditView->execute(SCI_GETSELECTIONSTART);
|
||||
size_t lineNumber = _pEditView->execute(SCI_LINEFROMPOSITION, selStartPos);
|
||||
size_t numSelections = _pEditView->execute(SCI_GETSELECTIONS);
|
||||
size_t selEndPos = _pEditView->execute(SCI_GETSELECTIONEND);
|
||||
size_t selEndLineNumber = _pEditView->execute(SCI_LINEFROMPOSITION, selEndPos);
|
||||
if ((numSelections > 1) || (lineNumber != selEndLineNumber))
|
||||
{
|
||||
// multiple-selection or multi-line selection; use Scintilla SCI_TAB / SCI_BACKTAB behavior
|
||||
@ -1719,10 +1719,10 @@ void Notepad_plus::command(int id)
|
||||
{
|
||||
// zero-length selection (simple single caret) or selected text is all on single line
|
||||
// depart from Scintilla behavior and do it our way
|
||||
int currentIndent = static_cast<int>(_pEditView->execute(SCI_GETLINEINDENTATION, lineNumber));
|
||||
int indentDelta = static_cast<int>(_pEditView->execute(SCI_GETTABWIDTH));
|
||||
size_t currentIndent = _pEditView->execute(SCI_GETLINEINDENTATION, lineNumber);
|
||||
INT_PTR indentDelta = _pEditView->execute(SCI_GETTABWIDTH);
|
||||
if (!forwards) indentDelta = -indentDelta;
|
||||
_pEditView->setLineIndent(lineNumber, currentIndent + indentDelta);
|
||||
_pEditView->setLineIndent(lineNumber, static_cast<INT_PTR>(currentIndent) + indentDelta);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1747,12 +1747,12 @@ void Notepad_plus::command(int id)
|
||||
{
|
||||
if (_pEditView->execute(SCI_GETSELECTIONS) == 1)
|
||||
{
|
||||
pair<int, int> lineRange = _pEditView->getSelectionLinesRange();
|
||||
pair<size_t, size_t> lineRange = _pEditView->getSelectionLinesRange();
|
||||
auto anchorPos = _pEditView->execute(SCI_POSITIONFROMLINE, lineRange.first);
|
||||
auto caretPos = _pEditView->execute(SCI_GETLINEENDPOSITION, lineRange.second);
|
||||
_pEditView->execute(SCI_SETSELECTION, caretPos, anchorPos);
|
||||
_pEditView->execute(SCI_TARGETFROMSELECTION);
|
||||
int edgeMode = static_cast<int>(_pEditView->execute(SCI_GETEDGEMODE));
|
||||
size_t edgeMode = _pEditView->execute(SCI_GETEDGEMODE);
|
||||
if (edgeMode == EDGE_NONE)
|
||||
{
|
||||
_pEditView->execute(SCI_LINESSPLIT, 0);
|
||||
@ -1776,7 +1776,7 @@ void Notepad_plus::command(int id)
|
||||
|
||||
case IDM_EDIT_JOIN_LINES:
|
||||
{
|
||||
const pair<int, int> lineRange = _pEditView->getSelectionLinesRange();
|
||||
const pair<size_t, size_t> lineRange = _pEditView->getSelectionLinesRange();
|
||||
if (lineRange.first != lineRange.second)
|
||||
{
|
||||
auto anchorPos = _pEditView->execute(SCI_POSITIONFROMLINE, lineRange.first);
|
||||
@ -2454,13 +2454,13 @@ void Notepad_plus::command(int id)
|
||||
generic_string nbRangeLabel = pNativeSpeaker->getLocalizedStrFromID("summary-nbrange", TEXT(" ranges"));
|
||||
|
||||
UniMode um = _pEditView->getCurrentBuffer()->getUnicodeMode();
|
||||
auto nbChar = getCurrentDocCharCount(um);
|
||||
size_t nbChar = getCurrentDocCharCount(um);
|
||||
int nbWord = wordCount();
|
||||
auto nbLine = _pEditView->execute(SCI_GETLINECOUNT);
|
||||
auto nbByte = _pEditView->execute(SCI_GETLENGTH);
|
||||
auto nbSel = getSelectedCharNumber(um);
|
||||
auto nbSelByte = getSelectedBytes();
|
||||
auto nbRange = getSelectedAreas();
|
||||
size_t nbLine = _pEditView->execute(SCI_GETLINECOUNT);
|
||||
size_t nbByte = _pEditView->execute(SCI_GETLENGTH);
|
||||
size_t nbSel = getSelectedCharNumber(um);
|
||||
size_t nbSelByte = getSelectedBytes();
|
||||
size_t nbRange = getSelectedAreas();
|
||||
|
||||
characterNumber += nbCharLabel;
|
||||
characterNumber += commafyInt(nbChar).c_str();
|
||||
@ -2471,7 +2471,7 @@ void Notepad_plus::command(int id)
|
||||
characterNumber += TEXT("\r");
|
||||
|
||||
characterNumber += nbLineLabel;
|
||||
characterNumber += commafyInt(static_cast<int>(nbLine)).c_str();
|
||||
characterNumber += commafyInt(nbLine).c_str();
|
||||
characterNumber += TEXT("\r");
|
||||
|
||||
characterNumber += nbByteLabel;
|
||||
@ -2895,7 +2895,7 @@ void Notepad_plus::command(int id)
|
||||
_pEditView->saveCurrentPos();
|
||||
|
||||
// Cut all text
|
||||
int docLen = _pEditView->getCurrentDocLen();
|
||||
size_t docLen = _pEditView->getCurrentDocLen();
|
||||
_pEditView->execute(SCI_COPYRANGE, 0, docLen);
|
||||
_pEditView->execute(SCI_CLEARALL);
|
||||
|
||||
|
@ -2162,14 +2162,14 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session& s
|
||||
if (fileName)
|
||||
{
|
||||
Position position;
|
||||
(childNode->ToElement())->Attribute(TEXT("firstVisibleLine"), &position._firstVisibleLine);
|
||||
(childNode->ToElement())->Attribute(TEXT("xOffset"), &position._xOffset);
|
||||
(childNode->ToElement())->Attribute(TEXT("startPos"), &position._startPos);
|
||||
(childNode->ToElement())->Attribute(TEXT("endPos"), &position._endPos);
|
||||
(childNode->ToElement())->Attribute(TEXT("selMode"), &position._selMode);
|
||||
(childNode->ToElement())->Attribute(TEXT("scrollWidth"), &position._scrollWidth);
|
||||
(childNode->ToElement())->Attribute(TEXT("offset"), &position._offset);
|
||||
(childNode->ToElement())->Attribute(TEXT("wrapCount"), &position._wrapCount);
|
||||
(childNode->ToElement())->Attribute(TEXT("firstVisibleLine"), reinterpret_cast<int*>(&position._firstVisibleLine));
|
||||
(childNode->ToElement())->Attribute(TEXT("xOffset"), reinterpret_cast<int*>(&position._xOffset));
|
||||
(childNode->ToElement())->Attribute(TEXT("startPos"), reinterpret_cast<int*>(&position._startPos));
|
||||
(childNode->ToElement())->Attribute(TEXT("endPos"), reinterpret_cast<int*>(&position._endPos));
|
||||
(childNode->ToElement())->Attribute(TEXT("selMode"), reinterpret_cast<int*>(&position._selMode));
|
||||
(childNode->ToElement())->Attribute(TEXT("scrollWidth"), reinterpret_cast<int*>(&position._scrollWidth));
|
||||
(childNode->ToElement())->Attribute(TEXT("offset"), reinterpret_cast<int*>(&position._offset));
|
||||
(childNode->ToElement())->Attribute(TEXT("wrapCount"), reinterpret_cast<int*>(&position._wrapCount));
|
||||
MapPosition mapPosition;
|
||||
int32_t mapPosVal;
|
||||
const TCHAR *mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapFirstVisibleDisplayLine"), &mapPosVal);
|
||||
@ -3273,14 +3273,14 @@ void NppParameters::writeSession(const Session & session, const TCHAR *fileName)
|
||||
{
|
||||
TiXmlNode *fileNameNode = viewElems[k].viewNode->InsertEndChild(TiXmlElement(TEXT("File")));
|
||||
|
||||
(fileNameNode->ToElement())->SetAttribute(TEXT("firstVisibleLine"), viewSessionFiles[i]._firstVisibleLine);
|
||||
(fileNameNode->ToElement())->SetAttribute(TEXT("xOffset"), viewSessionFiles[i]._xOffset);
|
||||
(fileNameNode->ToElement())->SetAttribute(TEXT("scrollWidth"), viewSessionFiles[i]._scrollWidth);
|
||||
(fileNameNode->ToElement())->SetAttribute(TEXT("startPos"), viewSessionFiles[i]._startPos);
|
||||
(fileNameNode->ToElement())->SetAttribute(TEXT("endPos"), viewSessionFiles[i]._endPos);
|
||||
(fileNameNode->ToElement())->SetAttribute(TEXT("selMode"), viewSessionFiles[i]._selMode);
|
||||
(fileNameNode->ToElement())->SetAttribute(TEXT("offset"), viewSessionFiles[i]._offset);
|
||||
(fileNameNode->ToElement())->SetAttribute(TEXT("wrapCount"), viewSessionFiles[i]._wrapCount);
|
||||
(fileNameNode->ToElement())->SetAttribute(TEXT("firstVisibleLine"), static_cast<int>(viewSessionFiles[i]._firstVisibleLine));
|
||||
(fileNameNode->ToElement())->SetAttribute(TEXT("xOffset"), static_cast<int>(viewSessionFiles[i]._xOffset));
|
||||
(fileNameNode->ToElement())->SetAttribute(TEXT("scrollWidth"), static_cast<int>(viewSessionFiles[i]._scrollWidth));
|
||||
(fileNameNode->ToElement())->SetAttribute(TEXT("startPos"), static_cast<int>(viewSessionFiles[i]._startPos));
|
||||
(fileNameNode->ToElement())->SetAttribute(TEXT("endPos"), static_cast<int>(viewSessionFiles[i]._endPos));
|
||||
(fileNameNode->ToElement())->SetAttribute(TEXT("selMode"), static_cast<int>(viewSessionFiles[i]._selMode));
|
||||
(fileNameNode->ToElement())->SetAttribute(TEXT("offset"), static_cast<int>(viewSessionFiles[i]._offset));
|
||||
(fileNameNode->ToElement())->SetAttribute(TEXT("wrapCount"), static_cast<int>(viewSessionFiles[i]._wrapCount));
|
||||
(fileNameNode->ToElement())->SetAttribute(TEXT("lang"), viewSessionFiles[i]._langName.c_str());
|
||||
(fileNameNode->ToElement())->SetAttribute(TEXT("encoding"), viewSessionFiles[i]._encoding);
|
||||
(fileNameNode->ToElement())->SetAttribute(TEXT("userReadOnly"), (viewSessionFiles[i]._isUserReadOnly && !viewSessionFiles[i]._isMonitoring) ? TEXT("yes") : TEXT("no"));
|
||||
@ -6004,8 +6004,8 @@ bool NppParameters::writeScintillaParams()
|
||||
}
|
||||
(scintNode->ToElement())->SetAttribute(TEXT("isEdgeBgMode"), _svp._isEdgeBgMode ? TEXT("yes") : TEXT("no"));
|
||||
(scintNode->ToElement())->SetAttribute(TEXT("edgeMultiColumnPos"), edgeColumnPosStr);
|
||||
(scintNode->ToElement())->SetAttribute(TEXT("zoom"), _svp._zoom);
|
||||
(scintNode->ToElement())->SetAttribute(TEXT("zoom2"), _svp._zoom2);
|
||||
(scintNode->ToElement())->SetAttribute(TEXT("zoom"), static_cast<int>(_svp._zoom));
|
||||
(scintNode->ToElement())->SetAttribute(TEXT("zoom2"), static_cast<int>(_svp._zoom2));
|
||||
(scintNode->ToElement())->SetAttribute(TEXT("whiteSpaceShow"), _svp._whiteSpaceShow?TEXT("show"):TEXT("hide"));
|
||||
(scintNode->ToElement())->SetAttribute(TEXT("eolShow"), _svp._eolShow?TEXT("show"):TEXT("hide"));
|
||||
(scintNode->ToElement())->SetAttribute(TEXT("borderWidth"), _svp._borderWidth);
|
||||
|
@ -143,14 +143,14 @@ void cutString(const TCHAR *str2cut, std::vector<generic_string> & patternVect);
|
||||
|
||||
struct Position
|
||||
{
|
||||
int _firstVisibleLine = 0;
|
||||
int _startPos = 0;
|
||||
int _endPos = 0;
|
||||
int _xOffset = 0;
|
||||
int _selMode = 0;
|
||||
int _scrollWidth = 1;
|
||||
int _offset = 0;
|
||||
int _wrapCount = 0;
|
||||
size_t _firstVisibleLine = 0;
|
||||
size_t _startPos = 0;
|
||||
size_t _endPos = 0;
|
||||
size_t _xOffset = 0;
|
||||
size_t _selMode = 0;
|
||||
size_t _scrollWidth = 1;
|
||||
size_t _offset = 0;
|
||||
size_t _wrapCount = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -874,8 +874,8 @@ struct ScintillaViewParams
|
||||
bool _isEdgeBgMode = false;
|
||||
|
||||
std::vector<size_t> _edgeMultiColumnPos;
|
||||
int _zoom = 0;
|
||||
int _zoom2 = 0;
|
||||
INT_PTR _zoom = 0;
|
||||
INT_PTR _zoom2 = 0;
|
||||
bool _whiteSpaceShow = false;
|
||||
bool _eolShow = false;
|
||||
int _borderWidth = 2;
|
||||
|
@ -165,7 +165,7 @@ void AutoCompletion::getWordArray(vector<generic_string> & wordArray, TCHAR *beg
|
||||
int flags = SCFIND_WORDSTART | SCFIND_MATCHCASE | SCFIND_REGEXP | SCFIND_POSIX;
|
||||
|
||||
_pEditView->execute(SCI_SETSEARCHFLAGS, flags);
|
||||
int posFind = _pEditView->searchInTarget(expr.c_str(), int(expr.length()), 0, docLength);
|
||||
INT_PTR posFind = _pEditView->searchInTarget(expr.c_str(), expr.length(), 0, docLength);
|
||||
|
||||
while (posFind >= 0)
|
||||
{
|
||||
@ -379,7 +379,7 @@ bool AutoCompletion::showWordComplete(bool autoInsert)
|
||||
|
||||
if (wordArray.size() == 1 && autoInsert)
|
||||
{
|
||||
int replacedLength = _pEditView->replaceTarget(wordArray[0].c_str(), startPos, curPos);
|
||||
INT_PTR replacedLength = _pEditView->replaceTarget(wordArray[0].c_str(), startPos, curPos);
|
||||
_pEditView->execute(SCI_GOTOPOS, startPos + replacedLength);
|
||||
return true;
|
||||
}
|
||||
@ -422,7 +422,7 @@ void AutoCompletion::getCloseTag(char *closeTag, size_t closeTagSize, size_t car
|
||||
if (isHTML)
|
||||
{
|
||||
// Skip if caretPos is within any scripting language
|
||||
int style = static_cast<int>(_pEditView->execute(SCI_GETSTYLEAT, caretPos));
|
||||
size_t style = _pEditView->execute(SCI_GETSTYLEAT, caretPos);
|
||||
if (style >= SCE_HJ_START)
|
||||
return;
|
||||
}
|
||||
@ -442,17 +442,17 @@ void AutoCompletion::getCloseTag(char *closeTag, size_t closeTagSize, size_t car
|
||||
_pEditView->execute(SCI_SETSEARCHFLAGS, flags);
|
||||
TCHAR tag2find[] = TEXT("<[^\\s>]*");
|
||||
|
||||
int targetStart = _pEditView->searchInTarget(tag2find, lstrlen(tag2find), caretPos, 0);
|
||||
INT_PTR targetStart = _pEditView->searchInTarget(tag2find, lstrlen(tag2find), caretPos, 0);
|
||||
|
||||
if (targetStart < 0)
|
||||
return;
|
||||
|
||||
int targetEnd = int(_pEditView->execute(SCI_GETTARGETEND));
|
||||
int foundTextLen = targetEnd - targetStart;
|
||||
INT_PTR targetEnd = _pEditView->execute(SCI_GETTARGETEND);
|
||||
INT_PTR foundTextLen = targetEnd - targetStart;
|
||||
if (foundTextLen < 2) // "<>" will be ignored
|
||||
return;
|
||||
|
||||
if (size_t(foundTextLen) > closeTagSize - 2) // buffer size is not large enough. -2 for '/' & '\0'
|
||||
if (foundTextLen > static_cast<INT_PTR>(closeTagSize) - 2) // buffer size is not large enough. -2 for '/' & '\0'
|
||||
return;
|
||||
|
||||
char tagHead[tagMaxLen];
|
||||
@ -527,7 +527,7 @@ void InsertedMatchedChars::add(MatchedCharInserted mci)
|
||||
// if current pos > matchedStartSybol Pos and current pos is on the same line of matchedStartSybolPos, it'll be checked then removed
|
||||
// otherwise it is just removed
|
||||
// return the pos of matchedEndSybol or -1 if matchedEndSybol not found
|
||||
int InsertedMatchedChars::search(char startChar, char endChar, int posToDetect)
|
||||
INT_PTR InsertedMatchedChars::search(char startChar, char endChar, size_t posToDetect)
|
||||
{
|
||||
if (isEmpty())
|
||||
return -1;
|
||||
@ -542,9 +542,9 @@ int InsertedMatchedChars::search(char startChar, char endChar, int posToDetect)
|
||||
auto startPosLine = _pEditView->execute(SCI_LINEFROMPOSITION, _insertedMatchedChars[i]._pos);
|
||||
if (posToDetectLine == startPosLine)
|
||||
{
|
||||
auto endPos = _pEditView->execute(SCI_GETLINEENDPOSITION, startPosLine);
|
||||
size_t endPos = _pEditView->execute(SCI_GETLINEENDPOSITION, startPosLine);
|
||||
|
||||
for (int j = posToDetect; j <= endPos; ++j)
|
||||
for (auto j = posToDetect; j <= endPos; ++j)
|
||||
{
|
||||
char aChar = static_cast<char>(_pEditView->execute(SCI_GETCHARAT, j));
|
||||
|
||||
@ -581,14 +581,14 @@ int InsertedMatchedChars::search(char startChar, char endChar, int posToDetect)
|
||||
void AutoCompletion::insertMatchedChars(int character, const MatchedPairConf & matchedPairConf)
|
||||
{
|
||||
const vector< pair<char, char> > & matchedPairs = matchedPairConf._matchedPairs;
|
||||
int caretPos = static_cast<int32_t>(_pEditView->execute(SCI_GETCURRENTPOS));
|
||||
size_t caretPos = _pEditView->execute(SCI_GETCURRENTPOS);
|
||||
const char *matchedChars = NULL;
|
||||
|
||||
char charPrev = static_cast<char>(_pEditView->execute(SCI_GETCHARAT, caretPos - 2));
|
||||
char charNext = static_cast<char>(_pEditView->execute(SCI_GETCHARAT, caretPos));
|
||||
|
||||
bool isCharPrevBlank = (charPrev == ' ' || charPrev == '\t' || charPrev == '\n' || charPrev == '\r' || charPrev == '\0');
|
||||
int docLen = _pEditView->getCurrentDocLen();
|
||||
size_t docLen = _pEditView->getCurrentDocLen();
|
||||
bool isCharNextBlank = (charNext == ' ' || charNext == '\t' || charNext == '\n' || charNext == '\r' || caretPos == docLen);
|
||||
bool isCharNextCloseSymbol = (charNext == ')' || charNext == ']' || charNext == '}');
|
||||
bool isInSandwich = (charPrev == '(' && charNext == ')') || (charPrev == '[' && charNext == ']') || (charPrev == '{' && charNext == '}');
|
||||
@ -653,7 +653,7 @@ void AutoCompletion::insertMatchedChars(int character, const MatchedPairConf & m
|
||||
{
|
||||
if (!_insertedMatchedChars.isEmpty())
|
||||
{
|
||||
int pos = _insertedMatchedChars.search('"', static_cast<char>(character), caretPos);
|
||||
INT_PTR pos = _insertedMatchedChars.search('"', static_cast<char>(character), caretPos);
|
||||
if (pos != -1)
|
||||
{
|
||||
_pEditView->execute(SCI_DELETERANGE, pos, 1);
|
||||
@ -677,7 +677,7 @@ void AutoCompletion::insertMatchedChars(int character, const MatchedPairConf & m
|
||||
{
|
||||
if (!_insertedMatchedChars.isEmpty())
|
||||
{
|
||||
int pos = _insertedMatchedChars.search('\'', static_cast<char>(character), caretPos);
|
||||
INT_PTR pos = _insertedMatchedChars.search('\'', static_cast<char>(character), caretPos);
|
||||
if (pos != -1)
|
||||
{
|
||||
_pEditView->execute(SCI_DELETERANGE, pos, 1);
|
||||
@ -733,7 +733,7 @@ void AutoCompletion::insertMatchedChars(int character, const MatchedPairConf & m
|
||||
startChar = '{';
|
||||
}
|
||||
|
||||
int pos = _insertedMatchedChars.search(startChar, static_cast<char>(character), caretPos);
|
||||
INT_PTR pos = _insertedMatchedChars.search(startChar, static_cast<char>(character), caretPos);
|
||||
if (pos != -1)
|
||||
{
|
||||
_pEditView->execute(SCI_DELETERANGE, pos, 1);
|
||||
|
@ -27,8 +27,8 @@ class ScintillaEditView;
|
||||
struct MatchedCharInserted {
|
||||
MatchedCharInserted() = delete;
|
||||
char _c;
|
||||
int _pos;
|
||||
MatchedCharInserted(char c, int pos) : _c(c), _pos(pos) {};
|
||||
size_t _pos;
|
||||
MatchedCharInserted(char c, size_t pos) : _c(c), _pos(pos) {};
|
||||
};
|
||||
|
||||
class InsertedMatchedChars {
|
||||
@ -37,7 +37,7 @@ public:
|
||||
void removeInvalidElements(MatchedCharInserted mci);
|
||||
void add(MatchedCharInserted mci);
|
||||
bool isEmpty() const { return _insertedMatchedChars.size() == 0; };
|
||||
int search(char startChar, char endChar, int posToDetect);
|
||||
INT_PTR search(char startChar, char endChar, size_t posToDetect);
|
||||
|
||||
private:
|
||||
std::vector<MatchedCharInserted> _insertedMatchedChars;
|
||||
|
@ -515,7 +515,7 @@ int Buffer::removeReference(ScintillaEditView * identifier)
|
||||
}
|
||||
|
||||
|
||||
void Buffer::setHideLineChanged(bool isHide, int location)
|
||||
void Buffer::setHideLineChanged(bool isHide, size_t location)
|
||||
{
|
||||
//First run through all docs without removing markers
|
||||
for (int i = 0; i < _references; ++i)
|
||||
@ -937,7 +937,7 @@ bool FileManager::backupCurrentBuffer()
|
||||
|
||||
if (UnicodeConvertor.openFile(fullpath))
|
||||
{
|
||||
int lengthDoc = _pNotepadPlus->_pEditView->getCurrentDocLen();
|
||||
size_t lengthDoc = _pNotepadPlus->_pEditView->getCurrentDocLen();
|
||||
char* buf = (char*)_pNotepadPlus->_pEditView->execute(SCI_GETCHARACTERPOINTER); //to get characters directly from Scintilla buffer
|
||||
boolean isWrittenSuccessful = false;
|
||||
|
||||
@ -950,8 +950,8 @@ bool FileManager::backupCurrentBuffer()
|
||||
else
|
||||
{
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
int grabSize;
|
||||
for (int i = 0; i < lengthDoc; i += grabSize)
|
||||
size_t grabSize;
|
||||
for (size_t i = 0; i < lengthDoc; i += grabSize)
|
||||
{
|
||||
grabSize = lengthDoc - i;
|
||||
if (grabSize > blockSize)
|
||||
@ -959,7 +959,7 @@ bool FileManager::backupCurrentBuffer()
|
||||
|
||||
int newDataLen = 0;
|
||||
int incompleteMultibyteChar = 0;
|
||||
const char *newData = wmc.encode(SC_CP_UTF8, encoding, buf+i, grabSize, &newDataLen, &incompleteMultibyteChar);
|
||||
const char *newData = wmc.encode(SC_CP_UTF8, encoding, buf+i, static_cast<int>(grabSize), &newDataLen, &incompleteMultibyteChar);
|
||||
grabSize -= incompleteMultibyteChar;
|
||||
isWrittenSuccessful = UnicodeConvertor.writeFile(newData, static_cast<unsigned long>(newDataLen));
|
||||
}
|
||||
@ -1063,7 +1063,7 @@ SavingStatus FileManager::saveBuffer(BufferID id, const TCHAR * filename, bool i
|
||||
{
|
||||
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, buffer->_doc); //generate new document
|
||||
|
||||
int lengthDoc = _pscratchTilla->getCurrentDocLen();
|
||||
size_t lengthDoc = _pscratchTilla->getCurrentDocLen();
|
||||
char* buf = (char*)_pscratchTilla->execute(SCI_GETCHARACTERPOINTER); //to get characters directly from Scintilla buffer
|
||||
boolean isWrittenSuccessful = false;
|
||||
|
||||
@ -1082,8 +1082,8 @@ SavingStatus FileManager::saveBuffer(BufferID id, const TCHAR * filename, bool i
|
||||
}
|
||||
else
|
||||
{
|
||||
int grabSize;
|
||||
for (int i = 0; i < lengthDoc; i += grabSize)
|
||||
size_t grabSize;
|
||||
for (size_t i = 0; i < lengthDoc; i += grabSize)
|
||||
{
|
||||
grabSize = lengthDoc - i;
|
||||
if (grabSize > blockSize)
|
||||
@ -1091,7 +1091,7 @@ SavingStatus FileManager::saveBuffer(BufferID id, const TCHAR * filename, bool i
|
||||
|
||||
int newDataLen = 0;
|
||||
int incompleteMultibyteChar = 0;
|
||||
const char* newData = wmc.encode(SC_CP_UTF8, encoding, buf + i, grabSize, &newDataLen, &incompleteMultibyteChar);
|
||||
const char* newData = wmc.encode(SC_CP_UTF8, encoding, buf + i, static_cast<int>(grabSize), &newDataLen, &incompleteMultibyteChar);
|
||||
grabSize -= incompleteMultibyteChar;
|
||||
isWrittenSuccessful = UnicodeConvertor.writeFile(newData, static_cast<unsigned long>(newDataLen));
|
||||
}
|
||||
@ -1342,26 +1342,25 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, char* data,
|
||||
unsigned __int64 fileSize =_ftelli64(fp);
|
||||
rewind(fp);
|
||||
// size/6 is the normal room Scintilla keeps for editing, but here we limit it to 1MiB when loading (maybe we want to load big files without editing them too much)
|
||||
unsigned __int64 bufferSizeRequested = fileSize + min(1<<20,fileSize/6);
|
||||
|
||||
unsigned __int64 bufferSizeRequested = fileSize + min(1<<20, fileSize/6);
|
||||
|
||||
NppParameters& nppParam = NppParameters::getInstance();
|
||||
NativeLangSpeaker* pNativeSpeaker = nppParam.getNativeLangSpeaker();
|
||||
|
||||
// As a 32bit application, we cannot allocate 2 buffer of more than INT_MAX size (it takes the whole address space).
|
||||
// As a 64bit binary, we have more address for the allocation. However loading a 2GB file takes from 3 minutes to 7 minutes, which makes Notepad++ unusable:
|
||||
// https://github.com/notepad-plus-plus/notepad-plus-plus/pull/11044
|
||||
// So here we fix the size limit to 2GB
|
||||
if (bufferSizeRequested > INT_MAX)
|
||||
{
|
||||
pNativeSpeaker->messageBox("FileTooBigToOpen",
|
||||
_pNotepadPlus->_pEditView->getHSelf(),
|
||||
TEXT("File is too big to be opened by Notepad++"),
|
||||
TEXT("File size problem"),
|
||||
MB_OK|MB_APPLMODAL);
|
||||
// As a 32bit application, we cannot allocate 2 buffer of more than INT_MAX size (it takes the whole address space).
|
||||
if (nppParam.archType() == IMAGE_FILE_MACHINE_I386)
|
||||
{
|
||||
pNativeSpeaker->messageBox("FileTooBigToOpen",
|
||||
_pNotepadPlus->_pEditView->getHSelf(),
|
||||
TEXT("File is too big to be opened by Notepad++"),
|
||||
TEXT("File size problem"),
|
||||
MB_OK | MB_APPLMODAL);
|
||||
|
||||
fclose(fp);
|
||||
return false;
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Setup scratchtilla for new filedata
|
||||
@ -1507,6 +1506,7 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, char* data,
|
||||
fileFormat._eolFormat = format;
|
||||
}
|
||||
|
||||
|
||||
_pscratchTilla->execute(SCI_EMPTYUNDOBUFFER);
|
||||
_pscratchTilla->execute(SCI_SETSAVEPOINT);
|
||||
|
||||
@ -1574,11 +1574,11 @@ int FileManager::getFileNameFromBuffer(BufferID id, TCHAR * fn2copy)
|
||||
}
|
||||
|
||||
|
||||
int FileManager::docLength(Buffer* buffer) const
|
||||
size_t FileManager::docLength(Buffer* buffer) const
|
||||
{
|
||||
Document curDoc = _pscratchTilla->execute(SCI_GETDOCPOINTER);
|
||||
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, buffer->_doc);
|
||||
int docLen = _pscratchTilla->getCurrentDocLen();
|
||||
size_t docLen = _pscratchTilla->getCurrentDocLen();
|
||||
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, curDoc);
|
||||
return docLen;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public:
|
||||
return instance;
|
||||
};
|
||||
int getFileNameFromBuffer(BufferID id, TCHAR * fn2copy);
|
||||
int docLength(Buffer * buffer) const;
|
||||
size_t docLength(Buffer * buffer) const;
|
||||
size_t nextUntitledNewNumber() const;
|
||||
|
||||
private:
|
||||
@ -258,14 +258,14 @@ public:
|
||||
int addReference(ScintillaEditView * identifier); //if ID not registered, creates a new Position for that ID and new foldstate
|
||||
int removeReference(ScintillaEditView * identifier); //reduces reference. If zero, Document is purged
|
||||
|
||||
void setHideLineChanged(bool isHide, int location);
|
||||
void setHideLineChanged(bool isHide, size_t location);
|
||||
|
||||
void setDeferredReload();
|
||||
|
||||
bool getNeedReload() const { return _needReloading; }
|
||||
void setNeedReload(bool reload) { _needReloading = reload; }
|
||||
|
||||
int docLength() const {
|
||||
size_t docLength() const {
|
||||
assert(_pManager != nullptr);
|
||||
return _pManager->docLength(_id);
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ bool Searching::readBase(const TCHAR * str, int * value, int base, int size)
|
||||
return true;
|
||||
}
|
||||
|
||||
void Searching::displaySectionCentered(int posStart, int posEnd, ScintillaEditView * pEditView, bool isDownwards)
|
||||
void Searching::displaySectionCentered(size_t posStart, size_t posEnd, ScintillaEditView * pEditView, bool isDownwards)
|
||||
{
|
||||
// Make sure target lines are unfolded
|
||||
pEditView->execute(SCI_ENSUREVISIBLE, pEditView->execute(SCI_LINEFROMPOSITION, posStart));
|
||||
@ -1953,8 +1953,8 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op
|
||||
break;
|
||||
}
|
||||
|
||||
int start, end;
|
||||
int posFind;
|
||||
INT_PTR start, end;
|
||||
INT_PTR posFind;
|
||||
|
||||
// Never allow a zero length match in the middle of a line end marker
|
||||
if ((*_ppEditView)->execute(SCI_GETCHARAT, startPosition - 1) == '\r'
|
||||
@ -2097,8 +2097,8 @@ bool FindReplaceDlg::processReplace(const TCHAR *txt2find, const TCHAR *txt2repl
|
||||
{
|
||||
bool isRegExp = replaceOptions._searchType == FindRegex;
|
||||
|
||||
int start = currentSelection.cpMin;
|
||||
int replacedLen = 0;
|
||||
INT_PTR start = currentSelection.cpMin;
|
||||
INT_PTR replacedLen = 0;
|
||||
if (isRegExp)
|
||||
{
|
||||
replacedLen = (*_ppEditView)->replaceTargetRegExMode(txt2replace);
|
||||
@ -2207,14 +2207,14 @@ int FindReplaceDlg::processAll(ProcessOperation op, const FindOption *opt, bool
|
||||
const TCHAR *txt2replace = pOptions->_str4Replace.c_str();
|
||||
|
||||
Sci_CharacterRange cr = (*_ppEditView)->getSelection();
|
||||
int docLength = int((*_ppEditView)->execute(SCI_GETLENGTH));
|
||||
size_t docLength = (*_ppEditView)->execute(SCI_GETLENGTH);
|
||||
|
||||
// Default :
|
||||
// direction : down
|
||||
// begin at : 0
|
||||
// end at : end of doc
|
||||
int startPosition = 0;
|
||||
int endPosition = docLength;
|
||||
size_t startPosition = 0;
|
||||
size_t endPosition = docLength;
|
||||
|
||||
bool direction = pOptions->_whichDirection;
|
||||
|
||||
@ -2266,7 +2266,7 @@ int FindReplaceDlg::processAll(ProcessOperation op, const FindOption *opt, bool
|
||||
|
||||
if (nbProcessed > 0 && op == ProcessReplaceAll && pOptions->_isInSelection)
|
||||
{
|
||||
int newDocLength = static_cast<int>((*_ppEditView)->execute(SCI_GETLENGTH));
|
||||
size_t newDocLength = (*_ppEditView)->execute(SCI_GETLENGTH);
|
||||
endPosition += newDocLength - docLength;
|
||||
(*_ppEditView)->execute(SCI_SETSELECTION, endPosition, startPosition);
|
||||
(*_ppEditView)->execute(SCI_SCROLLRANGE, startPosition, endPosition);
|
||||
@ -2368,8 +2368,8 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||
}
|
||||
}
|
||||
|
||||
int targetStart = 0;
|
||||
int targetEnd = 0;
|
||||
INT_PTR targetStart = 0;
|
||||
INT_PTR targetEnd = 0;
|
||||
|
||||
//Initial range for searching
|
||||
pEditView->execute(SCI_SETSEARCHFLAGS, flags);
|
||||
@ -2385,7 +2385,7 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||
if (targetStart == -1 || targetStart == -2)
|
||||
break;
|
||||
|
||||
targetEnd = int(pEditView->execute(SCI_GETTARGETEND));
|
||||
targetEnd = pEditView->execute(SCI_GETTARGETEND);
|
||||
|
||||
if (targetEnd > findReplaceInfo._endRange)
|
||||
{
|
||||
@ -2393,8 +2393,8 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||
break;
|
||||
}
|
||||
|
||||
int foundTextLen = targetEnd - targetStart;
|
||||
int replaceDelta = 0;
|
||||
INT_PTR foundTextLen = targetEnd - targetStart;
|
||||
INT_PTR replaceDelta = 0;
|
||||
bool processed = true;
|
||||
|
||||
switch (op)
|
||||
@ -2412,9 +2412,9 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||
}
|
||||
|
||||
auto lineNumber = pEditView->execute(SCI_LINEFROMPOSITION, targetStart);
|
||||
int lend = static_cast<int32_t>(pEditView->execute(SCI_GETLINEENDPOSITION, lineNumber));
|
||||
int lstart = static_cast<int32_t>(pEditView->execute(SCI_POSITIONFROMLINE, lineNumber));
|
||||
int nbChar = lend - lstart;
|
||||
INT_PTR lend = pEditView->execute(SCI_GETLINEENDPOSITION, lineNumber);
|
||||
INT_PTR lstart = pEditView->execute(SCI_POSITIONFROMLINE, lineNumber);
|
||||
INT_PTR nbChar = lend - lstart;
|
||||
|
||||
// use the static buffer
|
||||
TCHAR lineBuf[SC_SEARCHRESULT_LINEBUFFERMAXLENGTH];
|
||||
@ -2422,16 +2422,16 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||
if (nbChar > SC_SEARCHRESULT_LINEBUFFERMAXLENGTH - 3)
|
||||
lend = lstart + SC_SEARCHRESULT_LINEBUFFERMAXLENGTH - 4;
|
||||
|
||||
int start_mark = targetStart - lstart;
|
||||
int end_mark = targetEnd - lstart;
|
||||
INT_PTR start_mark = targetStart - lstart;
|
||||
INT_PTR end_mark = targetEnd - lstart;
|
||||
|
||||
pEditView->getGenericText(lineBuf, SC_SEARCHRESULT_LINEBUFFERMAXLENGTH, lstart, lend, &start_mark, &end_mark);
|
||||
|
||||
generic_string line = lineBuf;
|
||||
line += TEXT("\r\n");
|
||||
SearchResultMarking srm;
|
||||
srm._start = start_mark;
|
||||
srm._end = end_mark;
|
||||
srm._start = static_cast<long>(start_mark);
|
||||
srm._end = static_cast<long>(end_mark);
|
||||
_pFinder->add(FoundInfo(targetStart, targetEnd, lineNumber + 1, pFileName), srm, line.c_str());
|
||||
|
||||
break;
|
||||
@ -2445,9 +2445,9 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||
const TCHAR *pFileName = pFindersInfo->_pFileName ? pFindersInfo->_pFileName : TEXT("");
|
||||
|
||||
auto lineNumber = pEditView->execute(SCI_LINEFROMPOSITION, targetStart);
|
||||
int lend = static_cast<int32_t>(pEditView->execute(SCI_GETLINEENDPOSITION, lineNumber));
|
||||
int lstart = static_cast<int32_t>(pEditView->execute(SCI_POSITIONFROMLINE, lineNumber));
|
||||
int nbChar = lend - lstart;
|
||||
INT_PTR lend = pEditView->execute(SCI_GETLINEENDPOSITION, lineNumber);
|
||||
INT_PTR lstart = pEditView->execute(SCI_POSITIONFROMLINE, lineNumber);
|
||||
INT_PTR nbChar = lend - lstart;
|
||||
|
||||
// use the static buffer
|
||||
TCHAR lineBuf[SC_SEARCHRESULT_LINEBUFFERMAXLENGTH];
|
||||
@ -2455,16 +2455,16 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||
if (nbChar > SC_SEARCHRESULT_LINEBUFFERMAXLENGTH - 3)
|
||||
lend = lstart + SC_SEARCHRESULT_LINEBUFFERMAXLENGTH - 4;
|
||||
|
||||
int start_mark = targetStart - lstart;
|
||||
int end_mark = targetEnd - lstart;
|
||||
INT_PTR start_mark = targetStart - lstart;
|
||||
INT_PTR end_mark = targetEnd - lstart;
|
||||
|
||||
pEditView->getGenericText(lineBuf, SC_SEARCHRESULT_LINEBUFFERMAXLENGTH, lstart, lend, &start_mark, &end_mark);
|
||||
|
||||
generic_string line = lineBuf;
|
||||
line += TEXT("\r\n");
|
||||
SearchResultMarking srm;
|
||||
srm._start = start_mark;
|
||||
srm._end = end_mark;
|
||||
srm._start = static_cast<long>(start_mark);
|
||||
srm._end = static_cast<long>(end_mark);
|
||||
processed = (!pOptions->_isMatchLineNumber) || (pFindersInfo->_pSourceFinder->canFind(pFileName, lineNumber + 1));
|
||||
if (processed)
|
||||
{
|
||||
@ -2480,7 +2480,7 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||
|
||||
case ProcessReplaceAll:
|
||||
{
|
||||
int replacedLength;
|
||||
INT_PTR replacedLength;
|
||||
if (isRegExp)
|
||||
replacedLength = pEditView->replaceTargetRegExMode(pTextReplace);
|
||||
else
|
||||
@ -3629,10 +3629,10 @@ LRESULT FAR PASCAL FindReplaceDlg::comboEditProc(HWND hwnd, UINT message, WPARAM
|
||||
|
||||
if (isDropped && (message == WM_KEYDOWN) && (wParam == VK_DELETE))
|
||||
{
|
||||
int curSel = static_cast<int>(::SendMessage(hwndCombo, CB_GETCURSEL, 0, 0));
|
||||
auto curSel = ::SendMessage(hwndCombo, CB_GETCURSEL, 0, 0);
|
||||
if (curSel != CB_ERR)
|
||||
{
|
||||
int itemsRemaining = static_cast<int>(::SendMessage(hwndCombo, CB_DELETESTRING, curSel, 0));
|
||||
auto itemsRemaining = ::SendMessage(hwndCombo, CB_DELETESTRING, curSel, 0);
|
||||
// if we close the dropdown and reopen it, it will be correctly-sized for remaining items
|
||||
::SendMessage(hwndCombo, CB_SHOWDROPDOWN, FALSE, 0);
|
||||
if (itemsRemaining > 0)
|
||||
@ -4191,7 +4191,7 @@ void Finder::copy()
|
||||
|
||||
size_t fromLine, toLine;
|
||||
{
|
||||
const pair<int, int> lineRange = _scintView.getSelectionLinesRange();
|
||||
const pair<size_t, size_t> lineRange = _scintView.getSelectionLinesRange();
|
||||
fromLine = lineRange.first;
|
||||
toLine = lineRange.second;
|
||||
|
||||
|
@ -39,10 +39,10 @@ enum DIALOG_TYPE {FIND_DLG, REPLACE_DLG, FINDINFILES_DLG, FINDINPROJECTS_DLG, MA
|
||||
enum InWhat{ALL_OPEN_DOCS, FILES_IN_DIR, CURRENT_DOC, CURR_DOC_SELECTION, FILES_IN_PROJECTS};
|
||||
|
||||
struct FoundInfo {
|
||||
FoundInfo(int start, int end, size_t lineNumber, const TCHAR *fullPath)
|
||||
FoundInfo(INT_PTR start, INT_PTR end, size_t lineNumber, const TCHAR *fullPath)
|
||||
: _start(start), _end(end), _lineNumber(lineNumber), _fullPath(fullPath) {};
|
||||
int _start;
|
||||
int _end;
|
||||
INT_PTR _start;
|
||||
INT_PTR _end;
|
||||
size_t _lineNumber;
|
||||
generic_string _fullPath;
|
||||
};
|
||||
@ -91,7 +91,7 @@ public:
|
||||
(option->_searchType == FindRegex ? SCFIND_REGEXP|SCFIND_POSIX : 0) |
|
||||
((option->_searchType == FindRegex && option->_dotMatchesNewline) ? SCFIND_REGEXP_DOTMATCHESNL : 0);
|
||||
};
|
||||
static void displaySectionCentered(int posStart, int posEnd, ScintillaEditView * pEditView, bool isDownwards = true);
|
||||
static void displaySectionCentered(size_t posStart, size_t posEnd, ScintillaEditView * pEditView, bool isDownwards = true);
|
||||
|
||||
private:
|
||||
static bool readBase(const TCHAR * str, int * value, int base, int size);
|
||||
@ -190,8 +190,8 @@ struct FindReplaceInfo
|
||||
{
|
||||
const TCHAR *_txt2find = nullptr;
|
||||
const TCHAR *_txt2replace = nullptr;
|
||||
int _startRange = -1;
|
||||
int _endRange = -1;
|
||||
INT_PTR _startRange = -1;
|
||||
INT_PTR _endRange = -1;
|
||||
};
|
||||
|
||||
struct FindersInfo
|
||||
|
@ -100,13 +100,13 @@ INT_PTR CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
|
||||
}
|
||||
else
|
||||
{
|
||||
int posToGoto = 0;
|
||||
size_t posToGoto = 0;
|
||||
if (line > 0)
|
||||
{
|
||||
// make sure not jumping into the middle of a multibyte character
|
||||
// or into the middle of a CR/LF pair for Windows files
|
||||
auto before = (*_ppEditView)->execute(SCI_POSITIONBEFORE, line);
|
||||
posToGoto = static_cast<int>((*_ppEditView)->execute(SCI_POSITIONAFTER, before));
|
||||
posToGoto = (*_ppEditView)->execute(SCI_POSITIONAFTER, before);
|
||||
}
|
||||
auto sci_line = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, posToGoto);
|
||||
(*_ppEditView)->execute(SCI_ENSUREVISIBLE, sci_line);
|
||||
@ -182,7 +182,7 @@ void GoToLineDlg::updateLinesNumbers() const
|
||||
else
|
||||
{
|
||||
current = static_cast<unsigned int>((*_ppEditView)->execute(SCI_GETCURRENTPOS));
|
||||
int currentDocLength = (*_ppEditView)->getCurrentDocLen();
|
||||
size_t currentDocLength = (*_ppEditView)->getCurrentDocLen();
|
||||
limit = static_cast<unsigned int>(currentDocLength > 0 ? currentDocLength - 1 : 0);
|
||||
}
|
||||
::SetDlgItemInt(_hSelf, ID_CURRLINE, current, FALSE);
|
||||
|
@ -67,11 +67,7 @@ void Printer::init(HINSTANCE hInst, HWND hwnd, ScintillaEditView *pSEView, bool
|
||||
|
||||
|
||||
size_t Printer::doPrint(bool justDoIt)
|
||||
{/*
|
||||
if (!::PrintDlg(&_pdlg))
|
||||
return 0;
|
||||
*/
|
||||
|
||||
{
|
||||
const NppGUI & nppGUI = (NppParameters::getInstance()).getNppGUI();
|
||||
|
||||
POINT ptPage;
|
||||
@ -190,9 +186,9 @@ size_t Printer::doPrint(bool justDoIt)
|
||||
}
|
||||
|
||||
// By default, we will print all the document
|
||||
long lengthPrinted = 0;
|
||||
long lengthDoc = _pSEView->getCurrentDocLen();
|
||||
long lengthDocMax = lengthDoc;
|
||||
size_t lengthPrinted = 0;
|
||||
size_t lengthDoc = _pSEView->getCurrentDocLen();
|
||||
size_t lengthDocMax = lengthDoc;
|
||||
|
||||
// In the case that the print dialog was launched and that there's a range of selection
|
||||
// We print the range of selection
|
||||
@ -200,13 +196,13 @@ size_t Printer::doPrint(bool justDoIt)
|
||||
{
|
||||
if (_startPos > _endPos)
|
||||
{
|
||||
lengthPrinted = static_cast<long>(_endPos);
|
||||
lengthDoc = static_cast<long>(_startPos);
|
||||
lengthPrinted = _endPos;
|
||||
lengthDoc = _startPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
lengthPrinted = static_cast<long>(_startPos);
|
||||
lengthDoc = static_cast<long>(_endPos);
|
||||
lengthPrinted = _startPos;
|
||||
lengthDoc = _endPos;
|
||||
}
|
||||
|
||||
if (lengthPrinted < 0)
|
||||
@ -408,8 +404,8 @@ size_t Printer::doPrint(bool justDoIt)
|
||||
}
|
||||
}
|
||||
|
||||
frPrint.chrg.cpMin = lengthPrinted;
|
||||
frPrint.chrg.cpMax = lengthDoc;
|
||||
frPrint.chrg.cpMin = static_cast<Sci_PositionCR>(lengthPrinted);
|
||||
frPrint.chrg.cpMax = static_cast<Sci_PositionCR>(lengthDoc);
|
||||
lengthPrinted = long(_pSEView->execute(SCI_FORMATRANGE, printPage, reinterpret_cast<LPARAM>(&frPrint)));
|
||||
|
||||
if (printPage)
|
||||
|
@ -386,7 +386,7 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
|
||||
|
||||
if (wParam == IMR_RECONVERTSTRING)
|
||||
{
|
||||
int textLength;
|
||||
INT_PTR textLength;
|
||||
int selectSize;
|
||||
char smallTextBuffer[128];
|
||||
char * selectedStr = smallTextBuffer;
|
||||
@ -398,7 +398,8 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
|
||||
|
||||
// get the codepage of the text
|
||||
|
||||
UINT codepage = static_cast<UINT>(execute(SCI_GETCODEPAGE));
|
||||
size_t cp = execute(SCI_GETCODEPAGE);
|
||||
UINT codepage = static_cast<UINT>(cp);
|
||||
|
||||
// get the current text selection
|
||||
|
||||
@ -441,9 +442,9 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
|
||||
|
||||
// fill the structure
|
||||
reconvert->dwVersion = 0;
|
||||
reconvert->dwStrLen = textLength;
|
||||
reconvert->dwStrLen = static_cast<DWORD>(textLength);
|
||||
reconvert->dwStrOffset = sizeof(RECONVERTSTRING);
|
||||
reconvert->dwCompStrLen = textLength;
|
||||
reconvert->dwCompStrLen = static_cast<DWORD>(textLength);
|
||||
reconvert->dwCompStrOffset = 0;
|
||||
reconvert->dwTargetStrLen = reconvert->dwCompStrLen;
|
||||
reconvert->dwTargetStrOffset = reconvert->dwCompStrOffset;
|
||||
@ -485,8 +486,8 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
|
||||
bool rightClickKeepsSelection = ((NppParameters::getInstance()).getSVP())._rightClickKeepsSelection;
|
||||
if (rightClickKeepsSelection)
|
||||
{
|
||||
int clickX = GET_X_LPARAM(lParam);
|
||||
int marginX = static_cast<int>(execute(SCI_POINTXFROMPOSITION, 0, 0));
|
||||
size_t clickX = GET_X_LPARAM(lParam);
|
||||
size_t marginX = execute(SCI_POINTXFROMPOSITION, 0, 0);
|
||||
if (clickX >= marginX)
|
||||
{
|
||||
// if right-click in the editing area (not the margins!),
|
||||
@ -1763,21 +1764,21 @@ BufferID ScintillaEditView::attachDefaultDoc()
|
||||
void ScintillaEditView::saveCurrentPos()
|
||||
{
|
||||
//Save data so, that the current topline becomes visible again after restoring.
|
||||
int32_t displayedLine = static_cast<int32_t>(execute(SCI_GETFIRSTVISIBLELINE));
|
||||
int32_t docLine = static_cast<int32_t>(execute(SCI_DOCLINEFROMVISIBLE, displayedLine)); //linenumber of the line displayed in the top
|
||||
int32_t offset = displayedLine - static_cast<int32_t>(execute(SCI_VISIBLEFROMDOCLINE, docLine)); //use this to calc offset of wrap. If no wrap this should be zero
|
||||
int wrapCount = static_cast<int32_t>(execute(SCI_WRAPCOUNT, docLine));
|
||||
size_t displayedLine = execute(SCI_GETFIRSTVISIBLELINE);
|
||||
size_t docLine = execute(SCI_DOCLINEFROMVISIBLE, displayedLine); //linenumber of the line displayed in the top
|
||||
size_t offset = displayedLine - execute(SCI_VISIBLEFROMDOCLINE, docLine); //use this to calc offset of wrap. If no wrap this should be zero
|
||||
size_t wrapCount = execute(SCI_WRAPCOUNT, docLine);
|
||||
|
||||
Buffer * buf = MainFileManager.getBufferByID(_currentBufferID);
|
||||
|
||||
Position pos;
|
||||
// the correct visible line number
|
||||
pos._firstVisibleLine = docLine;
|
||||
pos._startPos = static_cast<int>(execute(SCI_GETANCHOR));
|
||||
pos._endPos = static_cast<int>(execute(SCI_GETCURRENTPOS));
|
||||
pos._xOffset = static_cast<int>(execute(SCI_GETXOFFSET));
|
||||
pos._selMode = static_cast<int32_t>(execute(SCI_GETSELECTIONMODE));
|
||||
pos._scrollWidth = static_cast<int32_t>(execute(SCI_GETSCROLLWIDTH));
|
||||
pos._startPos = execute(SCI_GETANCHOR);
|
||||
pos._endPos = execute(SCI_GETCURRENTPOS);
|
||||
pos._xOffset = execute(SCI_GETXOFFSET);
|
||||
pos._selMode = execute(SCI_GETSELECTIONMODE);
|
||||
pos._scrollWidth = execute(SCI_GETSCROLLWIDTH);
|
||||
pos._offset = offset;
|
||||
pos._wrapCount = wrapCount;
|
||||
|
||||
@ -1803,7 +1804,7 @@ void ScintillaEditView::restoreCurrentPosPreStep()
|
||||
execute(SCI_SETXOFFSET, pos._xOffset);
|
||||
}
|
||||
execute(SCI_CHOOSECARETX); // choose current x position
|
||||
int lineToShow = static_cast<int32_t>(execute(SCI_VISIBLEFROMDOCLINE, pos._firstVisibleLine));
|
||||
INT_PTR lineToShow = execute(SCI_VISIBLEFROMDOCLINE, pos._firstVisibleLine);
|
||||
execute(SCI_SETFIRSTVISIBLELINE, lineToShow);
|
||||
if (isWrap())
|
||||
{
|
||||
@ -1837,8 +1838,8 @@ void ScintillaEditView::restoreCurrentPosPostStep()
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t displayedLine = static_cast<int32_t>(execute(SCI_GETFIRSTVISIBLELINE));
|
||||
int32_t docLine = static_cast<int32_t>(execute(SCI_DOCLINEFROMVISIBLE, displayedLine)); //linenumber of the line displayed in the
|
||||
size_t displayedLine = execute(SCI_GETFIRSTVISIBLELINE);
|
||||
size_t docLine = execute(SCI_DOCLINEFROMVISIBLE, displayedLine); //linenumber of the line displayed in the
|
||||
|
||||
|
||||
// check docLine must equals saved position
|
||||
@ -1846,14 +1847,14 @@ void ScintillaEditView::restoreCurrentPosPostStep()
|
||||
{
|
||||
|
||||
// Scintilla has paint the buffer but the position is not correct.
|
||||
int lineToShow = static_cast<int32_t>(execute(SCI_VISIBLEFROMDOCLINE, pos._firstVisibleLine));
|
||||
INT_PTR lineToShow = execute(SCI_VISIBLEFROMDOCLINE, pos._firstVisibleLine);
|
||||
execute(SCI_SETFIRSTVISIBLELINE, lineToShow);
|
||||
}
|
||||
else if (pos._offset > 0)
|
||||
{
|
||||
// don't scroll anything if the wrap count is different than the saved one.
|
||||
// Buffer update may be in progress (in case wrap is enabled)
|
||||
int wrapCount = static_cast<int32_t>(execute(SCI_WRAPCOUNT, docLine));
|
||||
size_t wrapCount = execute(SCI_WRAPCOUNT, docLine);
|
||||
if (wrapCount == pos._wrapCount)
|
||||
{
|
||||
scroll(0, pos._offset);
|
||||
@ -1927,10 +1928,10 @@ void ScintillaEditView::activateBuffer(BufferID buffer)
|
||||
restoreCurrentPosPreStep();
|
||||
|
||||
//setup line number margin
|
||||
int numLines = static_cast<int32_t>(execute(SCI_GETLINECOUNT));
|
||||
INT_PTR numLines = execute(SCI_GETLINECOUNT);
|
||||
|
||||
char numLineStr[32];
|
||||
itoa(numLines, numLineStr, 10);
|
||||
itoa(static_cast<int>(numLines), numLineStr, 10);
|
||||
|
||||
runMarkers(true, 0, true, false);
|
||||
return; //all done
|
||||
@ -1943,7 +1944,7 @@ void ScintillaEditView::getCurrentFoldStates(std::vector<size_t> & lineStateVect
|
||||
size_t contractedFoldHeaderLine = 0;
|
||||
|
||||
do {
|
||||
contractedFoldHeaderLine = static_cast<size_t>(execute(SCI_CONTRACTEDFOLDNEXT, contractedFoldHeaderLine));
|
||||
contractedFoldHeaderLine = execute(SCI_CONTRACTEDFOLDNEXT, contractedFoldHeaderLine);
|
||||
if (contractedFoldHeaderLine != -1)
|
||||
{
|
||||
//-- Store contracted line
|
||||
@ -2032,9 +2033,9 @@ namespace {
|
||||
struct FoldLevelStack
|
||||
{
|
||||
int levelCount = 0; // 1-based level number
|
||||
int levelStack[MAX_FOLD_COLLAPSE_LEVEL]{};
|
||||
INT_PTR levelStack[MAX_FOLD_COLLAPSE_LEVEL]{};
|
||||
|
||||
void push(int level)
|
||||
void push(INT_PTR level)
|
||||
{
|
||||
while (levelCount != 0 && level <= levelStack[levelCount - 1])
|
||||
{
|
||||
@ -2053,12 +2054,12 @@ void ScintillaEditView::collapseFoldIndentationBased(int level2Collapse, bool mo
|
||||
FoldLevelStack levelStack;
|
||||
++level2Collapse; // 1-based level number
|
||||
|
||||
const int maxLine = static_cast<int32_t>(execute(SCI_GETLINECOUNT));
|
||||
int line = 0;
|
||||
const INT_PTR maxLine = execute(SCI_GETLINECOUNT);
|
||||
INT_PTR line = 0;
|
||||
|
||||
while (line < maxLine)
|
||||
{
|
||||
int level = static_cast<int32_t>(execute(SCI_GETFOLDLEVEL, line));
|
||||
INT_PTR level = execute(SCI_GETFOLDLEVEL, line);
|
||||
if (level & SC_FOLDLEVELHEADERFLAG)
|
||||
{
|
||||
level &= SC_FOLDLEVELNUMBERMASK;
|
||||
@ -2071,7 +2072,7 @@ void ScintillaEditView::collapseFoldIndentationBased(int level2Collapse, bool mo
|
||||
fold(line, mode);
|
||||
}
|
||||
// skip all children lines, required to avoid buffer overrun.
|
||||
line = static_cast<int32_t>(execute(SCI_GETLASTCHILD, line, -1));
|
||||
line = execute(SCI_GETLASTCHILD, line, -1);
|
||||
}
|
||||
}
|
||||
++line;
|
||||
@ -2090,11 +2091,11 @@ void ScintillaEditView::collapse(int level2Collapse, bool mode)
|
||||
|
||||
execute(SCI_COLOURISE, 0, -1);
|
||||
|
||||
int maxLine = static_cast<int32_t>(execute(SCI_GETLINECOUNT));
|
||||
INT_PTR maxLine = execute(SCI_GETLINECOUNT);
|
||||
|
||||
for (int line = 0; line < maxLine; ++line)
|
||||
{
|
||||
int level = static_cast<int32_t>(execute(SCI_GETFOLDLEVEL, line));
|
||||
INT_PTR level = execute(SCI_GETFOLDLEVEL, line);
|
||||
if (level & SC_FOLDLEVELHEADERFLAG)
|
||||
{
|
||||
level -= SC_FOLDLEVELBASE;
|
||||
@ -2123,14 +2124,14 @@ void ScintillaEditView::fold(size_t line, bool mode)
|
||||
if (endStyled < len)
|
||||
execute(SCI_COLOURISE, 0, -1);
|
||||
|
||||
int headerLine;
|
||||
INT_PTR headerLine;
|
||||
auto level = execute(SCI_GETFOLDLEVEL, line);
|
||||
|
||||
if (level & SC_FOLDLEVELHEADERFLAG)
|
||||
headerLine = static_cast<int32_t>(line);
|
||||
headerLine = line;
|
||||
else
|
||||
{
|
||||
headerLine = static_cast<int32_t>(execute(SCI_GETFOLDPARENT, line));
|
||||
headerLine = execute(SCI_GETFOLDPARENT, line);
|
||||
if (headerLine == -1)
|
||||
return;
|
||||
}
|
||||
@ -2166,8 +2167,8 @@ void ScintillaEditView::foldAll(bool mode)
|
||||
void ScintillaEditView::getText(char *dest, size_t start, size_t end) const
|
||||
{
|
||||
Sci_TextRange tr;
|
||||
tr.chrg.cpMin = static_cast<long>(start);
|
||||
tr.chrg.cpMax = static_cast<long>(end);
|
||||
tr.chrg.cpMin = static_cast<Sci_PositionCR>(start);
|
||||
tr.chrg.cpMax = static_cast<Sci_PositionCR>(end);
|
||||
tr.lpstrText = dest;
|
||||
execute(SCI_GETTEXTRANGE, 0, reinterpret_cast<LPARAM>(&tr));
|
||||
}
|
||||
@ -2188,7 +2189,7 @@ void ScintillaEditView::getGenericText(TCHAR *dest, size_t destlen, size_t start
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
char *destA = new char[end - start + 1];
|
||||
getText(destA, start, end);
|
||||
UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
|
||||
size_t cp = execute(SCI_GETCODEPAGE);
|
||||
const TCHAR *destW = wmc.char2wchar(destA, cp);
|
||||
_tcsncpy_s(dest, destlen, destW, _TRUNCATE);
|
||||
delete [] destA;
|
||||
@ -2197,12 +2198,12 @@ void ScintillaEditView::getGenericText(TCHAR *dest, size_t destlen, size_t start
|
||||
// "mstart" and "mend" are pointers to indexes in the read string,
|
||||
// which are converted to the corresponding indexes in the returned TCHAR string.
|
||||
|
||||
void ScintillaEditView::getGenericText(TCHAR *dest, size_t destlen, int start, int end, int *mstart, int *mend) const
|
||||
void ScintillaEditView::getGenericText(TCHAR *dest, size_t destlen, size_t start, size_t end, INT_PTR* mstart, INT_PTR* mend) const
|
||||
{
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
char *destA = new char[end - start + 1];
|
||||
getText(destA, start, end);
|
||||
UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE)) ;
|
||||
size_t cp = execute(SCI_GETCODEPAGE) ;
|
||||
const TCHAR *destW = wmc.char2wchar(destA, cp, mstart, mend);
|
||||
_tcsncpy_s(dest, destlen, destW, _TRUNCATE);
|
||||
delete [] destA;
|
||||
@ -2211,7 +2212,7 @@ void ScintillaEditView::getGenericText(TCHAR *dest, size_t destlen, int start, i
|
||||
void ScintillaEditView::insertGenericTextFrom(size_t position, const TCHAR *text2insert) const
|
||||
{
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
|
||||
size_t cp = execute(SCI_GETCODEPAGE);
|
||||
const char *text2insertA = wmc.wchar2char(text2insert, cp);
|
||||
execute(SCI_INSERTTEXT, position, reinterpret_cast<LPARAM>(text2insertA));
|
||||
}
|
||||
@ -2221,7 +2222,7 @@ void ScintillaEditView::replaceSelWith(const char * replaceText)
|
||||
execute(SCI_REPLACESEL, 0, reinterpret_cast<LPARAM>(replaceText));
|
||||
}
|
||||
|
||||
void ScintillaEditView::getVisibleStartAndEndPosition(int * startPos, int * endPos)
|
||||
void ScintillaEditView::getVisibleStartAndEndPosition(INT_PTR* startPos, INT_PTR* endPos)
|
||||
{
|
||||
assert(startPos != NULL && endPos != NULL);
|
||||
// Get the position of the 1st and last showing chars from the edit view
|
||||
@ -2229,24 +2230,24 @@ void ScintillaEditView::getVisibleStartAndEndPosition(int * startPos, int * endP
|
||||
getClientRect(rcEditView);
|
||||
LRESULT pos = execute(SCI_POSITIONFROMPOINT, 0, 0);
|
||||
LRESULT line = execute(SCI_LINEFROMPOSITION, pos);
|
||||
*startPos = static_cast<int32_t>(execute(SCI_POSITIONFROMLINE, line));
|
||||
*startPos = execute(SCI_POSITIONFROMLINE, line);
|
||||
pos = execute(SCI_POSITIONFROMPOINT, rcEditView.right - rcEditView.left, rcEditView.bottom - rcEditView.top);
|
||||
line = execute(SCI_LINEFROMPOSITION, pos);
|
||||
*endPos = static_cast<int32_t>(execute(SCI_GETLINEENDPOSITION, line));
|
||||
*endPos = execute(SCI_GETLINEENDPOSITION, line);
|
||||
}
|
||||
|
||||
char * ScintillaEditView::getWordFromRange(char * txt, int size, int pos1, int pos2)
|
||||
char * ScintillaEditView::getWordFromRange(char * txt, size_t size, size_t pos1, size_t pos2)
|
||||
{
|
||||
if (!size)
|
||||
return NULL;
|
||||
if (pos1 > pos2)
|
||||
{
|
||||
int tmp = pos1;
|
||||
size_t tmp = pos1;
|
||||
pos1 = pos2;
|
||||
pos2 = tmp;
|
||||
}
|
||||
|
||||
if (size < pos2-pos1)
|
||||
if (size < pos2 - pos1)
|
||||
return NULL;
|
||||
|
||||
getText(txt, pos1, pos2);
|
||||
@ -2258,14 +2259,14 @@ char * ScintillaEditView::getWordOnCaretPos(char * txt, int size)
|
||||
if (!size)
|
||||
return NULL;
|
||||
|
||||
pair<int,int> range = getWordRange();
|
||||
pair<size_t, size_t> range = getWordRange();
|
||||
return getWordFromRange(txt, size, range.first, range.second);
|
||||
}
|
||||
|
||||
TCHAR * ScintillaEditView::getGenericWordOnCaretPos(TCHAR * txt, int size)
|
||||
{
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
|
||||
size_t cp = execute(SCI_GETCODEPAGE);
|
||||
char *txtA = new char[size + 1];
|
||||
getWordOnCaretPos(txtA, size);
|
||||
|
||||
@ -2296,7 +2297,7 @@ char * ScintillaEditView::getSelectedText(char * txt, int size, bool expand)
|
||||
TCHAR * ScintillaEditView::getGenericSelectedText(TCHAR * txt, int size, bool expand)
|
||||
{
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
|
||||
size_t cp = execute(SCI_GETCODEPAGE);
|
||||
char *txtA = new char[size + 1];
|
||||
getSelectedText(txtA, size, expand);
|
||||
|
||||
@ -2306,22 +2307,22 @@ TCHAR * ScintillaEditView::getGenericSelectedText(TCHAR * txt, int size, bool ex
|
||||
return txt;
|
||||
}
|
||||
|
||||
int ScintillaEditView::searchInTarget(const TCHAR * text2Find, size_t lenOfText2Find, size_t fromPos, size_t toPos) const
|
||||
INT_PTR ScintillaEditView::searchInTarget(const TCHAR * text2Find, size_t lenOfText2Find, size_t fromPos, size_t toPos) const
|
||||
{
|
||||
execute(SCI_SETTARGETRANGE, fromPos, toPos);
|
||||
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
|
||||
size_t cp = execute(SCI_GETCODEPAGE);
|
||||
const char *text2FindA = wmc.wchar2char(text2Find, cp);
|
||||
size_t text2FindALen = strlen(text2FindA);
|
||||
size_t len = (lenOfText2Find > text2FindALen) ? lenOfText2Find : text2FindALen;
|
||||
return static_cast<int32_t>(execute(SCI_SEARCHINTARGET, len, reinterpret_cast<LPARAM>(text2FindA)));
|
||||
return execute(SCI_SEARCHINTARGET, len, reinterpret_cast<LPARAM>(text2FindA));
|
||||
}
|
||||
|
||||
void ScintillaEditView::appandGenericText(const TCHAR * text2Append) const
|
||||
{
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
|
||||
size_t cp = execute(SCI_GETCODEPAGE);
|
||||
const char *text2AppendA =wmc.wchar2char(text2Append, cp);
|
||||
execute(SCI_APPENDTEXT, strlen(text2AppendA), reinterpret_cast<LPARAM>(text2AppendA));
|
||||
}
|
||||
@ -2329,7 +2330,7 @@ void ScintillaEditView::appandGenericText(const TCHAR * text2Append) const
|
||||
void ScintillaEditView::addGenericText(const TCHAR * text2Append) const
|
||||
{
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
|
||||
size_t cp = execute(SCI_GETCODEPAGE);
|
||||
const char *text2AppendA =wmc.wchar2char(text2Append, cp);
|
||||
execute(SCI_ADDTEXT, strlen(text2AppendA), reinterpret_cast<LPARAM>(text2AppendA));
|
||||
}
|
||||
@ -2337,76 +2338,76 @@ void ScintillaEditView::addGenericText(const TCHAR * text2Append) const
|
||||
void ScintillaEditView::addGenericText(const TCHAR * text2Append, long *mstart, long *mend) const
|
||||
{
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
|
||||
size_t cp = execute(SCI_GETCODEPAGE);
|
||||
const char *text2AppendA =wmc.wchar2char(text2Append, cp, mstart, mend);
|
||||
execute(SCI_ADDTEXT, strlen(text2AppendA), reinterpret_cast<LPARAM>(text2AppendA));
|
||||
}
|
||||
|
||||
int32_t ScintillaEditView::replaceTarget(const TCHAR * str2replace, int fromTargetPos, int toTargetPos) const
|
||||
INT_PTR ScintillaEditView::replaceTarget(const TCHAR * str2replace, INT_PTR fromTargetPos, INT_PTR toTargetPos) const
|
||||
{
|
||||
if (fromTargetPos != -1 || toTargetPos != -1)
|
||||
{
|
||||
execute(SCI_SETTARGETRANGE, fromTargetPos, toTargetPos);
|
||||
}
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
|
||||
size_t cp = execute(SCI_GETCODEPAGE);
|
||||
const char *str2replaceA = wmc.wchar2char(str2replace, cp);
|
||||
return static_cast<int32_t>(execute(SCI_REPLACETARGET, static_cast<WPARAM>(-1), reinterpret_cast<LPARAM>(str2replaceA)));
|
||||
return execute(SCI_REPLACETARGET, static_cast<WPARAM>(-1), reinterpret_cast<LPARAM>(str2replaceA));
|
||||
}
|
||||
|
||||
int ScintillaEditView::replaceTargetRegExMode(const TCHAR * re, int fromTargetPos, int toTargetPos) const
|
||||
INT_PTR ScintillaEditView::replaceTargetRegExMode(const TCHAR * re, INT_PTR fromTargetPos, INT_PTR toTargetPos) const
|
||||
{
|
||||
if (fromTargetPos != -1 || toTargetPos != -1)
|
||||
{
|
||||
execute(SCI_SETTARGETRANGE, fromTargetPos, toTargetPos);
|
||||
}
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
|
||||
size_t cp = execute(SCI_GETCODEPAGE);
|
||||
const char *reA = wmc.wchar2char(re, cp);
|
||||
return static_cast<int32_t>(execute(SCI_REPLACETARGETRE, static_cast<WPARAM>(-1), reinterpret_cast<LPARAM>(reA)));
|
||||
return execute(SCI_REPLACETARGETRE, static_cast<WPARAM>(-1), reinterpret_cast<LPARAM>(reA));
|
||||
}
|
||||
|
||||
void ScintillaEditView::showAutoComletion(size_t lenEntered, const TCHAR* list)
|
||||
{
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
|
||||
size_t cp = execute(SCI_GETCODEPAGE);
|
||||
const char *listA = wmc.wchar2char(list, cp);
|
||||
execute(SCI_AUTOCSHOW, lenEntered, reinterpret_cast<LPARAM>(listA));
|
||||
}
|
||||
|
||||
void ScintillaEditView::showCallTip(int startPos, const TCHAR * def)
|
||||
void ScintillaEditView::showCallTip(size_t startPos, const TCHAR * def)
|
||||
{
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
|
||||
size_t cp = execute(SCI_GETCODEPAGE);
|
||||
const char *defA = wmc.wchar2char(def, cp);
|
||||
execute(SCI_CALLTIPSHOW, startPos, reinterpret_cast<LPARAM>(defA));
|
||||
}
|
||||
|
||||
generic_string ScintillaEditView::getLine(size_t lineNumber)
|
||||
{
|
||||
int32_t lineLen = static_cast<int32_t>(execute(SCI_LINELENGTH, lineNumber));
|
||||
const int bufSize = lineLen + 1;
|
||||
size_t lineLen = execute(SCI_LINELENGTH, lineNumber);
|
||||
const size_t bufSize = lineLen + 1;
|
||||
std::unique_ptr<TCHAR[]> buf = std::make_unique<TCHAR[]>(bufSize);
|
||||
getLine(lineNumber, buf.get(), bufSize);
|
||||
return buf.get();
|
||||
}
|
||||
|
||||
void ScintillaEditView::getLine(size_t lineNumber, TCHAR * line, int lineBufferLen)
|
||||
void ScintillaEditView::getLine(size_t lineNumber, TCHAR * line, size_t lineBufferLen)
|
||||
{
|
||||
// make sure the buffer length is enough to get the whole line
|
||||
auto lineLen = execute(SCI_LINELENGTH, lineNumber);
|
||||
size_t lineLen = execute(SCI_LINELENGTH, lineNumber);
|
||||
if (lineLen >= lineBufferLen)
|
||||
return;
|
||||
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
|
||||
size_t cp = execute(SCI_GETCODEPAGE);
|
||||
char *lineA = new char[lineBufferLen];
|
||||
// From Scintilla documentation for SCI_GETLINE: "The buffer is not terminated by a 0 character."
|
||||
memset(lineA, 0x0, sizeof(char) * lineBufferLen);
|
||||
|
||||
execute(SCI_GETLINE, lineNumber, reinterpret_cast<LPARAM>(lineA));
|
||||
const TCHAR *lineW = wmc.char2wchar(lineA, cp);
|
||||
lstrcpyn(line, lineW, lineBufferLen);
|
||||
lstrcpyn(line, lineW, static_cast<int>(lineBufferLen));
|
||||
delete [] lineA;
|
||||
}
|
||||
|
||||
@ -2419,7 +2420,7 @@ void ScintillaEditView::beginOrEndSelect()
|
||||
{
|
||||
if (_beginSelectPosition == -1)
|
||||
{
|
||||
_beginSelectPosition = static_cast<int32_t>(execute(SCI_GETCURRENTPOS));
|
||||
_beginSelectPosition = execute(SCI_GETCURRENTPOS);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2449,12 +2450,12 @@ void ScintillaEditView::showMargin(int whichMarge, bool willBeShowed)
|
||||
|
||||
void ScintillaEditView::updateBeginEndSelectPosition(bool is_insert, size_t position, size_t length)
|
||||
{
|
||||
if (_beginSelectPosition != -1 && static_cast<long long>(position) < _beginSelectPosition - 1)
|
||||
if (_beginSelectPosition != -1 && static_cast<INT_PTR>(position) < _beginSelectPosition - 1)
|
||||
{
|
||||
if (is_insert)
|
||||
_beginSelectPosition += static_cast<long long>(length);
|
||||
_beginSelectPosition += length;
|
||||
else
|
||||
_beginSelectPosition -= static_cast<long long>(length);
|
||||
_beginSelectPosition -= length;
|
||||
|
||||
assert(_beginSelectPosition >= 0);
|
||||
}
|
||||
@ -2463,7 +2464,7 @@ void ScintillaEditView::updateBeginEndSelectPosition(bool is_insert, size_t posi
|
||||
void ScintillaEditView::marginClick(Sci_Position position, int modifiers)
|
||||
{
|
||||
size_t lineClick = execute(SCI_LINEFROMPOSITION, position, 0);
|
||||
int levelClick = int(execute(SCI_GETFOLDLEVEL, lineClick, 0));
|
||||
INT_PTR levelClick = execute(SCI_GETFOLDLEVEL, lineClick, 0);
|
||||
if (levelClick & SC_FOLDLEVELHEADERFLAG)
|
||||
{
|
||||
if (modifiers & SCMOD_SHIFT)
|
||||
@ -2497,7 +2498,7 @@ void ScintillaEditView::marginClick(Sci_Position position, int modifiers)
|
||||
}
|
||||
}
|
||||
|
||||
void ScintillaEditView::expand(size_t& line, bool doExpand, bool force, int visLevels, int level)
|
||||
void ScintillaEditView::expand(size_t& line, bool doExpand, bool force, INT_PTR visLevels, INT_PTR level)
|
||||
{
|
||||
size_t lineMaxSubord = execute(SCI_GETLASTCHILD, line, level & SC_FOLDLEVELNUMBERMASK);
|
||||
++line;
|
||||
@ -2513,9 +2514,9 @@ void ScintillaEditView::expand(size_t& line, bool doExpand, bool force, int visL
|
||||
execute(SCI_SHOWLINES, line, line);
|
||||
}
|
||||
|
||||
int levelLine = level;
|
||||
INT_PTR levelLine = level;
|
||||
if (levelLine == -1)
|
||||
levelLine = int(execute(SCI_GETFOLDLEVEL, line, 0));
|
||||
levelLine = execute(SCI_GETFOLDLEVEL, line, 0);
|
||||
|
||||
if (levelLine & SC_FOLDLEVELHEADERFLAG)
|
||||
{
|
||||
@ -2650,44 +2651,42 @@ void ScintillaEditView::showIndentGuideLine(bool willBeShowed)
|
||||
execute(SCI_SETINDENTATIONGUIDES, willBeShowed ? docIndentMode : SC_IV_NONE);
|
||||
}
|
||||
|
||||
void ScintillaEditView::setLineIndent(int line, int indent) const
|
||||
void ScintillaEditView::setLineIndent(size_t line, size_t indent) const
|
||||
{
|
||||
if (indent < 0)
|
||||
return;
|
||||
Sci_CharacterRange crange = getSelection();
|
||||
int posBefore = static_cast<int32_t>(execute(SCI_GETLINEINDENTPOSITION, line));
|
||||
size_t posBefore = execute(SCI_GETLINEINDENTPOSITION, line);
|
||||
execute(SCI_SETLINEINDENTATION, line, indent);
|
||||
int32_t posAfter = static_cast<int32_t>(execute(SCI_GETLINEINDENTPOSITION, line));
|
||||
int posDifference = posAfter - posBefore;
|
||||
size_t posAfter = execute(SCI_GETLINEINDENTPOSITION, line);
|
||||
long long posDifference = posAfter - posBefore;
|
||||
if (posAfter > posBefore)
|
||||
{
|
||||
// Move selection on
|
||||
if (crange.cpMin >= posBefore)
|
||||
if (crange.cpMin >= static_cast<Sci_PositionCR>(posBefore))
|
||||
{
|
||||
crange.cpMin += posDifference;
|
||||
crange.cpMin += static_cast<Sci_PositionCR>(posDifference);
|
||||
}
|
||||
if (crange.cpMax >= posBefore)
|
||||
if (crange.cpMax >= static_cast<Sci_PositionCR>(posBefore))
|
||||
{
|
||||
crange.cpMax += posDifference;
|
||||
crange.cpMax += static_cast<Sci_PositionCR>(posDifference);
|
||||
}
|
||||
}
|
||||
else if (posAfter < posBefore)
|
||||
{
|
||||
// Move selection back
|
||||
if (crange.cpMin >= posAfter)
|
||||
if (crange.cpMin >= static_cast<Sci_PositionCR>(posAfter))
|
||||
{
|
||||
if (crange.cpMin >= posBefore)
|
||||
crange.cpMin += posDifference;
|
||||
if (crange.cpMin >= static_cast<Sci_PositionCR>(posBefore))
|
||||
crange.cpMin += static_cast<Sci_PositionCR>(posDifference);
|
||||
else
|
||||
crange.cpMin = posAfter;
|
||||
crange.cpMin = static_cast<Sci_PositionCR>(posAfter);
|
||||
}
|
||||
|
||||
if (crange.cpMax >= posAfter)
|
||||
if (crange.cpMax >= static_cast<Sci_PositionCR>(posAfter))
|
||||
{
|
||||
if (crange.cpMax >= posBefore)
|
||||
crange.cpMax += posDifference;
|
||||
if (crange.cpMax >= static_cast<Sci_PositionCR>(posBefore))
|
||||
crange.cpMax += static_cast<Sci_PositionCR>(posDifference);
|
||||
else
|
||||
crange.cpMax = posAfter;
|
||||
crange.cpMax = static_cast<Sci_PositionCR>(posAfter);
|
||||
}
|
||||
}
|
||||
execute(SCI_SETSEL, crange.cpMin, crange.cpMax);
|
||||
@ -2744,51 +2743,49 @@ void ScintillaEditView::setMultiSelections(const ColumnModeInfos & cmi)
|
||||
{
|
||||
if (cmi[i].isValid())
|
||||
{
|
||||
int selStart = cmi[i]._direction == L2R?cmi[i]._selLpos:cmi[i]._selRpos;
|
||||
int selEnd = cmi[i]._direction == L2R?cmi[i]._selRpos:cmi[i]._selLpos;
|
||||
INT_PTR selStart = cmi[i]._direction == L2R?cmi[i]._selLpos:cmi[i]._selRpos;
|
||||
INT_PTR selEnd = cmi[i]._direction == L2R?cmi[i]._selRpos:cmi[i]._selLpos;
|
||||
execute(SCI_SETSELECTIONNSTART, i, selStart);
|
||||
execute(SCI_SETSELECTIONNEND, i, selEnd);
|
||||
}
|
||||
//if (cmi[i].hasVirtualSpace())
|
||||
//{
|
||||
|
||||
if (cmi[i]._nbVirtualAnchorSpc)
|
||||
execute(SCI_SETSELECTIONNANCHORVIRTUALSPACE, i, cmi[i]._nbVirtualAnchorSpc);
|
||||
if (cmi[i]._nbVirtualCaretSpc)
|
||||
execute(SCI_SETSELECTIONNCARETVIRTUALSPACE, i, cmi[i]._nbVirtualCaretSpc);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
// Get selection range (fromLine, toLine) for the specified selection
|
||||
// specify selectionNumber = -1 for the MAIN selection
|
||||
pair<int, int> ScintillaEditView::getSelectionLinesRange(int selectionNumber /* = -1 */) const
|
||||
pair<size_t, size_t> ScintillaEditView::getSelectionLinesRange(INT_PTR selectionNumber /* = -1 */) const
|
||||
{
|
||||
int numSelections = static_cast<int>(execute(SCI_GETSELECTIONS));
|
||||
size_t numSelections = execute(SCI_GETSELECTIONS);
|
||||
|
||||
int start_pos, end_pos;
|
||||
size_t start_pos, end_pos;
|
||||
|
||||
if ((selectionNumber < 0) || (selectionNumber >= numSelections))
|
||||
if ((selectionNumber < 0) || (static_cast<size_t>(selectionNumber) >= numSelections))
|
||||
{
|
||||
start_pos = static_cast<int>(execute(SCI_GETSELECTIONSTART));
|
||||
end_pos = static_cast<int>(execute(SCI_GETSELECTIONEND));
|
||||
start_pos = execute(SCI_GETSELECTIONSTART);
|
||||
end_pos = execute(SCI_GETSELECTIONEND);
|
||||
}
|
||||
else
|
||||
{
|
||||
start_pos = static_cast<int>(execute(SCI_GETSELECTIONNSTART, selectionNumber));
|
||||
end_pos = static_cast<int>(execute(SCI_GETSELECTIONNEND, selectionNumber));
|
||||
start_pos = execute(SCI_GETSELECTIONNSTART, selectionNumber);
|
||||
end_pos = execute(SCI_GETSELECTIONNEND, selectionNumber);
|
||||
}
|
||||
|
||||
int line1 = static_cast<int>(execute(SCI_LINEFROMPOSITION, start_pos));
|
||||
int line2 = static_cast<int>(execute(SCI_LINEFROMPOSITION, end_pos));
|
||||
size_t line1 = execute(SCI_LINEFROMPOSITION, start_pos);
|
||||
size_t line2 = execute(SCI_LINEFROMPOSITION, end_pos);
|
||||
|
||||
if ((line1 != line2) && (execute(SCI_POSITIONFROMLINE, line2) == end_pos))
|
||||
if ((line1 != line2) && (static_cast<size_t>(execute(SCI_POSITIONFROMLINE, line2)) == end_pos))
|
||||
{
|
||||
// if the end of the selection includes the line-ending,
|
||||
// then don't include the following line in the range
|
||||
--line2;
|
||||
}
|
||||
|
||||
return pair<int, int>(line1, line2);
|
||||
return pair<size_t, size_t>(line1, line2);
|
||||
}
|
||||
|
||||
void ScintillaEditView::currentLinesUp() const
|
||||
@ -2941,19 +2938,19 @@ void ScintillaEditView::convertSelectedTextTo(const TextCase & caseToConvert)
|
||||
|
||||
for (size_t i = 0, cmiLen = cmi.size(); i < cmiLen ; ++i)
|
||||
{
|
||||
const int len = cmi[i]._selRpos - cmi[i]._selLpos;
|
||||
const INT_PTR len = cmi[i]._selRpos - cmi[i]._selLpos;
|
||||
char *srcStr = new char[len+1];
|
||||
wchar_t *destStr = new wchar_t[len+1];
|
||||
|
||||
int start = cmi[i]._selLpos;
|
||||
int end = cmi[i]._selRpos;
|
||||
INT_PTR start = cmi[i]._selLpos;
|
||||
INT_PTR end = cmi[i]._selRpos;
|
||||
getText(srcStr, start, end);
|
||||
|
||||
int nbChar = ::MultiByteToWideChar(codepage, 0, srcStr, len, destStr, len);
|
||||
int nbChar = ::MultiByteToWideChar(codepage, 0, srcStr, (int)len, destStr, (int)len);
|
||||
|
||||
changeCase(destStr, nbChar, caseToConvert);
|
||||
|
||||
::WideCharToMultiByte(codepage, 0, destStr, len, srcStr, len, NULL, NULL);
|
||||
::WideCharToMultiByte(codepage, 0, destStr, (int)len, srcStr, (int)len, NULL, NULL);
|
||||
|
||||
execute(SCI_SETTARGETRANGE, start, end);
|
||||
execute(SCI_REPLACETARGET, static_cast<WPARAM>(-1), reinterpret_cast<LPARAM>(srcStr));
|
||||
@ -2971,21 +2968,21 @@ void ScintillaEditView::convertSelectedTextTo(const TextCase & caseToConvert)
|
||||
size_t selectionStart = execute(SCI_GETSELECTIONSTART);
|
||||
size_t selectionEnd = execute(SCI_GETSELECTIONEND);
|
||||
|
||||
int32_t strLen = static_cast<int32_t>(selectionEnd - selectionStart);
|
||||
size_t strLen = selectionEnd - selectionStart;
|
||||
if (strLen)
|
||||
{
|
||||
int strSize = strLen + 1;
|
||||
size_t strSize = strLen + 1;
|
||||
char *selectedStr = new char[strSize];
|
||||
int strWSize = strSize * 2;
|
||||
size_t strWSize = strSize * 2;
|
||||
wchar_t *selectedStrW = new wchar_t[strWSize+3];
|
||||
|
||||
execute(SCI_GETSELTEXT, 0, reinterpret_cast<LPARAM>(selectedStr));
|
||||
|
||||
int nbChar = ::MultiByteToWideChar(codepage, 0, selectedStr, strSize, selectedStrW, strWSize);
|
||||
int nbChar = ::MultiByteToWideChar(codepage, 0, selectedStr, static_cast<int>(strSize), selectedStrW, static_cast<int>(strWSize));
|
||||
|
||||
changeCase(selectedStrW, nbChar, caseToConvert);
|
||||
|
||||
::WideCharToMultiByte(codepage, 0, selectedStrW, strWSize, selectedStr, strSize, NULL, NULL);
|
||||
::WideCharToMultiByte(codepage, 0, selectedStrW, static_cast<int>(strWSize), selectedStr, static_cast<int>(strSize), NULL, NULL);
|
||||
|
||||
execute(SCI_SETTARGETRANGE, selectionStart, selectionEnd);
|
||||
execute(SCI_REPLACETARGET, strLen, reinterpret_cast<LPARAM>(selectedStr));
|
||||
@ -2996,18 +2993,17 @@ void ScintillaEditView::convertSelectedTextTo(const TextCase & caseToConvert)
|
||||
}
|
||||
|
||||
|
||||
|
||||
pair<int, int> ScintillaEditView::getWordRange()
|
||||
pair<size_t, size_t> ScintillaEditView::getWordRange()
|
||||
{
|
||||
auto caretPos = execute(SCI_GETCURRENTPOS, 0, 0);
|
||||
int startPos = static_cast<int>(execute(SCI_WORDSTARTPOSITION, caretPos, true));
|
||||
int endPos = static_cast<int>(execute(SCI_WORDENDPOSITION, caretPos, true));
|
||||
return pair<int, int>(startPos, endPos);
|
||||
size_t caretPos = execute(SCI_GETCURRENTPOS, 0, 0);
|
||||
size_t startPos = execute(SCI_WORDSTARTPOSITION, caretPos, true);
|
||||
size_t endPos = execute(SCI_WORDENDPOSITION, caretPos, true);
|
||||
return pair<size_t, size_t>(startPos, endPos);
|
||||
}
|
||||
|
||||
bool ScintillaEditView::expandWordSelection()
|
||||
{
|
||||
pair<int, int> wordRange = getWordRange();
|
||||
pair<size_t, size_t> wordRange = getWordRange();
|
||||
if (wordRange.first != wordRange.second)
|
||||
{
|
||||
execute(SCI_SETSELECTIONSTART, wordRange.first);
|
||||
@ -3082,14 +3078,14 @@ ColumnModeInfos ScintillaEditView::getColumnModeSelectInfo()
|
||||
ColumnModeInfos columnModeInfos;
|
||||
if (execute(SCI_GETSELECTIONS) > 1) // Multi-Selection || Column mode
|
||||
{
|
||||
int nbSel = static_cast<int32_t>(execute(SCI_GETSELECTIONS));
|
||||
INT_PTR nbSel = execute(SCI_GETSELECTIONS);
|
||||
|
||||
for (int i = 0 ; i < nbSel ; ++i)
|
||||
{
|
||||
int absPosSelStartPerLine = static_cast<int32_t>(execute(SCI_GETSELECTIONNANCHOR, i));
|
||||
int absPosSelEndPerLine = static_cast<int32_t>(execute(SCI_GETSELECTIONNCARET, i));
|
||||
int nbVirtualAnchorSpc = static_cast<int32_t>(execute(SCI_GETSELECTIONNANCHORVIRTUALSPACE, i));
|
||||
int nbVirtualCaretSpc = static_cast<int32_t>(execute(SCI_GETSELECTIONNCARETVIRTUALSPACE, i));
|
||||
INT_PTR absPosSelStartPerLine = execute(SCI_GETSELECTIONNANCHOR, i);
|
||||
INT_PTR absPosSelEndPerLine = execute(SCI_GETSELECTIONNCARET, i);
|
||||
INT_PTR nbVirtualAnchorSpc = execute(SCI_GETSELECTIONNANCHORVIRTUALSPACE, i);
|
||||
INT_PTR nbVirtualCaretSpc = execute(SCI_GETSELECTIONNCARETVIRTUALSPACE, i);
|
||||
|
||||
if (absPosSelStartPerLine == absPosSelEndPerLine && execute(SCI_SELECTIONISRECTANGLE))
|
||||
{
|
||||
@ -3107,13 +3103,13 @@ ColumnModeInfos ScintillaEditView::getColumnModeSelectInfo()
|
||||
|
||||
void ScintillaEditView::columnReplace(ColumnModeInfos & cmi, const TCHAR *str)
|
||||
{
|
||||
int totalDiff = 0;
|
||||
INT_PTR totalDiff = 0;
|
||||
for (size_t i = 0, len = cmi.size(); i < len ; ++i)
|
||||
{
|
||||
if (cmi[i].isValid())
|
||||
{
|
||||
int len2beReplace = cmi[i]._selRpos - cmi[i]._selLpos;
|
||||
int diff = lstrlen(str) - len2beReplace;
|
||||
INT_PTR len2beReplace = cmi[i]._selRpos - cmi[i]._selLpos;
|
||||
INT_PTR diff = lstrlen(str) - len2beReplace;
|
||||
|
||||
cmi[i]._selLpos += totalDiff;
|
||||
cmi[i]._selRpos += totalDiff;
|
||||
@ -3121,7 +3117,7 @@ void ScintillaEditView::columnReplace(ColumnModeInfos & cmi, const TCHAR *str)
|
||||
|
||||
if (hasVirtualSpc) // if virtual space is present, then insert space
|
||||
{
|
||||
for (int j = 0, k = cmi[i]._selLpos; j < cmi[i]._nbVirtualCaretSpc ; ++j, ++k)
|
||||
for (INT_PTR j = 0, k = cmi[i]._selLpos; j < cmi[i]._nbVirtualCaretSpc ; ++j, ++k)
|
||||
{
|
||||
execute(SCI_INSERTTEXT, k, reinterpret_cast<LPARAM>(" "));
|
||||
}
|
||||
@ -3132,7 +3128,7 @@ void ScintillaEditView::columnReplace(ColumnModeInfos & cmi, const TCHAR *str)
|
||||
execute(SCI_SETTARGETRANGE, cmi[i]._selLpos, cmi[i]._selRpos);
|
||||
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
|
||||
size_t cp = execute(SCI_GETCODEPAGE);
|
||||
const char *strA = wmc.wchar2char(str, cp);
|
||||
execute(SCI_REPLACETARGET, static_cast<WPARAM>(-1), reinterpret_cast<LPARAM>(strA));
|
||||
|
||||
@ -3212,14 +3208,14 @@ void ScintillaEditView::columnReplace(ColumnModeInfos & cmi, int initial, int in
|
||||
const int kibInit = getNbDigits(initial, base);
|
||||
const int kib = std::max<int>(kibInit, kibEnd);
|
||||
|
||||
int totalDiff = 0;
|
||||
INT_PTR totalDiff = 0;
|
||||
const size_t len = cmi.size();
|
||||
for (size_t i = 0 ; i < len ; i++)
|
||||
{
|
||||
if (cmi[i].isValid())
|
||||
{
|
||||
const int len2beReplaced = cmi[i]._selRpos - cmi[i]._selLpos;
|
||||
const int diff = kib - len2beReplaced;
|
||||
const INT_PTR len2beReplaced = cmi[i]._selRpos - cmi[i]._selLpos;
|
||||
const INT_PTR diff = kib - len2beReplaced;
|
||||
|
||||
cmi[i]._selLpos += totalDiff;
|
||||
cmi[i]._selRpos += totalDiff;
|
||||
@ -3229,7 +3225,7 @@ void ScintillaEditView::columnReplace(ColumnModeInfos & cmi, int initial, int in
|
||||
const bool hasVirtualSpc = cmi[i]._nbVirtualAnchorSpc > 0;
|
||||
if (hasVirtualSpc) // if virtual space is present, then insert space
|
||||
{
|
||||
for (int j = 0, k = cmi[i]._selLpos; j < cmi[i]._nbVirtualCaretSpc ; ++j, ++k)
|
||||
for (INT_PTR j = 0, k = cmi[i]._selLpos; j < cmi[i]._nbVirtualCaretSpc ; ++j, ++k)
|
||||
{
|
||||
execute(SCI_INSERTTEXT, k, reinterpret_cast<LPARAM>(" "));
|
||||
}
|
||||
@ -3239,7 +3235,7 @@ void ScintillaEditView::columnReplace(ColumnModeInfos & cmi, int initial, int in
|
||||
execute(SCI_SETTARGETRANGE, cmi[i]._selLpos, cmi[i]._selRpos);
|
||||
|
||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||
UINT cp = static_cast<UINT>(execute(SCI_GETCODEPAGE));
|
||||
size_t cp = execute(SCI_GETCODEPAGE);
|
||||
const char *strA = wmc.wchar2char(str, cp);
|
||||
execute(SCI_REPLACETARGET, static_cast<WPARAM>(-1), reinterpret_cast<LPARAM>(strA));
|
||||
|
||||
@ -3285,20 +3281,20 @@ void ScintillaEditView::foldChanged(size_t line, int levelNow, int levelPrev)
|
||||
((levelPrev & SC_FOLDLEVELNUMBERMASK) > (levelNow & SC_FOLDLEVELNUMBERMASK)))
|
||||
{
|
||||
// See if should still be hidden
|
||||
int parentLine = static_cast<int32_t>(execute(SCI_GETFOLDPARENT, line));
|
||||
INT_PTR parentLine = execute(SCI_GETFOLDPARENT, line);
|
||||
if ((parentLine < 0) || !isFolded(parentLine && execute(SCI_GETLINEVISIBLE, parentLine)))
|
||||
execute(SCI_SHOWLINES, line, line);
|
||||
}
|
||||
}
|
||||
|
||||
bool ScintillaEditView::getIndicatorRange(int indicatorNumber, int *from, int *to, int *cur)
|
||||
bool ScintillaEditView::getIndicatorRange(size_t indicatorNumber, size_t* from, size_t* to, size_t* cur)
|
||||
{
|
||||
int curPos = static_cast<int>(execute(SCI_GETCURRENTPOS));
|
||||
int indicMsk = static_cast<int>(execute(SCI_INDICATORALLONFOR, curPos));
|
||||
if (!(indicMsk & (1 << indicatorNumber)))
|
||||
size_t curPos = execute(SCI_GETCURRENTPOS);
|
||||
size_t indicMsk = execute(SCI_INDICATORALLONFOR, curPos);
|
||||
if (!(static_cast<int>(indicMsk) & (1 << indicatorNumber)))
|
||||
return false;
|
||||
int startPos = static_cast<int>(execute(SCI_INDICATORSTART, indicatorNumber, curPos));
|
||||
int endPos = static_cast<int>(execute(SCI_INDICATOREND, indicatorNumber, curPos));
|
||||
size_t startPos = execute(SCI_INDICATORSTART, indicatorNumber, curPos);
|
||||
size_t endPos = execute(SCI_INDICATOREND, indicatorNumber, curPos);
|
||||
if ((curPos < startPos) || (curPos > endPos))
|
||||
return false;
|
||||
if (from) *from = startPos;
|
||||
@ -3313,19 +3309,19 @@ void ScintillaEditView::scrollPosToCenter(size_t pos)
|
||||
_positionRestoreNeeded = false;
|
||||
|
||||
execute(SCI_GOTOPOS, pos);
|
||||
int line = static_cast<int32_t>(execute(SCI_LINEFROMPOSITION, pos));
|
||||
size_t line = execute(SCI_LINEFROMPOSITION, pos);
|
||||
|
||||
int firstVisibleDisplayLine = static_cast<int32_t>(execute(SCI_GETFIRSTVISIBLELINE));
|
||||
int firstVisibleDocLine = static_cast<int32_t>(execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine));
|
||||
int nbLine = static_cast<int32_t>(execute(SCI_LINESONSCREEN, firstVisibleDisplayLine));
|
||||
int lastVisibleDocLine = static_cast<int32_t>(execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine + nbLine));
|
||||
size_t firstVisibleDisplayLine = execute(SCI_GETFIRSTVISIBLELINE);
|
||||
size_t firstVisibleDocLine = execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine);
|
||||
size_t nbLine = execute(SCI_LINESONSCREEN, firstVisibleDisplayLine);
|
||||
size_t lastVisibleDocLine = execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine + nbLine);
|
||||
|
||||
int middleLine;
|
||||
size_t middleLine;
|
||||
if (line - firstVisibleDocLine < lastVisibleDocLine - line)
|
||||
middleLine = firstVisibleDocLine + nbLine/2;
|
||||
else
|
||||
middleLine = lastVisibleDocLine - nbLine/2;
|
||||
int nbLines2scroll = line - middleLine;
|
||||
size_t nbLines2scroll = line - middleLine;
|
||||
scroll(0, nbLines2scroll);
|
||||
execute(SCI_ENSUREVISIBLEENFORCEPOLICY, line);
|
||||
}
|
||||
@ -3336,11 +3332,11 @@ void ScintillaEditView::hideLines()
|
||||
//Adding runMarkers(hide, foldstart) directly (folding on single document) can help
|
||||
|
||||
//Special func on buffer. If markers are added, create notification with location of start, and hide bool set to true
|
||||
int startLine = static_cast<int32_t>(execute(SCI_LINEFROMPOSITION, execute(SCI_GETSELECTIONSTART)));
|
||||
int endLine = static_cast<int32_t>(execute(SCI_LINEFROMPOSITION, execute(SCI_GETSELECTIONEND)));
|
||||
size_t startLine = execute(SCI_LINEFROMPOSITION, execute(SCI_GETSELECTIONSTART));
|
||||
size_t endLine = execute(SCI_LINEFROMPOSITION, execute(SCI_GETSELECTIONEND));
|
||||
//perform range check: cannot hide very first and very last lines
|
||||
//Offset them one off the edges, and then check if they are within the reasonable
|
||||
int nbLines = static_cast<int32_t>(execute(SCI_GETLINECOUNT));
|
||||
size_t nbLines = execute(SCI_GETLINECOUNT);
|
||||
if (nbLines < 3)
|
||||
return; //cannot possibly hide anything
|
||||
if (!startLine)
|
||||
@ -3360,7 +3356,7 @@ void ScintillaEditView::hideLines()
|
||||
|
||||
//remove any markers in between
|
||||
int scope = 0;
|
||||
for (int i = startLine; i <= endLine; ++i)
|
||||
for (size_t i = startLine; i <= endLine; ++i)
|
||||
{
|
||||
auto state = execute(SCI_MARKERGET, i);
|
||||
bool closePresent = ((state & (1 << MARK_HIDELINESEND)) != 0); //check close first, then open, since close closes scope
|
||||
@ -3420,7 +3416,7 @@ bool ScintillaEditView::markerMarginClick(int lineNumber)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ScintillaEditView::notifyMarkers(Buffer * buf, bool isHide, int location, bool del)
|
||||
void ScintillaEditView::notifyMarkers(Buffer * buf, bool isHide, size_t location, bool del)
|
||||
{
|
||||
if (buf != _currentBuffer) //if not visible buffer dont do a thing
|
||||
return;
|
||||
@ -3585,7 +3581,7 @@ void ScintillaEditView::insertNewLineAboveCurrentLine()
|
||||
else
|
||||
{
|
||||
const auto eol_length = newline.length();
|
||||
const auto position = static_cast<size_t>(execute(SCI_POSITIONFROMLINE, current_line)) - eol_length;
|
||||
const auto position = execute(SCI_POSITIONFROMLINE, current_line) - eol_length;
|
||||
insertGenericTextFrom(position, newline.c_str());
|
||||
}
|
||||
execute(SCI_SETEMPTYSELECTION, execute(SCI_POSITIONFROMLINE, current_line));
|
||||
@ -3595,7 +3591,7 @@ void ScintillaEditView::insertNewLineAboveCurrentLine()
|
||||
void ScintillaEditView::insertNewLineBelowCurrentLine()
|
||||
{
|
||||
generic_string newline = getEOLString();
|
||||
const auto line_count = static_cast<size_t>(execute(SCI_GETLINECOUNT));
|
||||
const auto line_count = execute(SCI_GETLINECOUNT);
|
||||
const auto current_line = getCurrentLineNumber();
|
||||
if (current_line == line_count - 1)
|
||||
{
|
||||
@ -3645,7 +3641,7 @@ void ScintillaEditView::sortLines(size_t fromLine, size_t toLine, ISorter* pSort
|
||||
}
|
||||
if (text != joined)
|
||||
{
|
||||
replaceTarget(joined.c_str(), int(startPos), int(endPos));
|
||||
replaceTarget(joined.c_str(), startPos, endPos);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3693,7 +3689,7 @@ void ScintillaEditView::changeTextDirection(bool isRTL)
|
||||
|
||||
generic_string ScintillaEditView::getEOLString()
|
||||
{
|
||||
const int eol_mode = int(execute(SCI_GETEOLMODE));
|
||||
INT_PTR eol_mode = execute(SCI_GETEOLMODE);
|
||||
if (eol_mode == SC_EOL_CRLF)
|
||||
{
|
||||
return TEXT("\r\n");
|
||||
@ -3760,25 +3756,25 @@ int ScintillaEditView::getTextZoneWidth() const
|
||||
RECT editorRect;
|
||||
getClientRect(editorRect);
|
||||
|
||||
int marginWidths = 0;
|
||||
INT_PTR marginWidths = 0;
|
||||
for (int m = 0; m < 4; ++m)
|
||||
{
|
||||
marginWidths += static_cast<int32_t>(execute(SCI_GETMARGINWIDTHN, m));
|
||||
marginWidths += execute(SCI_GETMARGINWIDTHN, m);
|
||||
}
|
||||
return editorRect.right - editorRect.left - marginWidths;
|
||||
return editorRect.right - editorRect.left - static_cast<LONG>(marginWidths);
|
||||
}
|
||||
|
||||
pair<int, int> ScintillaEditView::getSelectedCharsAndLinesCount(int maxSelectionsForLineCount /* = -1 */) const
|
||||
pair<size_t, size_t> ScintillaEditView::getSelectedCharsAndLinesCount(long long maxSelectionsForLineCount /* = -1 */) const
|
||||
{
|
||||
pair<int, int> selectedCharsAndLines(0, 0);
|
||||
pair<size_t, size_t> selectedCharsAndLines(0, 0);
|
||||
|
||||
selectedCharsAndLines.first = getUnicodeSelectedLength();
|
||||
|
||||
int numSelections = static_cast<int>(execute(SCI_GETSELECTIONS));
|
||||
size_t numSelections = execute(SCI_GETSELECTIONS);
|
||||
|
||||
if (numSelections == 1)
|
||||
{
|
||||
pair<int, int> lineRange = getSelectionLinesRange();
|
||||
pair<size_t, size_t> lineRange = getSelectionLinesRange();
|
||||
selectedCharsAndLines.second = lineRange.second - lineRange.first + 1;
|
||||
}
|
||||
else if (execute(SCI_SELECTIONISRECTANGLE))
|
||||
@ -3786,7 +3782,7 @@ pair<int, int> ScintillaEditView::getSelectedCharsAndLinesCount(int maxSelection
|
||||
selectedCharsAndLines.second = numSelections;
|
||||
}
|
||||
else if ((maxSelectionsForLineCount == -1) || // -1 means process ALL of the selections
|
||||
(numSelections <= maxSelectionsForLineCount))
|
||||
(numSelections <= static_cast<size_t>(maxSelectionsForLineCount)))
|
||||
{
|
||||
// selections are obtained from Scintilla in the order user creates them,
|
||||
// not in a lowest-to-highest position-based order;
|
||||
@ -3794,37 +3790,37 @@ pair<int, int> ScintillaEditView::getSelectedCharsAndLinesCount(int maxSelection
|
||||
// we have to reorder the lines touched
|
||||
// by selection into low-to-high line number order before processing them further
|
||||
|
||||
vector< pair <int, int> > v;
|
||||
for (int s = 0; s < numSelections; ++s)
|
||||
vector< pair <size_t, size_t> > v;
|
||||
for (size_t s = 0; s < numSelections; ++s)
|
||||
{
|
||||
v.push_back(getSelectionLinesRange(s));
|
||||
}
|
||||
sort(v.begin(), v.end());
|
||||
int previousSecondLine = -1;
|
||||
INT_PTR previousSecondLine = -1;
|
||||
for (auto lineRange : v)
|
||||
{
|
||||
selectedCharsAndLines.second += lineRange.second - lineRange.first;
|
||||
if (lineRange.first != previousSecondLine)
|
||||
if (lineRange.first != static_cast<size_t>(previousSecondLine))
|
||||
{
|
||||
++selectedCharsAndLines.second;
|
||||
}
|
||||
previousSecondLine = lineRange.second;
|
||||
previousSecondLine = static_cast<INT_PTR>(lineRange.second);
|
||||
}
|
||||
}
|
||||
|
||||
return selectedCharsAndLines;
|
||||
};
|
||||
|
||||
int ScintillaEditView::getUnicodeSelectedLength() const
|
||||
size_t ScintillaEditView::getUnicodeSelectedLength() const
|
||||
{
|
||||
int length = 0;
|
||||
int numSelections = static_cast<int>(execute(SCI_GETSELECTIONS));
|
||||
size_t length = 0;
|
||||
size_t numSelections = execute(SCI_GETSELECTIONS);
|
||||
|
||||
for (int s = 0; s < numSelections; ++s)
|
||||
for (size_t s = 0; s < numSelections; ++s)
|
||||
{
|
||||
int start = static_cast<int>(execute(SCI_GETSELECTIONNSTART, s));
|
||||
int end = static_cast<int>(execute(SCI_GETSELECTIONNEND, s));
|
||||
length += static_cast<int>(execute(SCI_COUNTCHARACTERS, start, end));
|
||||
size_t start = execute(SCI_GETSELECTIONNSTART, s);
|
||||
size_t end = execute(SCI_GETSELECTIONNEND, s);
|
||||
length += execute(SCI_COUNTCHARACTERS, start, end);
|
||||
}
|
||||
|
||||
return length;
|
||||
@ -3850,7 +3846,7 @@ void ScintillaEditView::markedTextToClipboard(int indiStyle, bool doAll /*= fals
|
||||
}
|
||||
|
||||
// vector of pairs: starting position of styled text, and styled text
|
||||
std::vector<std::pair<int, generic_string>> styledVect;
|
||||
std::vector<std::pair<size_t, generic_string>> styledVect;
|
||||
|
||||
const generic_string cr = TEXT("\r");
|
||||
const generic_string lf = TEXT("\n");
|
||||
@ -3859,11 +3855,11 @@ void ScintillaEditView::markedTextToClipboard(int indiStyle, bool doAll /*= fals
|
||||
|
||||
for (int si = 0; styleIndicators[si] != -1; ++si)
|
||||
{
|
||||
int pos = static_cast<int>(execute(SCI_INDICATOREND, styleIndicators[si], 0));
|
||||
size_t pos = execute(SCI_INDICATOREND, styleIndicators[si], 0);
|
||||
if (pos > 0)
|
||||
{
|
||||
bool atEndOfIndic = execute(SCI_INDICATORVALUEAT, styleIndicators[si], 0) != 0;
|
||||
int prevPos = pos;
|
||||
size_t prevPos = pos;
|
||||
if (atEndOfIndic) prevPos = 0;
|
||||
|
||||
do
|
||||
@ -3883,7 +3879,7 @@ void ScintillaEditView::markedTextToClipboard(int indiStyle, bool doAll /*= fals
|
||||
}
|
||||
atEndOfIndic = !atEndOfIndic;
|
||||
prevPos = pos;
|
||||
pos = static_cast<int>(execute(SCI_INDICATOREND, styleIndicators[si], pos));
|
||||
pos = execute(SCI_INDICATOREND, styleIndicators[si], pos);
|
||||
} while (pos != prevPos);
|
||||
}
|
||||
}
|
||||
@ -3926,7 +3922,7 @@ void ScintillaEditView::removeAnyDuplicateLines()
|
||||
|
||||
if (hasLineSelection)
|
||||
{
|
||||
const pair<int, int> lineRange = getSelectionLinesRange();
|
||||
const pair<size_t, size_t> lineRange = getSelectionLinesRange();
|
||||
// One single line selection is not allowed.
|
||||
if (lineRange.first == lineRange.second)
|
||||
{
|
||||
@ -3973,7 +3969,7 @@ void ScintillaEditView::removeAnyDuplicateLines()
|
||||
}
|
||||
if (text != joined)
|
||||
{
|
||||
replaceTarget(joined.c_str(), int(startPos), int(endPos));
|
||||
replaceTarget(joined.c_str(), startPos, endPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -134,14 +134,14 @@ const bool L2R = true;
|
||||
const bool R2L = false;
|
||||
|
||||
struct ColumnModeInfo {
|
||||
int _selLpos = 0;
|
||||
int _selRpos = 0;
|
||||
int _order = -1; // 0 based index
|
||||
INT_PTR _selLpos = 0;
|
||||
INT_PTR _selRpos = 0;
|
||||
INT_PTR _order = -1; // 0 based index
|
||||
bool _direction = L2R; // L2R or R2L
|
||||
int _nbVirtualCaretSpc = 0;
|
||||
int _nbVirtualAnchorSpc = 0;
|
||||
INT_PTR _nbVirtualCaretSpc = 0;
|
||||
INT_PTR _nbVirtualAnchorSpc = 0;
|
||||
|
||||
ColumnModeInfo(int lPos, int rPos, int order, bool dir = L2R, int vAnchorNbSpc = 0, int vCaretNbSpc = 0)
|
||||
ColumnModeInfo(INT_PTR lPos, INT_PTR rPos, INT_PTR order, bool dir = L2R, INT_PTR vAnchorNbSpc = 0, INT_PTR vCaretNbSpc = 0)
|
||||
: _selLpos(lPos), _selRpos(rPos), _order(order), _direction(dir), _nbVirtualAnchorSpc(vAnchorNbSpc), _nbVirtualCaretSpc(vCaretNbSpc){};
|
||||
|
||||
bool isValid() const {
|
||||
@ -229,7 +229,7 @@ public:
|
||||
|
||||
void getText(char *dest, size_t start, size_t end) const;
|
||||
void getGenericText(TCHAR *dest, size_t destlen, size_t start, size_t end) const;
|
||||
void getGenericText(TCHAR *dest, size_t deslen, int start, int end, int *mstart, int *mend) const;
|
||||
void getGenericText(TCHAR *dest, size_t deslen, size_t start, size_t end, INT_PTR* mstart, INT_PTR* mend) const;
|
||||
generic_string getGenericTextAsString(size_t start, size_t end) const;
|
||||
void insertGenericTextFrom(size_t position, const TCHAR *text2insert) const;
|
||||
void replaceSelWith(const char * replaceText);
|
||||
@ -239,22 +239,22 @@ public:
|
||||
return (range.cpMax - range.cpMin);
|
||||
};
|
||||
|
||||
void getVisibleStartAndEndPosition(int * startPos, int * endPos);
|
||||
char * getWordFromRange(char * txt, int size, int pos1, int pos2);
|
||||
void getVisibleStartAndEndPosition(INT_PTR* startPos, INT_PTR* endPos);
|
||||
char * getWordFromRange(char * txt, size_t size, size_t pos1, size_t pos2);
|
||||
char * getSelectedText(char * txt, int size, bool expand = true);
|
||||
char * getWordOnCaretPos(char * txt, int size);
|
||||
TCHAR * getGenericWordOnCaretPos(TCHAR * txt, int size);
|
||||
TCHAR * getGenericSelectedText(TCHAR * txt, int size, bool expand = true);
|
||||
int searchInTarget(const TCHAR * Text2Find, size_t lenOfText2Find, size_t fromPos, size_t toPos) const;
|
||||
INT_PTR searchInTarget(const TCHAR * Text2Find, size_t lenOfText2Find, size_t fromPos, size_t toPos) const;
|
||||
void appandGenericText(const TCHAR * text2Append) const;
|
||||
void addGenericText(const TCHAR * text2Append) const;
|
||||
void addGenericText(const TCHAR * text2Append, long *mstart, long *mend) const;
|
||||
int replaceTarget(const TCHAR * str2replace, int fromTargetPos = -1, int toTargetPos = -1) const;
|
||||
int replaceTargetRegExMode(const TCHAR * re, int fromTargetPos = -1, int toTargetPos = -1) const;
|
||||
INT_PTR replaceTarget(const TCHAR * str2replace, INT_PTR fromTargetPos = -1, INT_PTR toTargetPos = -1) const;
|
||||
INT_PTR replaceTargetRegExMode(const TCHAR * re, INT_PTR fromTargetPos = -1, INT_PTR toTargetPos = -1) const;
|
||||
void showAutoComletion(size_t lenEntered, const TCHAR * list);
|
||||
void showCallTip(int startPos, const TCHAR * def);
|
||||
void showCallTip(size_t startPos, const TCHAR * def);
|
||||
generic_string getLine(size_t lineNumber);
|
||||
void getLine(size_t lineNumber, TCHAR * line, int lineBufferLen);
|
||||
void getLine(size_t lineNumber, TCHAR * line, size_t lineBufferLen);
|
||||
void addText(size_t length, const char *buf);
|
||||
|
||||
void insertNewLineAboveCurrentLine();
|
||||
@ -269,8 +269,8 @@ public:
|
||||
return _beginSelectPosition != -1;
|
||||
};
|
||||
|
||||
int getCurrentDocLen() const {
|
||||
return int(execute(SCI_GETLENGTH));
|
||||
size_t getCurrentDocLen() const {
|
||||
return size_t(execute(SCI_GETLENGTH));
|
||||
};
|
||||
|
||||
Sci_CharacterRange getSelection() const {
|
||||
@ -391,37 +391,37 @@ public:
|
||||
execute(SCI_SETWRAPVISUALFLAGS, willBeShown?SC_WRAPVISUALFLAG_END:SC_WRAPVISUALFLAG_NONE);
|
||||
};
|
||||
|
||||
size_t getCurrentLineNumber()const {
|
||||
return static_cast<size_t>(execute(SCI_LINEFROMPOSITION, execute(SCI_GETCURRENTPOS)));
|
||||
INT_PTR getCurrentLineNumber()const {
|
||||
return execute(SCI_LINEFROMPOSITION, execute(SCI_GETCURRENTPOS));
|
||||
};
|
||||
|
||||
int32_t lastZeroBasedLineNumber() const {
|
||||
INT_PTR lastZeroBasedLineNumber() const {
|
||||
auto endPos = execute(SCI_GETLENGTH);
|
||||
return static_cast<int32_t>(execute(SCI_LINEFROMPOSITION, endPos));
|
||||
return execute(SCI_LINEFROMPOSITION, endPos);
|
||||
};
|
||||
|
||||
long getCurrentXOffset()const{
|
||||
return long(execute(SCI_GETXOFFSET));
|
||||
INT_PTR getCurrentXOffset()const{
|
||||
return execute(SCI_GETXOFFSET);
|
||||
};
|
||||
|
||||
void setCurrentXOffset(long xOffset){
|
||||
execute(SCI_SETXOFFSET,xOffset);
|
||||
};
|
||||
|
||||
void scroll(int column, int line){
|
||||
void scroll(size_t column, size_t line){
|
||||
execute(SCI_LINESCROLL, column, line);
|
||||
};
|
||||
|
||||
long getCurrentPointX()const{
|
||||
return long (execute(SCI_POINTXFROMPOSITION, 0, execute(SCI_GETCURRENTPOS)));
|
||||
INT_PTR getCurrentPointX()const{
|
||||
return execute(SCI_POINTXFROMPOSITION, 0, execute(SCI_GETCURRENTPOS));
|
||||
};
|
||||
|
||||
long getCurrentPointY()const{
|
||||
return long (execute(SCI_POINTYFROMPOSITION, 0, execute(SCI_GETCURRENTPOS)));
|
||||
INT_PTR getCurrentPointY()const{
|
||||
return execute(SCI_POINTYFROMPOSITION, 0, execute(SCI_GETCURRENTPOS));
|
||||
};
|
||||
|
||||
long getTextHeight()const{
|
||||
return long(execute(SCI_TEXTHEIGHT));
|
||||
INT_PTR getTextHeight()const{
|
||||
return execute(SCI_TEXTHEIGHT);
|
||||
};
|
||||
|
||||
int getTextZoneWidth() const;
|
||||
@ -431,23 +431,23 @@ public:
|
||||
execute(SCI_GOTOLINE,line);
|
||||
};
|
||||
|
||||
long getCurrentColumnNumber() const {
|
||||
return long(execute(SCI_GETCOLUMN, execute(SCI_GETCURRENTPOS)));
|
||||
INT_PTR getCurrentColumnNumber() const {
|
||||
return execute(SCI_GETCOLUMN, execute(SCI_GETCURRENTPOS));
|
||||
};
|
||||
|
||||
std::pair<int, int> getSelectedCharsAndLinesCount(int maxSelectionsForLineCount = -1) const;
|
||||
std::pair<size_t, size_t> getSelectedCharsAndLinesCount(long long maxSelectionsForLineCount = -1) const;
|
||||
|
||||
int getUnicodeSelectedLength() const;
|
||||
size_t getUnicodeSelectedLength() const;
|
||||
|
||||
long getLineLength(int line) const {
|
||||
return long(execute(SCI_GETLINEENDPOSITION, line) - execute(SCI_POSITIONFROMLINE, line));
|
||||
INT_PTR getLineLength(size_t line) const {
|
||||
return execute(SCI_GETLINEENDPOSITION, line) - execute(SCI_POSITIONFROMLINE, line);
|
||||
};
|
||||
|
||||
long getLineIndent(int line) const {
|
||||
return long(execute(SCI_GETLINEINDENTATION, line));
|
||||
INT_PTR getLineIndent(int line) const {
|
||||
return execute(SCI_GETLINEINDENTATION, line);
|
||||
};
|
||||
|
||||
void setLineIndent(int line, int indent) const;
|
||||
void setLineIndent(size_t line, size_t indent) const;
|
||||
|
||||
void updateLineNumbersMargin(bool forcedToHide) {
|
||||
const ScintillaViewParams& svp = NppParameters::getInstance().getSVP();
|
||||
@ -481,9 +481,9 @@ public:
|
||||
|
||||
void performGlobalStyles();
|
||||
|
||||
void expand(size_t& line, bool doExpand, bool force = false, int visLevels = 0, int level = -1);
|
||||
void expand(size_t& line, bool doExpand, bool force = false, INT_PTR visLevels = 0, INT_PTR level = -1);
|
||||
|
||||
std::pair<int, int> getSelectionLinesRange(int selectionNumber = -1) const;
|
||||
std::pair<size_t, size_t> getSelectionLinesRange(INT_PTR selectionNumber = -1) const;
|
||||
void currentLinesUp() const;
|
||||
void currentLinesDown() const;
|
||||
|
||||
@ -533,13 +533,13 @@ public:
|
||||
|
||||
void foldChanged(size_t line, int levelNow, int levelPrev);
|
||||
void clearIndicator(int indicatorNumber) {
|
||||
int docStart = 0;
|
||||
int docEnd = getCurrentDocLen();
|
||||
size_t docStart = 0;
|
||||
size_t docEnd = getCurrentDocLen();
|
||||
execute(SCI_SETINDICATORCURRENT, indicatorNumber);
|
||||
execute(SCI_INDICATORCLEARRANGE, docStart, docEnd-docStart);
|
||||
execute(SCI_INDICATORCLEARRANGE, docStart, docEnd - docStart);
|
||||
};
|
||||
|
||||
bool getIndicatorRange(int indicatorNumber, int *from = NULL, int *to = NULL, int *cur = NULL);
|
||||
bool getIndicatorRange(size_t indicatorNumber, size_t* from = NULL, size_t* to = NULL, size_t* cur = NULL);
|
||||
|
||||
static LanguageName langNames[L_EXTERNAL+1];
|
||||
|
||||
@ -552,7 +552,7 @@ public:
|
||||
void hideLines();
|
||||
|
||||
bool markerMarginClick(int lineNumber); //true if it did something
|
||||
void notifyMarkers(Buffer * buf, bool isHide, int location, bool del);
|
||||
void notifyMarkers(Buffer * buf, bool isHide, size_t location, bool del);
|
||||
void runMarkers(bool doHide, size_t searchStart, bool endOfDoc, bool doDelete);
|
||||
|
||||
bool isSelecting() const {
|
||||
@ -641,7 +641,7 @@ protected:
|
||||
typedef std::unordered_map<BufferID, StyleMap*> BufferStyleMap;
|
||||
BufferStyleMap _hotspotStyles;
|
||||
|
||||
long long _beginSelectPosition = -1;
|
||||
INT_PTR _beginSelectPosition = -1;
|
||||
|
||||
static std::string _defaultCharList;
|
||||
|
||||
@ -1003,7 +1003,7 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
std::pair<int, int> getWordRange();
|
||||
std::pair<size_t, size_t> getWordRange();
|
||||
bool expandWordSelection();
|
||||
void getFoldColor(COLORREF& fgColor, COLORREF& bgColor, COLORREF& activeFgColor);
|
||||
};
|
||||
|
@ -33,14 +33,14 @@ void SmartHighlighter::highlightViewWithWord(ScintillaEditView * pHighlightView,
|
||||
auto originalEndPos = pHighlightView->execute(SCI_GETTARGETEND);
|
||||
|
||||
// Get the range of text visible and highlight everything in it
|
||||
auto firstLine = static_cast<int>(pHighlightView->execute(SCI_GETFIRSTVISIBLELINE));
|
||||
auto firstLine = pHighlightView->execute(SCI_GETFIRSTVISIBLELINE);
|
||||
auto nbLineOnScreen = pHighlightView->execute(SCI_LINESONSCREEN);
|
||||
auto nbLines = min(nbLineOnScreen, MAXLINEHIGHLIGHT) + 1;
|
||||
auto lastLine = firstLine + nbLines;
|
||||
int startPos = 0;
|
||||
int endPos = 0;
|
||||
size_t startPos = 0;
|
||||
INT_PTR endPos = 0;
|
||||
auto currentLine = firstLine;
|
||||
int prevDocLineChecked = -1; //invalid start
|
||||
INT_PTR prevDocLineChecked = -1; //invalid start
|
||||
|
||||
// Determine mode for SmartHighlighting
|
||||
bool isWordOnly = true;
|
||||
@ -71,12 +71,12 @@ void SmartHighlighter::highlightViewWithWord(ScintillaEditView * pHighlightView,
|
||||
|
||||
for (; currentLine < lastLine; ++currentLine)
|
||||
{
|
||||
int docLine = static_cast<int>(pHighlightView->execute(SCI_DOCLINEFROMVISIBLE, currentLine));
|
||||
INT_PTR docLine = pHighlightView->execute(SCI_DOCLINEFROMVISIBLE, currentLine);
|
||||
if (docLine == prevDocLineChecked)
|
||||
continue; //still on same line (wordwrap)
|
||||
prevDocLineChecked = docLine;
|
||||
startPos = static_cast<int>(pHighlightView->execute(SCI_POSITIONFROMLINE, docLine));
|
||||
endPos = static_cast<int>(pHighlightView->execute(SCI_POSITIONFROMLINE, docLine + 1));
|
||||
prevDocLineChecked = static_cast<INT_PTR>(docLine);
|
||||
startPos = pHighlightView->execute(SCI_POSITIONFROMLINE, docLine);
|
||||
endPos = pHighlightView->execute(SCI_POSITIONFROMLINE, docLine + 1);
|
||||
|
||||
frInfo._startRange = startPos;
|
||||
frInfo._endRange = endPos;
|
||||
|
@ -124,56 +124,60 @@ INT_PTR CALLBACK FindCharsInRangeDlg::run_dlgProc(UINT message, WPARAM wParam, L
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool FindCharsInRangeDlg::findCharInRange(unsigned char beginRange, unsigned char endRange, int startPos, bool direction, bool wrap)
|
||||
bool FindCharsInRangeDlg::findCharInRange(unsigned char beginRange, unsigned char endRange, INT_PTR startPos, bool direction, bool wrap)
|
||||
{
|
||||
int totalSize = (*_ppEditView)->getCurrentDocLen();
|
||||
size_t totalSize = (*_ppEditView)->getCurrentDocLen();
|
||||
if (startPos == -1)
|
||||
startPos = direction==dirDown?0:totalSize-1;
|
||||
if (startPos > totalSize)
|
||||
startPos = direction == dirDown ? 0 : totalSize - 1;
|
||||
if (static_cast<size_t>(startPos) > totalSize)
|
||||
return false;
|
||||
|
||||
char *content = new char[totalSize+1];
|
||||
char *content = new char[totalSize + 1];
|
||||
(*_ppEditView)->getText(content, 0, totalSize);
|
||||
int found = -1;
|
||||
|
||||
for (int i = startPos-(direction == dirUp?1:0);
|
||||
(direction == dirDown)?i < totalSize:i >= 0 ;
|
||||
(direction == dirDown)?(++i):(--i))
|
||||
bool isFound = false;
|
||||
size_t found = 0;
|
||||
|
||||
for (INT_PTR i = startPos - (direction == dirUp ? 1 : 0);
|
||||
(direction == dirDown) ? i < static_cast<long long>(totalSize) : i >= 0 ;
|
||||
(direction == dirDown) ? (++i) : (--i))
|
||||
{
|
||||
if (static_cast<unsigned char>(content[i]) >= beginRange && static_cast<unsigned char>(content[i]) <= endRange)
|
||||
{
|
||||
found = i;
|
||||
isFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found == -1)
|
||||
if (!isFound)
|
||||
{
|
||||
if (wrap)
|
||||
{
|
||||
for (int i = (direction == dirUp?totalSize-1:0);
|
||||
(direction == dirDown)?i < totalSize:i >= 0 ;
|
||||
(direction == dirDown)?(++i):(--i))
|
||||
for (size_t i = (direction == dirUp ? totalSize - 1 : 0);
|
||||
(direction == dirDown) ? i < totalSize : i >= 0 ;
|
||||
(direction == dirDown) ? (++i) : (--i))
|
||||
{
|
||||
if (static_cast<unsigned char>(content[i]) >= beginRange && static_cast<unsigned char>(content[i]) <= endRange)
|
||||
{
|
||||
found = i;
|
||||
isFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (found != -1)
|
||||
if (isFound)
|
||||
{
|
||||
//printInt(found);
|
||||
auto sci_line = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, found);
|
||||
(*_ppEditView)->execute(SCI_ENSUREVISIBLE, sci_line);
|
||||
(*_ppEditView)->execute(SCI_GOTOPOS, found);
|
||||
(*_ppEditView)->execute(SCI_SETSEL, (direction == dirDown)?found:found+1, (direction == dirDown)?found+1:found);
|
||||
(*_ppEditView)->execute(SCI_SETSEL, (direction == dirDown)? found : found+1, (direction == dirDown) ? found + 1 : found);
|
||||
}
|
||||
delete [] content;
|
||||
return (found != -1);
|
||||
return isFound;
|
||||
}
|
||||
|
||||
void FindCharsInRangeDlg::getDirectionFromUI(bool & whichDirection, bool & isWrap)
|
||||
|
@ -51,7 +51,7 @@ protected :
|
||||
|
||||
private :
|
||||
ScintillaEditView **_ppEditView = nullptr;
|
||||
bool findCharInRange(unsigned char beginRange, unsigned char endRange, int startPos, bool direction, bool wrap);
|
||||
bool findCharInRange(unsigned char beginRange, unsigned char endRange, INT_PTR startPos, bool direction, bool wrap);
|
||||
bool getRangeFromUI(unsigned char & startRange, unsigned char & endRange);
|
||||
void getDirectionFromUI(bool & whichDirection, bool & isWrap);
|
||||
};
|
||||
|
@ -77,7 +77,7 @@ size_t FunctionListPanel::getBodyClosePos(size_t begin, const TCHAR *bodyOpenSym
|
||||
{
|
||||
size_t cntOpen = 1;
|
||||
|
||||
int docLen = (*_ppEditView)->getCurrentDocLen();
|
||||
size_t docLen = (*_ppEditView)->getCurrentDocLen();
|
||||
|
||||
if (begin >= (size_t)docLen)
|
||||
return docLen;
|
||||
@ -92,17 +92,17 @@ size_t FunctionListPanel::getBodyClosePos(size_t begin, const TCHAR *bodyOpenSym
|
||||
int flags = SCFIND_REGEXP | SCFIND_POSIX;
|
||||
|
||||
(*_ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
||||
int targetStart = (*_ppEditView)->searchInTarget(exprToSearch.c_str(), exprToSearch.length(), begin, docLen);
|
||||
int targetEnd = 0;
|
||||
INT_PTR targetStart = (*_ppEditView)->searchInTarget(exprToSearch.c_str(), exprToSearch.length(), begin, docLen);
|
||||
INT_PTR targetEnd = 0;
|
||||
|
||||
do
|
||||
{
|
||||
if (targetStart >= 0) // found open or close symbol
|
||||
{
|
||||
targetEnd = int((*_ppEditView)->execute(SCI_GETTARGETEND));
|
||||
targetEnd = (*_ppEditView)->execute(SCI_GETTARGETEND);
|
||||
|
||||
// Now we determinate the symbol (open or close)
|
||||
int tmpStart = (*_ppEditView)->searchInTarget(bodyOpenSymbol, lstrlen(bodyOpenSymbol), targetStart, targetEnd);
|
||||
INT_PTR tmpStart = (*_ppEditView)->searchInTarget(bodyOpenSymbol, lstrlen(bodyOpenSymbol), targetStart, targetEnd);
|
||||
if (tmpStart >= 0) // open symbol found
|
||||
{
|
||||
++cntOpen;
|
||||
@ -125,7 +125,7 @@ size_t FunctionListPanel::getBodyClosePos(size_t begin, const TCHAR *bodyOpenSym
|
||||
return targetEnd;
|
||||
}
|
||||
|
||||
generic_string FunctionListPanel::parseSubLevel(size_t begin, size_t end, std::vector< generic_string > dataToSearch, int & foundPos)
|
||||
generic_string FunctionListPanel::parseSubLevel(size_t begin, size_t end, std::vector< generic_string > dataToSearch, INT_PTR& foundPos)
|
||||
{
|
||||
if (begin >= end)
|
||||
{
|
||||
@ -140,14 +140,14 @@ generic_string FunctionListPanel::parseSubLevel(size_t begin, size_t end, std::v
|
||||
|
||||
(*_ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
||||
const TCHAR *regExpr2search = dataToSearch[0].c_str();
|
||||
int targetStart = (*_ppEditView)->searchInTarget(regExpr2search, lstrlen(regExpr2search), begin, end);
|
||||
INT_PTR targetStart = (*_ppEditView)->searchInTarget(regExpr2search, lstrlen(regExpr2search), begin, end);
|
||||
|
||||
if (targetStart < 0)
|
||||
{
|
||||
foundPos = -1;
|
||||
return TEXT("");
|
||||
}
|
||||
int targetEnd = int((*_ppEditView)->execute(SCI_GETTARGETEND));
|
||||
INT_PTR targetEnd = (*_ppEditView)->execute(SCI_GETTARGETEND);
|
||||
|
||||
if (dataToSearch.size() >= 2)
|
||||
{
|
||||
|
@ -125,7 +125,7 @@ private:
|
||||
std::vector<TreeParams> _treeParams;
|
||||
HIMAGELIST _hTreeViewImaLst = nullptr;
|
||||
|
||||
generic_string parseSubLevel(size_t begin, size_t end, std::vector< generic_string > dataToSearch, int & foundPos);
|
||||
generic_string parseSubLevel(size_t begin, size_t end, std::vector< generic_string > dataToSearch, INT_PTR& foundPos);
|
||||
size_t getBodyClosePos(size_t begin, const TCHAR *bodyOpenSymbol, const TCHAR *bodyCloseSymbol);
|
||||
void notified(LPNMHDR notification);
|
||||
void addInStateArray(TreeStateNode tree2Update, const TCHAR *searchText, bool isSorted);
|
||||
|
@ -377,7 +377,7 @@ FunctionParser * FunctionParsersManager::getParser(const AssociationInfo & assoI
|
||||
}
|
||||
|
||||
|
||||
void FunctionParser::funcParse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName, const std::vector< std::pair<int, int> > * commentZones)
|
||||
void FunctionParser::funcParse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName, const std::vector< std::pair<size_t, size_t> > * commentZones)
|
||||
{
|
||||
if (begin >= end)
|
||||
return;
|
||||
@ -388,20 +388,20 @@ void FunctionParser::funcParse(std::vector<foundInfo> & foundInfos, size_t begin
|
||||
int flags = SCFIND_REGEXP | SCFIND_POSIX | SCFIND_REGEXP_DOTMATCHESNL;
|
||||
|
||||
(*ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
||||
int targetStart = (*ppEditView)->searchInTarget(_functionExpr.c_str(), _functionExpr.length(), begin, end);
|
||||
int targetEnd = 0;
|
||||
size_t targetStart = (*ppEditView)->searchInTarget(_functionExpr.c_str(), _functionExpr.length(), begin, end);
|
||||
size_t targetEnd = 0;
|
||||
|
||||
//foundInfos.clear();
|
||||
while (targetStart >= 0)
|
||||
{
|
||||
targetStart = int((*ppEditView)->execute(SCI_GETTARGETSTART));
|
||||
targetEnd = int((*ppEditView)->execute(SCI_GETTARGETEND));
|
||||
if (targetEnd > int(end)) //we found a result but outside our range, therefore do not process it
|
||||
targetStart = (*ppEditView)->execute(SCI_GETTARGETSTART);
|
||||
targetEnd = (*ppEditView)->execute(SCI_GETTARGETEND);
|
||||
if (targetEnd > end) //we found a result but outside our range, therefore do not process it
|
||||
{
|
||||
break;
|
||||
}
|
||||
int foundTextLen = targetEnd - targetStart;
|
||||
if (targetStart + foundTextLen == int(end))
|
||||
size_t foundTextLen = targetEnd - targetStart;
|
||||
if (targetStart + foundTextLen == end)
|
||||
break;
|
||||
|
||||
foundInfo fi;
|
||||
@ -418,7 +418,7 @@ void FunctionParser::funcParse(std::vector<foundInfo> & foundInfos, size_t begin
|
||||
}
|
||||
else
|
||||
{
|
||||
int foundPos;
|
||||
INT_PTR foundPos;
|
||||
if (_functionNameExprArray.size())
|
||||
{
|
||||
fi._data = parseSubLevel(targetStart, targetEnd, _functionNameExprArray, foundPos, ppEditView);
|
||||
@ -454,7 +454,7 @@ void FunctionParser::funcParse(std::vector<foundInfo> & foundInfos, size_t begin
|
||||
}
|
||||
|
||||
|
||||
generic_string FunctionParser::parseSubLevel(size_t begin, size_t end, std::vector< generic_string > dataToSearch, int & foundPos, ScintillaEditView **ppEditView)
|
||||
generic_string FunctionParser::parseSubLevel(size_t begin, size_t end, std::vector< generic_string > dataToSearch, INT_PTR & foundPos, ScintillaEditView **ppEditView)
|
||||
{
|
||||
if (begin >= end)
|
||||
{
|
||||
@ -469,7 +469,7 @@ generic_string FunctionParser::parseSubLevel(size_t begin, size_t end, std::vect
|
||||
|
||||
(*ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
||||
const TCHAR *regExpr2search = dataToSearch[0].c_str();
|
||||
int targetStart = (*ppEditView)->searchInTarget(regExpr2search, lstrlen(regExpr2search), begin, end);
|
||||
INT_PTR targetStart = (*ppEditView)->searchInTarget(regExpr2search, lstrlen(regExpr2search), begin, end);
|
||||
|
||||
if (targetStart < 0)
|
||||
{
|
||||
@ -501,20 +501,20 @@ bool FunctionParsersManager::parse(std::vector<foundInfo> & foundInfos, const As
|
||||
return false;
|
||||
|
||||
// parse
|
||||
int docLen = (*_ppEditView)->getCurrentDocLen();
|
||||
size_t docLen = (*_ppEditView)->getCurrentDocLen();
|
||||
fp->parse(foundInfos, 0, docLen, _ppEditView);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
size_t FunctionZoneParser::getBodyClosePos(size_t begin, const TCHAR *bodyOpenSymbol, const TCHAR *bodyCloseSymbol, const std::vector< std::pair<int, int> > & commentZones, ScintillaEditView **ppEditView)
|
||||
size_t FunctionZoneParser::getBodyClosePos(size_t begin, const TCHAR *bodyOpenSymbol, const TCHAR *bodyCloseSymbol, const std::vector< std::pair<size_t, size_t> > & commentZones, ScintillaEditView **ppEditView)
|
||||
{
|
||||
size_t cntOpen = 1;
|
||||
|
||||
int docLen = (*ppEditView)->getCurrentDocLen();
|
||||
size_t docLen = (*ppEditView)->getCurrentDocLen();
|
||||
|
||||
if (begin >= (size_t)docLen)
|
||||
if (begin >= docLen)
|
||||
return docLen;
|
||||
|
||||
generic_string exprToSearch = TEXT("(");
|
||||
@ -527,7 +527,7 @@ size_t FunctionZoneParser::getBodyClosePos(size_t begin, const TCHAR *bodyOpenSy
|
||||
int flags = SCFIND_REGEXP | SCFIND_POSIX | SCFIND_REGEXP_DOTMATCHESNL;
|
||||
|
||||
(*ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
||||
int targetStart = (*ppEditView)->searchInTarget(exprToSearch.c_str(), exprToSearch.length(), begin, docLen);
|
||||
INT_PTR targetStart = (*ppEditView)->searchInTarget(exprToSearch.c_str(), exprToSearch.length(), begin, docLen);
|
||||
LRESULT targetEnd = 0;
|
||||
|
||||
do
|
||||
@ -540,7 +540,7 @@ size_t FunctionZoneParser::getBodyClosePos(size_t begin, const TCHAR *bodyOpenSy
|
||||
if (!isInZones(targetStart, commentZones))
|
||||
{
|
||||
// Now we determinate the symbol (open or close)
|
||||
int tmpStart = (*ppEditView)->searchInTarget(bodyOpenSymbol, lstrlen(bodyOpenSymbol), targetStart, targetEnd);
|
||||
INT_PTR tmpStart = (*ppEditView)->searchInTarget(bodyOpenSymbol, lstrlen(bodyOpenSymbol), targetStart, targetEnd);
|
||||
if (tmpStart >= 0) // open symbol found
|
||||
{
|
||||
++cntOpen;
|
||||
@ -564,7 +564,7 @@ size_t FunctionZoneParser::getBodyClosePos(size_t begin, const TCHAR *bodyOpenSy
|
||||
return targetEnd;
|
||||
}
|
||||
|
||||
void FunctionZoneParser::classParse(vector<foundInfo> & foundInfos, vector< pair<int, int> > &scannedZones, const std::vector< std::pair<int, int> > & commentZones, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName)
|
||||
void FunctionZoneParser::classParse(vector<foundInfo> & foundInfos, vector< pair<size_t, size_t> > &scannedZones, const std::vector< std::pair<size_t, size_t> > & commentZones, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName)
|
||||
{
|
||||
if (begin >= end)
|
||||
return;
|
||||
@ -572,31 +572,31 @@ void FunctionZoneParser::classParse(vector<foundInfo> & foundInfos, vector< pair
|
||||
int flags = SCFIND_REGEXP | SCFIND_POSIX | SCFIND_REGEXP_DOTMATCHESNL;
|
||||
|
||||
(*ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
||||
int targetStart = (*ppEditView)->searchInTarget(_rangeExpr.c_str(), _rangeExpr.length(), begin, end);
|
||||
INT_PTR targetStart = (*ppEditView)->searchInTarget(_rangeExpr.c_str(), _rangeExpr.length(), begin, end);
|
||||
|
||||
int targetEnd = 0;
|
||||
INT_PTR targetEnd = 0;
|
||||
|
||||
while (targetStart >= 0)
|
||||
{
|
||||
targetEnd = int((*ppEditView)->execute(SCI_GETTARGETEND));
|
||||
targetEnd = (*ppEditView)->execute(SCI_GETTARGETEND);
|
||||
|
||||
// Get class name
|
||||
int foundPos = 0;
|
||||
INT_PTR foundPos = 0;
|
||||
generic_string classStructName = parseSubLevel(targetStart, targetEnd, _classNameExprArray, foundPos, ppEditView);
|
||||
|
||||
|
||||
if (!_openSymbole.empty() && !_closeSymbole.empty())
|
||||
{
|
||||
targetEnd = static_cast<int32_t>(getBodyClosePos(targetEnd, _openSymbole.c_str(), _closeSymbole.c_str(), commentZones, ppEditView));
|
||||
targetEnd = getBodyClosePos(targetEnd, _openSymbole.c_str(), _closeSymbole.c_str(), commentZones, ppEditView);
|
||||
}
|
||||
|
||||
if (targetEnd > int(end)) //we found a result but outside our range, therefore do not process it
|
||||
if (targetEnd > static_cast<INT_PTR>(end)) //we found a result but outside our range, therefore do not process it
|
||||
break;
|
||||
|
||||
scannedZones.push_back(pair<int, int>(targetStart, targetEnd));
|
||||
scannedZones.push_back(pair<size_t, size_t>(targetStart, targetEnd));
|
||||
|
||||
int foundTextLen = targetEnd - targetStart;
|
||||
if (targetStart + foundTextLen == int(end))
|
||||
size_t foundTextLen = targetEnd - targetStart;
|
||||
if (targetStart + foundTextLen == end)
|
||||
break;
|
||||
|
||||
// Begin to search all method inside
|
||||
@ -611,7 +611,7 @@ void FunctionZoneParser::classParse(vector<foundInfo> & foundInfos, vector< pair
|
||||
}
|
||||
|
||||
|
||||
void FunctionParser::getCommentZones(vector< pair<int, int> > & commentZone, size_t begin, size_t end, ScintillaEditView **ppEditView)
|
||||
void FunctionParser::getCommentZones(vector< pair<size_t, size_t> > & commentZone, size_t begin, size_t end, ScintillaEditView **ppEditView)
|
||||
{
|
||||
if ((begin >= end) || (_commentExpr.empty()))
|
||||
return;
|
||||
@ -619,20 +619,20 @@ void FunctionParser::getCommentZones(vector< pair<int, int> > & commentZone, siz
|
||||
int flags = SCFIND_REGEXP | SCFIND_POSIX | SCFIND_REGEXP_DOTMATCHESNL;
|
||||
|
||||
(*ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
||||
int targetStart = (*ppEditView)->searchInTarget(_commentExpr.c_str(), _commentExpr.length(), begin, end);
|
||||
int targetEnd = 0;
|
||||
INT_PTR targetStart = (*ppEditView)->searchInTarget(_commentExpr.c_str(), _commentExpr.length(), begin, end);
|
||||
INT_PTR targetEnd = 0;
|
||||
|
||||
while (targetStart >= 0)
|
||||
{
|
||||
targetStart = int((*ppEditView)->execute(SCI_GETTARGETSTART));
|
||||
targetEnd = int((*ppEditView)->execute(SCI_GETTARGETEND));
|
||||
if (targetEnd > int(end)) //we found a result but outside our range, therefore do not process it
|
||||
targetStart = (*ppEditView)->execute(SCI_GETTARGETSTART);
|
||||
targetEnd = (*ppEditView)->execute(SCI_GETTARGETEND);
|
||||
if (targetEnd > static_cast<INT_PTR>(end)) //we found a result but outside our range, therefore do not process it
|
||||
break;
|
||||
|
||||
commentZone.push_back(pair<int, int>(targetStart, targetEnd));
|
||||
commentZone.push_back(pair<size_t, size_t>(targetStart, targetEnd));
|
||||
|
||||
int foundTextLen = targetEnd - targetStart;
|
||||
if (targetStart + foundTextLen == int(end))
|
||||
INT_PTR foundTextLen = targetEnd - targetStart;
|
||||
if (targetStart + foundTextLen == static_cast<INT_PTR>(end))
|
||||
break;
|
||||
|
||||
begin = targetStart + foundTextLen;
|
||||
@ -641,7 +641,7 @@ void FunctionParser::getCommentZones(vector< pair<int, int> > & commentZone, siz
|
||||
}
|
||||
|
||||
|
||||
bool FunctionParser::isInZones(int pos2Test, const std::vector< std::pair<int, int> > & zones)
|
||||
bool FunctionParser::isInZones(size_t pos2Test, const std::vector< std::pair<size_t, size_t>> & zones)
|
||||
{
|
||||
for (size_t i = 0, len = zones.size(); i < len; ++i)
|
||||
{
|
||||
@ -652,38 +652,38 @@ bool FunctionParser::isInZones(int pos2Test, const std::vector< std::pair<int, i
|
||||
}
|
||||
|
||||
|
||||
void FunctionParser::getInvertZones(vector< pair<int, int> > & destZones, vector< pair<int, int> > & sourceZones, size_t begin, size_t end)
|
||||
void FunctionParser::getInvertZones(vector< pair<size_t, size_t> > & destZones, vector< pair<size_t, size_t> > & sourceZones, size_t begin, size_t end)
|
||||
{
|
||||
if (sourceZones.size() == 0)
|
||||
{
|
||||
destZones.push_back(pair<int, int>(static_cast<int>(begin), static_cast<int>(end)));
|
||||
destZones.push_back(pair<size_t, size_t>(begin, end));
|
||||
}
|
||||
else
|
||||
{
|
||||
// check the begin
|
||||
if (int(begin) < sourceZones[0].first)
|
||||
{
|
||||
destZones.push_back(pair<int, int>(static_cast<int>(begin), sourceZones[0].first - 1));
|
||||
destZones.push_back(pair<size_t, size_t>(begin, sourceZones[0].first - 1));
|
||||
}
|
||||
|
||||
size_t i = 0;
|
||||
for (size_t len = sourceZones.size() - 1; i < len; ++i)
|
||||
{
|
||||
int newBegin = sourceZones[i].second + 1;
|
||||
int newEnd = sourceZones[i+1].first - 1;
|
||||
size_t newBegin = sourceZones[i].second + 1;
|
||||
size_t newEnd = sourceZones[i+1].first - 1;
|
||||
if (newBegin < newEnd)
|
||||
destZones.push_back(pair<int, int>(newBegin, newEnd));
|
||||
destZones.push_back(pair<size_t, size_t>(newBegin, newEnd));
|
||||
}
|
||||
int lastBegin = sourceZones[i].second + 1;
|
||||
if (lastBegin < int(end))
|
||||
destZones.push_back(pair<int, int>(lastBegin, static_cast<int>(end)));
|
||||
size_t lastBegin = sourceZones[i].second + 1;
|
||||
if (lastBegin < end)
|
||||
destZones.push_back(pair<size_t, size_t>(lastBegin, end));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FunctionZoneParser::parse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName)
|
||||
{
|
||||
vector< pair<int, int> > classZones, commentZones, nonCommentZones;
|
||||
vector< pair<size_t, size_t> > classZones, commentZones, nonCommentZones;
|
||||
getCommentZones(commentZones, begin, end, ppEditView);
|
||||
getInvertZones(nonCommentZones, commentZones, begin, end);
|
||||
for (size_t i = 0, len = nonCommentZones.size(); i < len; ++i)
|
||||
@ -694,7 +694,7 @@ void FunctionZoneParser::parse(std::vector<foundInfo> & foundInfos, size_t begin
|
||||
|
||||
void FunctionUnitParser::parse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName)
|
||||
{
|
||||
vector< pair<int, int> > commentZones, nonCommentZones;
|
||||
vector< pair<size_t, size_t> > commentZones, nonCommentZones;
|
||||
getCommentZones(commentZones, begin, end, ppEditView);
|
||||
getInvertZones(nonCommentZones, commentZones, begin, end);
|
||||
for (size_t i = 0, len = nonCommentZones.size(); i < len; ++i)
|
||||
@ -716,7 +716,7 @@ struct SortZones final
|
||||
|
||||
void FunctionMixParser::parse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName)
|
||||
{
|
||||
vector< pair<int, int> > commentZones, scannedZones, nonScannedZones;
|
||||
vector< pair<size_t, size_t> > commentZones, scannedZones, nonScannedZones;
|
||||
getCommentZones(commentZones, begin, end, ppEditView);
|
||||
|
||||
classParse(foundInfos, scannedZones, commentZones, begin, end, ppEditView, classStructName);
|
||||
@ -724,7 +724,7 @@ void FunctionMixParser::parse(std::vector<foundInfo> & foundInfos, size_t begin,
|
||||
// the second level
|
||||
for (size_t i = 0, len = scannedZones.size(); i < len; ++i)
|
||||
{
|
||||
vector< pair<int, int> > temp;
|
||||
vector< pair<size_t, size_t> > temp;
|
||||
classParse(foundInfos, temp, commentZones, scannedZones[i].first, scannedZones[i].second, ppEditView, classStructName);
|
||||
}
|
||||
// invert scannedZones
|
||||
|
@ -24,8 +24,8 @@ struct foundInfo final
|
||||
{
|
||||
generic_string _data;
|
||||
generic_string _data2;
|
||||
int _pos = -1;
|
||||
int _pos2 = -1;
|
||||
INT_PTR _pos = -1;
|
||||
INT_PTR _pos2 = -1;
|
||||
};
|
||||
|
||||
class FunctionParser
|
||||
@ -36,8 +36,8 @@ public:
|
||||
_id(id), _displayName(displayName), _commentExpr(commentExpr?commentExpr:TEXT("")), _functionExpr(functionExpr), _functionNameExprArray(functionNameExprArray), _classNameExprArray(classNameExprArray){};
|
||||
|
||||
virtual void parse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName = TEXT("")) = 0;
|
||||
void funcParse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName = TEXT(""), const std::vector< std::pair<int, int> > * commentZones = NULL);
|
||||
bool isInZones(int pos2Test, const std::vector< std::pair<int, int> > & zones);
|
||||
void funcParse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName = TEXT(""), const std::vector< std::pair<size_t, size_t> > * commentZones = NULL);
|
||||
bool isInZones(size_t pos2Test, const std::vector< std::pair<size_t, size_t> > & zones);
|
||||
virtual ~FunctionParser() = default;
|
||||
|
||||
protected:
|
||||
@ -47,9 +47,9 @@ protected:
|
||||
generic_string _functionExpr;
|
||||
std::vector<generic_string> _functionNameExprArray;
|
||||
std::vector<generic_string> _classNameExprArray;
|
||||
void getCommentZones(std::vector< std::pair<int, int> > & commentZone, size_t begin, size_t end, ScintillaEditView **ppEditView);
|
||||
void getInvertZones(std::vector< std::pair<int, int> > & destZones, std::vector< std::pair<int, int> > & sourceZones, size_t begin, size_t end);
|
||||
generic_string parseSubLevel(size_t begin, size_t end, std::vector< generic_string > dataToSearch, int & foundPos, ScintillaEditView **ppEditView);
|
||||
void getCommentZones(std::vector< std::pair<size_t, size_t> > & commentZone, size_t begin, size_t end, ScintillaEditView **ppEditView);
|
||||
void getInvertZones(std::vector< std::pair<size_t, size_t> > & destZones, std::vector< std::pair<size_t, size_t> > & sourceZones, size_t begin, size_t end);
|
||||
generic_string parseSubLevel(size_t begin, size_t end, std::vector< generic_string > dataToSearch, INT_PTR & foundPos, ScintillaEditView **ppEditView);
|
||||
};
|
||||
|
||||
|
||||
@ -64,14 +64,14 @@ public:
|
||||
void parse(std::vector<foundInfo> & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName = TEXT(""));
|
||||
|
||||
protected:
|
||||
void classParse(std::vector<foundInfo> & foundInfos, std::vector< std::pair<int, int> > & scannedZones, const std::vector< std::pair<int, int> > & commentZones, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName = TEXT(""));
|
||||
void classParse(std::vector<foundInfo> & foundInfos, std::vector< std::pair<size_t, size_t> > & scannedZones, const std::vector< std::pair<size_t, size_t> > & commentZones, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName = TEXT(""));
|
||||
|
||||
private:
|
||||
generic_string _rangeExpr;
|
||||
generic_string _openSymbole;
|
||||
generic_string _closeSymbole;
|
||||
|
||||
size_t getBodyClosePos(size_t begin, const TCHAR *bodyOpenSymbol, const TCHAR *bodyCloseSymbol, const std::vector< std::pair<int, int> > & commentZones, ScintillaEditView **ppEditView);
|
||||
size_t getBodyClosePos(size_t begin, const TCHAR *bodyOpenSymbol, const TCHAR *bodyCloseSymbol, const std::vector< std::pair<size_t, size_t> > & commentZones, ScintillaEditView **ppEditView);
|
||||
};
|
||||
|
||||
|
||||
|
@ -422,7 +422,7 @@ INT_PTR CALLBACK WindowsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPa
|
||||
}
|
||||
else if (pLvdi->item.iSubItem == 3) // size
|
||||
{
|
||||
int docSize = buf->docLength();
|
||||
size_t docSize = buf->docLength();
|
||||
string docSizeText = to_string(docSize);
|
||||
text = wstring(docSizeText.begin(), docSizeText.end());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user