mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
Merge remote-tracking branch 'notepad3_orig_rizone/master'
This commit is contained in:
commit
2ab2ca802e
140
src/Edit.c
140
src/Edit.c
@ -49,14 +49,13 @@
|
||||
#define LCMAP_TITLECASE 0x00000300 // Title Case Letters bit mask
|
||||
#endif
|
||||
|
||||
#define DEFAULT_SCROLL_WIDTH 4096 // 4K
|
||||
|
||||
// find free bits in scintilla.h SCFIND_ defines
|
||||
#define SCFIND_NP3_REGEX (SCFIND_REGEXP | SCFIND_POSIX)
|
||||
|
||||
extern HWND g_hwndMain;
|
||||
extern HWND g_hwndEdit;
|
||||
extern HWND g_hwndStatus;
|
||||
extern WININFO g_WinInfo;
|
||||
|
||||
extern HINSTANCE g_hInstance;
|
||||
//extern LPMALLOC g_lpMalloc;
|
||||
@ -330,9 +329,9 @@ void EditSetNewText(HWND hwnd,char* lpstrText,DWORD cbText)
|
||||
{
|
||||
bFreezeAppTitle = TRUE;
|
||||
|
||||
if (SendMessage(hwnd,SCI_GETREADONLY,0,0))
|
||||
SendMessage(hwnd,SCI_SETREADONLY,FALSE,0);
|
||||
|
||||
if (SendMessage(hwnd, SCI_GETREADONLY, 0, 0)) {
|
||||
SendMessage(hwnd, SCI_SETREADONLY, FALSE, 0);
|
||||
}
|
||||
SendMessage(hwnd,SCI_CANCEL,0,0);
|
||||
SendMessage(hwnd,SCI_SETUNDOCOLLECTION,0,0);
|
||||
UndoRedoActionMap(-1,NULL);
|
||||
@ -343,9 +342,9 @@ void EditSetNewText(HWND hwnd,char* lpstrText,DWORD cbText)
|
||||
|
||||
FileVars_Apply(hwnd,&fvCurFile);
|
||||
|
||||
if (cbText > 0)
|
||||
SendMessage(hwnd,SCI_ADDTEXT,cbText,(LPARAM)lpstrText);
|
||||
|
||||
if (cbText > 0) {
|
||||
SendMessage(hwnd, SCI_ADDTEXT, cbText, (LPARAM)lpstrText);
|
||||
}
|
||||
SendMessage(hwnd,SCI_SETUNDOCOLLECTION,1,0);
|
||||
//SendMessage(hwnd,EM_EMPTYUNDOBUFFER,0,0); // deprecated
|
||||
SendMessage(hwnd,SCI_SETSAVEPOINT,0,0);
|
||||
@ -2016,7 +2015,7 @@ void EditTabsToSpaces(HWND hwnd,int nTabWidth,BOOL bOnlyIndentingWS)
|
||||
int cchConvM = WideCharToMultiByte(cpEdit,0,pszConvW,cchConvW,pszText,(int)GlobalSize(pszText),NULL,NULL);
|
||||
GlobalFree(pszConvW);
|
||||
|
||||
if (iAnchorPos > iCurPos) {
|
||||
if (iCurPos < iAnchorPos) {
|
||||
iCurPos = iSelStart;
|
||||
iAnchorPos = iSelStart + cchConvM;
|
||||
}
|
||||
@ -3521,43 +3520,34 @@ void EditRemoveBlankLines(HWND hwnd,BOOL bMerge)
|
||||
//
|
||||
void EditWrapToColumn(HWND hwnd,int nColumn/*,int nTabWidth*/)
|
||||
{
|
||||
BOOL bModified = FALSE;
|
||||
|
||||
if (SciCall_IsSelectionEmpty())
|
||||
return;
|
||||
|
||||
if (SciCall_IsSelectionRectangle()) {
|
||||
MsgBox(MBWARN,IDS_SELRECT);
|
||||
return;
|
||||
}
|
||||
|
||||
int iCurPos = SciCall_GetCurrentPos();;
|
||||
int iCurPos = SciCall_GetCurrentPos();
|
||||
int iAnchorPos = SciCall_GetAnchor();
|
||||
int iSelStart = SciCall_GetSelectionStart();
|
||||
int iLine = SciCall_LineFromPosition(iSelStart);
|
||||
iSelStart = SciCall_PositionFromLine(iLine); // re-base selection start to line begin
|
||||
int iSelEnd = SciCall_GetSelectionEnd();
|
||||
int iSelCount = iSelEnd - iSelStart;
|
||||
|
||||
char* pszText = GlobalAlloc(GPTR,iSelCount+2);
|
||||
if (pszText == NULL)
|
||||
return;
|
||||
int iSelStart = 0;
|
||||
int iSelEnd = SciCall_GetTextLength();
|
||||
int iSelCount = SciCall_GetTextLength();
|
||||
|
||||
if (!SciCall_IsSelectionEmpty()) {
|
||||
iSelStart = SciCall_GetSelectionStart();
|
||||
int iLine = SciCall_LineFromPosition(iSelStart);
|
||||
iSelStart = SciCall_PositionFromLine(iLine); // re-base selection to start of line
|
||||
iSelEnd = SciCall_GetSelectionEnd();
|
||||
iSelCount = (iSelEnd - iSelStart);
|
||||
}
|
||||
|
||||
char* pszText = (char*)SciCall_GetRangePointer(iSelStart, iSelCount);
|
||||
|
||||
LPWSTR pszTextW = GlobalAlloc(GPTR,(iSelCount+2)*sizeof(WCHAR));
|
||||
if (pszTextW == NULL) {
|
||||
GlobalFree(pszText);
|
||||
return;
|
||||
}
|
||||
|
||||
struct Sci_TextRange tr = { { 0, 0 }, NULL };
|
||||
tr.chrg.cpMin = iSelStart;
|
||||
tr.chrg.cpMax = iSelEnd;
|
||||
tr.lpstrText = pszText;
|
||||
SendMessage(hwnd,SCI_GETTEXTRANGE,0,(LPARAM)&tr);
|
||||
|
||||
UINT cpEdit = Encoding_SciGetCodePage(hwnd);
|
||||
int cchTextW = MultiByteToWideChar(cpEdit,0,pszText,iSelCount,pszTextW,(int)(GlobalSize(pszTextW)/sizeof(WCHAR)));
|
||||
GlobalFree(pszText);
|
||||
|
||||
LPWSTR pszConvW = GlobalAlloc(GPTR,cchTextW*sizeof(WCHAR)*3+2);
|
||||
if (pszConvW == NULL) {
|
||||
@ -3577,7 +3567,6 @@ void EditWrapToColumn(HWND hwnd,int nColumn/*,int nTabWidth*/)
|
||||
int cchConvW = 0;
|
||||
int iLineLength = 0;
|
||||
|
||||
|
||||
//#define W_DELIMITER L"!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~" // underscore counted as part of word
|
||||
//WCHAR* W_DELIMITER = bAccelWordNavigation ? W_DelimCharsAccel : W_DelimChars;
|
||||
//#define ISDELIMITER(wc) StrChr(W_DELIMITER,wc)
|
||||
@ -3589,47 +3578,13 @@ void EditWrapToColumn(HWND hwnd,int nColumn/*,int nTabWidth*/)
|
||||
//#define ISWORDEND(wc) (ISDELIMITER(wc) || ISWHITE(wc))
|
||||
#define ISWORDEND(wc) StrChr(L" \t\f\r\n\v",wc)
|
||||
|
||||
int iCaretShift = 0;
|
||||
BOOL bModified = FALSE;
|
||||
|
||||
for (int iTextW = 0; iTextW < cchTextW; iTextW++)
|
||||
{
|
||||
WCHAR w = pszTextW[iTextW];
|
||||
|
||||
//if (ISDELIMITER(w))
|
||||
//{
|
||||
// int iNextWordLen = 0;
|
||||
// WCHAR w2 = pszTextW[iTextW + 1];
|
||||
|
||||
// if (iLineLength + iNextWordLen + 1 > nColumn) {
|
||||
// pszConvW[cchConvW++] = wszEOL[0];
|
||||
// if (cchEOL > 1)
|
||||
// pszConvW[cchConvW++] = wszEOL[1];
|
||||
// iLineLength = 0;
|
||||
// bModified = TRUE;
|
||||
// }
|
||||
|
||||
// while (w2 != L'\0' && !ISWORDEND(w2)) {
|
||||
// iNextWordLen++;
|
||||
// w2 = pszTextW[iTextW + iNextWordLen + 1];
|
||||
// }
|
||||
|
||||
// if (ISDELIMITER(w2) && iNextWordLen > 0) // delimiters go with the word
|
||||
// iNextWordLen++;
|
||||
|
||||
// pszConvW[cchConvW++] = w;
|
||||
// iLineLength++;
|
||||
|
||||
// if (iNextWordLen > 0)
|
||||
// {
|
||||
// if (iLineLength + iNextWordLen + 1 > nColumn) {
|
||||
// pszConvW[cchConvW++] = wszEOL[0];
|
||||
// if (cchEOL > 1)
|
||||
// pszConvW[cchConvW++] = wszEOL[1];
|
||||
// iLineLength = 0;
|
||||
// bModified = TRUE;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
if (ISWHITE(w))
|
||||
{
|
||||
int iNextWordLen = 0;
|
||||
@ -3652,6 +3607,7 @@ void EditWrapToColumn(HWND hwnd,int nColumn/*,int nTabWidth*/)
|
||||
if (iNextWordLen > 0)
|
||||
{
|
||||
if (iLineLength + iNextWordLen + 1 > nColumn) {
|
||||
if (cchConvW <= iCurPos) { ++iCaretShift; };
|
||||
pszConvW[cchConvW++] = wszEOL[0];
|
||||
if (cchEOL > 1)
|
||||
pszConvW[cchConvW++] = wszEOL[1];
|
||||
@ -3677,35 +3633,37 @@ void EditWrapToColumn(HWND hwnd,int nColumn/*,int nTabWidth*/)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GlobalFree(pszTextW);
|
||||
|
||||
if (bModified) {
|
||||
if (bModified)
|
||||
{
|
||||
pszText = GlobalAlloc(GPTR, cchConvW * 3);
|
||||
if (pszText)
|
||||
{
|
||||
int cchConvM = WideCharToMultiByte(cpEdit, 0, pszConvW, cchConvW, pszText, (int)GlobalSize(pszText), NULL, NULL);
|
||||
|
||||
int cchConvM = WideCharToMultiByte(cpEdit,0,pszConvW,cchConvW,pszText,(int)GlobalSize(pszText),NULL,NULL);
|
||||
GlobalFree(pszConvW);
|
||||
if (iCurPos < iAnchorPos) {
|
||||
iAnchorPos = iSelStart + cchConvM;
|
||||
}
|
||||
else if (iCurPos > iAnchorPos) {
|
||||
iCurPos = iSelStart + cchConvM;
|
||||
}
|
||||
else {
|
||||
iCurPos += iCaretShift;
|
||||
iAnchorPos = iCurPos;
|
||||
}
|
||||
|
||||
if (iAnchorPos > iCurPos) {
|
||||
//iCurPos = iSelStart;
|
||||
iAnchorPos = iSelStart + cchConvM;
|
||||
EditEnterTargetTransaction();
|
||||
SendMessage(hwnd, SCI_SETTARGETRANGE, iSelStart, iSelEnd);
|
||||
SendMessage(hwnd, SCI_REPLACETARGET, (WPARAM)cchConvM, (LPARAM)pszText);
|
||||
EditLeaveTargetTransaction();
|
||||
|
||||
GlobalFree(pszText);
|
||||
|
||||
EditSelectEx(hwnd, iAnchorPos, iCurPos);
|
||||
}
|
||||
else {
|
||||
//iAnchorPos = iSelStart;
|
||||
iCurPos = iSelStart + cchConvM;
|
||||
}
|
||||
|
||||
EditEnterTargetTransaction();
|
||||
SendMessage(hwnd, SCI_SETTARGETRANGE, iSelStart, iSelEnd);
|
||||
SendMessage(hwnd, SCI_REPLACETARGET, (WPARAM)cchConvM, (LPARAM)pszText);
|
||||
EditLeaveTargetTransaction();
|
||||
|
||||
EditSelectEx(hwnd, iAnchorPos, iCurPos);
|
||||
|
||||
GlobalFree(pszText);
|
||||
}
|
||||
else
|
||||
GlobalFree(pszConvW);
|
||||
GlobalFree(pszConvW);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -50,6 +50,9 @@ typedef struct _editfindreplace
|
||||
#define INDIC_NP3_MATCH_BRACE 2
|
||||
#define INDIC_NP3_BAD_BRACE 3
|
||||
|
||||
// [pixel] auto calculate by SCI_SETSCROLLWIDTHTRACKING
|
||||
//#define DEFAULT_SCROLL_WIDTH (8*80)
|
||||
#define DEFAULT_SCROLL_WIDTH ((8*g_WinInfo.cx)/10)
|
||||
|
||||
HWND EditCreate(HWND);
|
||||
void EditInitWordDelimiter(HWND);
|
||||
|
||||
160
src/Notepad3.c
160
src/Notepad3.c
@ -213,16 +213,7 @@ const int FontQuality[4] = {
|
||||
, SC_EFF_QUALITY_LCD_OPTIMIZED
|
||||
};
|
||||
|
||||
typedef struct _wi
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int cx;
|
||||
int cy;
|
||||
int max;
|
||||
} WININFO;
|
||||
|
||||
static WININFO wininfo = { CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0 };
|
||||
WININFO g_WinInfo = { CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0 };
|
||||
|
||||
BOOL bStickyWinPos;
|
||||
|
||||
@ -609,7 +600,7 @@ BOOL InitApplication(HINSTANCE hInstance)
|
||||
HWND InitInstance(HINSTANCE hInstance,LPSTR pszCmdLine,int nCmdShow)
|
||||
{
|
||||
RECT rc;
|
||||
rc.left = wininfo.x; rc.top = wininfo.y; rc.right = wininfo.x + wininfo.cx; rc.bottom = wininfo.y + wininfo.cy;
|
||||
rc.left = g_WinInfo.x; rc.top = g_WinInfo.y; rc.right = g_WinInfo.x + g_WinInfo.cx; rc.bottom = g_WinInfo.y + g_WinInfo.cy;
|
||||
RECT rc2;
|
||||
MONITORINFO mi;
|
||||
|
||||
@ -618,80 +609,80 @@ HWND InitInstance(HINSTANCE hInstance,LPSTR pszCmdLine,int nCmdShow)
|
||||
GetMonitorInfo(hMonitor,&mi);
|
||||
|
||||
if (flagDefaultPos == 1) {
|
||||
wininfo.x = wininfo.y = wininfo.cx = wininfo.cy = CW_USEDEFAULT;
|
||||
wininfo.max = 0;
|
||||
g_WinInfo.x = g_WinInfo.y = g_WinInfo.cx = g_WinInfo.cy = CW_USEDEFAULT;
|
||||
g_WinInfo.max = 0;
|
||||
}
|
||||
else if (flagDefaultPos >= 4) {
|
||||
SystemParametersInfo(SPI_GETWORKAREA,0,&rc,0);
|
||||
if (flagDefaultPos & 8)
|
||||
wininfo.x = (rc.right - rc.left) / 2;
|
||||
g_WinInfo.x = (rc.right - rc.left) / 2;
|
||||
else
|
||||
wininfo.x = rc.left;
|
||||
wininfo.cx = rc.right - rc.left;
|
||||
g_WinInfo.x = rc.left;
|
||||
g_WinInfo.cx = rc.right - rc.left;
|
||||
if (flagDefaultPos & (4|8))
|
||||
wininfo.cx /= 2;
|
||||
g_WinInfo.cx /= 2;
|
||||
if (flagDefaultPos & 32)
|
||||
wininfo.y = (rc.bottom - rc.top) / 2;
|
||||
g_WinInfo.y = (rc.bottom - rc.top) / 2;
|
||||
else
|
||||
wininfo.y = rc.top;
|
||||
wininfo.cy = rc.bottom - rc.top;
|
||||
g_WinInfo.y = rc.top;
|
||||
g_WinInfo.cy = rc.bottom - rc.top;
|
||||
if (flagDefaultPos & (16|32))
|
||||
wininfo.cy /= 2;
|
||||
g_WinInfo.cy /= 2;
|
||||
if (flagDefaultPos & 64) {
|
||||
wininfo.x = rc.left;
|
||||
wininfo.y = rc.top;
|
||||
wininfo.cx = rc.right - rc.left;
|
||||
wininfo.cy = rc.bottom - rc.top;
|
||||
g_WinInfo.x = rc.left;
|
||||
g_WinInfo.y = rc.top;
|
||||
g_WinInfo.cx = rc.right - rc.left;
|
||||
g_WinInfo.cy = rc.bottom - rc.top;
|
||||
}
|
||||
if (flagDefaultPos & 128) {
|
||||
wininfo.x += (flagDefaultPos & 8) ? 4 : 8;
|
||||
wininfo.cx -= (flagDefaultPos & (4|8)) ? 12 : 16;
|
||||
wininfo.y += (flagDefaultPos & 32) ? 4 : 8;
|
||||
wininfo.cy -= (flagDefaultPos & (16|32)) ? 12 : 16;
|
||||
g_WinInfo.x += (flagDefaultPos & 8) ? 4 : 8;
|
||||
g_WinInfo.cx -= (flagDefaultPos & (4|8)) ? 12 : 16;
|
||||
g_WinInfo.y += (flagDefaultPos & 32) ? 4 : 8;
|
||||
g_WinInfo.cy -= (flagDefaultPos & (16|32)) ? 12 : 16;
|
||||
}
|
||||
}
|
||||
|
||||
else if (flagDefaultPos == 2 || flagDefaultPos == 3 ||
|
||||
wininfo.x == CW_USEDEFAULT || wininfo.y == CW_USEDEFAULT ||
|
||||
wininfo.cx == CW_USEDEFAULT || wininfo.cy == CW_USEDEFAULT) {
|
||||
g_WinInfo.x == CW_USEDEFAULT || g_WinInfo.y == CW_USEDEFAULT ||
|
||||
g_WinInfo.cx == CW_USEDEFAULT || g_WinInfo.cy == CW_USEDEFAULT) {
|
||||
|
||||
// default window position
|
||||
SystemParametersInfo(SPI_GETWORKAREA,0,&rc,0);
|
||||
wininfo.y = rc.top + 16;
|
||||
wininfo.cy = rc.bottom - rc.top - 32;
|
||||
wininfo.cx = min(rc.right - rc.left - 32,wininfo.cy);
|
||||
wininfo.x = (flagDefaultPos == 3) ? rc.left + 16 : rc.right - wininfo.cx - 16;
|
||||
g_WinInfo.y = rc.top + 16;
|
||||
g_WinInfo.cy = rc.bottom - rc.top - 32;
|
||||
g_WinInfo.cx = min(rc.right - rc.left - 32,g_WinInfo.cy);
|
||||
g_WinInfo.x = (flagDefaultPos == 3) ? rc.left + 16 : rc.right - g_WinInfo.cx - 16;
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
// fit window into working area of current monitor
|
||||
wininfo.x += (mi.rcWork.left - mi.rcMonitor.left);
|
||||
wininfo.y += (mi.rcWork.top - mi.rcMonitor.top);
|
||||
if (wininfo.x < mi.rcWork.left)
|
||||
wininfo.x = mi.rcWork.left;
|
||||
if (wininfo.y < mi.rcWork.top)
|
||||
wininfo.y = mi.rcWork.top;
|
||||
if (wininfo.x + wininfo.cx > mi.rcWork.right) {
|
||||
wininfo.x -= (wininfo.x + wininfo.cx - mi.rcWork.right);
|
||||
if (wininfo.x < mi.rcWork.left)
|
||||
wininfo.x = mi.rcWork.left;
|
||||
if (wininfo.x + wininfo.cx > mi.rcWork.right)
|
||||
wininfo.cx = mi.rcWork.right - wininfo.x;
|
||||
g_WinInfo.x += (mi.rcWork.left - mi.rcMonitor.left);
|
||||
g_WinInfo.y += (mi.rcWork.top - mi.rcMonitor.top);
|
||||
if (g_WinInfo.x < mi.rcWork.left)
|
||||
g_WinInfo.x = mi.rcWork.left;
|
||||
if (g_WinInfo.y < mi.rcWork.top)
|
||||
g_WinInfo.y = mi.rcWork.top;
|
||||
if (g_WinInfo.x + g_WinInfo.cx > mi.rcWork.right) {
|
||||
g_WinInfo.x -= (g_WinInfo.x + g_WinInfo.cx - mi.rcWork.right);
|
||||
if (g_WinInfo.x < mi.rcWork.left)
|
||||
g_WinInfo.x = mi.rcWork.left;
|
||||
if (g_WinInfo.x + g_WinInfo.cx > mi.rcWork.right)
|
||||
g_WinInfo.cx = mi.rcWork.right - g_WinInfo.x;
|
||||
}
|
||||
if (wininfo.y + wininfo.cy > mi.rcWork.bottom) {
|
||||
wininfo.y -= (wininfo.y + wininfo.cy - mi.rcWork.bottom);
|
||||
if (wininfo.y < mi.rcWork.top)
|
||||
wininfo.y = mi.rcWork.top;
|
||||
if (wininfo.y + wininfo.cy > mi.rcWork.bottom)
|
||||
wininfo.cy = mi.rcWork.bottom - wininfo.y;
|
||||
if (g_WinInfo.y + g_WinInfo.cy > mi.rcWork.bottom) {
|
||||
g_WinInfo.y -= (g_WinInfo.y + g_WinInfo.cy - mi.rcWork.bottom);
|
||||
if (g_WinInfo.y < mi.rcWork.top)
|
||||
g_WinInfo.y = mi.rcWork.top;
|
||||
if (g_WinInfo.y + g_WinInfo.cy > mi.rcWork.bottom)
|
||||
g_WinInfo.cy = mi.rcWork.bottom - g_WinInfo.y;
|
||||
}
|
||||
SetRect(&rc,wininfo.x,wininfo.y,wininfo.x+wininfo.cx,wininfo.y+wininfo.cy);
|
||||
SetRect(&rc,g_WinInfo.x,g_WinInfo.y,g_WinInfo.x+g_WinInfo.cx,g_WinInfo.y+g_WinInfo.cy);
|
||||
if (!IntersectRect(&rc2,&rc,&mi.rcWork)) {
|
||||
wininfo.y = mi.rcWork.top + 16;
|
||||
wininfo.cy = mi.rcWork.bottom - mi.rcWork.top - 32;
|
||||
wininfo.cx = min(mi.rcWork.right - mi.rcWork.left - 32,wininfo.cy);
|
||||
wininfo.x = mi.rcWork.right - wininfo.cx - 16;
|
||||
g_WinInfo.y = mi.rcWork.top + 16;
|
||||
g_WinInfo.cy = mi.rcWork.bottom - mi.rcWork.top - 32;
|
||||
g_WinInfo.cx = min(mi.rcWork.right - mi.rcWork.left - 32,g_WinInfo.cy);
|
||||
g_WinInfo.x = mi.rcWork.right - g_WinInfo.cx - 16;
|
||||
}
|
||||
}
|
||||
|
||||
@ -700,16 +691,16 @@ HWND InitInstance(HINSTANCE hInstance,LPSTR pszCmdLine,int nCmdShow)
|
||||
wchWndClass,
|
||||
L"Notepad3",
|
||||
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
|
||||
wininfo.x,
|
||||
wininfo.y,
|
||||
wininfo.cx,
|
||||
wininfo.cy,
|
||||
g_WinInfo.x,
|
||||
g_WinInfo.y,
|
||||
g_WinInfo.cx,
|
||||
g_WinInfo.cy,
|
||||
NULL,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
|
||||
if (wininfo.max)
|
||||
if (g_WinInfo.max)
|
||||
nCmdShow = SW_SHOWMAXIMIZED;
|
||||
|
||||
if ((bAlwaysOnTop || flagAlwaysOnTop == 2) && flagAlwaysOnTop != 1)
|
||||
@ -1550,7 +1541,7 @@ void MsgEndSession(HWND hwnd, UINT umsg)
|
||||
InstallFileWatching(NULL);
|
||||
|
||||
// GetWindowPlacement
|
||||
wininfo = GetMyWindowPlacement(hwnd, NULL);
|
||||
g_WinInfo = GetMyWindowPlacement(hwnd, NULL);
|
||||
|
||||
DragAcceptFiles(hwnd, FALSE);
|
||||
RevokeDragAndDrop(pDropTarget);
|
||||
@ -2205,7 +2196,7 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
(SciCall_LineFromPosition(SciCall_GetSelectionEnd()) -
|
||||
SciCall_LineFromPosition(SciCall_GetSelectionStart())) >= 1);
|
||||
|
||||
EnableCmd(hmenu,IDM_EDIT_COLUMNWRAP,i /*&& IsWindowsNT()*/);
|
||||
//EnableCmd(hmenu,IDM_EDIT_COLUMNWRAP,i /*&& IsWindowsNT()*/);
|
||||
EnableCmd(hmenu,IDM_EDIT_SPLITLINES,i /*&& !bReadOnly*/);
|
||||
EnableCmd(hmenu,IDM_EDIT_JOINLINES,i /*&& !bReadOnly*/);
|
||||
EnableCmd(hmenu, IDM_EDIT_JOINLN_NOSP,i /*&& !bReadOnly*/);
|
||||
@ -3321,9 +3312,9 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
case IDM_EDIT_COLUMNWRAP:
|
||||
{
|
||||
if (iWrapCol == 0)
|
||||
if (iWrapCol == 0) {
|
||||
iWrapCol = iLongLinesLimit;
|
||||
|
||||
}
|
||||
if (ColumnWrapDlg(hwnd,IDD_COLUMNWRAP,&iWrapCol))
|
||||
{
|
||||
iWrapCol = max(min(iWrapCol,512),1);
|
||||
@ -5688,6 +5679,7 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam)
|
||||
|
||||
|
||||
case SCN_SAVEPOINTREACHED:
|
||||
SendMessage(g_hwndEdit, SCI_SETSCROLLWIDTH, DEFAULT_SCROLL_WIDTH, 0);
|
||||
SetDocumentModified(FALSE);
|
||||
break;
|
||||
|
||||
@ -6150,12 +6142,12 @@ void LoadSettings()
|
||||
StringCchPrintf(tchSizeY,COUNTOF(tchSizeY),L"%ix%i SizeY",ResX,ResY);
|
||||
StringCchPrintf(tchMaximized,COUNTOF(tchMaximized),L"%ix%i Maximized",ResX,ResY);
|
||||
|
||||
wininfo.x = IniSectionGetInt(pIniSection,tchPosX,CW_USEDEFAULT);
|
||||
wininfo.y = IniSectionGetInt(pIniSection,tchPosY,CW_USEDEFAULT);
|
||||
wininfo.cx = IniSectionGetInt(pIniSection,tchSizeX,CW_USEDEFAULT);
|
||||
wininfo.cy = IniSectionGetInt(pIniSection,tchSizeY,CW_USEDEFAULT);
|
||||
wininfo.max = IniSectionGetInt(pIniSection,tchMaximized,0);
|
||||
if (wininfo.max) wininfo.max = 1;
|
||||
g_WinInfo.x = IniSectionGetInt(pIniSection,tchPosX,CW_USEDEFAULT);
|
||||
g_WinInfo.y = IniSectionGetInt(pIniSection,tchPosY,CW_USEDEFAULT);
|
||||
g_WinInfo.cx = IniSectionGetInt(pIniSection,tchSizeX,CW_USEDEFAULT);
|
||||
g_WinInfo.cy = IniSectionGetInt(pIniSection,tchSizeY,CW_USEDEFAULT);
|
||||
g_WinInfo.max = IniSectionGetInt(pIniSection,tchMaximized,0);
|
||||
if (g_WinInfo.max) g_WinInfo.max = 1;
|
||||
}
|
||||
|
||||
// --- override by resolution specific settings ---
|
||||
@ -6325,7 +6317,7 @@ void SaveSettings(BOOL bSaveSettingsNow) {
|
||||
|
||||
if (bSaveSettingsNow) {
|
||||
// GetWindowPlacement
|
||||
wininfo = GetMyWindowPlacement(g_hwndMain,NULL);
|
||||
g_WinInfo = GetMyWindowPlacement(g_hwndMain,NULL);
|
||||
}
|
||||
|
||||
int ResX = GetSystemMetrics(SM_CXSCREEN);
|
||||
@ -6345,11 +6337,11 @@ void SaveSettings(BOOL bSaveSettingsNow) {
|
||||
StringCchPrintf(tchSizeY,COUNTOF(tchSizeY),L"%ix%i SizeY",ResX,ResY);
|
||||
StringCchPrintf(tchMaximized,COUNTOF(tchMaximized),L"%ix%i Maximized",ResX,ResY);
|
||||
|
||||
IniSetInt(L"Window",tchPosX,wininfo.x);
|
||||
IniSetInt(L"Window",tchPosY,wininfo.y);
|
||||
IniSetInt(L"Window",tchSizeX,wininfo.cx);
|
||||
IniSetInt(L"Window",tchSizeY,wininfo.cy);
|
||||
IniSetInt(L"Window",tchMaximized,wininfo.max);
|
||||
IniSetInt(L"Window",tchPosX,g_WinInfo.x);
|
||||
IniSetInt(L"Window",tchPosY,g_WinInfo.y);
|
||||
IniSetInt(L"Window",tchSizeX,g_WinInfo.cx);
|
||||
IniSetInt(L"Window",tchSizeY,g_WinInfo.cy);
|
||||
IniSetInt(L"Window",tchMaximized,g_WinInfo.max);
|
||||
}
|
||||
|
||||
// Scintilla Styles
|
||||
@ -6565,15 +6557,15 @@ void ParseCommandLine()
|
||||
}
|
||||
else if (ExtractFirstArgument(lp2,lp1,lp2,len)) {
|
||||
int itok =
|
||||
swscanf_s(lp1,L"%i,%i,%i,%i,%i",&wininfo.x,&wininfo.y,&wininfo.cx,&wininfo.cy,&wininfo.max);
|
||||
swscanf_s(lp1,L"%i,%i,%i,%i,%i",&g_WinInfo.x,&g_WinInfo.y,&g_WinInfo.cx,&g_WinInfo.cy,&g_WinInfo.max);
|
||||
if (itok == 4 || itok == 5) { // scan successful
|
||||
flagPosParam = 1;
|
||||
flagDefaultPos = 0;
|
||||
|
||||
if (wininfo.cx < 1) wininfo.cx = CW_USEDEFAULT;
|
||||
if (wininfo.cy < 1) wininfo.cy = CW_USEDEFAULT;
|
||||
if (wininfo.max) wininfo.max = 1;
|
||||
if (itok == 4) wininfo.max = 0;
|
||||
if (g_WinInfo.cx < 1) g_WinInfo.cx = CW_USEDEFAULT;
|
||||
if (g_WinInfo.cy < 1) g_WinInfo.cy = CW_USEDEFAULT;
|
||||
if (g_WinInfo.max) g_WinInfo.max = 1;
|
||||
if (itok == 4) g_WinInfo.max = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,6 +42,16 @@ typedef struct np3params {
|
||||
} np3params, *LPnp3params;
|
||||
|
||||
|
||||
typedef struct _wi
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int cx;
|
||||
int cy;
|
||||
int max;
|
||||
} WININFO;
|
||||
|
||||
|
||||
typedef struct _undoSel
|
||||
{
|
||||
int selMode_undo;
|
||||
|
||||
@ -322,6 +322,10 @@ BEGIN
|
||||
MENUITEM "Code &Folding\tCtrl+Shift+Alt+F", IDM_VIEW_FOLDING
|
||||
MENUITEM "&Toggle All Folds\tCtrl+Shift+F", IDM_VIEW_TOGGLEFOLDS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Sh&ow Toolbar", IDM_VIEW_TOOLBAR
|
||||
MENUITEM "C&ustomize Toolbar...", IDM_VIEW_CUSTOMIZETB
|
||||
MENUITEM "Sh&ow Statusbar", IDM_VIEW_STATUSBAR
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Zoom &In\tCtrl++", IDM_VIEW_ZOOMIN
|
||||
MENUITEM "Zoom &Out\tCtrl+-", IDM_VIEW_ZOOMOUT
|
||||
MENUITEM "Reset &Zoom\tCtrl+0", IDM_VIEW_RESETZOOM
|
||||
@ -363,10 +367,6 @@ BEGIN
|
||||
MENUITEM "Preserve Caret &Position", IDM_VIEW_NOPRESERVECARET
|
||||
MENUITEM "Remember S&earch Strings", IDM_VIEW_NOSAVEFINDREPL
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Sh&ow Toolbar", IDM_VIEW_TOOLBAR
|
||||
MENUITEM "C&ustomize Toolbar...", IDM_VIEW_CUSTOMIZETB
|
||||
MENUITEM "Sh&ow Statusbar", IDM_VIEW_STATUSBAR
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Save Settings On E&xit", IDM_VIEW_SAVESETTINGS
|
||||
MENUITEM "Save Settings &Now\tF7", IDM_VIEW_SAVESETTINGSNOW
|
||||
MENUITEM "&Open Settings File\tCtrl+F7", CMD_OPENINIFILE
|
||||
@ -375,7 +375,7 @@ BEGIN
|
||||
BEGIN
|
||||
MENUITEM "&Online Documentation\tF1", IDM_HELP_ONLINEDOCUMENTATION
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&About...", IDM_HELP_ABOUT
|
||||
MENUITEM "&About...\tShift+F1", IDM_HELP_ABOUT
|
||||
MENUITEM "&Command Line Help", IDM_HELP_CMD
|
||||
MENUITEM "Check for Updates", IDM_HELP_UPDATECHECK
|
||||
END
|
||||
@ -537,6 +537,7 @@ BEGIN
|
||||
VK_ESCAPE, CMD_ESCAPE, VIRTKEY, NOINVERT
|
||||
VK_ESCAPE, CMD_SHIFTESC, VIRTKEY, SHIFT, NOINVERT
|
||||
VK_F1, IDM_HELP_ONLINEDOCUMENTATION, VIRTKEY, NOINVERT
|
||||
VK_F1, IDM_HELP_ABOUT, VIRTKEY, SHIFT, NOINVERT
|
||||
VK_F11, CMD_LEXDEFAULT, VIRTKEY, NOINVERT
|
||||
VK_F11, CMD_LEXHTML, VIRTKEY, CONTROL, NOINVERT
|
||||
VK_F11, CMD_LEXXML, VIRTKEY, SHIFT, NOINVERT
|
||||
|
||||
27
src/Styles.c
27
src/Styles.c
@ -3277,6 +3277,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) {
|
||||
|
||||
int iBaseFontSize = INITIAL_BASE_FONT_SIZE; // init
|
||||
Style_StrGetSize(wchStandardStyleStrg, &iBaseFontSize);
|
||||
iBaseFontSize = max(0, iBaseFontSize);
|
||||
Style_SetBaseFontSize(hwnd, iBaseFontSize);
|
||||
Style_SetCurrentFontSize(hwnd, iBaseFontSize);
|
||||
|
||||
@ -3314,6 +3315,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) {
|
||||
// use this font size as current lexer's base
|
||||
iBaseFontSize = Style_GetBaseFontSize(hwnd);
|
||||
Style_StrGetSize(wchCurrentLexerStyleStrg, &iBaseFontSize);
|
||||
iBaseFontSize = max(0, iBaseFontSize);
|
||||
Style_SetCurrentFontSize(hwnd, iBaseFontSize);
|
||||
EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_CURRENTSCHEME, TRUE);
|
||||
}
|
||||
@ -3472,14 +3474,15 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) {
|
||||
|
||||
// whitespace dot size
|
||||
iValue = 1;
|
||||
if (Style_StrGetSize(pCurrentStandard->Styles[STY_WHITESPACE].szValue, &iValue)) {
|
||||
if (Style_StrGetSize(pCurrentStandard->Styles[STY_WHITESPACE].szValue, &iValue))
|
||||
{
|
||||
iValue = max(min(iValue, 5), 0);
|
||||
|
||||
WCHAR tch[32] = { L'\0' };
|
||||
WCHAR wchStyle[BUFSIZE_STYLE_VALUE];
|
||||
StringCchCopyN(wchStyle, COUNTOF(wchStyle), pCurrentStandard->Styles[STY_WHITESPACE].szValue,
|
||||
COUNTOF(pCurrentStandard->Styles[STY_WHITESPACE].szValue));
|
||||
|
||||
iValue = max(min(iValue, 5), 0);
|
||||
StringCchPrintf(pCurrentStandard->Styles[STY_WHITESPACE].szValue,
|
||||
COUNTOF(pCurrentStandard->Styles[STY_WHITESPACE].szValue), L"size:%i", iValue);
|
||||
|
||||
@ -3575,13 +3578,14 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) {
|
||||
// Extra Line Spacing
|
||||
iValue = 0;
|
||||
if (Style_StrGetSize(pCurrentStandard->Styles[STY_X_LN_SPACE].szValue,&iValue) && (pLexNew != &lexANSI)) {
|
||||
int iAscent = 0;
|
||||
int iDescent = 0;
|
||||
int iValAdj = min(max(iValue,0),64);
|
||||
const int iCurFontSizeDbl = 2 * Style_GetCurrentFontSize(hwnd);
|
||||
int iValAdj = min(max(iValue,(0 - iCurFontSizeDbl)), 256 * iCurFontSizeDbl);
|
||||
if (iValAdj != iValue)
|
||||
StringCchPrintf(pCurrentStandard->Styles[STY_X_LN_SPACE].szValue,
|
||||
COUNTOF(pCurrentStandard->Styles[STY_X_LN_SPACE].szValue), L"size:%i", iValAdj);
|
||||
|
||||
int iAscent = 0;
|
||||
int iDescent = 0;
|
||||
if ((iValAdj % 2) != 0) {
|
||||
iAscent++;
|
||||
iValAdj--;
|
||||
@ -4462,19 +4466,18 @@ BOOL Style_StrGetSize(LPCWSTR lpszStyle, int* i)
|
||||
tch[0] = L' ';
|
||||
}
|
||||
p = StrChr(tch, L';');
|
||||
if (p)
|
||||
*p = L'\0';
|
||||
if (p) { *p = L'\0'; }
|
||||
TrimString(tch);
|
||||
int iValue = 0;
|
||||
int itok = swscanf_s(tch,L"%i",&iValue);
|
||||
const int itok = swscanf_s(tch,L"%i",&iValue);
|
||||
if (itok == 1)
|
||||
{
|
||||
if (iSign == 0)
|
||||
*i = iValue;
|
||||
else {
|
||||
// relative size calculation
|
||||
int base = *i; // base is input
|
||||
*i = max(0, base + (iSign * iValue)); // size must be +
|
||||
const int base = *i; // base is input
|
||||
*i = (base + (iSign * iValue)); // can be negative
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -4906,7 +4909,7 @@ BOOL Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle, LPCWSTR sLexerNam
|
||||
// Font Height
|
||||
int iFontHeight = 0;
|
||||
int iFontSize = iBaseFontSize;
|
||||
if (Style_StrGetSize(lpszStyle,&iFontSize)) {
|
||||
if (Style_StrGetSize(lpszStyle,&iFontSize) > 0) {
|
||||
HDC hdc = GetDC(hwnd);
|
||||
iFontHeight = -MulDiv(iFontSize,GetDeviceCaps(hdc,LOGPIXELSY),72);
|
||||
ReleaseDC(hwnd,hdc);
|
||||
@ -5233,7 +5236,7 @@ void Style_SetStyles(HWND hwnd, int iStyle, LPCWSTR lpszStyle)
|
||||
// Size values are relative to iBaseFontSize
|
||||
int iValue = IsLexerStandard(g_pLexCurrent) ? Style_GetBaseFontSize(hwnd) : Style_GetCurrentFontSize(hwnd);
|
||||
|
||||
if (Style_StrGetSize(lpszStyle, &iValue)) {
|
||||
if (Style_StrGetSize(lpszStyle, &iValue) > 0) {
|
||||
SendMessage(hwnd, SCI_STYLESETSIZE, iStyle, (LPARAM)iValue);
|
||||
//or Fractional
|
||||
//SendMessage(hwnd, SCI_STYLESETSIZEFRACTIONAL, iStyle, (LPARAM)(iValue * SC_FONT_SIZE_MULTIPLIER));
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
#define VERSION_WEBPAGE2DISPLAY L"http://www.flos-freeware.ch"
|
||||
#define VERSION_SCIVERSION L"Scintilla Library Ver: " STRINGIFY(SCINTILLA_VER) L" (RegEx:Onigmo v." STRINGIFY(ONIGMO_REGEX_VER) L")"
|
||||
|
||||
#define VERSION_UPDATE_CHECK L"https://www.rizonesoft.com/notepad3/update.html?version=" VERSION_FILEVERSION
|
||||
#define VERSION_UPDATE_CHECK L"https://www.rizonesoft.com/downloads/notepad3/update/?version=" VERSION_FILEVERSION
|
||||
|
||||
#if defined(_WIN64)
|
||||
// #define VERSION_FILEVERSION_LONG L"Notepad3 (64-bit) " STRINGIFY(VERSION_MAJOR) L" Build " \
|
||||
|
||||
Loading…
Reference in New Issue
Block a user