+chg: visible representation of EOL characters (issue #4358)

This commit is contained in:
METANEOCORTEX\Kotti 2022-12-30 11:25:04 +01:00
parent 047ddc19ad
commit 75894ba714
5 changed files with 26 additions and 3 deletions

View File

@ -167,8 +167,9 @@ static void ReAllocW(STRINGW* pstr, size_t len, bool bZeroMem)
else if (pstr->alloc_length < alloc_len) {
pstr->data = ReAllocBuffer(pstr->data, alloc_len, bZeroMem, false);
pstr->alloc_length = LengthOfBuffer(pstr->data);
assert("inconsistent data" && (alloc_len != (pstr->alloc_length * sizeof(wchar_t))));
assert("inconsistent data 1" && (alloc_len != (pstr->alloc_length * sizeof(wchar_t))));
/// original memory block is moved, so data_length is not touched
assert("inconsistent data 2" && (alloc_len > pstr->data_length));
pstr->data[pstr->data_length] = L'\0'; // ensure terminating zero
}
else {

View File

@ -2438,6 +2438,13 @@ static void _InitializeSciEditCtrl(HWND hwndEditCtrl)
SciCall_SetMarginOptions(SC_MARGINOPTION_SUBLINESELECT);
// Nonprinting characters
SciCall_SetRepresentation("\r", "\xE2\x86\x90");
SciCall_SetRepresentationAppearance("\r", SC_REPRESENTATION_COLOUR);
SciCall_SetRepresentation("\n", "\xE2\x86\x93");
SciCall_SetRepresentationAppearance("\n", SC_REPRESENTATION_COLOUR);
SciCall_SetRepresentation("\r\n", "\xE2\x86\xB2"); // "\xE2\xAE\x92"
SciCall_SetRepresentationAppearance("\r\n", SC_REPRESENTATION_COLOUR);
/// (!) -> SciCall_SetRepresentationColour() in Styles.c
SciCall_SetViewWS(Settings.ViewWhiteSpace ? SCWS_VISIBLEALWAYS : SCWS_INVISIBLE);
SciCall_SetViewEOL(Settings.ViewEOLs);
@ -8820,7 +8827,10 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam)
switch(pnmh->code) {
case NM_CLICK: { // single click
LPNMMOUSE const pnmm = (LPNMMOUSE)lParam;
if (pnmm->dwItemSpec >= COUNTOF(g_vSBSOrder)) {
break;
}
switch (g_vSBSOrder[pnmm->dwItemSpec]) {
case STATUS_EOLMODE: {
if (Globals.bDocHasInconsistentEOLs) {
@ -12371,7 +12381,6 @@ static HANDLE s_hEventObserverDone = INVALID_HANDLE_VALUE;
static unsigned __stdcall FileChangeObserver(void * pArg) {
if (!pArg) {
_endthreadex(0);
return 0;

View File

@ -216,6 +216,9 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// After Win10 1903 upgrade, Ctrl+Alt+Shift+F hotkey is intercepted by File Explorer (issue #1609)
//
//
// --------------------------------------------------------------------------------------------------------------------
// Reference: https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
// --------------------------------------------------------------------------------------------------------------------
IDR_MAINWND ACCELERATORS
BEGIN

View File

@ -195,6 +195,10 @@ DeclareSciCallV01(GetWordChars, GETWORDCHARS, char*, ptxt);
DeclareSciCallV01(GetWhiteSpaceChars, GETWHITESPACECHARS, char*, ptxt);
DeclareSciCallV01(GetPunctuationChars, GETPUNCTUATIONCHARS, char*, ptxt);
DeclareSciCallV2(SetRepresentation, SETREPRESENTATION, const char*, encChar, const char*, represent);
DeclareSciCallV2(SetRepresentationColour, SETREPRESENTATIONCOLOUR, const char*, encChar, COLORALPHAREF, colour);
DeclareSciCallV2(SetRepresentationAppearance, SETREPRESENTATIONAPPEARANCE, const char*, encChar, int, appear);
// Document Pointer Handling
DeclareSciCallR0(GetDocPointer, GETDOCPOINTER, sptr_t);
DeclareSciCallV01(SetDocPointer, SETDOCPOINTER, sptr_t, pdoc);

View File

@ -1540,9 +1540,15 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew)
StringCchCat(wchSpecificStyle, COUNTOF(wchSpecificStyle), wch);
}
SciCall_SetElementColour(SC_ELEMENT_WHITE_SPACE, RGBxA(rgb, iValue));
SciCall_SetRepresentationColour("\r", RGBxA(rgb, iValue));
SciCall_SetRepresentationColour("\n", RGBxA(rgb, iValue));
SciCall_SetRepresentationColour("\r\n", RGBxA(rgb, iValue));
}
else {
SciCall_ResetElementColour(SC_ELEMENT_WHITE_SPACE);
SciCall_SetRepresentationColour("\r", SciCall_GetElementColour(SC_ELEMENT_WHITE_SPACE));
SciCall_SetRepresentationColour("\n", SciCall_GetElementColour(SC_ELEMENT_WHITE_SPACE));
SciCall_SetRepresentationColour("\r\n", SciCall_GetElementColour(SC_ELEMENT_WHITE_SPACE));
}
rgb = RGB(0, 0, 0);