Merge pull request #486 from RaiKoHoff/Bugfix_Release_II

Bugfixes Release II
This commit is contained in:
Derick Payne 2018-05-09 13:12:41 +02:00 committed by GitHub
commit 07d1a2f3dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 101 additions and 65 deletions

Binary file not shown.

View File

@ -2783,16 +2783,16 @@ void DialogFileBrowse(HWND hwnd)
//=============================================================================
//
// DialogUpdateCheck()
// DialogAdminExe()
//
//
extern WCHAR g_tchUpdateCheckerExe[];
extern WCHAR g_tchAdministrationExe[];
void DialogUpdateCheck(HWND hwnd, bool bExecInstaller)
void DialogAdminExe(HWND hwnd, bool bExecInstaller)
{
WCHAR tchExe[MAX_PATH+2];
StringCchCopyW(tchExe, COUNTOF(tchExe), g_tchUpdateCheckerExe);
StringCchCopyW(tchExe, COUNTOF(tchExe), g_tchAdministrationExe);
if (bExecInstaller && !StringCchLenW(tchExe, COUNTOF(tchExe))) { return; }
WCHAR tchExePath[MAX_PATH + 2];
@ -2818,7 +2818,7 @@ void DialogUpdateCheck(HWND hwnd, bool bExecInstaller)
ShellExecuteEx(&sei);
if ((INT_PTR)sei.hInstApp < 32)
{
if (IDOK == InfoBox(MBOKCANCEL, L"NoUpdateChecker", IDS_ERR_UPDATECHECKER))
if (IDOK == InfoBox(MBOKCANCEL, L"NoAdminTool", IDS_ERR_ADMINEXE))
{
sei.lpFile = VERSION_UPDATE_CHECK;
ShellExecuteEx(&sei);

View File

@ -42,7 +42,7 @@ WININFO GetMyWindowPlacement(HWND,MONITORINFO *);
void DialogNewWindow(HWND,bool,bool);
void DialogFileBrowse(HWND);
void DialogUpdateCheck(HWND,bool);
void DialogAdminExe(HWND,bool);
INT_PTR InfoBox(int,LPCWSTR,int,...);

View File

@ -3097,41 +3097,67 @@ void EditPadWithSpaces(HWND hwnd, bool bSkipEmpty, bool bNoUndoGroup)
int const token = (!bNoUndoGroup ? BeginUndoAction() : -1);
if (SciCall_IsSelectionRectangle())
if (SciCall_IsSelectionRectangle() && !SciCall_IsSelectionEmpty())
{
const DocPos selAnchorMainPos = SciCall_GetRectangularSelectionAnchor();
const DocPos selCaretMainPos = SciCall_GetRectangularSelectionCaret();
const DocPos vSpcAnchorMainPos = 0; // SciCall_GetRectangularSelectionAnchorVirtualSpace();
const DocPos vSpcCaretMainPos = 0; // SciCall_GetRectangularSelectionCaretVirtualSpace();
DocPos const selAnchorMainPos = SciCall_GetRectangularSelectionAnchor();
DocPos const selCaretMainPos = SciCall_GetRectangularSelectionCaret();
const DocLn iRcCurLine = SciCall_LineFromPosition(selCaretMainPos);
const DocLn iRcAnchorLine = SciCall_LineFromPosition(selAnchorMainPos);
DocPos const iAnchorColumn = SciCall_GetColumn(SciCall_GetSelectionNAnchor(0)) + SciCall_GetSelectionNAnchorVirtualSpace(0);
DocPos const iCaretColumn = SciCall_GetColumn(SciCall_GetSelectionNCaret(0)) + SciCall_GetSelectionNCaretVirtualSpace(0);
bool const bSelLeft2Right = (iAnchorColumn <= iCaretColumn);
DocLn iStartLine = 0;
DocLn iEndLine = 0;
if (iRcAnchorLine == iRcCurLine) {
iEndLine = SciCall_GetLineCount() - 1;
DocLn iRcAnchorLine = SciCall_LineFromPosition(selAnchorMainPos);
DocLn iRcCaretLine = SciCall_LineFromPosition(selCaretMainPos);
DocLn const iLineCount = abs(iRcCaretLine - iRcAnchorLine) + 1;
// lots of spaces
DocPos const spBufSize = max(iAnchorColumn, selCaretMainPos);
char* pSpaceBuffer = (char*)AllocMem((spBufSize + 1) * sizeof(char), HEAP_ZERO_MEMORY);
FillMemory(pSpaceBuffer, spBufSize * sizeof(char), ' ');
DocPos* pVspAVec = (int*)AllocMem(iLineCount * sizeof(DocPos), HEAP_ZERO_MEMORY);
DocPos* pVspCVec = (int*)AllocMem(iLineCount * sizeof(DocPos), HEAP_ZERO_MEMORY);
for (DocLn i = 0; i < iLineCount; ++i) {
pVspAVec[i] = SciCall_GetSelectionNAnchorVirtualSpace(i);
pVspCVec[i] = SciCall_GetSelectionNCaretVirtualSpace(i);
}
DocPosU i = 0;
DocPos iSpcCount = 0;
DocLn const iLnIncr = (iRcAnchorLine <= iRcCaretLine) ? (DocLn)+1 : (DocLn)-1;
DocLn iLine = iRcAnchorLine - iLnIncr;
do {
iLine += iLnIncr;
DocPos const iInsPos = SciCall_GetLineEndPosition(iLine);
DocPos const cntVSp = bSelLeft2Right ? pVspCVec[i++] : pVspAVec[i++];
bool const bSkip = (bSkipEmpty && (iInsPos <= SciCall_PositionFromLine(iLine)));
if ((cntVSp > 0) && !bSkip) {
pSpaceBuffer[cntVSp] = '\0';
SciCall_InsertText(iInsPos, pSpaceBuffer);
pSpaceBuffer[cntVSp] = ' ';
iSpcCount += cntVSp;
}
} while (iLine != iRcCaretLine);
FreeMem(pSpaceBuffer);
if (iRcAnchorLine <= iRcCaretLine) {
if (bSelLeft2Right)
EditSelectEx(hwnd, selAnchorMainPos + pVspAVec[0], selCaretMainPos + iSpcCount, 0, 0);
else
EditSelectEx(hwnd, selAnchorMainPos + pVspAVec[0], selCaretMainPos + pVspCVec[iLineCount - 1] + iSpcCount - pVspAVec[iLineCount - 1], 0, 0);
}
else {
iStartLine = (iRcCurLine < iRcAnchorLine) ? iRcCurLine : iRcAnchorLine;
iEndLine = (iRcCurLine < iRcAnchorLine) ? iRcAnchorLine : iRcCurLine;
if (bSelLeft2Right)
EditSelectEx(hwnd, selAnchorMainPos + pVspAVec[0] + iSpcCount - pVspCVec[0], selCaretMainPos + pVspCVec[iLineCount - 1], 0, 0);
else
EditSelectEx(hwnd, selAnchorMainPos + iSpcCount, selCaretMainPos + pVspCVec[iLineCount - 1], 0, 0);
}
DocPos iMaxColumn = 0;
for (DocLn iLine = iStartLine; iLine <= iEndLine; iLine++) {
const DocPos iPos = SciCall_GetLineSelEndPosition(iLine);
if (iPos != INVALID_POSITION) {
iMaxColumn = max(iMaxColumn, SciCall_GetColumn(iPos));
}
}
if (iMaxColumn <= 0) { return; }
const DocPos iSpcCount = _AppendSpaces(hwnd, iStartLine, iEndLine, iMaxColumn, bSkipEmpty);
if (iRcCurLine < iRcAnchorLine)
EditSelectEx(hwnd, selAnchorMainPos + iSpcCount, selCaretMainPos, vSpcAnchorMainPos, vSpcCaretMainPos);
else
EditSelectEx(hwnd, selAnchorMainPos, selCaretMainPos + iSpcCount, vSpcAnchorMainPos, vSpcCaretMainPos);
FreeMem(pVspCVec);
FreeMem(pVspAVec);
}
else // SC_SEL_LINES | SC_SEL_STREAM
{
@ -4910,6 +4936,8 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
{
static LPEDITFINDREPLACE sg_pefrData = NULL;
static DocPos s_InitialSearchStart = 0;
static DocPos s_InitialAnchortPos = 0;
static DocPos s_InitialCaretPos = 0;
static RegExResult_t regexMatch = INVALID;
static COLORREF rgbRed = RGB(255, 170, 170);
@ -5089,6 +5117,8 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
_SetSearchFlags(hwnd, sg_pefrData);
s_InitialSearchStart = SciCall_GetSelectionStart();
s_InitialAnchortPos = SciCall_GetAnchor();
s_InitialCaretPos = SciCall_GetCurrentPos();
_DelayMarkAll(hwnd, 50, s_InitialSearchStart);
}
return true;
@ -5115,6 +5145,7 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
}
MarkAllOccurrences(50, true);
EditSelectEx(g_hwndEdit, s_InitialAnchortPos, s_InitialCaretPos, -1, -1);
EditEnsureSelectionVisible(g_hwndEdit);
CmdMessageQueue_t* pmqc = NULL;
@ -5137,6 +5168,8 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
case WM_ACTIVATE:
{
s_InitialSearchStart = SciCall_GetSelectionStart();
s_InitialAnchortPos = SciCall_GetAnchor();
s_InitialCaretPos = SciCall_GetCurrentPos();
DialogEnableWindow(hwnd, IDC_REPLACEINSEL, !SciCall_IsSelectionEmpty());
@ -5158,6 +5191,8 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
case IDC_DOC_MODIFIED:
sg_pefrData->bStateChanged = true;
s_InitialSearchStart = SciCall_GetSelectionStart();
s_InitialAnchortPos = SciCall_GetAnchor();
s_InitialCaretPos = SciCall_GetCurrentPos();
break;
case IDC_FINDTEXT:
@ -5254,14 +5289,16 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
if (EditToggleView(g_hwndEdit, false)) { _DeleteLineStateAll(LINESTATE_OCCURRENCE_MARK); }
StringCchCopyA(g_lastFind, COUNTOF(g_lastFind), sg_pefrData->szFind);
RegExResult_t match = _FindHasMatch(g_hwndEdit, sg_pefrData, 0, (sg_pefrData->bMarkOccurences), false);
if (regexMatch != match) {
regexMatch = match;
}
if (regexMatch != match) { regexMatch = match; }
// we have to set Sci's regex instance to first find (have substitution in place)
DocPos const iStartPos = (DocPos)lParam;
_FindHasMatch(g_hwndEdit, sg_pefrData, iStartPos, false, true);
sg_pefrData->bStateChanged = false;
InvalidateRect(GetDlgItem(hwnd, IDC_FINDTEXT), NULL, true);
if (match != MATCH) {
EditClearAllOccurrenceMarkers(g_hwndEdit);
EditSelectEx(g_hwndEdit, s_InitialAnchortPos, s_InitialCaretPos, -1, -1);
}
if (EditToggleView(g_hwndEdit, false)) { EditHideNotMarkedLineRange(g_hwndEdit, -1, -1, true); }
_OBSERVE_NOTIFY_CHANGE_;
}
@ -5477,6 +5514,8 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
if (!SciCall_IsSelectionEmpty()) { EditJumpToSelectionEnd(hwnd); }
EditFindNext(sg_pefrData->hwnd, sg_pefrData, (LOWORD(wParam) == IDACC_SELTONEXT), HIBYTE(GetKeyState(VK_F3)));
s_InitialSearchStart = SciCall_GetSelectionStart();
s_InitialAnchortPos = SciCall_GetAnchor();
s_InitialCaretPos = SciCall_GetCurrentPos();
break;
case IDC_FINDPREV: // find previous
@ -5485,6 +5524,8 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA
if (!SciCall_IsSelectionEmpty()) { EditJumpToSelectionStart(hwnd); }
EditFindPrev(sg_pefrData->hwnd, sg_pefrData, (LOWORD(wParam) == IDACC_SELTOPREV), HIBYTE(GetKeyState(VK_F3)));
s_InitialSearchStart = SciCall_GetSelectionStart();
s_InitialAnchortPos = SciCall_GetAnchor();
s_InitialCaretPos = SciCall_GetCurrentPos();
break;
case IDC_REPLACE:

View File

@ -135,7 +135,7 @@ WCHAR g_tchFileDlgFilters[XXXL_BUFFER] = { L'\0' };
WCHAR g_tchLastSaveCopyDir[MAX_PATH] = { L'\0' };
WCHAR g_tchOpenWithDir[MAX_PATH] = { L'\0' };
WCHAR g_tchFavoritesDir[MAX_PATH] = { L'\0' };
WCHAR g_tchUpdateCheckerExe[MAX_PATH] = { L'\0' };
WCHAR g_tchAdministrationExe[MAX_PATH] = { L'\0' };
static WCHAR g_tchDefaultExtension[64] = { L'\0' };
static WCHAR g_tchDefaultDir[MAX_PATH] = { L'\0' };
@ -2753,8 +2753,8 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam)
}
EnableCmd(hmenu, CMD_OPEN_HYPERLINK, bIsHLink);
i = StringCchLenW(g_tchUpdateCheckerExe, COUNTOF(g_tchUpdateCheckerExe));
EnableCmd(hmenu, IDM_HELP_UPDATEINSTALLER, i);
i = StringCchLenW(g_tchAdministrationExe, COUNTOF(g_tchAdministrationExe));
EnableCmd(hmenu, IDM_HELP_ADMINEXE, i);
UNUSED(lParam);
}
@ -5153,12 +5153,12 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
break;
case IDM_HELP_UPDATEINSTALLER:
DialogUpdateCheck(hwnd, true);
case IDM_HELP_ADMINEXE:
DialogAdminExe(hwnd, true);
break;
case IDM_HELP_UPDATEWEBSITE:
DialogUpdateCheck(hwnd, false);
DialogAdminExe(hwnd, false);
break;
case CMD_WEBACTION1:
@ -6495,7 +6495,7 @@ void LoadSettings()
iCurrentLineVerticalSlop = IniSectionGetInt(pIniSection, L"CurrentLineVerticalSlop", 5);
iCurrentLineVerticalSlop = max(min(iCurrentLineVerticalSlop, 200), 0);
IniSectionGetString(pIniSection, L"UpdateChecker.exe", L"", g_tchUpdateCheckerExe, COUNTOF(g_tchUpdateCheckerExe));
IniSectionGetString(pIniSection, L"AdministrationTool.exe", L"", g_tchAdministrationExe, COUNTOF(g_tchAdministrationExe));
// --------------------------------------------------------------------------
LoadIniSection(L"Statusbar Settings", pIniSection, cchIniSection);
@ -7950,7 +7950,7 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw)
// ------------------------------------------------------
static bool s_bUse2ndDefault = -1;
bool const bUse2ndDefault = Style_GetUse2ndDefault();
bool bUse2ndDefault = Style_GetUse2ndDefault();
if (s_bUse2ndDefault != bUse2ndDefault) {
if (bUse2ndDefault)
{

View File

@ -394,7 +394,7 @@ BEGIN
BEGIN
MENUITEM "&Online Documentation\tF1", IDM_HELP_ONLINEDOCUMENTATION
MENUITEM SEPARATOR
MENUITEM "Launch &Update Installer...", IDM_HELP_UPDATEINSTALLER
MENUITEM "Launch Administration &Tool...", IDM_HELP_ADMINEXE
MENUITEM "Check &Website for Update", IDM_HELP_UPDATEWEBSITE
MENUITEM SEPARATOR
MENUITEM "&Command Line Help...", IDM_HELP_CMD
@ -1574,7 +1574,7 @@ BEGIN
IDS_REGEX_INVALID "Error evaluating regular expression. Expression is invalid!"
IDS_DROP_NO_FILE "No valid filename retrieved.\nIf dropping from 32-bit application,\nplease drag and drop to Notepad3's tool bar."
IDS_APPLY_DEFAULT_FONT "Apply these font settings to current ('%s') scheme's default text also?"
IDS_ERR_UPDATECHECKER "No update installer executable found.\nCheck for update on website https://rizonesoft.com ?"
IDS_ERR_ADMINEXE "No administration executable found.\nCheck website https://rizonesoft.com ?"
END
STRINGTABLE

View File

@ -3135,7 +3135,7 @@ void Style_Load()
LoadIniSection(L"Styles",pIniSection,cchIniSection);
// 2nd default
Style_SetUse2ndDefault(IniSectionGetBool(pIniSection, L"Use2ndDefaultStyle", 0));
Style_SetUse2ndDefault(IniSectionGetBool(pIniSection, L"Use2ndDefaultStyle", false));
// default scheme
g_iDefaultLexer = IniSectionGetInt(pIniSection,L"DefaultScheme",0);
@ -3348,13 +3348,14 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew)
if (!pLexNew) {
pLexNew = GetDefaultLexer();
}
if (IsLexerStandard(pLexNew)) {
pLexNew = Style_GetUse2ndDefault() ? &lexStandard2nd : &lexStandard;
}
const WCHAR* const wchNewLexerStyleStrg = pLexNew->Styles[STY_DEFAULT].szValue;
// first set standard lexer's default values
g_pLexCurrent = GetCurrentStdLexer();
if (IsLexerStandard(pLexNew))
g_pLexCurrent = pLexNew;
else
g_pLexCurrent = GetCurrentStdLexer();
const WCHAR* const wchStandardStyleStrg = g_pLexCurrent->Styles[STY_DEFAULT].szValue;
// Lexer
@ -4463,7 +4464,7 @@ void Style_SetLexerFromID(HWND hwnd,int id)
//
void Style_ToggleUse2ndDefault(HWND hwnd)
{
bool use2ndDefStyle = Style_GetUse2ndDefault();
bool const use2ndDefStyle = Style_GetUse2ndDefault();
Style_SetUse2ndDefault(use2ndDefStyle ? false : true); // swap
Style_SetLexer(hwnd,g_pLexCurrent);
}
@ -4477,8 +4478,8 @@ void Style_SetDefaultFont(HWND hwnd, bool bGlobalDefault)
{
WCHAR newStyle[BUFSIZE_STYLE_VALUE] = { L'\0' };
const PEDITLEXER pLexer = bGlobalDefault ? GetCurrentStdLexer() : g_pLexCurrent;
const PEDITSTYLE pLexerDefStyle = &(pLexer->Styles[STY_DEFAULT]);
PEDITLEXER const pLexer = bGlobalDefault ? GetCurrentStdLexer() : g_pLexCurrent;
PEDITSTYLE const pLexerDefStyle = &(pLexer->Styles[STY_DEFAULT]);
StringCchCopyW(newStyle, COUNTOF(newStyle), pLexer->Styles[STY_DEFAULT].szValue);
@ -5661,13 +5662,8 @@ int Style_GetCurrentLexerRID()
//
void Style_GetCurrentLexerName(LPWSTR lpszName, int cchName)
{
if (IsLexerStandard(g_pLexCurrent)) {
StringCchPrintfW(lpszName, cchName, L" %s", GetCurrentStdLexer()->pszName);
}
else {
if (!GetString(g_pLexCurrent->resID, lpszName, cchName)) {
StringCchCopyW(lpszName, cchName, g_pLexCurrent->pszName);
}
if (!GetString(g_pLexCurrent->resID, lpszName, cchName)) {
StringCchCopyW(lpszName, cchName, g_pLexCurrent->pszName);
}
}
@ -6644,7 +6640,6 @@ void Style_SelectLexerDlg(HWND hwnd)
MAKEINTRESOURCE(IDD_STYLESELECT),
GetParent(hwnd), Style_SelectLexerDlgProc, 0))
Style_SetUse2ndDefault(g_pLexCurrent == &lexStandard2nd);
Style_SetLexer(hwnd, g_pLexCurrent);
}

Binary file not shown.

View File

@ -167,7 +167,7 @@
#define IDC_EDIT3 412
#define IDS_PASS_FAILURE 413
#define IDS_NOPASS 414
#define IDM_HELP_UPDATEINSTALLER 415
#define IDM_HELP_ADMINEXE 415
#define IDM_HELP_UPDATEWEBSITE 416
#define IDS_FR_STATUS_TEXT 417
#define IDC_CHECK4 418
@ -519,7 +519,7 @@
#define IDS_REGEX_INVALID 50043
#define IDS_DROP_NO_FILE 50044
#define IDS_APPLY_DEFAULT_FONT 50045
#define IDS_ERR_UPDATECHECKER 50046
#define IDS_ERR_ADMINEXE 50046
#define IDS_CMDLINEHELP 60000
#define IDM_EDIT_INSERT_GUID 60001
#define IDC_STATIC -1