mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
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 svn path=/trunk/; revision=18182
This commit is contained in:
parent
0a52c57489
commit
403e26da1b
4 changed files with 21 additions and 8 deletions
|
@ -624,6 +624,8 @@ VOID DIALOG_EditWrap(VOID)
|
|||
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 @@ VOID DIALOG_EditWrap(VOID)
|
|||
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 @@ VOID DIALOG_GoTo(VOID)
|
|||
|
||||
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--;
|
||||
|
|
|
@ -258,6 +258,9 @@ static VOID NOTEPAD_InitMenuPopup(HMENU menu, int index)
|
|||
{
|
||||
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 LRESULT WINAPI NOTEPAD_WndProc(HWND hWnd, UINT msg, WPARAM wParam,
|
|||
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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -117,6 +117,15 @@ static BOOL QueryByte(HKEY hKey, LPCSTR pszValueName, BYTE *pbResult)
|
|||
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 @@ void LoadSettings(void)
|
|||
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 @@ void SaveSettings(void)
|
|||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue