Merge branch 'Bugfixes_RC_VI' into DocTailChasing

This commit is contained in:
Rainer Kottenhoff 2018-04-27 01:50:12 +02:00
commit 194c5df055
6 changed files with 122 additions and 58 deletions

View File

@ -206,8 +206,8 @@ static CmdMessageQueue_t* MessageQueue = NULL;
static int msgcmp(void* mqc1, void* mqc2)
{
const CmdMessageQueue_t* pMQC1 = (CmdMessageQueue_t*)mqc1;
const CmdMessageQueue_t* pMQC2 = (CmdMessageQueue_t*)mqc2;
CmdMessageQueue_t* const pMQC1 = (CmdMessageQueue_t*)mqc1;
CmdMessageQueue_t* const pMQC2 = (CmdMessageQueue_t*)mqc2;
if ((pMQC1->hwnd == pMQC2->hwnd)
&& (pMQC1->cmd == pMQC2->cmd)
@ -219,7 +219,8 @@ static int msgcmp(void* mqc1, void* mqc2)
}
// ----------------------------------------------------------------------------
static void __fastcall _MQ_AppendCmd(CmdMessageQueue_t* pMsgQCmd, int delay)
static void __fastcall _MQ_AppendCmd(CmdMessageQueue_t* const pMsgQCmd, int delay)
{
CmdMessageQueue_t* pmqc = NULL;
DL_SEARCH(MessageQueue, pmqc, pMsgQCmd, msgcmp);
@ -230,18 +231,37 @@ static void __fastcall _MQ_AppendCmd(CmdMessageQueue_t* pMsgQCmd, int delay)
pmqc->cmd = pMsgQCmd->cmd;
pmqc->wparam = pMsgQCmd->wparam;
pmqc->lparam = pMsgQCmd->lparam;
pmqc->delay = 0;
pmqc->delay = delay;
DL_APPEND(MessageQueue, pmqc);
}
if (delay < 2) {
pmqc->delay = 0; // execute next
PostMessage(pMsgQCmd->hwnd, pMsgQCmd->cmd, pMsgQCmd->wparam, pMsgQCmd->lparam);
pmqc->delay = -1; // execute now (do not use PostMessage() here)
SendMessage(pMsgQCmd->hwnd, pMsgQCmd->cmd, pMsgQCmd->wparam, pMsgQCmd->lparam);
}
else {
pmqc->delay = (pmqc->delay + delay) / 2; // increase delay
}
}
// ----------------------------------------------------------------------------
static void __fastcall _MQ_RemoveCmd(CmdMessageQueue_t* const pMsgQCmd)
{
CmdMessageQueue_t* pmqc = NULL;
DL_FOREACH(MessageQueue, pmqc)
{
if ((pMsgQCmd->hwnd == pmqc->hwnd)
&& (pMsgQCmd->cmd == pmqc->cmd)
&& (pMsgQCmd->wparam == pmqc->wparam))
{
pmqc->delay = -1;
}
}
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
//
@ -5956,14 +5976,7 @@ void EditMarkAllOccurrences()
}
if (EditIsInTargetTransaction()) { return; } // do not block, next event occurs for sure
bool bWaitCursor = false;
if (g_iMarkOccurrencesCount > 2000) {
BeginWaitCursor(NULL);
bWaitCursor = true;
}
else {
IgnoreNotifyChangeEvent();
}
IgnoreNotifyChangeEvent();
EditEnterTargetTransaction();
if (g_bMarkOccurrencesMatchVisible) {
@ -5983,14 +5996,9 @@ void EditMarkAllOccurrences()
else {
EditMarkAll(g_hwndEdit, NULL, bMarkOccurrencesCurrentWord, 0, SciCall_GetTextLength(), bMarkOccurrencesMatchCase, bMarkOccurrencesMatchWords);
}
EditLeaveTargetTransaction();
if (bWaitCursor) {
EndWaitCursor();
}
else {
ObserveNotifyChangeEvent();
}
ObserveNotifyChangeEvent();
}
@ -6004,7 +6012,7 @@ void EditUpdateVisibleUrlHotspot(bool bEnabled)
{
if (EditIsInTargetTransaction()) { return; } // do not block, next event occurs for sure
BeginWaitCursor(NULL);
IgnoreNotifyChangeEvent();
EditEnterTargetTransaction();
// get visible lines for update
@ -6019,7 +6027,7 @@ void EditUpdateVisibleUrlHotspot(bool bEnabled)
EditUpdateUrlHotspots(g_hwndEdit, iPosStart, iPosEnd, bEnabled);
EditLeaveTargetTransaction();
EndWaitCursor();
ObserveNotifyChangeEvent();
}
}
@ -6251,20 +6259,14 @@ bool EditReplaceAllInSelection(HWND hwnd, LPCEDITFINDREPLACE lpefr, bool bShowIn
const DocPos currPos = SciCall_GetCurrentPos();
const DocPos anchorPos = SciCall_GetAnchor();
DocPos enlargement = 0;
bool bWaitCursor = false;
if ((end - start) > (512 * 512)) {
BeginWaitCursor(NULL);
bWaitCursor = true;
}
IgnoreNotifyChangeEvent();
int token = BeginUndoAction();
iReplacedOccurrences = EditReplaceAllInRange(hwnd, lpefr, start, end, &enlargement);
if (bWaitCursor) {
EndWaitCursor();
}
ObserveNotifyChangeEvent();
if (iReplacedOccurrences <= 0) {
EndUndoAction(token);
@ -6349,7 +6351,7 @@ bool EditToggleView(HWND hwnd, bool bToggleView)
if (bToggleView) {
BeginWaitCursor(NULL);
IgnoreNotifyChangeEvent();
if (!bHideNonMatchedLines) {
bSaveFoldingAvailable = g_bCodeFoldingAvailable;
@ -6377,7 +6379,7 @@ bool EditToggleView(HWND hwnd, bool bToggleView)
SciCall_SetReadOnly(false);
}
EndWaitCursor();
ObserveNotifyChangeEvent();
}
return bHideNonMatchedLines;
}

View File

@ -103,11 +103,6 @@ __forceinline bool IniSectionSetPos(LPWSTR lpCachedIniSection, LPCWSTR lpName, D
WCHAR tch[64] = { L'\0' }; StringCchPrintf(tch, COUNTOF(tch), L"%td", (long long)pos); return IniSectionSetString(lpCachedIniSection, lpName, tch);
}
//extern HWND g_hwndEdit;
#define BeginWaitCursor(TCH) { SciCall_SetCursor(SC_CURSORWAIT); StatusSetText(g_hwndStatus,STATUS_HELP,(TCH)); IgnoreNotifyChangeEvent(); }
#define BeginWaitCursorID(UID) { SciCall_SetCursor(SC_CURSORWAIT); StatusSetTextID(g_hwndStatus,STATUS_HELP,(UID)); IgnoreNotifyChangeEvent(); }
#define EndWaitCursor() { POINT pt; SciCall_SetCursor(SC_CURSORNORMAL); GetCursorPos(&pt); SetCursorPos(pt.x,pt.y); StatusSetSimple(g_hwndStatus,false); ObserveNotifyChangeEvent(); UpdateStatusbar(); }
//#define Is2k() (g_uWinVer >= 0x0500)
#define IsXP() IsWindowsXPOrGreater() // Indicates if the current OS version matches,or is greater than,the Windows XP version.

View File

@ -375,12 +375,14 @@ static volatile LONG iNotifyChangeStackCounter = 0;
void IgnoreNotifyChangeEvent() {
InterlockedIncrement(&iNotifyChangeStackCounter);
BeginWaitCursor(NULL);
}
void ObserveNotifyChangeEvent() {
if (iNotifyChangeStackCounter > 0L) {
InterlockedDecrement(&iNotifyChangeStackCounter);
if (iNotifyChangeStackCounter == 0L) {
EndWaitCursor();
UpdateToolbar();
UpdateStatusbar();
UpdateLineNumberWidth();
@ -407,8 +409,8 @@ static CmdMessageQueue_t* MessageQueue = NULL;
static int msgcmp(void* mqc1, void* mqc2)
{
const CmdMessageQueue_t* pMQC1 = (CmdMessageQueue_t*)mqc1;
const CmdMessageQueue_t* pMQC2 = (CmdMessageQueue_t*)mqc2;
CmdMessageQueue_t* const pMQC1 = (CmdMessageQueue_t*)mqc1;
CmdMessageQueue_t* const pMQC2 = (CmdMessageQueue_t*)mqc2;
if ((pMQC1->hwnd == pMQC2->hwnd)
&& (pMQC1->cmd == pMQC2->cmd)
@ -421,7 +423,8 @@ static int msgcmp(void* mqc1, void* mqc2)
}
// ----------------------------------------------------------------------------
static void __fastcall _MQ_AppendCmd(CmdMessageQueue_t* pMsgQCmd, int delay)
static void __fastcall _MQ_AppendCmd(CmdMessageQueue_t* const pMsgQCmd, int delay)
{
CmdMessageQueue_t* pmqc = NULL;
DL_SEARCH(MessageQueue, pmqc, pMsgQCmd, msgcmp);
@ -432,18 +435,36 @@ static void __fastcall _MQ_AppendCmd(CmdMessageQueue_t* pMsgQCmd, int delay)
pmqc->cmd = pMsgQCmd->cmd;
pmqc->wparam = pMsgQCmd->wparam;
pmqc->lparam = pMsgQCmd->lparam;
pmqc->delay = 0;
pmqc->delay = delay;
DL_APPEND(MessageQueue, pmqc);
}
if (delay < 2) {
pmqc->delay = 0; // execute next
PostMessage(pMsgQCmd->hwnd, pMsgQCmd->cmd, pMsgQCmd->wparam, pMsgQCmd->lparam);
pmqc->delay = -1; // execute now (do not use PostMessage() here)
SendMessage(pMsgQCmd->hwnd, pMsgQCmd->cmd, pMsgQCmd->wparam, pMsgQCmd->lparam);
}
else {
pmqc->delay = (pmqc->delay + delay) / 2; // increase delay
}
}
// ----------------------------------------------------------------------------
static void __fastcall _MQ_RemoveCmd(CmdMessageQueue_t* const pMsgQCmd)
{
CmdMessageQueue_t* pmqc;
DL_FOREACH(MessageQueue, pmqc)
{
if ((pMsgQCmd->hwnd == pmqc->hwnd)
&& (pMsgQCmd->cmd == pmqc->cmd)
&& (pMsgQCmd->wparam == pmqc->wparam))
{
pmqc->delay = -1;
}
}
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
//
@ -737,6 +758,41 @@ bool InitApplication(HINSTANCE hInstance)
}
//=============================================================================
//
// BeginWaitCursor()
//
//
void BeginWaitCursor(LPCWSTR text)
{
static CmdMessageQueue_t mqc = { NULL, WM_COMMAND, (WPARAM)MAKELONG(CMD_WAITCURSOR, 1), (LPARAM)0, 0 };
mqc.hwnd = g_hwndMain;
mqc.lparam = (LPARAM)text;
_MQ_AppendCmd(&mqc, 500U);
}
//=============================================================================
//
// EndWaitCursor()
//
//
void EndWaitCursor()
{
static CmdMessageQueue_t mqc = { NULL, WM_COMMAND, (WPARAM)MAKELONG(CMD_WAITCURSOR, 1), (LPARAM)0, 0 };
mqc.hwnd = g_hwndMain;
_MQ_RemoveCmd(&mqc);
POINT pt;
GetCursorPos(&pt); SetCursorPos(pt.x, pt.y);
StatusSetSimple(g_hwndStatus, false);
SciCall_SetCursor(SC_CURSORNORMAL);
}
static prefix_t g_mxStatusBarPrefix[STATUS_SECTOR_COUNT];
static int g_vStatusbarSectionWidth[STATUS_SECTOR_COUNT];
static int g_aSBSOrder[STATUS_SECTOR_COUNT];
@ -2721,14 +2777,21 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
switch(LOWORD(wParam))
{
case IDT_TIMER_MAIN_MRKALL:
EditMarkAllOccurrences();
break;
case IDT_TIMER_MAIN_MRKALL:
EditMarkAllOccurrences();
break;
case IDT_TIMER_UPDATE_HOTSPOT:
EditUpdateVisibleUrlHotspot(g_bHyperlinkHotspot);
break;
case IDT_TIMER_UPDATE_HOTSPOT:
EditUpdateVisibleUrlHotspot(g_bHyperlinkHotspot);
break;
case CMD_WAITCURSOR:
SciCall_SetCursor(SC_CURSORWAIT);
StatusSetText(g_hwndStatus, STATUS_HELP, (LPCWSTR)lParam);
//StatusSetTextID(g_hwndStatus, STATUS_HELP, uid);
break;
case IDM_FILE_NEW:
@ -2995,7 +3058,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
}
}
BeginWaitCursor(NULL);
IgnoreNotifyChangeEvent();
if (EditSetNewEncoding(g_hwndEdit,
iNewEncoding,
(flagSetEncoding),
@ -3010,9 +3073,8 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
Encoding_HasChanged(CPI_NONE);
Encoding_Current(iNewEncoding);
}
UpdateToolbar();
}
EndWaitCursor();
ObserveNotifyChangeEvent();
}
break;
@ -3049,15 +3111,13 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
case IDM_LINEENDINGS_LF:
case IDM_LINEENDINGS_CR:
{
BeginWaitCursor(NULL)
IgnoreNotifyChangeEvent();
int iNewEOLMode = iLineEndings[LOWORD(wParam)-IDM_LINEENDINGS_CRLF];
g_iEOLMode = iNewEOLMode;
SendMessage(g_hwndEdit,SCI_SETEOLMODE,g_iEOLMode,0);
SendMessage(g_hwndEdit,SCI_CONVERTEOLS,g_iEOLMode,0);
EditFixPositions(g_hwndEdit);
EndWaitCursor()
UpdateToolbar();
UpdateStatusbar();
ObserveNotifyChangeEvent();
}
break;
@ -4761,7 +4821,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
if (WritePrivateProfileString(L"Settings",L"WriteTest",L"ok",g_wchIniFile)) {
BeginWaitCursorID(IDS_SAVINGSETTINGS);
BeginWaitCursor(L"Saving settings..."); // IDS_SAVINGSETTINGS
SaveSettings(true);
EndWaitCursor();
MsgBox(MBINFO,IDS_SAVEDSETTINGS);
@ -7323,6 +7383,10 @@ int CreateIniFileEx(LPCWSTR lpszIniFile) {
}
//=============================================================================
//
// MarkAllOccurrences()

View File

@ -113,6 +113,8 @@ typedef enum {
//==== Function Declarations ==================================================
bool InitApplication(HINSTANCE);
HWND InitInstance(HINSTANCE,LPSTR,int);
void BeginWaitCursor(LPCWSTR text);
void EndWaitCursor();
bool ActivatePrevInst();
bool RelaunchMultiInst();
bool RelaunchElevated(LPWSTR);

Binary file not shown.

View File

@ -249,6 +249,7 @@
#define CMD_ALTRIGHT 20045
#define CMD_TAB 20046
#define CMD_BACKTAB 20047
#define CMD_WAITCURSOR 20048
#define IDM_FILE_NEW 40000
#define IDM_FILE_OPEN 40001
#define IDM_FILE_REVERT 40002