Skip to content

Commit

Permalink
wait cursor (hourglass) fix
Browse files Browse the repository at this point in the history
  • Loading branch information
katahiromz committed Sep 11, 2023
1 parent f82a46f commit ef600ad
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 16 deletions.
54 changes: 52 additions & 2 deletions dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,33 @@ void UpdateWindowCaption(BOOL clearModifyAlert)
SetWindowText(Globals.hMainWnd, szCaption);
}

VOID WaitCursor(BOOL bBegin)
{
static HCURSOR s_hWaitCursor = NULL;
static HCURSOR s_hOldCursor = NULL;
static INT s_nLock = 0;

if (bBegin)
{
if (s_nLock++ == 0)
{
if (s_hWaitCursor == NULL)
s_hWaitCursor = LoadCursor(NULL, IDC_WAIT);
s_hOldCursor = SetCursor(s_hWaitCursor);
}
else
{
SetCursor(s_hWaitCursor);
}
}
else
{
if (--s_nLock == 0)
SetCursor(s_hOldCursor);
}
}


VOID DIALOG_StatusBarAlignParts(VOID)
{
static const int defaultWidths[] = {120, 120, 120};
Expand Down Expand Up @@ -220,11 +247,14 @@ static BOOL DoSaveFile(VOID)
HANDLE hFile;
DWORD cchText;

WaitCursor(TRUE);

hFile = CreateFileW(Globals.szFileName, GENERIC_WRITE, FILE_SHARE_WRITE,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
ShowLastError();
WaitCursor(FALSE);
return FALSE;
}

Expand Down Expand Up @@ -259,6 +289,7 @@ static BOOL DoSaveFile(VOID)
SetFileName(Globals.szFileName);
}

WaitCursor(FALSE);
return bRet;
}

Expand Down Expand Up @@ -307,6 +338,8 @@ VOID DoOpenFile(LPCTSTR szFileName)
if (!DoCloseFile())
return;

WaitCursor(TRUE);

hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
Expand Down Expand Up @@ -347,6 +380,7 @@ VOID DoOpenFile(LPCTSTR szFileName)
done:
if (hFile != INVALID_HANDLE_VALUE)
CloseHandle(hFile);
WaitCursor(FALSE);
}

VOID DIALOG_FileNew(VOID)
Expand All @@ -355,20 +389,29 @@ VOID DIALOG_FileNew(VOID)
if (!DoCloseFile())
return;

WaitCursor(TRUE);

SetWindowText(Globals.hEdit, NULL);
SendMessage(Globals.hEdit, EM_EMPTYUNDOBUFFER, 0, 0);
Globals.iEoln = EOLN_CRLF;
Globals.encFile = ENCODING_DEFAULT;

NOTEPAD_EnableSearchMenu();
DIALOG_StatusBarUpdateAll();

WaitCursor(FALSE);
}

VOID DIALOG_FileNewWindow(VOID)
{
TCHAR pszNotepadExe[MAX_PATH];

WaitCursor(TRUE);

GetModuleFileName(NULL, pszNotepadExe, _countof(pszNotepadExe));
ShellExecute(NULL, NULL, pszNotepadExe, NULL, NULL, SW_SHOWNORMAL);

WaitCursor(FALSE);
}

VOID DIALOG_FileOpen(VOID)
Expand Down Expand Up @@ -865,20 +908,27 @@ VOID DIALOG_GoTo(VOID)
else
ich = (INT)SendMessage(Globals.hEdit, EM_LINEINDEX, GotoData.iLine, 0);

/* EM_LINEINDEX can return -1 on failure */
if (ich < 0)
ich = 0;

/* Move the caret */
SendMessage(Globals.hEdit, EM_SETSEL, ich, ich);
SendMessage(Globals.hEdit, EM_SCROLLCARET, 0, 0);
}

VOID DIALOG_StatusBarUpdateCaretPos(VOID)
{
int line, col;
int line, ich, col;
TCHAR buff[MAX_PATH];
DWORD dwStart, dwSize;

SendMessage(Globals.hEdit, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwSize);
line = SendMessage(Globals.hEdit, EM_LINEFROMCHAR, (WPARAM)dwStart, 0);
col = dwStart - SendMessage(Globals.hEdit, EM_LINEINDEX, (WPARAM)line, 0);
ich = (int)SendMessage(Globals.hEdit, EM_LINEINDEX, (WPARAM)line, 0);

/* EM_LINEINDEX can return -1 on failure */
col = ((ich < 0) ? 0 : (dwStart - ich));

StringCchPrintf(buff, _countof(buff), Globals.szStatusBarLineCol, line + 1, col + 1);
SendMessage(Globals.hStatusBar, SB_SETTEXT, SBPART_CURPOS, (LPARAM)buff);
Expand Down
1 change: 1 addition & 0 deletions dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ VOID DoOpenFile(LPCTSTR szFileName);
VOID DoShowHideStatusBar(VOID);
VOID DoCreateEditWindow(VOID);
void UpdateWindowCaption(BOOL clearModifyAlert);
VOID WaitCursor(BOOL bBegin);
10 changes: 5 additions & 5 deletions lang/hi-IN.rc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* PROJECT: Notepad Hindi Translation
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Hindi Translation Of Notepad
* COPYRIGHT: Copyright 2018 Arnav Bhatt (arnavbhatt2004@gmail.com)
* PROJECT: ReactOS Notepad
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
* PURPOSE: Hindi (India) resource file
* TRANSLATOR: Copyright 2018 Arnav Bhatt <arnavbhatt2004@gmail.com>
*/

LANGUAGE LANG_HINDI, SUBLANG_HINDI_INDIA
Expand Down Expand Up @@ -159,7 +159,7 @@ BEGIN
STRING_UNTITLED "शीर्षकहीन"
STRING_ALL_FILES "सभी फाइलें (*.*)"
STRING_TEXT_FILES_TXT "पाठ फाइलें (*.txt)"
STRING_TOOLARGE "नोटपैड के लिए फ़ाइल '% s' बहुत बड़ी है।\n\
STRING_TOOLARGE "नोटपैड के लिए फ़ाइल '%s' बहुत बड़ी है।\n\
कृपया एक अलग इडिटर का प्रयोग करें।"
STRING_NOTEXT "आपने कोई टेक्स्ट दर्ज नहीं किया है।\
\nकृपया कुछ टाइप करें और पुनः प्रयास करें"
Expand Down
11 changes: 8 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ static VOID NOTEPAD_InitData(HINSTANCE hInstance)
*/
static VOID NOTEPAD_InitMenuPopup(HMENU menu, LPARAM index)
{
DWORD dwStart, dwEnd;
int enable;

UNREFERENCED_PARAMETER(index);
Expand All @@ -280,8 +281,8 @@ static VOID NOTEPAD_InitMenuPopup(HMENU menu, LPARAM index)
SendMessage(Globals.hEdit, EM_CANUNDO, 0, 0) ? MF_ENABLED : MF_GRAYED);
EnableMenuItem(menu, CMD_PASTE,
IsClipboardFormatAvailable(CF_TEXT) ? MF_ENABLED : MF_GRAYED);
enable = (int) SendMessage(Globals.hEdit, EM_GETSEL, 0, 0);
enable = (HIWORD(enable) == LOWORD(enable)) ? MF_GRAYED : MF_ENABLED;
SendMessage(Globals.hEdit, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd);
enable = ((dwStart == dwEnd) ? MF_GRAYED : MF_ENABLED);
EnableMenuItem(menu, CMD_CUT, enable);
EnableMenuItem(menu, CMD_COPY, enable);
EnableMenuItem(menu, CMD_DELETE, enable);
Expand Down Expand Up @@ -432,6 +433,8 @@ NOTEPAD_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
FINDREPLACE *pFindReplace = (FINDREPLACE *) lParam;
Globals.find = *(FINDREPLACE *) lParam;

WaitCursor(TRUE);

if (pFindReplace->Flags & FR_FINDNEXT)
NOTEPAD_FindNext(pFindReplace, FALSE, TRUE);
else if (pFindReplace->Flags & FR_REPLACE)
Expand All @@ -440,6 +443,8 @@ NOTEPAD_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
NOTEPAD_ReplaceAll(pFindReplace);
else if (pFindReplace->Flags & FR_DIALOGTERM)
NOTEPAD_FindTerm();

WaitCursor(FALSE);
break;
}

Expand Down Expand Up @@ -586,7 +591,7 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE prev, LPTSTR cmdline, int sh
wndclass.lpfnWndProc = NOTEPAD_WndProc;
wndclass.hInstance = Globals.hInstance;
wndclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_NPICON));
wndclass.hCursor = LoadCursor(0, IDC_ARROW);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wndclass.lpszMenuName = MAKEINTRESOURCE(MAIN_MENU);
wndclass.lpszClassName = className;
Expand Down
12 changes: 6 additions & 6 deletions reactos/buildno.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
#ifndef _INC_REACTOS_BUILDNO
#define _INC_REACTOS_BUILDNO

#define KERNEL_VERSION_BUILD 20230905
#define KERNEL_VERSION_BUILD_STR "20230905-0.4.15-dev-6584-g2508cdf"
#define KERNEL_VERSION_BUILD_RC "20230905-0.4.15-dev-6584-g2508cdf\0"
#define KERNEL_VERSION_BUILD 20230911
#define KERNEL_VERSION_BUILD_STR "20230911-0.4.15-dev-6611-ge4512e6"
#define KERNEL_VERSION_BUILD_RC "20230911-0.4.15-dev-6611-ge4512e6\0"

#define KERNEL_VERSION_RC "0.4.15-x86-dev\0"
#define KERNEL_VERSION_STR "0.4.15-x86-dev"

#define KERNEL_VERSION_REVISION_RC "0.4.15-dev-6584-g2508cdf\0"
#define KERNEL_VERSION_REVISION_STR "0.4.15-dev-6584-g2508cdf"
#define KERNEL_VERSION_REVISION_RC "0.4.15-dev-6611-ge4512e6\0"
#define KERNEL_VERSION_REVISION_STR "0.4.15-dev-6611-ge4512e6"

#define KERNEL_VERSION_COMMIT_HASH "2508cdfe2e4e99ef76a060dff58d8a136112890d"
#define KERNEL_VERSION_COMMIT_HASH "e4512e6af250d261c8ff4b0ece6b3411c503d6b0"

#define REACTOS_DLL_VERSION_MAJOR 42
#define REACTOS_DLL_VERSION_RC "42.4.15-dev\0"
Expand Down

0 comments on commit ef600ad

Please sign in to comment.