Merge pull request #5034 from RaiKoHoff/Dev_Master

Chg: Long Line wrapping and ColorDef Dig positioning
This commit is contained in:
Rainer Kottenhoff 2023-10-16 18:45:43 +02:00 committed by GitHub
commit 0e9128efdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 109 additions and 77 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -4744,8 +4744,52 @@ 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;
}
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();
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 +4831,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 +4939,39 @@ 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:
EditWrapToColumn(hwnd, 0);
break;
}
}
@ -5506,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' ') {

View File

@ -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);

View File

@ -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);

View File

@ -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));
}
@ -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);
}
@ -6010,26 +6009,26 @@ 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)) {
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) {
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];
@ -7249,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));
@ -7262,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;
@ -7272,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) {
@ -8312,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;
@ -11835,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",
@ -12346,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);

View File

@ -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);

View File

@ -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);

View File

@ -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),