mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
+ dynamic allocation of temp. line buffer instead of fixed max. buffer size
This commit is contained in:
parent
7dd1962d7c
commit
003c8c8dfa
273
src/Edit.c
273
src/Edit.c
@ -144,11 +144,6 @@ static char AutoCompleteWordASCII[ANSI_CAHR_BUFFER] = { '\0' };
|
||||
#define IsAccelWhiteSpace(ch) StrChrA(WhiteSpaceCharsAccelerated, (ch))
|
||||
|
||||
|
||||
// temporary line buffer for fast line ops
|
||||
// make sure to handle it in closed loops locally only
|
||||
static char g_pTempLineBuffer[TEMPLINE_BUFFER];
|
||||
|
||||
|
||||
enum AlignMask {
|
||||
ALIGN_LEFT = 0,
|
||||
ALIGN_RIGHT = 1,
|
||||
@ -2751,6 +2746,7 @@ void EditIndentBlock(HWND hwnd, int cmd, bool bFormatIndentation)
|
||||
void EditAlignText(HWND hwnd,int nMode)
|
||||
{
|
||||
#define BUFSIZE_ALIGN 512
|
||||
char chNewLineBuf[BUFSIZE_ALIGN * 3] = { '\0' };
|
||||
WCHAR wchNewLineBuf[BUFSIZE_ALIGN * 3] = { L'\0' };
|
||||
|
||||
const DocPos iSelStart = SciCall_GetSelectionStart();
|
||||
@ -2893,9 +2889,10 @@ void EditAlignText(HWND hwnd,int nMode)
|
||||
}
|
||||
}
|
||||
|
||||
int const cch = WideCharToMultiByteStrg(Encoding_SciCP, wchNewLineBuf, g_pTempLineBuffer) - 1;
|
||||
|
||||
int const cch = WideCharToMultiByteStrg(Encoding_SciCP, wchNewLineBuf, chNewLineBuf) - 1;
|
||||
SciCall_SetTargetRange(SciCall_PositionFromLine(iLine), SciCall_GetLineEndPosition(iLine));
|
||||
SciCall_ReplaceTarget(cch, g_pTempLineBuffer);
|
||||
SciCall_ReplaceTarget(cch, chNewLineBuf);
|
||||
SciCall_SetLineIndentation(iLine, iMinIndent);
|
||||
}
|
||||
else {
|
||||
@ -2926,7 +2923,7 @@ void EditAlignText(HWND hwnd,int nMode)
|
||||
p = StrEnd(p,0);
|
||||
}
|
||||
|
||||
int cch = WideCharToMultiByteStrg(Encoding_SciCP,wchNewLineBuf,g_pTempLineBuffer) - 1;
|
||||
int cch = WideCharToMultiByteStrg(Encoding_SciCP,wchNewLineBuf,chNewLineBuf) - 1;
|
||||
|
||||
DocPos iPos = 0;
|
||||
if (nMode == ALIGN_RIGHT || nMode == ALIGN_CENTER) {
|
||||
@ -2937,7 +2934,7 @@ void EditAlignText(HWND hwnd,int nMode)
|
||||
iPos = SciCall_PositionFromLine(iLine);
|
||||
}
|
||||
SciCall_SetTargetRange(iPos, SciCall_GetLineEndPosition(iLine));
|
||||
SciCall_ReplaceTarget(cch, g_pTempLineBuffer);
|
||||
SciCall_ReplaceTarget(cch, chNewLineBuf);
|
||||
|
||||
if (nMode == ALIGN_LEFT) {
|
||||
SciCall_SetLineIndentation(iLine, iMinIndent);
|
||||
@ -3295,8 +3292,10 @@ void EditStripFirstCharacter(HWND hwnd)
|
||||
{
|
||||
UNUSED(hwnd);
|
||||
|
||||
DocPos iSelStart = 0;
|
||||
DocPos iSelEnd = 0;
|
||||
DocPos const iSelStart = SciCall_IsSelectionEmpty() ? 0 : SciCall_GetSelectionStart();
|
||||
DocPos const iSelEnd = SciCall_IsSelectionEmpty() ? Sci_GetDocEndPosition() : SciCall_GetSelectionEnd();
|
||||
DocLn const iLineStart = SciCall_LineFromPosition(iSelStart);
|
||||
DocLn const iLineEnd = SciCall_LineFromPosition(iSelEnd);
|
||||
|
||||
_IGNORE_NOTIFY_CHANGE_;
|
||||
_ENTER_TARGET_TRANSACTION_;
|
||||
@ -3312,31 +3311,27 @@ void EditStripFirstCharacter(HWND hwnd)
|
||||
const DocPos vSpcAnchorMainPos = SciCall_GetRectangularSelectionAnchorVirtualSpace();
|
||||
const DocPos vSpcCaretMainPos = SciCall_GetRectangularSelectionCaretVirtualSpace();
|
||||
|
||||
DocPos iMaxLineLen = Sci_GetRangeMaxLineLength(iLineStart, iLineEnd);
|
||||
char* lineBuffer = AllocMem(iMaxLineLen + 1, HEAP_ZERO_MEMORY);
|
||||
DocPos remCount = 0;
|
||||
const DocPosU selCount = SciCall_GetSelections();
|
||||
for (DocPosU s = 0; s < selCount; ++s) {
|
||||
const DocPos selCaretPos = SciCall_GetSelectionNCaret(s);
|
||||
const DocPos selAnchorPos = SciCall_GetSelectionNAnchor(s);
|
||||
//const DocPos vSpcCaretPos = SciCall_GetSelectionNCaretVirtualSpace(s);
|
||||
//const DocPos vSpcAnchorPos = SciCall_GetSelectionNAnchorVirtualSpace(s);
|
||||
|
||||
const DocPos selTargetStart = (selAnchorPos < selCaretPos) ? selAnchorPos : selCaretPos;
|
||||
const DocPos selTargetEnd = (selAnchorPos < selCaretPos) ? selCaretPos : selAnchorPos;
|
||||
//const DocPos vSpcLength = (selAnchorPos < selCaretPos) ? (vSpcCaretPos - vSpcAnchorPos) : (vSpcAnchorPos - vSpcCaretPos);
|
||||
|
||||
const DocPos nextPos = (selTargetStart < selTargetEnd) ? SciCall_PositionAfter(selTargetStart) : selTargetEnd;
|
||||
const DocPos diff = (nextPos <= selTargetEnd) ? (nextPos - selTargetStart) : 0;
|
||||
|
||||
const DocPos len = (selTargetEnd - nextPos);
|
||||
if ((len >= 0) && (len < TEMPLINE_BUFFER)) //TODO: @@@ alloc memory dynamically
|
||||
if (lineBuffer) {
|
||||
DocPosU const selCount = SciCall_GetSelections();
|
||||
for (DocPosU s = 0; s < selCount; ++s)
|
||||
{
|
||||
StringCchCopyNA(g_pTempLineBuffer, TEMPLINE_BUFFER, SciCall_GetRangePointer(nextPos, len + 1), len);
|
||||
SciCall_SetTargetRange(selTargetStart, selTargetEnd);
|
||||
SciCall_ReplaceTarget(len, g_pTempLineBuffer);
|
||||
}
|
||||
remCount += diff;
|
||||
} // for()
|
||||
|
||||
DocPos const selTargetStart = SciCall_GetSelectionNStart(s);
|
||||
DocPos const selTargetEnd = SciCall_GetSelectionNEnd(s);
|
||||
DocPos const nextPos = SciCall_PositionAfter(selTargetStart);
|
||||
DocPos const len = (selTargetEnd - nextPos);
|
||||
if (len > 0) {
|
||||
StringCchCopyNA(lineBuffer, iMaxLineLen, SciCall_GetRangePointer(nextPos, len + 1), len);
|
||||
SciCall_SetTargetRange(selTargetStart, selTargetEnd);
|
||||
SciCall_ReplaceTarget(len, lineBuffer);
|
||||
}
|
||||
remCount += (nextPos - selTargetStart);
|
||||
} // for()
|
||||
FreeMem(lineBuffer);
|
||||
}
|
||||
|
||||
SciCall_SetRectangularSelectionAnchor(selAnchorMainPos);
|
||||
if (vSpcAnchorMainPos > 0)
|
||||
SciCall_SetRectangularSelectionAnchorVirtualSpace(vSpcAnchorMainPos);
|
||||
@ -3348,18 +3343,6 @@ void EditStripFirstCharacter(HWND hwnd)
|
||||
}
|
||||
else // SC_SEL_LINES | SC_SEL_STREAM
|
||||
{
|
||||
if (SciCall_IsSelectionEmpty())
|
||||
{
|
||||
iSelEnd = Sci_GetDocEndPosition();
|
||||
}
|
||||
else {
|
||||
iSelStart = SciCall_GetSelectionStart();
|
||||
iSelEnd = SciCall_GetSelectionEnd();
|
||||
}
|
||||
|
||||
const DocLn iLineStart = SciCall_LineFromPosition(iSelStart);
|
||||
const DocLn iLineEnd = SciCall_LineFromPosition(iSelEnd);
|
||||
|
||||
for (DocLn iLine = iLineStart; iLine <= iLineEnd; ++iLine) {
|
||||
const DocPos iPos = SciCall_PositionFromLine(iLine);
|
||||
if (iPos < SciCall_GetLineEndPosition(iLine)) {
|
||||
@ -3381,13 +3364,16 @@ void EditStripLastCharacter(HWND hwnd, bool bIgnoreSelection, bool bTrailingBlan
|
||||
{
|
||||
UNUSED(hwnd);
|
||||
|
||||
DocPos iSelStart = 0;
|
||||
DocPos iSelEnd = 0;
|
||||
DocPos const iSelStart = (SciCall_IsSelectionEmpty() || bIgnoreSelection) ? 0 : SciCall_GetSelectionStart();
|
||||
DocPos const iSelEnd = (SciCall_IsSelectionEmpty() || bIgnoreSelection) ? Sci_GetDocEndPosition() : SciCall_GetSelectionEnd();
|
||||
DocLn const iLineStart = SciCall_LineFromPosition(iSelStart);
|
||||
DocLn const iLineEnd = SciCall_LineFromPosition(iSelEnd);
|
||||
|
||||
_IGNORE_NOTIFY_CHANGE_;
|
||||
_ENTER_TARGET_TRANSACTION_;
|
||||
|
||||
if (SciCall_IsSelectionRectangle() && !bIgnoreSelection) {
|
||||
if (SciCall_IsSelectionRectangle() && !bIgnoreSelection)
|
||||
{
|
||||
if (SciCall_IsSelectionEmpty()) {
|
||||
SciCall_Clear();
|
||||
}
|
||||
@ -3397,62 +3383,54 @@ void EditStripLastCharacter(HWND hwnd, bool bIgnoreSelection, bool bTrailingBlan
|
||||
const DocPos vSpcAnchorMainPos = SciCall_GetRectangularSelectionAnchorVirtualSpace();
|
||||
const DocPos vSpcCaretMainPos = SciCall_GetRectangularSelectionCaretVirtualSpace();
|
||||
|
||||
DocPos iMaxLineLen = Sci_GetRangeMaxLineLength(iLineStart, iLineEnd);
|
||||
char* lineBuffer = AllocMem(iMaxLineLen + 1, HEAP_ZERO_MEMORY);
|
||||
DocPos remCount = 0;
|
||||
const DocPosU selCount = SciCall_GetSelections();
|
||||
for (DocPosU s = 0; s < selCount; ++s)
|
||||
{
|
||||
const DocPos selCaretPos = SciCall_GetSelectionNCaret(s);
|
||||
const DocPos selAnchorPos = SciCall_GetSelectionNAnchor(s);
|
||||
//const DocPos vSpcCaretPos = SciCall_GetSelectionNCaretVirtualSpace(s);
|
||||
//const DocPos vSpcAnchorPos = SciCall_GetSelectionNAnchorVirtualSpace(s);
|
||||
|
||||
const DocPos selTargetStart = (selAnchorPos < selCaretPos) ? selAnchorPos : selCaretPos;
|
||||
const DocPos selTargetEnd = (selAnchorPos < selCaretPos) ? selCaretPos : selAnchorPos;
|
||||
//const DocPos vSpcLength = (selAnchorPos < selCaretPos) ? (vSpcCaretPos - vSpcAnchorPos) : (vSpcAnchorPos - vSpcCaretPos);
|
||||
|
||||
DocPos diff = 0;
|
||||
DocPos len = 0;
|
||||
|
||||
if (bTrailingBlanksOnly)
|
||||
if (lineBuffer) {
|
||||
const DocPosU selCount = SciCall_GetSelections();
|
||||
for (DocPosU s = 0; s < selCount; ++s)
|
||||
{
|
||||
len = (selTargetEnd - selTargetStart);
|
||||
if ((len >= 0) && (len < TEMPLINE_BUFFER))
|
||||
{
|
||||
StringCchCopyNA(g_pTempLineBuffer, TEMPLINE_BUFFER, SciCall_GetRangePointer(selTargetStart, len + 1), len);
|
||||
DocPos end = (DocPos)StrCSpnA(g_pTempLineBuffer, "\r\n");
|
||||
DocPos i = end;
|
||||
while (--i >= 0) {
|
||||
const char ch = g_pTempLineBuffer[i];
|
||||
if (IsBlankChar(ch)) {
|
||||
g_pTempLineBuffer[i] = '\0';
|
||||
DocPos const selTargetStart = SciCall_GetSelectionNStart(s);
|
||||
DocPos const selTargetEnd = SciCall_GetSelectionNEnd(s);
|
||||
|
||||
DocPos diff = 0;
|
||||
DocPos len = 0;
|
||||
if (bTrailingBlanksOnly) {
|
||||
len = (selTargetEnd - selTargetStart);
|
||||
if (len > 0) {
|
||||
StringCchCopyNA(lineBuffer, iMaxLineLen, SciCall_GetRangePointer(selTargetStart, len + 1), len);
|
||||
DocPos end = (DocPos)StrCSpnA(lineBuffer, "\r\n");
|
||||
DocPos i = end;
|
||||
while (--i >= 0) {
|
||||
const char ch = lineBuffer[i];
|
||||
if (IsBlankChar(ch)) {
|
||||
lineBuffer[i] = '\0';
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
while (end < len) {
|
||||
lineBuffer[++i] = lineBuffer[end++]; // add "\r\n" if any
|
||||
}
|
||||
diff = len - (++i);
|
||||
SciCall_SetTargetRange(selTargetStart, selTargetEnd);
|
||||
SciCall_ReplaceTarget(-1, lineBuffer);
|
||||
}
|
||||
while (end < len) {
|
||||
g_pTempLineBuffer[++i] = g_pTempLineBuffer[end++]; // add "\r\n" if anny
|
||||
}
|
||||
else {
|
||||
DocPos const prevPos = SciCall_PositionBefore(selTargetEnd);
|
||||
diff = (selTargetEnd - prevPos);
|
||||
len = (prevPos - selTargetStart);
|
||||
if (len > 0) {
|
||||
StringCchCopyNA(lineBuffer, iMaxLineLen, SciCall_GetRangePointer(selTargetStart, len + 1), len);
|
||||
SciCall_SetTargetRange(selTargetStart, selTargetEnd);
|
||||
SciCall_ReplaceTarget(len, lineBuffer);
|
||||
}
|
||||
diff = len - (++i);
|
||||
SciCall_SetTargetRange(selTargetStart, selTargetEnd);
|
||||
SciCall_ReplaceTarget(-1, g_pTempLineBuffer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
const DocPos prevPos = (selTargetStart < selTargetEnd) ? SciCall_PositionBefore(selTargetEnd) : selTargetStart;
|
||||
diff = (prevPos >= selTargetStart) ? (selTargetEnd - prevPos) : 0;
|
||||
len = (prevPos - selTargetStart);
|
||||
|
||||
if ((len >= 0) && (len < TEMPLINE_BUFFER))
|
||||
{
|
||||
StringCchCopyNA(g_pTempLineBuffer, TEMPLINE_BUFFER, SciCall_GetRangePointer(selTargetStart, len + 1), len);
|
||||
SciCall_SetTargetRange(selTargetStart, selTargetEnd);
|
||||
SciCall_ReplaceTarget(len, g_pTempLineBuffer);
|
||||
}
|
||||
}
|
||||
remCount += diff;
|
||||
|
||||
} // for()
|
||||
remCount += diff;
|
||||
} // for()
|
||||
FreeMem(lineBuffer);
|
||||
}
|
||||
|
||||
SciCall_SetRectangularSelectionAnchor(selAnchorMainPos);
|
||||
if (vSpcAnchorMainPos > 0)
|
||||
@ -3465,21 +3443,10 @@ void EditStripLastCharacter(HWND hwnd, bool bIgnoreSelection, bool bTrailingBlan
|
||||
}
|
||||
else // SC_SEL_LINES | SC_SEL_STREAM
|
||||
{
|
||||
if (SciCall_IsSelectionEmpty() || bIgnoreSelection) {
|
||||
iSelEnd = Sci_GetDocEndPosition();
|
||||
}
|
||||
else {
|
||||
iSelStart = SciCall_GetSelectionStart();
|
||||
iSelEnd = SciCall_GetSelectionEnd();
|
||||
}
|
||||
|
||||
const DocLn iLineStart = SciCall_LineFromPosition(iSelStart);
|
||||
const DocLn iLineEnd = SciCall_LineFromPosition(iSelEnd);
|
||||
|
||||
for (DocLn iLine = iLineStart; iLine <= iLineEnd; ++iLine)
|
||||
{
|
||||
const DocPos iStartPos = SciCall_PositionFromLine(iLine);
|
||||
const DocPos iEndPos = SciCall_GetLineEndPosition(iLine);
|
||||
DocPos const iStartPos = SciCall_PositionFromLine(iLine);
|
||||
DocPos const iEndPos = SciCall_GetLineEndPosition(iLine);
|
||||
|
||||
if (bTrailingBlanksOnly)
|
||||
{
|
||||
@ -3515,6 +3482,11 @@ void EditCompressBlanks(HWND hwnd)
|
||||
{
|
||||
const bool bIsSelEmpty = SciCall_IsSelectionEmpty();
|
||||
|
||||
const DocPos iSelStartPos = SciCall_GetSelectionStart();
|
||||
const DocPos iSelEndPos = SciCall_GetSelectionEnd();
|
||||
const DocLn iLineStart = SciCall_LineFromPosition(iSelStartPos);
|
||||
const DocLn iLineEnd = SciCall_LineFromPosition(iSelEndPos);
|
||||
|
||||
if (SciCall_IsSelectionRectangle()) {
|
||||
if (bIsSelEmpty) {
|
||||
return;
|
||||
@ -3525,44 +3497,44 @@ void EditCompressBlanks(HWND hwnd)
|
||||
const DocPos vSpcAnchorMainPos = SciCall_GetRectangularSelectionAnchorVirtualSpace();
|
||||
const DocPos vSpcCaretMainPos = SciCall_GetRectangularSelectionCaretVirtualSpace();
|
||||
|
||||
DocPos iMaxLineLen = Sci_GetRangeMaxLineLength(iLineStart, iLineEnd);
|
||||
char* lineBuffer = AllocMem(iMaxLineLen + 1, HEAP_ZERO_MEMORY);
|
||||
DocPos remCount = 0;
|
||||
const DocPosU selCount = SciCall_GetSelections();
|
||||
for (DocPosU s = 0; s < selCount; ++s)
|
||||
{
|
||||
const DocPos selCaretPos = SciCall_GetSelectionNCaret(s);
|
||||
const DocPos selAnchorPos = SciCall_GetSelectionNAnchor(s);
|
||||
//const DocPos vSpcCaretPos = SciCall_GetSelectionNCaretVirtualSpace(s);
|
||||
//const DocPos vSpcAnchorPos = SciCall_GetSelectionNAnchorVirtualSpace(s);
|
||||
if (lineBuffer) {
|
||||
const DocPosU selCount = SciCall_GetSelections();
|
||||
for (DocPosU s = 0; s < selCount; ++s) {
|
||||
const DocPos selCaretPos = SciCall_GetSelectionNCaret(s);
|
||||
const DocPos selAnchorPos = SciCall_GetSelectionNAnchor(s);
|
||||
//const DocPos vSpcCaretPos = SciCall_GetSelectionNCaretVirtualSpace(s);
|
||||
//const DocPos vSpcAnchorPos = SciCall_GetSelectionNAnchorVirtualSpace(s);
|
||||
|
||||
const DocPos selTargetStart = (selAnchorPos < selCaretPos) ? selAnchorPos : selCaretPos;
|
||||
const DocPos selTargetEnd = (selAnchorPos < selCaretPos) ? selCaretPos : selAnchorPos;
|
||||
//const DocPos vSpcLength = (selAnchorPos < selCaretPos) ? (vSpcCaretPos - vSpcAnchorPos) : (vSpcAnchorPos - vSpcCaretPos);
|
||||
const DocPos selTargetStart = (selAnchorPos < selCaretPos) ? selAnchorPos : selCaretPos;
|
||||
const DocPos selTargetEnd = (selAnchorPos < selCaretPos) ? selCaretPos : selAnchorPos;
|
||||
//const DocPos vSpcLength = (selAnchorPos < selCaretPos) ? (vSpcCaretPos - vSpcAnchorPos) : (vSpcAnchorPos - vSpcCaretPos);
|
||||
|
||||
DocPos diff = 0;
|
||||
DocPos len = 0;
|
||||
|
||||
len = (selTargetEnd - selTargetStart);
|
||||
if ((len >= 0) && (len < TEMPLINE_BUFFER))
|
||||
{
|
||||
char* pText = SciCall_GetRangePointer(selTargetStart, len + 1);
|
||||
const char* pEnd = (pText + len);
|
||||
DocPos i = 0;
|
||||
while (pText < pEnd) {
|
||||
const char ch = *pText++;
|
||||
if (IsBlankChar(ch)) {
|
||||
g_pTempLineBuffer[i++] = ' ';
|
||||
while (IsBlankChar(*pText)) { ++pText; }
|
||||
DocPos diff = 0;
|
||||
DocPos const len = (selTargetEnd - selTargetStart);
|
||||
if (len >= 0) {
|
||||
char* pText = SciCall_GetRangePointer(selTargetStart, len + 1);
|
||||
const char* pEnd = (pText + len);
|
||||
DocPos i = 0;
|
||||
while (pText < pEnd) {
|
||||
const char ch = *pText++;
|
||||
if (IsBlankChar(ch)) {
|
||||
lineBuffer[i++] = ' ';
|
||||
while (IsBlankChar(*pText)) { ++pText; }
|
||||
}
|
||||
else { lineBuffer[i++] = ch; }
|
||||
}
|
||||
else { g_pTempLineBuffer[i++] = ch; }
|
||||
lineBuffer[i] = '\0';
|
||||
diff = len - i;
|
||||
SciCall_SetTargetRange(selTargetStart, selTargetEnd);
|
||||
SciCall_ReplaceTarget(-1, lineBuffer);
|
||||
}
|
||||
g_pTempLineBuffer[i] = '\0';
|
||||
diff = len - i;
|
||||
SciCall_SetTargetRange(selTargetStart, selTargetEnd);
|
||||
SciCall_ReplaceTarget(-1, g_pTempLineBuffer);
|
||||
}
|
||||
remCount += diff;
|
||||
|
||||
} // for()
|
||||
remCount += diff;
|
||||
} // for()
|
||||
FreeMem(lineBuffer);
|
||||
}
|
||||
|
||||
SciCall_SetRectangularSelectionAnchor(selAnchorMainPos);
|
||||
if (vSpcAnchorMainPos > 0)
|
||||
@ -3577,12 +3549,7 @@ void EditCompressBlanks(HWND hwnd)
|
||||
{
|
||||
const DocPos iCurPos = SciCall_GetCurrentPos();
|
||||
const DocPos iAnchorPos = SciCall_GetAnchor();
|
||||
const DocPos iSelStartPos = SciCall_GetSelectionStart();
|
||||
const DocPos iSelEndPos = SciCall_GetSelectionEnd();
|
||||
const DocPos iSelLength = (iSelEndPos - iSelStartPos);
|
||||
|
||||
const DocLn iLineStart = SciCall_LineFromPosition(iSelStartPos);
|
||||
const DocLn iLineEnd = SciCall_LineFromPosition(iSelEndPos);
|
||||
const DocPos iTxtLength = SciCall_GetTextLength();
|
||||
|
||||
bool bIsLineStart = true;
|
||||
@ -3598,7 +3565,7 @@ void EditCompressBlanks(HWND hwnd)
|
||||
pszOut = AllocMem(cch + 1, HEAP_ZERO_MEMORY);
|
||||
}
|
||||
else {
|
||||
pszIn = (const char*)SciCall_GetRangePointer(iSelStartPos, iSelLength);
|
||||
pszIn = (const char*)SciCall_GetRangePointer(iSelStartPos, iSelLength + 1);
|
||||
cch = SciCall_GetSelText(NULL) - 1;
|
||||
pszOut = AllocMem(cch + 1, HEAP_ZERO_MEMORY);
|
||||
bIsLineStart = (iSelStartPos == SciCall_PositionFromLine(iLineStart));
|
||||
@ -3606,7 +3573,7 @@ void EditCompressBlanks(HWND hwnd)
|
||||
}
|
||||
|
||||
if (pszIn && pszOut) {
|
||||
char* co = (char*)pszOut;
|
||||
char* co = pszOut;
|
||||
DocPos remWSuntilCaretPos = 0;
|
||||
for (int i = 0; i < cch; ++i) {
|
||||
if (IsBlankChar(pszIn[i])) {
|
||||
@ -7888,7 +7855,7 @@ static void __fastcall _SetFileVars(char* lpData, char* tch, LPFILEVARS lpfv)
|
||||
}
|
||||
|
||||
if (FileVars_ParseInt(tch, "fill-column", &i)) {
|
||||
lpfv->iLongLinesLimit = clampi(i, 0, 4096);
|
||||
lpfv->iLongLinesLimit = clampi(i, 0, LONG_LINES_MARKER_LIMIT);
|
||||
lpfv->mask |= FV_LONGLINESLIMIT;
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,8 +48,7 @@ extern LANGID g_iPrefLngLocID;
|
||||
|
||||
//=============================================================================
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifndef NDEBUG
|
||||
#if (defined(_DEBUG) || defined(DEBUG)) && !defined(NDEBUG)
|
||||
void DbgLog(const char *fmt, ...) {
|
||||
char buf[1024] = "";
|
||||
va_list va;
|
||||
@ -59,9 +58,6 @@ void DbgLog(const char *fmt, ...) {
|
||||
OutputDebugStringA(buf);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
|
||||
@ -59,7 +59,7 @@ extern UINT g_uCurrentPPI;
|
||||
|
||||
// ============================================================================
|
||||
|
||||
#if defined(DEBUG) && !defined(NDEBUG)
|
||||
#if (defined(_DEBUG) || defined(DEBUG)) && !defined(NDEBUG)
|
||||
void DbgLog(const char *fmt, ...);
|
||||
#else
|
||||
#define DbgLog(fmt, ...) NOOP
|
||||
@ -92,22 +92,23 @@ inline bool IsDigitW(WCHAR wch) { return ((wch >= L'0') && (wch <= L'9')); }
|
||||
inline bool IsBlankChar(CHAR ch) { return ((ch == ' ') || (ch == '\t')); }
|
||||
inline bool IsBlankCharW(WCHAR wch) { return ((wch == L' ') || (wch == L'\t')); }
|
||||
|
||||
|
||||
inline int float2int(float f) { return (int)lroundf(f); }
|
||||
inline float Round10th(float f) { return (float)float2int(f * 10.0f) / 10; }
|
||||
inline bool HasNonZeroFraction(float f) { return ((float2int(f * 10.0f) % 10) != 0); }
|
||||
|
||||
|
||||
// direct heap allocation
|
||||
inline LPVOID AllocMem(size_t numBytes, DWORD dwFlags) {
|
||||
return HeapAlloc(GetProcessHeap(), (dwFlags | HEAP_GENERATE_EXCEPTIONS), numBytes);
|
||||
#define DEFAULT_ALLOC_FLAGS (0) ///~ HEAP_GENERATE_EXCEPTIONS
|
||||
__forceinline LPVOID AllocMem(size_t numBytes, DWORD dwFlags) {
|
||||
return HeapAlloc(GetProcessHeap(), (dwFlags | DEFAULT_ALLOC_FLAGS), numBytes);
|
||||
}
|
||||
|
||||
inline bool FreeMem(LPVOID lpMemory) {
|
||||
return ((lpMemory != NULL) ? HeapFree(GetProcessHeap(), 0, lpMemory) : true);
|
||||
__forceinline bool FreeMem(LPVOID lpMemory) {
|
||||
return (lpMemory ? HeapFree(GetProcessHeap(), 0, lpMemory) : true);
|
||||
}
|
||||
|
||||
inline size_t SizeOfMem(LPVOID lpMemory) {
|
||||
return ((lpMemory != NULL) ? HeapSize(GetProcessHeap(), 0, lpMemory) : 0);
|
||||
__forceinline size_t SizeOfMem(LPCVOID lpMemory) {
|
||||
return (lpMemory ? HeapSize(GetProcessHeap(), 0, lpMemory) : 0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
159
src/Notepad3.c
159
src/Notepad3.c
@ -402,10 +402,6 @@ static DWORD DropFilesProc(CLIPFORMAT cf, HGLOBAL hData, HWND hWnd, DWORD dwKeyS
|
||||
|
||||
//=============================================================================
|
||||
|
||||
// temporary line buffer for fast line ops
|
||||
// make sure to handle it in closed loops locally only
|
||||
static char g_pTempLineBufferMain[TEMPLINE_BUFFER];
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
@ -3071,7 +3067,8 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
//
|
||||
LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
WCHAR tchMaxPathBuffer[MAX_PATH+4] = { L'\0' };
|
||||
char chMaxPathBuffer[MAX_PATH + 1] = { '\0' };
|
||||
WCHAR tchMaxPathBuffer[MAX_PATH + 1] = { L'\0' };
|
||||
|
||||
switch(LOWORD(wParam))
|
||||
{
|
||||
@ -4098,10 +4095,10 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
StringCchPrintf(tchDateTime,COUNTOF(tchDateTime),L"%s %s",tchTime,tchDate);
|
||||
}
|
||||
|
||||
WideCharToMultiByteStrg(Encoding_SciCP,tchDateTime, g_pTempLineBufferMain);
|
||||
char chDateTime[128] = { '\0' };
|
||||
WideCharToMultiByteStrg(Encoding_SciCP,tchDateTime, chDateTime);
|
||||
_BEGIN_UNDO_ACTION_;
|
||||
SendMessage(g_hwndEdit,SCI_REPLACESEL,0,(LPARAM)g_pTempLineBufferMain);
|
||||
SendMessage(g_hwndEdit,SCI_REPLACESEL,0,(LPARAM)chDateTime);
|
||||
_END_UNDO_ACTION_;
|
||||
}
|
||||
break;
|
||||
@ -4115,10 +4112,10 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
WCHAR tchUntitled[32];
|
||||
//int iSelStart;
|
||||
|
||||
if (StringCchLenW(g_wchCurFile,COUNTOF(g_wchCurFile))) {
|
||||
if (StringCchLenW(g_wchCurFile, COUNTOF(g_wchCurFile))) {
|
||||
if (LOWORD(wParam) == IDM_EDIT_INSERT_FILENAME) {
|
||||
SHGetFileInfo2(g_wchCurFile,FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(SHFILEINFO),
|
||||
SHGFI_DISPLAYNAME | SHGFI_USEFILEATTRIBUTES);
|
||||
SHGetFileInfo2(g_wchCurFile, FILE_ATTRIBUTE_NORMAL, &shfi, sizeof(SHFILEINFO),
|
||||
SHGFI_DISPLAYNAME | SHGFI_USEFILEATTRIBUTES);
|
||||
pszInsert = shfi.szDisplayName;
|
||||
}
|
||||
else
|
||||
@ -4128,12 +4125,12 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
GetLngString(IDS_MUI_UNTITLED, tchUntitled, COUNTOF(tchUntitled));
|
||||
pszInsert = tchUntitled;
|
||||
}
|
||||
|
||||
WideCharToMultiByteStrg(Encoding_SciCP,pszInsert, g_pTempLineBufferMain);
|
||||
char chPath[MAX_PATH + 1];
|
||||
WideCharToMultiByteStrg(Encoding_SciCP, pszInsert, chPath);
|
||||
_BEGIN_UNDO_ACTION_;
|
||||
SendMessage(g_hwndEdit,SCI_REPLACESEL,0,(LPARAM)g_pTempLineBufferMain);
|
||||
SendMessage(g_hwndEdit, SCI_REPLACESEL, 0, (LPARAM)chPath);
|
||||
_END_UNDO_ACTION_;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@ -4143,9 +4140,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
if (SUCCEEDED(CoCreateGuid(&guid))) {
|
||||
if (StringFromGUID2(&guid, tchMaxPathBuffer,COUNTOF(tchMaxPathBuffer))) {
|
||||
StrTrimW(tchMaxPathBuffer, L"{}");
|
||||
if (WideCharToMultiByteStrg(Encoding_SciCP, tchMaxPathBuffer, g_pTempLineBufferMain)) {
|
||||
if (WideCharToMultiByteStrg(Encoding_SciCP, tchMaxPathBuffer, chMaxPathBuffer)) {
|
||||
_BEGIN_UNDO_ACTION_;
|
||||
SendMessage(g_hwndEdit,SCI_REPLACESEL,0,(LPARAM)g_pTempLineBufferMain);
|
||||
SendMessage(g_hwndEdit,SCI_REPLACESEL,0,(LPARAM)chMaxPathBuffer);
|
||||
_END_UNDO_ACTION_;
|
||||
}
|
||||
}
|
||||
@ -4680,7 +4677,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
g_bMarkLongLines = true;
|
||||
SendMessage(g_hwndEdit, SCI_SETEDGEMODE, (iLongLineMode == EDGE_LINE) ? EDGE_LINE : EDGE_BACKGROUND, 0);
|
||||
Style_SetLongLineColors(g_hwndEdit);
|
||||
g_iLongLinesLimit = clampi(g_iLongLinesLimit, 0, 4096);
|
||||
g_iLongLinesLimit = clampi(g_iLongLinesLimit, 0, LONG_LINES_MARKER_LIMIT);
|
||||
SendMessage(g_hwndEdit,SCI_SETEDGECOLUMN,g_iLongLinesLimit,0);
|
||||
iLongLinesLimitG = g_iLongLinesLimit;
|
||||
UpdateToolbar();
|
||||
@ -5505,7 +5502,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
g_iLongLinesLimit++;
|
||||
else
|
||||
g_iLongLinesLimit--;
|
||||
g_iLongLinesLimit = clampi(g_iLongLinesLimit, 0, 4096);
|
||||
g_iLongLinesLimit = clampi(g_iLongLinesLimit, 0, LONG_LINES_MARKER_LIMIT);
|
||||
SendMessage(g_hwndEdit,SCI_SETEDGECOLUMN,g_iLongLinesLimit,0);
|
||||
UpdateToolbar();
|
||||
UpdateStatusbar(false);
|
||||
@ -6043,15 +6040,7 @@ static void __fastcall _HandleAutoIndent(int const charAdded)
|
||||
if (iCurLine > 0/* && iLineLength <= 2*/)
|
||||
{
|
||||
DocPos const iPrevLineLength = SciCall_LineLength(iCurLine - 1);
|
||||
char* pLineBuf = NULL;
|
||||
bool bAllocLnBuf = false;
|
||||
if (iPrevLineLength < TEMPLINE_BUFFER) {
|
||||
pLineBuf = g_pTempLineBufferMain;
|
||||
}
|
||||
else {
|
||||
bAllocLnBuf = true;
|
||||
pLineBuf = AllocMem(iPrevLineLength + 1, HEAP_ZERO_MEMORY);
|
||||
}
|
||||
char* pLineBuf = (char*)AllocMem(iPrevLineLength + 1, HEAP_ZERO_MEMORY);
|
||||
if (pLineBuf)
|
||||
{
|
||||
SciCall_GetLine_Safe(iCurLine - 1, pLineBuf);
|
||||
@ -6066,7 +6055,7 @@ static void __fastcall _HandleAutoIndent(int const charAdded)
|
||||
SciCall_AddText((DocPos)StringCchLenA(pLineBuf, iPrevLineLength), pLineBuf);
|
||||
_END_UNDO_ACTION_;
|
||||
}
|
||||
if (bAllocLnBuf) { FreeMem(pLineBuf); }
|
||||
FreeMem(pLineBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6079,11 +6068,12 @@ static void __fastcall _HandleAutoIndent(int const charAdded)
|
||||
//
|
||||
static void __fastcall _HandleAutoCloseTags()
|
||||
{
|
||||
//int lexerID = (int)SendMessage(g_hwndEdit,SCI_GETLEXER,0,0);
|
||||
//if (lexerID == SCLEX_HTML || lexerID == SCLEX_XML)
|
||||
///int lexerID = (int)SendMessage(g_hwndEdit,SCI_GETLEXER,0,0);
|
||||
///if (lexerID == SCLEX_HTML || lexerID == SCLEX_XML)
|
||||
DocPos const maxSearchBackward = 4096;
|
||||
{
|
||||
DocPos const iCurPos = SciCall_GetCurrentPos();
|
||||
DocPos const iHelper = iCurPos - (DocPos)(COUNTOF(g_pTempLineBufferMain) - 1);
|
||||
DocPos const iHelper = iCurPos - maxSearchBackward;
|
||||
DocPos const iStartPos = max(0, iHelper);
|
||||
DocPos const iSize = iCurPos - iStartPos;
|
||||
|
||||
@ -6091,37 +6081,38 @@ static void __fastcall _HandleAutoCloseTags()
|
||||
{
|
||||
const char* pBegin = SciCall_GetRangePointer(iStartPos, iSize);
|
||||
|
||||
if (pBegin[iSize - 2] != '/') {
|
||||
|
||||
if (pBegin[iSize - 2] != '/')
|
||||
{
|
||||
const char* pCur = &pBegin[iSize - 2];
|
||||
|
||||
while (pCur > pBegin && *pCur != '<' && *pCur != '>') { --pCur; }
|
||||
|
||||
int cchIns = 2;
|
||||
StringCchCopyA(g_pTempLineBufferMain, FNDRPL_BUFFER, "</");
|
||||
char replaceBuf[FNDRPL_BUFFER+2];
|
||||
StringCchCopyA(replaceBuf, FNDRPL_BUFFER, "</");
|
||||
if (*pCur == '<') {
|
||||
pCur++;
|
||||
while (StrChrA(":_-.", *pCur) || IsCharAlphaNumericA(*pCur)) {
|
||||
g_pTempLineBufferMain[cchIns++] = *pCur;
|
||||
pCur++;
|
||||
++pCur;
|
||||
while ((StrChrA(":_-.", *pCur) || IsCharAlphaNumericA(*pCur)) && (cchIns < (FNDRPL_BUFFER-2))) {
|
||||
replaceBuf[cchIns++] = *pCur;
|
||||
++pCur;
|
||||
}
|
||||
}
|
||||
g_pTempLineBufferMain[cchIns++] = '>';
|
||||
g_pTempLineBufferMain[cchIns] = '\0';
|
||||
replaceBuf[cchIns++] = '>';
|
||||
replaceBuf[cchIns] = '\0';
|
||||
|
||||
// except tags w/o closing tags
|
||||
if (cchIns > 3 &&
|
||||
StringCchCompareNIA(g_pTempLineBufferMain, COUNTOF(g_pTempLineBufferMain), "</base>", CSTRLEN("</base>")) &&
|
||||
StringCchCompareNIA(g_pTempLineBufferMain, COUNTOF(g_pTempLineBufferMain), "</bgsound>", CSTRLEN("</bgsound>")) &&
|
||||
StringCchCompareNIA(g_pTempLineBufferMain, COUNTOF(g_pTempLineBufferMain), "</br>", CSTRLEN("</br>")) &&
|
||||
StringCchCompareNIA(g_pTempLineBufferMain, COUNTOF(g_pTempLineBufferMain), "</embed>", CSTRLEN("</embed>")) &&
|
||||
StringCchCompareNIA(g_pTempLineBufferMain, COUNTOF(g_pTempLineBufferMain), "</hr>", CSTRLEN("</hr>")) &&
|
||||
StringCchCompareNIA(g_pTempLineBufferMain, COUNTOF(g_pTempLineBufferMain), "</img>", CSTRLEN("</img>")) &&
|
||||
StringCchCompareNIA(g_pTempLineBufferMain, COUNTOF(g_pTempLineBufferMain), "</input>", CSTRLEN("</input>")) &&
|
||||
StringCchCompareNIA(g_pTempLineBufferMain, COUNTOF(g_pTempLineBufferMain), "</link>", CSTRLEN("</link>")) &&
|
||||
StringCchCompareNIA(g_pTempLineBufferMain, COUNTOF(g_pTempLineBufferMain), "</meta>", CSTRLEN("</meta>")))
|
||||
StringCchCompareNIA(replaceBuf, COUNTOF(replaceBuf), "</base>", CSTRLEN("</base>")) &&
|
||||
StringCchCompareNIA(replaceBuf, COUNTOF(replaceBuf), "</bgsound>", CSTRLEN("</bgsound>")) &&
|
||||
StringCchCompareNIA(replaceBuf, COUNTOF(replaceBuf), "</br>", CSTRLEN("</br>")) &&
|
||||
StringCchCompareNIA(replaceBuf, COUNTOF(replaceBuf), "</embed>", CSTRLEN("</embed>")) &&
|
||||
StringCchCompareNIA(replaceBuf, COUNTOF(replaceBuf), "</hr>", CSTRLEN("</hr>")) &&
|
||||
StringCchCompareNIA(replaceBuf, COUNTOF(replaceBuf), "</img>", CSTRLEN("</img>")) &&
|
||||
StringCchCompareNIA(replaceBuf, COUNTOF(replaceBuf), "</input>", CSTRLEN("</input>")) &&
|
||||
StringCchCompareNIA(replaceBuf, COUNTOF(replaceBuf), "</link>", CSTRLEN("</link>")) &&
|
||||
StringCchCompareNIA(replaceBuf, COUNTOF(replaceBuf), "</meta>", CSTRLEN("</meta>")))
|
||||
{
|
||||
_BEGIN_UNDO_ACTION_;
|
||||
SciCall_ReplaceSel(g_pTempLineBufferMain);
|
||||
SciCall_ReplaceSel(replaceBuf);
|
||||
SciCall_SetSel(iCurPos, iCurPos);
|
||||
_END_UNDO_ACTION_;
|
||||
}
|
||||
@ -6142,21 +6133,26 @@ static void __fastcall _HandleTinyExpr()
|
||||
char const chBefore = SciCall_GetCharAt(iPosBefore - 1);
|
||||
if (chBefore == '=') // got "=?" evaluate expression trigger
|
||||
{
|
||||
DocPos const iLnCaretPos = SciCall_GetCurLine(COUNTOF(g_pTempLineBufferMain), g_pTempLineBufferMain);
|
||||
g_pTempLineBufferMain[(iLnCaretPos > 1) ? (iLnCaretPos-2) : 0] = '\0'; // breakbefore "=?"
|
||||
DocPos lineLen = SciCall_LineLength(SciCall_LineFromPosition(iCurPos));
|
||||
char* lineBuf = (char*)AllocMem(lineLen + 1, HEAP_ZERO_MEMORY);
|
||||
if (lineBuf) {
|
||||
DocPos const iLnCaretPos = SciCall_GetCurLine(lineLen, lineBuf);
|
||||
lineBuf[(iLnCaretPos > 1) ? (iLnCaretPos - 2) : 0] = '\0'; // break before "=?"
|
||||
|
||||
int iExprErr = 1;
|
||||
const char* pBegin = &g_pTempLineBufferMain[0];
|
||||
double dExprEval = 0.0;
|
||||
int iExprErr = 1;
|
||||
const char* pBegin = lineBuf;
|
||||
double dExprEval = 0.0;
|
||||
|
||||
while (*pBegin && iExprErr) {
|
||||
dExprEval = te_interp(pBegin++, &iExprErr);
|
||||
}
|
||||
if (*pBegin && !iExprErr) {
|
||||
char chExpr[64] = { '\0' };
|
||||
StringCchPrintfA(chExpr, COUNTOF(chExpr), "%.6G", dExprEval);
|
||||
SciCall_SetSel(iPosBefore, iCurPos);
|
||||
SciCall_ReplaceSel(chExpr);
|
||||
while (*pBegin && iExprErr) {
|
||||
dExprEval = te_interp(pBegin++, &iExprErr);
|
||||
}
|
||||
if (*pBegin && !iExprErr) {
|
||||
char chExpr[64] = { '\0' };
|
||||
StringCchPrintfA(chExpr, COUNTOF(chExpr), "%.6G", dExprEval);
|
||||
SciCall_SetSel(iPosBefore, iCurPos);
|
||||
SciCall_ReplaceSel(chExpr);
|
||||
}
|
||||
FreeMem(lineBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6811,7 +6807,7 @@ void LoadSettings()
|
||||
g_bMarkLongLines = IniSectionGetBool(pIniSection, L"MarkLongLines", true);
|
||||
|
||||
g_iLongLinesLimit = IniSectionGetInt(pIniSection, L"LongLinesLimit", 80);
|
||||
g_iLongLinesLimit = clampi(g_iLongLinesLimit, 0, 4096);
|
||||
g_iLongLinesLimit = clampi(g_iLongLinesLimit, 0, LONG_LINES_MARKER_LIMIT);
|
||||
iLongLinesLimitG = g_iLongLinesLimit;
|
||||
|
||||
iLongLineMode = IniSectionGetInt(pIniSection, L"LongLineMode", EDGE_LINE);
|
||||
@ -8207,13 +8203,12 @@ static void __fastcall _CalculateStatusbarSections(int vSectionWidth[], sectionT
|
||||
//
|
||||
static double __fastcall _InterpRectSelTinyExpr(int* piExprError)
|
||||
{
|
||||
#define _tmpBufCnt 256
|
||||
#define _tmpBufCnt 128
|
||||
char tmpRectSelN[_tmpBufCnt] = { '\0' };
|
||||
|
||||
g_pTempLineBufferMain[0] = '\0';
|
||||
size_t const tmpLineBufSize = COUNTOF(g_pTempLineBufferMain);
|
||||
|
||||
|
||||
DocPosU const selCount = SciCall_GetSelections();
|
||||
DocPosU const calcBufSize = _tmpBufCnt * selCount;
|
||||
char* calcBuffer = (char*)AllocMem(calcBufSize + 1, HEAP_ZERO_MEMORY);
|
||||
|
||||
bool bLastCharWasDigit = false;
|
||||
for (DocPosU i = 0; i < selCount; ++i)
|
||||
@ -8227,14 +8222,13 @@ static double __fastcall _InterpRectSelTinyExpr(int* piExprError)
|
||||
if (!StrIsEmptyA(tmpRectSelN))
|
||||
{
|
||||
if (IsDigitA(tmpRectSelN[0]) && bLastCharWasDigit) {
|
||||
StringCchCatA(g_pTempLineBufferMain, tmpLineBufSize, "+"); // default: add numbers
|
||||
StringCchCatA(calcBuffer, calcBufSize, "+"); // default: add numbers
|
||||
}
|
||||
bLastCharWasDigit = IsDigitA(tmpRectSelN[StringCchLenA(tmpRectSelN,COUNTOF(tmpRectSelN)) - 1]);
|
||||
StringCchCatA(g_pTempLineBufferMain, tmpLineBufSize, tmpRectSelN);
|
||||
StringCchCatA(calcBuffer, calcBufSize, tmpRectSelN);
|
||||
}
|
||||
}
|
||||
|
||||
return te_interp(g_pTempLineBufferMain, piExprError);
|
||||
return te_interp(calcBuffer, piExprError);
|
||||
}
|
||||
|
||||
|
||||
@ -8457,12 +8451,17 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw)
|
||||
|
||||
if (bIsSelCountable)
|
||||
{
|
||||
if (SciCall_GetSelText(NULL) < COUNTOF(g_pTempLineBufferMain))
|
||||
DocPos const iSelCharCount = SciCall_GetSelText(NULL);
|
||||
if (iSelCharCount < 2048) // should be fast !
|
||||
{
|
||||
SciCall_GetSelText(g_pTempLineBufferMain);
|
||||
//StrDelChrA(chExpression, " \r\n\t\v");
|
||||
StrDelChrA(g_pTempLineBufferMain, "\r\n");
|
||||
g_dExpression = te_interp(g_pTempLineBufferMain, &g_iExprError);
|
||||
char* selectionBuffer = (char*)AllocMem(iSelCharCount + 1, HEAP_ZERO_MEMORY);
|
||||
if (selectionBuffer) {
|
||||
SciCall_GetSelText(selectionBuffer);
|
||||
//StrDelChrA(chExpression, " \r\n\t\v");
|
||||
StrDelChrA(selectionBuffer, "\r\n");
|
||||
g_dExpression = te_interp(selectionBuffer, &g_iExprError);
|
||||
FreeMem(selectionBuffer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
g_iExprError = -1;
|
||||
|
||||
@ -94,7 +94,7 @@ typedef enum
|
||||
|
||||
FILE_ARG_BUF = MAX_PATH + 2,
|
||||
FNDRPL_BUFFER = 1024,
|
||||
TEMPLINE_BUFFER = 4096
|
||||
LONG_LINES_MARKER_LIMIT = 4096
|
||||
|
||||
} BUFFER_SIZES;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user