From 789273be64b651705f70aac284e95af9c3efdc1f Mon Sep 17 00:00:00 2001 From: "METANEOCORTEX\\Kotti" Date: Tue, 3 Oct 2023 00:30:07 +0200 Subject: [PATCH 1/3] +chg: Ctrl+I wraps according to highest column long-line-edge-marker, if defined --- src/Edit.c | 116 +++++++++++++++++++++++--------------- src/Edit.h | 4 +- src/EncodingDetection.cpp | 2 +- src/Notepad3.c | 9 ++- src/SciCall.h | 1 + src/Styles.c | 2 +- src/TypeDefs.h | 1 + 7 files changed, 80 insertions(+), 55 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index 421ffcebf..bd11f8d03 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -4744,8 +4744,49 @@ void EditFocusMarkedLinesCmd(HWND hwnd, bool bCopy, bool bDelete) // // EditWrapToColumn() // -void EditWrapToColumn(DocPosU nColumn) +void EditWrapToColumn(HWND hwnd, DocPosU nColumn) { + UNREFERENCED_PARAMETER(hwnd); + + if (Sci_IsMultiOrRectangleSelection()) { + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECTORMULTI); + return; + } + + size_t const size = (size_t)nColumn + 1LL; + char const spc = ' '; + char* const pTxt = (char* const)AllocMem(size + 1, HEAP_ZERO_MEMORY); + memset(pTxt, spc, size); + int const width_pix = SciCall_TextWidth(STYLE_DEFAULT, pTxt); + FreeMem(pTxt); + + UndoTransActionBegin(); + + if (SciCall_IsSelectionEmpty()) { + SciCall_TargetWholeDocument(); + } + else { + SciCall_TargetFromSelection(); + } + SciCall_LinesSplit(width_pix); + + EndUndoTransAction(); +} + + +//============================================================================= +// +// EditWrapToColumnEx() +// +void EditWrapToColumnEx(HWND hwnd, DocPosU nColumn) +{ + UNREFERENCED_PARAMETER(hwnd); + + if (Sci_IsMultiOrRectangleSelection()) { + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECTORMULTI); + return; + } + DocPosU const tabWidth = SciCall_GetTabWidth(); nColumn = clamppu(nColumn, tabWidth, LONG_LINES_MARKER_LIMIT); @@ -4787,13 +4828,13 @@ void EditWrapToColumn(DocPosU nColumn) // -------------------------------------------------------------------------- //#define W_DELIMITER L"!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~" // underscore counted as part of word const WCHAR* const W_DELIMITER = Settings.AccelWordNavigation ? W_DelimCharsAccel : W_DelimChars; -#define ISDELIMITER(wc) (!(wc) || StrChrW(W_DELIMITER,(wc))) + #define ISDELIMITER(wc) (!(wc) || StrChrW(W_DELIMITER,(wc))) //#define ISWHITE(wc) StrChr(L" \t\f",wc) const WCHAR* const W_WHITESPACE = Settings.AccelWordNavigation ? W_WhiteSpaceCharsAccelerated : W_WhiteSpaceCharsDefault; -#define ISWHITE(wc) (!(wc) || StrChrW(W_WHITESPACE,(wc))) -#define ISLINEBREAK(wc) (!(wc) || ((wc) == wszEOL[0]) || ((wc) == wszEOL[1])) -#define ISWORDCHAR(wc) (!ISWHITE(wc) && !ISLINEBREAK(wc) && !ISDELIMITER(wc)) -#define ISTAB(wc) ((wc) == L'\t') + #define ISWHITE(wc) (!(wc) || StrChrW(W_WHITESPACE,(wc))) + #define ISLINEBREAK(wc) (!(wc) || ((wc) == wszEOL[0]) || ((wc) == wszEOL[1])) + #define ISWORDCHAR(wc) (!ISWHITE(wc) && !ISLINEBREAK(wc) && !ISDELIMITER(wc)) + #define ISTAB(wc) ((wc) == L'\t') // -------------------------------------------------------------------------- DocPos iCaretShift = 0; @@ -4895,55 +4936,38 @@ void EditWrapToColumn(DocPosU nColumn) } -#if FALSE -//============================================================================= -// -// EditWrapToColumnForce() -// -void EditWrapToColumnForce(HWND hwnd, DocPosU nColumn/*,int nTabWidth*/) -{ - UNREFERENCED_PARAMETER(hwnd); - - if (Sci_IsMultiOrRectangleSelection()) { - InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECTORMULTI); - return; - } - - size_t const size = (size_t)nColumn + 1LL; - char const spc = ' '; - char* const pTxt = (char* const)AllocMem(size + 1, HEAP_ZERO_MEMORY); - memset(pTxt, spc, size); - int const width_pix = SciCall_TextWidth(STYLE_DEFAULT, pTxt); - FreeMem(pTxt); - - UndoTransActionBegin(); - - if (SciCall_IsSelectionEmpty()) { - SciCall_TargetWholeDocument(); - } else { - SciCall_TargetFromSelection(); - } - SciCall_LinesSplit(width_pix); - - EndUndoTransAction(); -} -#endif - - //============================================================================= // // EditSplitLines() // void EditSplitLines(HWND hwnd) { - UNREFERENCED_PARAMETER(hwnd); + if (Sci_IsMultiOrRectangleSelection()) { + InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_SELRECTORMULTI); + return; + } - UndoTransActionBegin(); + switch (SciCall_GetEdgeMode()) { + case EDGE_LINE: + case EDGE_BACKGROUND: { + EditWrapToColumn(hwnd, SciCall_GetEdgeColumn()); + } + break; - SciCall_TargetFromSelection(); - SciCall_LinesSplit(0); + case EDGE_MULTILINE: { + int n = 0; + for (n = 0; (n < EDGELINE_NUM_LIMIT) && (SciCall_GetMultiEdgeColumn(n) > 0); ++n) {} + DocPos const wrapColumn = SciCall_GetMultiEdgeColumn(clampi(n-1, 0, EDGELINE_NUM_LIMIT - 1)); + if (wrapColumn > 0) { + EditWrapToColumn(hwnd, wrapColumn); + } + } + break; - EndUndoTransAction(); + case EDGE_NONE: + default: + break; + } } diff --git a/src/Edit.h b/src/Edit.h index c4376097e..cb2aefe76 100644 --- a/src/Edit.h +++ b/src/Edit.h @@ -85,8 +85,8 @@ void EditCompressBlanks(); void EditRemoveBlankLines(HWND hwnd, bool bMerge, bool bRemoveWhiteSpace); void EditRemoveDuplicateLines(HWND hwnd, bool bRemoveEmptyLines); void EditFocusMarkedLinesCmd(HWND hwnd, bool bCopy, bool bDelete); -void EditWrapToColumn(DocPosU nColumn); -//void EditWrapToColumnForce(HWND hwnd, DocPosU nColumn); +void EditWrapToColumn(HWND hwnd, DocPosU nColumn); +void EditWrapToColumnEx(HWND hwnd, DocPosU nColumn); void EditSplitLines(HWND hwnd); void EditJoinLinesEx(bool,bool); diff --git a/src/EncodingDetection.cpp b/src/EncodingDetection.cpp index 12769f660..a4da5e107 100644 --- a/src/EncodingDetection.cpp +++ b/src/EncodingDetection.cpp @@ -1089,7 +1089,7 @@ extern "C" bool FileVars_Apply(LPFILEVARS lpfv) Globals.fvCurFile.bWordWrap = (lpfv->mask & FV_WORDWRAP) ? lpfv->bWordWrap : Settings.WordWrap; Sci_SetWrapModeEx(GET_WRAP_MODE()); - int edgeColumns[SMALL_BUFFER]; + int edgeColumns[EDGELINE_NUM_LIMIT]; size_t const cnt = ReadVectorFromString(lpfv->wchMultiEdgeLines, edgeColumns, COUNTOF(edgeColumns), 0, LONG_LINES_MARKER_LIMIT, 0, true); Style_SetMultiEdgeLine(edgeColumns, cnt); diff --git a/src/Notepad3.c b/src/Notepad3.c index bbd9a1d3b..dd12e9f91 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -4309,7 +4309,6 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) EnableCmd(hmenu, IDM_EDIT_SORTLINES, mls && !ro); //EnableCmd(hmenu,IDM_EDIT_COLUMNWRAP,i /*&& IsWindowsNT()*/); - EnableCmd(hmenu, IDM_EDIT_SPLITLINES, !se && !ro); EnableCmd(hmenu, IDM_EDIT_JOINLINES, !se && !ro); EnableCmd(hmenu, IDM_EDIT_JOINLN_NOSP, !se && !ro); EnableCmd(hmenu, IDM_EDIT_JOINLINES_PARA, !se && !ro); @@ -5479,7 +5478,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_EDIT_SORTLINES: if (EditSortDlg(hwnd,&s_iSortOptions)) { - EditSortLines(Globals.hwndEdit,s_iSortOptions); + EditSortLines(Globals.hwndEdit, s_iSortOptions); } break; @@ -5488,7 +5487,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) UINT uWrpCol = Globals.iWrapCol; if (ColumnWrapDlg(hwnd, IDD_MUI_COLUMNWRAP, &uWrpCol)) { Globals.iWrapCol = clampi((int)uWrpCol, SciCall_GetTabWidth(), LONG_LINES_MARKER_LIMIT); - EditWrapToColumn(Globals.iWrapCol); + EditWrapToColumnEx(Globals.hwndEdit, Globals.iWrapCol); } } break; @@ -6000,7 +5999,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_VIEW_LONGLINEMARKER: { Settings.MarkLongLines = !Settings.MarkLongLines; size_t cnt = 0; - int edgeColumns[SMALL_BUFFER] = { 0 }; + int edgeColumns[EDGELINE_NUM_LIMIT] = { 0 }; if (Settings.MarkLongLines) { cnt = ReadVectorFromString(Globals.fvCurFile.wchMultiEdgeLines, edgeColumns, COUNTOF(edgeColumns), 0, LONG_LINES_MARKER_LIMIT, 0, true); } @@ -6014,7 +6013,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (LongLineSettingsDlg(hwnd, IDD_MUI_LONGLINES, Globals.fvCurFile.wchMultiEdgeLines)) { - int edgeColumns[SMALL_BUFFER]; + int edgeColumns[EDGELINE_NUM_LIMIT]; size_t const cnt = ReadVectorFromString(Globals.fvCurFile.wchMultiEdgeLines, edgeColumns, COUNTOF(edgeColumns), 0, LONG_LINES_MARKER_LIMIT, 0, true); if (cnt == 0) { diff --git a/src/SciCall.h b/src/SciCall.h index 72ef42072..de1939c14 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -617,6 +617,7 @@ DeclareSciCallV1(SetEdgeColour, SETEDGECOLOUR, int, colour); DeclareSciCallR0(GetEdgeColour, GETEDGECOLOUR, int); DeclareSciCallV2(MultiEdgeAddLine, MULTIEDGEADDLINE, int, column, int, colour); DeclareSciCallV0(MultiEdgeClearAll, MULTIEDGECLEARALL); +DeclareSciCallR1(GetMultiEdgeColumn, GETMULTIEDGECOLUMN, DocPos, int, which); DeclareSciCallV1(SetTabWidth, SETTABWIDTH, int, width); DeclareSciCallR0(GetTabWidth, GETTABWIDTH, int); diff --git a/src/Styles.c b/src/Styles.c index 42f4286b2..9abb85b2f 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -1669,7 +1669,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) StringCchCopy(pCurrentStandard->Styles[STY_CARET].szValue, COUNTOF(pCurrentStandard->Styles[STY_CARET].szValue),wchStylesBuffer); - int edgeColumns[MIDSZ_BUFFER] = { 0 }; + int edgeColumns[EDGELINE_NUM_LIMIT] = { 0 }; size_t const cnt = ReadVectorFromString(Globals.fvCurFile.wchMultiEdgeLines, edgeColumns, COUNTOF(edgeColumns), 0, LONG_LINES_MARKER_LIMIT, 0, true); Style_SetMultiEdgeLine(edgeColumns, cnt); diff --git a/src/TypeDefs.h b/src/TypeDefs.h index 7859bf19c..0ec54a76b 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -208,6 +208,7 @@ typedef enum BUFFER_SIZES { XHUGE_BUFFER = 2048, XXXL_BUFFER = 4096, + EDGELINE_NUM_LIMIT = 256, ANSI_CHAR_BUFFER = 258, STYLE_EXTENTIONS_BUFFER = 512, EXTENTIONS_FILTER_BUFFER = (STYLE_EXTENTIONS_BUFFER << 1), From 5b72f484f19b7acfd45a7f0ad483fb11034c05cc Mon Sep 17 00:00:00 2001 From: "METANEOCORTEX\\Kotti" Date: Mon, 16 Oct 2023 11:50:58 +0200 Subject: [PATCH 2/3] +fix: show ColorDef Dlg always full visible --- src/Config/Config.cpp | 4 ++-- src/Dialogs.c | 10 ++++++---- src/Dialogs.h | 2 +- src/Notepad3.c | 19 ++++++++++--------- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/Config/Config.cpp b/src/Config/Config.cpp index cd15e93e4..8be8019d8 100644 --- a/src/Config/Config.cpp +++ b/src/Config/Config.cpp @@ -2264,8 +2264,8 @@ bool SaveWindowPositionSettings(bool bClearSettings) return false; } - // set current window position as ne initial window - WININFO const winInfo = GetMyWindowPlacement(Globals.hwndMain, NULL, 0); + // set current window position as new initial window + WININFO const winInfo = GetMyWindowPlacement(Globals.hwndMain, NULL, 0, false); int const ResX = GetSystemMetrics(SM_CXVIRTUALSCREEN); int const ResY = GetSystemMetrics(SM_CYVIRTUALSCREEN); diff --git a/src/Dialogs.c b/src/Dialogs.c index ab900b68c..d44bfc4ab 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -4623,7 +4623,7 @@ void FitIntoMonitorGeometry(LPRECT pRect, WININFO *pWinInfo, SCREEN_MODE mode, b // // GetMyWindowPlacement() // -WININFO GetMyWindowPlacement(HWND hwnd, MONITORINFO *hMonitorInfo, const int offset) { +WININFO GetMyWindowPlacement(HWND hwnd, MONITORINFO *hMonitorInfo, const int offset, const bool bFullVisible) { RECT rc; GetWindowRect(hwnd, &rc); @@ -4662,7 +4662,7 @@ WININFO GetMyWindowPlacement(HWND hwnd, MONITORINFO *hMonitorInfo, const int off wi.zoom = hwnd ? SciCall_GetZoom() : 100; wi.dpi = Scintilla_GetWindowDPI(hwnd); - if (Settings2.LaunchInstanceFullVisible) { + if (bFullVisible) { RECT rci; RectFromWinInfo(&wi, &rci); FitIntoMonitorGeometry(&rci, &wi, SCR_NORMAL, false); @@ -4834,7 +4834,7 @@ void DialogNewWindow(HWND hwnd, bool bSaveOnRunTools, const HPATHL hFilePath, WI StrgCat(hparam_str, Flags.bSingleFileInstance ? L" -ns" : L" -n"); WININFO const _wi = (Flags.bStickyWindowPosition ? g_IniWinInfo : - (wi ? *wi : GetMyWindowPlacement(hwnd, NULL, Settings2.LaunchInstanceWndPosOffset))); + (wi ? *wi : GetMyWindowPlacement(hwnd, NULL, Settings2.LaunchInstanceWndPosOffset, Settings2.LaunchInstanceFullVisible))); StringCchPrintf(wch, COUNTOF(wch), L" -pos " WINDOWPOS_STRGFORMAT, _wi.x, _wi.y, _wi.cx, _wi.cy, _wi.dpi, (int)_wi.max); StrgCat(hparam_str, wch); @@ -6700,7 +6700,9 @@ INT_PTR CALLBACK ColorDialogHookProc( const CHOOSECOLOR *const pChooseColor = ((CHOOSECOLOR *)lParam); if (pChooseColor && pChooseColor->lCustData) { POINT const pt = *(POINT*)pChooseColor->lCustData; - SetWindowPos(hdlg, NULL, pt.x, pt.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE); + SetWindowPos(hdlg, NULL, pt.x, pt.y, 0, 0, (SWP_NOZORDER | SWP_NOSIZE | SWP_HIDEWINDOW) & ~SWP_SHOWWINDOW); + WININFO wi = GetMyWindowPlacement(hdlg, NULL, 0, true); + SetWindowPos(hdlg, NULL, wi.x, wi.y, wi.cx, wi.cy, SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW); SetForegroundWindow(hdlg); } else { CenterDlgInParent(hdlg, NULL); diff --git a/src/Dialogs.h b/src/Dialogs.h index 2f87658f8..dbf354730 100644 --- a/src/Dialogs.h +++ b/src/Dialogs.h @@ -67,7 +67,7 @@ void RelAdjustRectForDPI(LPRECT rc, const UINT oldDPI, const UINT new void MapRectClientToWndCoords(HWND hwnd, LPRECT rc); bool GetMonitorInfoFromRect(const LPRECT rc, MONITORINFO* hMonitorInfo); void WinInfoToScreenCoord(WININFO* pWinInfo); -WININFO GetMyWindowPlacement(HWND hwnd, MONITORINFO* hMonitorInfo, const int offset); +WININFO GetMyWindowPlacement(HWND hwnd, MONITORINFO* hMonitorInfo, const int offset, const bool bFullVisible); bool GetWindowRectEx(HWND hwnd, LPRECT pRect); void FitIntoMonitorGeometry(LPRECT pRect, WININFO* pWinInfo, SCREEN_MODE mode, bool bTopLeft); WINDOWPLACEMENT WindowPlacementFromInfo(HWND hwnd, const WININFO* pWinInfo, SCREEN_MODE mode, UINT nCmdShow); diff --git a/src/Notepad3.c b/src/Notepad3.c index dd12e9f91..8210352d9 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -1506,7 +1506,7 @@ WININFO GetWinInfoByFlag(HWND hwnd, const int flagsPos) WININFO winfo = INIT_WININFO; if (flagsPos < 0) { - winfo = GetMyWindowPlacement(hwnd, NULL, 0); // current window position + winfo = GetMyWindowPlacement(hwnd, NULL, 0, false); // current window position } else if (flagsPos == 0) { winfo = g_IniWinInfo; // initial window position } else if (flagsPos == 1) { @@ -3732,9 +3732,9 @@ LRESULT MsgDropFiles(HWND hwnd, WPARAM wParam, LPARAM lParam) UINT const cnt = DragQueryFileW(hDrop, UINT_MAX, NULL, 0); int const offset = Settings2.LaunchInstanceWndPosOffset; - + bool const bFullVisible = Settings2.LaunchInstanceFullVisible; for (UINT i = 0; i < cnt; ++i) { - WININFO wi = GetMyWindowPlacement(hwnd, NULL, (vkCtrlDown ? (offset * (i + 1)) : 0)); + WININFO wi = GetMyWindowPlacement(hwnd, NULL, (vkCtrlDown ? (offset * (i + 1)) : 0), bFullVisible); DragQueryFileW(hDrop, i, drop_buf, (UINT)Path_GetBufCount(hdrop_pth)); _OnDropOneFile(hwnd, hdrop_pth, (((0 == i) && !IsKeyDown(VK_CONTROL)) ? NULL : &wi)); } @@ -7248,7 +7248,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case CMD_COPYWINPOS: { - WININFO wi = GetMyWindowPlacement(Globals.hwndMain, NULL, 0); + WININFO wi = GetMyWindowPlacement(Globals.hwndMain, NULL, 0, false); WCHAR wchBuf[128] = { L'\0' }; StringCchPrintf(wchBuf, COUNTOF(wchBuf), L"/pos " WINDOWPOS_STRGFORMAT, wi.x, wi.y, wi.cx, wi.cy, wi.dpi, (int)wi.max); SetClipboardText(hwnd, wchBuf, StringCchLen(wchBuf, 0)); @@ -7261,7 +7261,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) break; case CMD_FULLSCRWINPOS: { - WININFO wi = GetMyWindowPlacement(hwnd, NULL, 0); + WININFO wi = GetMyWindowPlacement(hwnd, NULL, 0, false); SnapToWinInfoPos(hwnd, wi, SCR_FULL_SCREEN, SW_SHOWDEFAULT); } break; @@ -7271,7 +7271,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) break; case CMD_SAVEASDEFWINPOS: { - WININFO const wi = GetMyWindowPlacement(hwnd, NULL, 0); + WININFO const wi = GetMyWindowPlacement(hwnd, NULL, 0, false); StringCchPrintf(Settings2.DefaultWindowPosition, COUNTOF(Settings2.DefaultWindowPosition), WINDOWPOS_STRGFORMAT, wi.x, wi.y, wi.cx, wi.cy, wi.dpi, (int)wi.max); if (Globals.bCanSaveIniFile) { @@ -8311,7 +8311,7 @@ void HandleColorDefClicked(HWND hwnd, const DocPos position) // custom hook cc.Flags |= CC_ENABLEHOOK; cc.lpfnHook = (LPCCHOOKPROC)ColorDialogHookProc; - WININFO const wi = GetMyWindowPlacement(Globals.hwndEdit, NULL, 0); + WININFO const wi = GetMyWindowPlacement(Globals.hwndEdit, NULL, 0, false); int const offset = f2int(Style_GetCurrentLexerFontSize()) << 1; POINT pt = { 0L, 0L }; pt.x = wi.x + SciCall_PointXFromPosition(SciCall_GetCurrentPos()) + offset; @@ -11834,7 +11834,7 @@ bool DoElevatedRelaunch(EditFileIOStatus* pFioStatus, bool bAutoSaveOnRelaunch) DocPos const iCurPos = SciCall_GetCurrentPos(); int const iCurLn = (int)SciCall_LineFromPosition(iCurPos) + 1; int const iCurCol = (int)SciCall_GetColumn(iCurPos) + 1; - WININFO const wi = GetMyWindowPlacement(Globals.hwndMain, NULL, 0); + WININFO const wi = GetMyWindowPlacement(Globals.hwndMain, NULL, 0, false); HSTRINGW hstr_args = StrgCreate(NULL); StrgFormat(hstr_args, L"%s/pos " WINDOWPOS_STRGFORMAT L" /g %i,%i %s", @@ -12345,8 +12345,9 @@ bool LaunchNewInstance(HWND hwnd, LPCWSTR lpszParameter, LPCWSTR lpszFilePath) } else { int const offset = Settings2.LaunchInstanceWndPosOffset; + int const bFullVisible = Settings2.LaunchInstanceFullVisible; int const instCnt = CountRunningInstances(); - WININFO wi = GetMyWindowPlacement(hwnd, NULL, offset * instCnt); + WININFO wi = GetMyWindowPlacement(hwnd, NULL, offset * instCnt, bFullVisible); WCHAR wchPos[80] = { L'\0' }; StringCchPrintf(wchPos, COUNTOF(wchPos), L"-pos " WINDOWPOS_STRGFORMAT, wi.x, wi.y, wi.cx, wi.cy, wi.dpi, (int)wi.max); From 78a19369e0a4944a7bee1459525d4d370eb95093 Mon Sep 17 00:00:00 2001 From: "METANEOCORTEX\\Kotti" Date: Mon, 16 Oct 2023 18:21:30 +0200 Subject: [PATCH 3/3] +chg: wrappimg at long line marker --- src/Edit.c | 20 ++++++++++++-------- src/Notepad3.c | 10 +++++----- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index bd11f8d03..c9fda17eb 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -4753,12 +4753,15 @@ void EditWrapToColumn(HWND hwnd, DocPosU nColumn) return; } - size_t const size = (size_t)nColumn + 1LL; - char const spc = ' '; - char* const pTxt = (char* const)AllocMem(size + 1, HEAP_ZERO_MEMORY); - memset(pTxt, spc, size); - int const width_pix = SciCall_TextWidth(STYLE_DEFAULT, pTxt); - FreeMem(pTxt); + int width_pix = 0; + if (nColumn > 0) { + size_t const size = (size_t)nColumn + 1LL; + char const spc = ' '; + char* const pTxt = (char* const)AllocMem(size + 1, HEAP_ZERO_MEMORY); + memset(pTxt, spc, size); + width_pix = SciCall_TextWidth(STYLE_DEFAULT, pTxt); + FreeMem(pTxt); + } UndoTransActionBegin(); @@ -4958,7 +4961,7 @@ void EditSplitLines(HWND hwnd) int n = 0; for (n = 0; (n < EDGELINE_NUM_LIMIT) && (SciCall_GetMultiEdgeColumn(n) > 0); ++n) {} DocPos const wrapColumn = SciCall_GetMultiEdgeColumn(clampi(n-1, 0, EDGELINE_NUM_LIMIT - 1)); - if (wrapColumn > 0) { + if (wrapColumn >= 0) { EditWrapToColumn(hwnd, wrapColumn); } } @@ -4966,6 +4969,7 @@ void EditSplitLines(HWND hwnd) case EDGE_NONE: default: + EditWrapToColumn(hwnd, 0); break; } } @@ -5530,7 +5534,7 @@ void EditGetExcerpt(HWND hwnd, LPWSTR lpszExcerpt, DWORD cchExcerpt) if (pszText && pszTextW) { tr.lpstrText = pszText; DocPos const rlen = SciCall_GetTextRangeFull(&tr); - MultiByteToWideCharEx(Encoding_SciCP,0,pszText,rlen,pszTextW,len); + MultiByteToWideCharEx(Encoding_SciCP, 0, pszText, rlen, pszTextW, len); for (WCHAR* p = pszTextW; *p && cch < COUNTOF(tch)-1; p++) { if (*p == L'\r' || *p == L'\n' || *p == L'\t' || *p == L' ') { diff --git a/src/Notepad3.c b/src/Notepad3.c index 8210352d9..34f081a9a 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -6009,7 +6009,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_SET_LONGLINESETTINGS: { - int _iLongLinesLimit = Defaults.LongLinesLimit; + int iLongLinesLimit = Defaults.LongLinesLimit; if (LongLineSettingsDlg(hwnd, IDD_MUI_LONGLINES, Globals.fvCurFile.wchMultiEdgeLines)) { @@ -6019,16 +6019,16 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) if (cnt == 0) { Settings.MarkLongLines = false; } else if (cnt == 1) { - _iLongLinesLimit = edgeColumns[0]; + iLongLinesLimit = edgeColumns[0]; Settings.MarkLongLines = true; //~Settings.LongLineMode = EDGE_LINE|EDGE_BACKGROUND; // set by Dlg } else { - _iLongLinesLimit = edgeColumns[cnt - 1]; + iLongLinesLimit = edgeColumns[cnt - 1]; Settings.MarkLongLines = true; Settings.LongLineMode = EDGE_MULTILINE; } - Globals.iWrapCol = _iLongLinesLimit; - Settings.LongLinesLimit = _iLongLinesLimit; + Globals.iWrapCol = iLongLinesLimit; + Settings.LongLinesLimit = iLongLinesLimit; // new multi-edge lines setting WCHAR col[32];