Notepad: 1. Fixed bug in Goto line command 2. Wrap long lines setting is persisted in the registry 3. Fixed length limit bug when wrap long lines is toggled Modified: trunk/reactos/subsys/system/notepad/dialog.c Modified: trunk/reactos/subsys/system/notepad/main.c Modified: trunk/reactos/subsys/system/notepad/main.h Modified: trunk/reactos/subsys/system/notepad/settings.c _____
Modified: trunk/reactos/subsys/system/notepad/dialog.c --- trunk/reactos/subsys/system/notepad/dialog.c 2005-09-30 23:32:24 UTC (rev 18181) +++ trunk/reactos/subsys/system/notepad/dialog.c 2005-10-01 00:36:17 UTC (rev 18182) @@ -624,6 +624,8 @@
DWORD size; LPWSTR pTemp;
+ Globals.bWrapLongLines = !Globals.bWrapLongLines; + size = GetWindowTextLength(Globals.hEdit) + 1; pTemp = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)); if (!pTemp) @@ -639,13 +641,10 @@ 0, 0, rc.right, rc.bottom, Globals.hMainWnd, NULL, Globals.hInstance, NULL); SendMessage(Globals.hEdit, WM_SETFONT, (WPARAM)Globals.hFont, (LPARAM)FALSE); + SendMessage(Globals.hEdit, EM_LIMITTEXT, 0, 0); SetWindowTextW(Globals.hEdit, pTemp); SetFocus(Globals.hEdit); HeapFree(GetProcessHeap(), 0, pTemp); - - Globals.bWrapLongLines = !Globals.bWrapLongLines; - CheckMenuItem(GetMenu(Globals.hMainWnd), CMD_WRAP, - MF_BYCOMMAND | (Globals.bWrapLongLines ? MF_CHECKED : MF_UNCHECKED)); }
VOID DIALOG_SelectFont(VOID) @@ -770,7 +769,7 @@
if (nLine >= 1) { - for (i = 0; pszText[i] && (nLine > 1) && (i < dwStart - 1); i++) + for (i = 0; pszText[i] && (nLine > 1) && (i < nLength - 1); i++) { if (pszText[i] == '\n') nLine--; _____
Modified: trunk/reactos/subsys/system/notepad/main.c --- trunk/reactos/subsys/system/notepad/main.c 2005-09-30 23:32:24 UTC (rev 18181) +++ trunk/reactos/subsys/system/notepad/main.c 2005-10-01 00:36:17 UTC (rev 18182) @@ -258,6 +258,9 @@
{ int enable;
+ CheckMenuItem(GetMenu(Globals.hMainWnd), CMD_WRAP, + MF_BYCOMMAND | (Globals.bWrapLongLines ? MF_CHECKED : MF_UNCHECKED)); + EnableMenuItem(menu, CMD_UNDO, SendMessage(Globals.hEdit, EM_CANUNDO, 0, 0) ? MF_ENABLED : MF_GRAYED); EnableMenuItem(menu, CMD_PASTE, @@ -286,7 +289,7 @@ static const WCHAR editW[] = { 'e','d','i','t',0 }; RECT rc; GetClientRect(hWnd, &rc); - Globals.hEdit = CreateWindowEx(EDIT_EXSTYLE, editW, NULL, EDIT_STYLE, + Globals.hEdit = CreateWindowEx(EDIT_EXSTYLE, editW, NULL, Globals.bWrapLongLines ? EDIT_STYLE_WRAP : EDIT_STYLE, 0, 0, rc.right, rc.bottom, hWnd, NULL, Globals.hInstance, NULL); if (!Globals.hEdit) _____
Modified: trunk/reactos/subsys/system/notepad/main.h --- trunk/reactos/subsys/system/notepad/main.h 2005-09-30 23:32:24 UTC (rev 18181) +++ trunk/reactos/subsys/system/notepad/main.h 2005-10-01 00:36:17 UTC (rev 18182) @@ -23,9 +23,9 @@
#include "notepad_res.h"
-#define EDIT_STYLE (WS_CHILD | WS_VISIBLE | WS_VSCROLL \ +#define EDIT_STYLE_WRAP (WS_CHILD | WS_VISIBLE | WS_VSCROLL \ | ES_AUTOVSCROLL | ES_MULTILINE | ES_NOHIDESEL) -#define EDIT_STYLE_WRAP (EDIT_STYLE | WS_HSCROLL | ES_AUTOHSCROLL) +#define EDIT_STYLE (EDIT_STYLE_WRAP | WS_HSCROLL | ES_AUTOHSCROLL) #define EDIT_EXSTYLE (WS_EX_CLIENTEDGE)
#define MAX_STRING_LEN 255 _____
Modified: trunk/reactos/subsys/system/notepad/settings.c --- trunk/reactos/subsys/system/notepad/settings.c 2005-09-30 23:32:24 UTC (rev 18181) +++ trunk/reactos/subsys/system/notepad/settings.c 2005-10-01 00:36:17 UTC (rev 18182) @@ -117,6 +117,15 @@
return TRUE; }
+static BOOL QueryBool(HKEY hKey, LPCSTR pszValueName, BOOL *pbResult) +{ + DWORD dwResult; + if (!QueryDword(hKey, pszValueName, &dwResult)) + return FALSE; + *pbResult = dwResult ? TRUE : FALSE; + return TRUE; +} + static BOOL QueryString(HKEY hKey, LPCSTR pszValueName, LPTSTR pszResult, DWORD dwResultSize) { return QueryGeneric(hKey, pszValueName, REG_SZ, pszResult, dwResultSize * sizeof(*pszResult)); @@ -143,6 +152,7 @@ QueryByte(hKey, "lfUnderline", &Globals.lfFont.lfUnderline); QueryDword(hKey, "lfWeight", (DWORD*)&Globals.lfFont.lfWeight); QueryDword(hKey, "iPointSize", &dwPointSize); + QueryBool(hKey, "fWrap", &Globals.bWrapLongLines);
if (dwPointSize != 0) Globals.lfFont.lfHeight = HeightFromPointSize(dwPointSize); @@ -210,6 +220,7 @@ SaveDword(hKey, "lfUnderline", Globals.lfFont.lfUnderline); SaveDword(hKey, "lfWeight", Globals.lfFont.lfWeight); SaveDword(hKey, "iPointSize", PointSizeFromHeight(Globals.lfFont.lfHeight)); + SaveDword(hKey, "fWrap", Globals.bWrapLongLines ? 1 : 0);
RegCloseKey(hKey); }