mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
+ add: highlight current (caret pos) folding block marker
+ fix: bug on left aligning text
This commit is contained in:
parent
e3ac393d96
commit
df9beb833e
@ -72,7 +72,7 @@
|
||||
</tr>
|
||||
</table>
|
||||
<ul id="versionlist">
|
||||
<li>Version 4.1.0 adds optional indexing of line starts in UTF-8 documents by UTF-32 code points and UTF-16 code units.</li>
|
||||
<li>Version 4.1.1 adds optional indexing of line starts in UTF-8 documents by UTF-32 code points and UTF-16 code units.</li>
|
||||
<li>Version 4.1.0 adds experimental support for bidirectional text as used by Arabic and Hebrew on Win32 and Cocoa.</li>
|
||||
<li>Version 4.0.5 adds experimental support for documents larger than 2 GigaBytes.</li>
|
||||
<li>Version 4.0.4 adds a lexer for Maxima.</li>
|
||||
@ -110,8 +110,8 @@ if (!IsRemote()) { //if NOT remote...
|
||||
colours and multiple fonts.
|
||||
</p>
|
||||
<p>
|
||||
Current development occurs on the default branch as 4.0.x which is unstable - interfaces may change before being
|
||||
declared stable in a future 4.1.0. 4.* requires a recent C++ compiler that supports C++14 and some of C++17.
|
||||
Current development occurs on the default branch as 4.* which requires a recent
|
||||
C++ compiler that supports C++17.
|
||||
</p>
|
||||
<p>
|
||||
For projects that need to work with older systems, a LongTerm3 branch is available which uses only features from C++11.
|
||||
|
||||
107
src/Edit.c
107
src/Edit.c
@ -2809,8 +2809,8 @@ void EditAlignText(HWND hwnd,int nMode)
|
||||
DocPos iIndentPos = SciCall_GetLineIndentPosition(iLine);
|
||||
|
||||
if ((iIndentPos == iEndPos) && (iEndPos > 0)) {
|
||||
SendMessage(hwnd, SCI_SETTARGETRANGE, SciCall_PositionFromLine(iLine), iEndPos);
|
||||
SendMessage(hwnd, SCI_REPLACETARGET, 0, (LPARAM)"");
|
||||
SciCall_SetTargetRange(SciCall_PositionFromLine(iLine), iEndPos);
|
||||
SciCall_ReplaceTarget(0, "");
|
||||
}
|
||||
else {
|
||||
g_pTempLineBuffer[0] = '\0';
|
||||
@ -2843,26 +2843,25 @@ void EditAlignText(HWND hwnd,int nMode)
|
||||
if (nMode == ALIGN_JUSTIFY || nMode == ALIGN_JUSTIFY_EX) {
|
||||
|
||||
bool bNextLineIsBlank = false;
|
||||
if (nMode == ALIGN_JUSTIFY_EX) {
|
||||
|
||||
if (nMode == ALIGN_JUSTIFY_EX)
|
||||
{
|
||||
if (SciCall_GetLineCount() <= iLine + 1) {
|
||||
bNextLineIsBlank = true;
|
||||
}
|
||||
else {
|
||||
|
||||
DocPos iLineEndPos = SciCall_GetLineEndPosition(iLine + 1);
|
||||
DocPos iLineIndentPos = SciCall_GetLineIndentPosition(iLine + 1);
|
||||
|
||||
if (iLineIndentPos == iLineEndPos)
|
||||
if (iLineIndentPos == iLineEndPos) {
|
||||
bNextLineIsBlank = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((nMode == ALIGN_JUSTIFY || nMode == ALIGN_JUSTIFY_EX) &&
|
||||
iWords > 1 && iWordsLength >= 2 &&
|
||||
((nMode != ALIGN_JUSTIFY_EX || !bNextLineIsBlank || iLineStart == iLineEnd) ||
|
||||
(bNextLineIsBlank && iWordsLength > (iMaxLength - iMinIndent) * 0.75))) {
|
||||
|
||||
(bNextLineIsBlank && iWordsLength > (iMaxLength - iMinIndent) * 0.75)))
|
||||
{
|
||||
int iGaps = iWords - 1;
|
||||
DocPos iSpacesPerGap = (iMaxLength - iMinIndent - iWordsLength) / iGaps;
|
||||
DocPos iExtraSpaces = (iMaxLength - iMinIndent - iWordsLength) % iGaps;
|
||||
@ -2884,16 +2883,8 @@ void EditAlignText(HWND hwnd,int nMode)
|
||||
StringCchCat(p,(length - StringCchLenW(wchNewLineBuf,COUNTOF(wchNewLineBuf))),pWords[i]);
|
||||
p = StrEnd(p,0);
|
||||
}
|
||||
|
||||
int cch = WideCharToMultiByteStrg(Encoding_SciCP,wchNewLineBuf,g_pTempLineBuffer) - 1;
|
||||
|
||||
SendMessage(hwnd, SCI_SETTARGETRANGE, SciCall_PositionFromLine(iLine), SciCall_GetLineEndPosition(iLine));
|
||||
SendMessage(hwnd, SCI_REPLACETARGET, (WPARAM)cch, (LPARAM)g_pTempLineBuffer);
|
||||
|
||||
SendMessage(hwnd,SCI_SETLINEINDENTATION,(WPARAM)iLine,(LPARAM)iMinIndent);
|
||||
}
|
||||
else {
|
||||
|
||||
StringCchCopy(wchNewLineBuf,COUNTOF(wchNewLineBuf),pWords[0]);
|
||||
p = StrEnd(wchNewLineBuf, COUNTOF(wchNewLineBuf));
|
||||
|
||||
@ -2903,35 +2894,30 @@ void EditAlignText(HWND hwnd,int nMode)
|
||||
StringCchCat(p,(COUNTOF(wchNewLineBuf) - StringCchLenW(wchNewLineBuf,COUNTOF(wchNewLineBuf))),pWords[i]);
|
||||
p = StrEnd(p,0);
|
||||
}
|
||||
|
||||
int cch = WideCharToMultiByteStrg(Encoding_SciCP,wchNewLineBuf,g_pTempLineBuffer) - 1;
|
||||
|
||||
SendMessage(hwnd, SCI_SETTARGETRANGE, SciCall_PositionFromLine(iLine), SciCall_GetLineEndPosition(iLine));
|
||||
SendMessage(hwnd, SCI_REPLACETARGET, (WPARAM)cch, (LPARAM)g_pTempLineBuffer);
|
||||
|
||||
SendMessage(hwnd, SCI_SETLINEINDENTATION, (WPARAM)iLine, (LPARAM)iMinIndent);
|
||||
}
|
||||
int cch = WideCharToMultiByteStrg(Encoding_SciCP, wchNewLineBuf, g_pTempLineBuffer) - 1;
|
||||
SciCall_SetTargetRange(SciCall_PositionFromLine(iLine), SciCall_GetLineEndPosition(iLine));
|
||||
SciCall_ReplaceTarget(cch, g_pTempLineBuffer);
|
||||
SciCall_SetLineIndentation(iLine, iMinIndent);
|
||||
}
|
||||
else {
|
||||
|
||||
DocPos iExtraSpaces = iMaxLength - iMinIndent - iWordsLength - iWords + 1;
|
||||
DocPos iOddSpaces = iExtraSpaces % 2;
|
||||
int i;
|
||||
DocPos iPos;
|
||||
|
||||
wchNewLineBuf[0] = L'\0';
|
||||
p = wchNewLineBuf;
|
||||
|
||||
DocPos iExtraSpaces = iMaxLength - iMinIndent - iWordsLength - iWords + 1;
|
||||
if (nMode == ALIGN_RIGHT) {
|
||||
for (i = 0; i < iExtraSpaces; i++)
|
||||
for (int i = 0; i < iExtraSpaces; i++)
|
||||
*p++ = L' ';
|
||||
*p = 0;
|
||||
}
|
||||
|
||||
DocPos iOddSpaces = iExtraSpaces % 2;
|
||||
if (nMode == ALIGN_CENTER) {
|
||||
for (i = 1; i < iExtraSpaces - iOddSpaces; i+=2)
|
||||
for (int i = 1; i < iExtraSpaces - iOddSpaces; i+=2)
|
||||
*p++ = L' ';
|
||||
*p = 0;
|
||||
}
|
||||
for (i = 0; i < iWords; i++) {
|
||||
for (int i = 0; i < iWords; i++) {
|
||||
StringCchCat(p,(COUNTOF(wchNewLineBuf) - StringCchLenW(wchNewLineBuf,COUNTOF(wchNewLineBuf))),pWords[i]);
|
||||
if (i < iWords - 1)
|
||||
StringCchCat(p,(COUNTOF(wchNewLineBuf) - StringCchLenW(wchNewLineBuf,COUNTOF(wchNewLineBuf))),L" ");
|
||||
@ -2944,18 +2930,20 @@ void EditAlignText(HWND hwnd,int nMode)
|
||||
|
||||
int cch = WideCharToMultiByteStrg(Encoding_SciCP,wchNewLineBuf,g_pTempLineBuffer) - 1;
|
||||
|
||||
DocPos iPos = 0;
|
||||
if (nMode == ALIGN_RIGHT || nMode == ALIGN_CENTER) {
|
||||
SendMessage(hwnd,SCI_SETLINEINDENTATION,(WPARAM)iLine,(LPARAM)iMinIndent);
|
||||
SciCall_SetLineIndentation(iLine, iMinIndent);
|
||||
iPos = SciCall_GetLineIndentPosition(iLine);
|
||||
}
|
||||
else
|
||||
else {
|
||||
iPos = SciCall_PositionFromLine(iLine);
|
||||
|
||||
SendMessage(hwnd, SCI_SETTARGETRANGE, iPos, SciCall_GetLineEndPosition(iLine));
|
||||
SendMessage(hwnd, SCI_REPLACETARGET, (WPARAM)cch, (LPARAM)g_pTempLineBuffer);
|
||||
}
|
||||
SciCall_SetTargetRange(iPos, SciCall_GetLineEndPosition(iLine));
|
||||
SciCall_ReplaceTarget(cch, g_pTempLineBuffer);
|
||||
|
||||
if (nMode == ALIGN_LEFT)
|
||||
SendMessage(hwnd, SCI_SETLINEINDENTATION, (WPARAM)iLine, (LPARAM)iMinIndent);
|
||||
if (nMode == ALIGN_LEFT) {
|
||||
SciCall_SetLineIndentation(iLine, iMinIndent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5060,9 +5048,6 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
|
||||
static RegExResult_t s_anyMatch = NO_MATCH;
|
||||
static RegExResult_t s_fwrdMatch = NO_MATCH;
|
||||
|
||||
static COLORREF rgbRed = RGB(255, 170, 170);
|
||||
static COLORREF rgbGreen = RGB(170, 255, 170);
|
||||
static COLORREF rgbBlue = RGB(170, 200, 255);
|
||||
static HBRUSH hBrushRed;
|
||||
static HBRUSH hBrushGreen;
|
||||
static HBRUSH hBrushBlue;
|
||||
@ -5230,9 +5215,9 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
|
||||
InsertMenu(hmenu, 1, MF_BYPOSITION | MF_STRING | MF_ENABLED, IDS_MUI_RESETPOS, tchBuf);
|
||||
InsertMenu(hmenu, 2, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
|
||||
|
||||
hBrushRed = CreateSolidBrush(rgbRed);
|
||||
hBrushGreen = CreateSolidBrush(rgbGreen);
|
||||
hBrushBlue = CreateSolidBrush(rgbBlue);
|
||||
hBrushRed = CreateSolidBrush(rgbRedColorRef);
|
||||
hBrushGreen = CreateSolidBrush(rgbGreenColorRef);
|
||||
hBrushBlue = CreateSolidBrush(rgbBlueColorRef);
|
||||
|
||||
SetTimer(hwnd, IDT_TIMER_MRKALL, USER_TIMER_MINIMUM, MQ_ExecuteNext);
|
||||
}
|
||||
@ -5858,18 +5843,18 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
|
||||
switch (s_anyMatch) {
|
||||
case MATCH:
|
||||
//SetTextColor(hDC, green);
|
||||
SetBkColor(hDC, rgbGreen);
|
||||
SetBkColor(hDC, rgbGreenColorRef);
|
||||
hBrush = (INT_PTR)hBrushGreen;
|
||||
break;
|
||||
case NO_MATCH:
|
||||
//SetTextColor(hDC, blue);
|
||||
SetBkColor(hDC, rgbBlue);
|
||||
SetBkColor(hDC, rgbBlueColorRef);
|
||||
hBrush = (INT_PTR)hBrushBlue;
|
||||
break;
|
||||
case INVALID:
|
||||
default:
|
||||
//SetTextColor(hDC, red);
|
||||
SetBkColor(hDC, rgbRed);
|
||||
SetBkColor(hDC, rgbRedColorRef);
|
||||
hBrush = (INT_PTR)hBrushRed;
|
||||
break;
|
||||
}
|
||||
@ -6882,7 +6867,10 @@ void EditHideNotMarkedLineRange(HWND hwnd, DocPos iStartPos, DocPos iEndPos, boo
|
||||
g_bCodeFoldingAvailable = true; // saved before
|
||||
g_bShowCodeFolding = true; // saved before
|
||||
SciCall_SetProperty("fold", "1");
|
||||
//SciCall_SetProperty("fold.compact", "1");
|
||||
SciCall_SetProperty("fold.foldsyntaxbased", "1");
|
||||
SciCall_SetProperty("fold.comment", "1");
|
||||
SciCall_SetProperty("fold.preprocessor", "1");
|
||||
SciCall_SetProperty("fold.compact", "0");
|
||||
Style_SetFolding(hwnd, true);
|
||||
SciCall_SetFoldFlags(0);
|
||||
//SciCall_SetFoldFlags(SC_FOLDFLAG_LEVELNUMBERS | SC_FOLDFLAG_LINESTATE); // Debug
|
||||
@ -6952,12 +6940,13 @@ void EditHideNotMarkedLineRange(HWND hwnd, DocPos iStartPos, DocPos iEndPos, boo
|
||||
//
|
||||
static bool __fastcall _HighlightIfBrace(HWND hwnd, DocPos iPos)
|
||||
{
|
||||
UNUSED(hwnd);
|
||||
if (iPos < 0) {
|
||||
// clear indicator
|
||||
SendMessage(hwnd, SCI_BRACEBADLIGHT, (WPARAM)INVALID_POSITION, 0);
|
||||
SendMessage(hwnd, SCI_SETHIGHLIGHTGUIDE, 0, 0);
|
||||
SciCall_BraceBadLight(INVALID_POSITION);
|
||||
SciCall_SetHighLightGuide(0);
|
||||
if (!g_bUseOldStyleBraceMatching)
|
||||
SendMessage(hwnd, SCI_BRACEBADLIGHTINDICATOR, 0, INDIC_NP3_BAD_BRACE);
|
||||
SciCall_BraceBadLightIndicator(false, INDIC_NP3_BAD_BRACE);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -6968,17 +6957,17 @@ static bool __fastcall _HighlightIfBrace(HWND hwnd, DocPos iPos)
|
||||
if (iBrace2 != -1) {
|
||||
DocPos col1 = SciCall_GetColumn(iPos);
|
||||
DocPos col2 = SciCall_GetColumn(iBrace2);
|
||||
SendMessage(hwnd, SCI_BRACEHIGHLIGHT, iPos, iBrace2);
|
||||
SendMessage(hwnd, SCI_SETHIGHLIGHTGUIDE, min(col1, col2), 0);
|
||||
SciCall_BraceHighLight(iPos, iBrace2);
|
||||
SciCall_SetHighLightGuide(min(col1, col2));
|
||||
if (!g_bUseOldStyleBraceMatching) {
|
||||
SendMessage(hwnd, SCI_BRACEHIGHLIGHTINDICATOR, 1, INDIC_NP3_MATCH_BRACE);
|
||||
SciCall_BraceHighLightIndicator(true, INDIC_NP3_MATCH_BRACE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
SendMessage(hwnd, SCI_BRACEBADLIGHT, iPos, 0);
|
||||
SendMessage(hwnd, SCI_SETHIGHLIGHTGUIDE, 0, 0);
|
||||
SciCall_BraceBadLight(iPos);
|
||||
SciCall_SetHighLightGuide(0);
|
||||
if (!g_bUseOldStyleBraceMatching) {
|
||||
SendMessage(hwnd, SCI_BRACEBADLIGHTINDICATOR, 1, INDIC_NP3_BAD_BRACE);
|
||||
SciCall_BraceHighLightIndicator(true, INDIC_NP3_BAD_BRACE);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -4829,7 +4829,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
if (bMatchBraces)
|
||||
EditMatchBrace(g_hwndEdit);
|
||||
else
|
||||
SendMessage(g_hwndEdit,SCI_BRACEHIGHLIGHT,(WPARAM)-1,(LPARAM)-1);
|
||||
SciCall_BraceHighLight(INVALID_POSITION, INVALID_POSITION);
|
||||
break;
|
||||
|
||||
|
||||
|
||||
@ -317,6 +317,19 @@ DeclareSciCallV1(StartStyling, STARTSTYLING, DocPos, position)
|
||||
DeclareSciCallR0(GetEndStyled, GETENDSTYLED, DocPos)
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Indentation Guides
|
||||
//
|
||||
DeclareSciCallR1(BraceMatch, BRACEMATCH, DocPos, DocPos, position)
|
||||
DeclareSciCallV2(BraceHighLight, BRACEHIGHLIGHT, DocPos, pos1, DocPos, pos2)
|
||||
DeclareSciCallV1(BraceBadLight, BRACEBADLIGHT, DocPos, pos)
|
||||
DeclareSciCallV2(BraceHighLightIndicator, BRACEHIGHLIGHTINDICATOR, bool, use, int, indic)
|
||||
DeclareSciCallV2(BraceBadLightIndicator, BRACEBADLIGHTINDICATOR, bool, use, int, indic)
|
||||
DeclareSciCallV1(SetHighLightGuide, SETHIGHLIGHTGUIDE, int, column)
|
||||
DeclareSciCallV2(SetLineIndentation, SETLINEINDENTATION, DocLn, line, DocPos, pos)
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Margins
|
||||
@ -329,9 +342,9 @@ DeclareSciCallV2(SetMarginSensitiveN, SETMARGINSENSITIVEN, int, margin, bool, se
|
||||
DeclareSciCallV2(SetMarginBackN, SETMARGINBACKN, int, margin, COLORREF, colour)
|
||||
DeclareSciCallV2(SetFoldMarginColour, SETFOLDMARGINCOLOUR, bool, useSetting, COLORREF, colour)
|
||||
DeclareSciCallV2(SetFoldMarginHiColour, SETFOLDMARGINHICOLOUR, bool, useSetting, COLORREF, colour)
|
||||
DeclareSciCallV1(MarkerEnableHighlight, MARKERENABLEHIGHLIGHT, bool, flag)
|
||||
DeclareSciCallR2(TextWidth, TEXTWIDTH, int, int, styleNumber, const char*, text)
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Markers
|
||||
@ -420,7 +433,6 @@ DeclareSciCallV1(SetBidirectional, SETBIDIRECTIONAL, int, direction)
|
||||
//
|
||||
// Utilities
|
||||
//
|
||||
DeclareSciCallR1(BraceMatch, BRACEMATCH, DocPos, DocPos, position)
|
||||
DeclareSciCallR0(IsSelectionEmpty, GETSELECTIONEMPTY, bool)
|
||||
DeclareSciCallR0(IsSelectionRectangle, SELECTIONISRECTANGLE, bool)
|
||||
|
||||
|
||||
@ -1350,6 +1350,7 @@ void Style_SetMargin(HWND hwnd, int iStyle, LPCWSTR lpszStyle)
|
||||
|
||||
SciCall_SetFoldMarginColour(true, clrBack); // background
|
||||
SciCall_SetFoldMarginHiColour(true, clrBack); // (!)
|
||||
SciCall_MarkerEnableHighlight(true);
|
||||
|
||||
//SciCall_FoldDisplayTextSetStyle(SC_FOLDDISPLAYTEXT_HIDDEN);
|
||||
|
||||
@ -1369,8 +1370,8 @@ void Style_SetMargin(HWND hwnd, int iStyle, LPCWSTR lpszStyle)
|
||||
}
|
||||
|
||||
for (int i = 0; i < COUNTOF(iMarkerIDs); ++i) {
|
||||
SciCall_MarkerSetBack(iMarkerIDs[i], bmkFore);
|
||||
SciCall_MarkerSetFore(iMarkerIDs[i], bmkBack);
|
||||
SciCall_MarkerSetFore(iMarkerIDs[i], bmkBack); // (!)
|
||||
SciCall_MarkerSetBack(iMarkerIDs[i], bmkFore); // (!)
|
||||
}
|
||||
|
||||
// set width
|
||||
|
||||
@ -171,6 +171,9 @@ typedef struct _cmq
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#define rgbRedColorRef (RGB(255, 170, 170))
|
||||
#define rgbGreenColorRef (RGB(170, 255, 170))
|
||||
#define rgbBlueColorRef (RGB(170, 200, 255))
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user