Commit 398af166 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

Convert Notepad to unicode.

parent 7924111b
......@@ -95,16 +95,6 @@ PUSHBUTTON "Cancel", 0x152, 180, 21, 40, 15, WS_TABSTOP
PUSHBUTTON "&Help", 0x153, 180, 39, 40, 15, WS_TABSTOP
}
ID_ACCEL ACCELERATORS
{
"^A", CMD_SELECT_ALL
"^F", CMD_SEARCH
"^O", CMD_OPEN
"^S", CMD_SAVE
VK_F3, CMD_SEARCH_NEXT, VIRTKEY
VK_F5, CMD_TIME_DATE, VIRTKEY
}
STRINGTABLE DISCARDABLE
{
STRING_PAGESETUP_HEADERVALUE, "&n" /* FIXME */
......
#include <windows.h>
#include "license.h"
static CHAR LicenseCaption_En[] = "LICENSE";
static CHAR License_En[] =
static const CHAR LicenseCaption_En[] = "LICENSE";
static const CHAR License_En[] =
"This library is free software; you can redistribute it and/or "
"modify it under the terms of the GNU Lesser General Public "
"License as published by the Free Software Foundation; either "
......@@ -17,8 +17,8 @@ static CHAR License_En[] =
"License along with this library; if not, write to the Free Software "
"Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA";
static CHAR NoWarrantyCaption_En[] = "NO WARRANTY";
static CHAR NoWarranty_En[] =
static const CHAR NoWarrantyCaption_En[] = "NO WARRANTY";
static const CHAR NoWarranty_En[] =
"This library is distributed in the hope that it will be useful, "
"but WITHOUT ANY WARRANTY; without even the implied warranty of "
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU "
......@@ -26,4 +26,3 @@ static CHAR NoWarranty_En[] =
LICENSE WineLicense_En = {License_En, LicenseCaption_En,
NoWarranty_En, NoWarrantyCaption_En};
......@@ -4,7 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = notepad.exe
APPMODE = gui
IMPORTS = comdlg32 shell32 msvcrt user32 gdi32 kernel32
IMPORTS = comdlg32 shell32 user32 gdi32 msvcrt advapi32 kernel32
EXTRAINCL = -I$(TOPSRCDIR)/include/msvcrt
EXTRADEFS = -DNO_LIBWINE_PORT
......
......@@ -34,11 +34,11 @@ VOID DIALOG_EditPaste(VOID);
VOID DIALOG_EditDelete(VOID);
VOID DIALOG_EditSelectAll(VOID);
VOID DIALOG_EditTimeDate(VOID);
VOID DIALOG_EditWrap(VOID);
VOID DIALOG_Search(VOID);
VOID DIALOG_SearchNext(VOID);
VOID DIALOG_EditWrap(VOID);
VOID DIALOG_SelectFont(VOID);
VOID DIALOG_HelpContents(VOID);
......@@ -48,11 +48,10 @@ VOID DIALOG_HelpLicense(VOID);
VOID DIALOG_HelpNoWarranty(VOID);
VOID DIALOG_HelpAboutWine(VOID);
VOID DIALOG_PageSetup(VOID);
VOID DIALOG_TimeDate(VOID);
/* utility functions */
VOID ShowLastError();
BOOL FileExists(LPSTR szFilename);
BOOL FileExists(LPCWSTR szFilename);
BOOL DoCloseFile(void);
void DoOpenFile(LPSTR szFileName);
void DoOpenFile(LPCWSTR szFileName);
......@@ -22,8 +22,9 @@
*
*/
#define UNICODE
#include <windows.h>
#include <richedit.h>
#include <stdio.h>
#include "main.h"
......@@ -31,6 +32,7 @@
#include "notepad_res.h"
NOTEPAD_GLOBALS Globals;
static ATOM aFINDMSGSTRING;
/***********************************************************************
*
......@@ -38,7 +40,7 @@ NOTEPAD_GLOBALS Globals;
*
* Sets Global File Name.
*/
VOID SetFileName(LPSTR szFileName)
VOID SetFileName(LPCWSTR szFileName)
{
lstrcpy(Globals.szFileName, szFileName);
Globals.szFileTitle[0] = 0;
......@@ -51,8 +53,7 @@ VOID SetFileName(LPSTR szFileName)
*
* All handling of main menu events
*/
int NOTEPAD_MenuCommand(WPARAM wParam)
static int NOTEPAD_MenuCommand(WPARAM wParam)
{
switch (wParam)
{
......@@ -85,6 +86,9 @@ int NOTEPAD_MenuCommand(WPARAM wParam)
case CMD_LICENSE: DIALOG_HelpLicense(); break;
case CMD_NO_WARRANTY: DIALOG_HelpNoWarranty(); break;
case CMD_ABOUT_WINE: DIALOG_HelpAboutWine(); break;
default:
break;
}
return 0;
}
......@@ -92,18 +96,20 @@ int NOTEPAD_MenuCommand(WPARAM wParam)
/***********************************************************************
* Data Initialization
*/
VOID NOTEPAD_InitData(VOID)
static VOID NOTEPAD_InitData(VOID)
{
LPSTR p = Globals.szFilter;
LPWSTR p = Globals.szFilter;
static const WCHAR txt_files[] = { '*','.','t','x','t',0 };
static const WCHAR all_files[] = { '*','.','*',0 };
LoadString(Globals.hInstance, STRING_TEXT_FILES_TXT, p, MAX_STRING_LEN);
p += strlen(p) + 1;
lstrcpy(p, "*.txt");
p += strlen(p) + 1;
p += lstrlen(p) + 1;
lstrcpy(p, txt_files);
p += lstrlen(p) + 1;
LoadString(Globals.hInstance, STRING_ALL_FILES, p, MAX_STRING_LEN);
p += strlen(p) + 1;
lstrcpy(p, "*.*");
p += strlen(p) + 1;
p += lstrlen(p) + 1;
lstrcpy(p, all_files);
p += lstrlen(p) + 1;
*p = '\0';
}
......@@ -111,16 +117,17 @@ VOID NOTEPAD_InitData(VOID)
*
* NOTEPAD_WndProc
*/
LRESULT WINAPI NOTEPAD_WndProc(HWND hWnd, UINT msg, WPARAM wParam,
static LRESULT WINAPI NOTEPAD_WndProc(HWND hWnd, UINT msg, WPARAM wParam,
LPARAM lParam)
{
switch (msg) {
case WM_CREATE:
{
static const WCHAR editW[] = { 'e','d','i','t',0 };
RECT rc;
GetClientRect(hWnd, &rc);
Globals.hEdit = CreateWindow("EDIT", "",
Globals.hEdit = CreateWindow(editW, NULL,
WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL |
ES_AUTOVSCROLL | ES_MULTILINE,
0, 0, rc.right, rc.bottom, hWnd,
......@@ -133,7 +140,7 @@ LRESULT WINAPI NOTEPAD_WndProc(HWND hWnd, UINT msg, WPARAM wParam,
break;
case WM_DESTROYCLIPBOARD:
MessageBox(Globals.hMainWnd, "Empty clipboard", "Debug", MB_ICONEXCLAMATION);
/*MessageBox(Globals.hMainWnd, "Empty clipboard", "Debug", MB_ICONEXCLAMATION);*/
break;
case WM_CLOSE:
......@@ -151,12 +158,16 @@ LRESULT WINAPI NOTEPAD_WndProc(HWND hWnd, UINT msg, WPARAM wParam,
SWP_NOOWNERZORDER | SWP_NOZORDER);
break;
case WM_SETFOCUS:
SetFocus(Globals.hEdit);
break;
case WM_DROPFILES:
{
CHAR szFileName[MAX_PATH];
WCHAR szFileName[MAX_PATH];
HANDLE hDrop = (HANDLE) wParam;
DragQueryFile(hDrop, 0, (CHAR *) &szFileName, sizeof(szFileName));
DragQueryFile(hDrop, 0, szFileName, SIZEOF(szFileName));
DragFinish(hDrop);
DoOpenFile(szFileName);
break;
......@@ -168,30 +179,45 @@ LRESULT WINAPI NOTEPAD_WndProc(HWND hWnd, UINT msg, WPARAM wParam,
return 0;
}
int AlertFileDoesNotExist(LPSTR szFileName) {
static int AlertFileDoesNotExist(LPCWSTR szFileName)
{
int nResult;
CHAR szMessage[MAX_STRING_LEN];
CHAR szRessource[MAX_STRING_LEN];
WCHAR szMessage[MAX_STRING_LEN];
WCHAR szResource[MAX_STRING_LEN];
LoadString(Globals.hInstance, STRING_DOESNOTEXIST, szRessource,
sizeof(szRessource));
wsprintf(szMessage, szRessource, szFileName);
LoadString(Globals.hInstance, STRING_DOESNOTEXIST, szResource, SIZEOF(szResource));
wsprintf(szMessage, szResource, szFileName);
LoadString(Globals.hInstance, STRING_ERROR, szRessource, sizeof(szRessource));
LoadString(Globals.hInstance, STRING_ERROR, szResource, SIZEOF(szResource));
nResult = MessageBox(Globals.hMainWnd, szMessage, szRessource,
nResult = MessageBox(Globals.hMainWnd, szMessage, szResource,
MB_ICONEXCLAMATION | MB_YESNO);
return(nResult);
}
void HandleCommandLine(LPSTR cmdline)
static void HandleCommandLine(LPWSTR cmdline)
{
WCHAR delimiter;
/* skip white space */
while (*cmdline && *cmdline == ' ') cmdline++;
/* skip executable name */
delimiter = ' ';
if (*cmdline == '"')
delimiter = '"';
do
{
cmdline++;
}
while (*cmdline && *cmdline != delimiter);
if (*cmdline == delimiter) cmdline++;
while (*cmdline && (*cmdline == ' ' || *cmdline == '-'))
{
CHAR option;
WCHAR option;
if (*cmdline++ == ' ') continue;
......@@ -211,15 +237,16 @@ void HandleCommandLine(LPSTR cmdline)
if (*cmdline)
{
/* file name is passed in the command line */
char *file_name;
LPCWSTR file_name;
BOOL file_exists;
char buf[MAX_PATH];
WCHAR buf[MAX_PATH];
if (cmdline[0] == '"')
{
cmdline++;
cmdline[strlen(cmdline) - 1] = 0;
cmdline[lstrlen(cmdline) - 1] = 0;
}
if (FileExists(cmdline))
{
file_exists = TRUE;
......@@ -227,16 +254,18 @@ void HandleCommandLine(LPSTR cmdline)
}
else
{
/* try to find file with ".txt" extension */
if (!strcmp(".txt", cmdline + strlen(cmdline) - strlen(".txt")))
static const WCHAR txtW[] = { '.','t','x','t',0 };
/* try to find file with ".txt" extention */
if (!lstrcmp(txtW, cmdline + lstrlen(cmdline) - lstrlen(txtW)))
{
file_exists = FALSE;
file_name = cmdline;
}
else
{
strncpy(buf, cmdline, MAX_PATH - strlen(".txt") - 1);
strcat(buf, ".txt");
lstrcpyn(buf, cmdline, MAX_PATH - lstrlen(txtW) - 1);
lstrcat(buf, txtW);
file_name = buf;
file_exists = FileExists(buf);
}
......@@ -270,8 +299,10 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show)
MSG msg;
HACCEL hAccel;
WNDCLASSEX class;
char className[] = "NPClass";
char winName[] = "Notepad";
static const WCHAR className[] = {'N','P','C','l','a','s','s',0};
static const WCHAR winName[] = {'N','o','t','e','p','a','d',0};
aFINDMSGSTRING = RegisterWindowMessage(FINDMSGSTRING);
ZeroMemory(&Globals, sizeof(Globals));
Globals.hInstance = hInstance;
......@@ -307,24 +338,17 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show)
UpdateWindow(Globals.hMainWnd);
DragAcceptFiles(Globals.hMainWnd, TRUE);
HandleCommandLine(cmdline);
HandleCommandLine(GetCommandLine());
hAccel=LoadAccelerators( hInstance, MAKEINTRESOURCE(ID_ACCEL) );
hAccel = LoadAccelerators( hInstance, MAKEINTRESOURCE(ID_ACCEL) );
if( hAccel!=NULL )
while (GetMessage(&msg, 0, 0, 0))
{
while( GetMessage(&msg, 0, 0, 0)) {
if( !TranslateAccelerator( Globals.hMainWnd, hAccel, &msg ) ) {
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
} else
{
while (GetMessage(&msg, 0, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if (!TranslateAccelerator(Globals.hMainWnd, hAccel, &msg) && !IsDialogMessage(Globals.hFindReplaceDlg, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
......@@ -19,26 +19,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define SIZEOF(a) sizeof(a)/sizeof((a)[0])
#include "notepad_res.h"
#define MAX_STRING_LEN 255
#define HELPFILE "notepad.hlp"
/* hide the following from winerc */
#ifndef RC_INVOKED
#define WINE_RELEASE_INFO "Wine (www.winehq.com)"
#include "commdlg.h"
VOID SetFileName(LPSTR szFileName);
/***** Compatibility *****/
#ifndef OIC_WINLOGO
#define OIC_WINLOGO 32517
#endif
#define DEFAULTICON OIC_WINLOGO
typedef struct
{
......@@ -48,26 +33,21 @@ typedef struct
HWND hEdit;
HFONT hFont; /* Font used by the edit control */
LOGFONT lfFont;
HICON hMainIcon;
HICON hDefaultIcon;
LPCSTR lpszIcoFile;
BOOL bWrapLongLines;
CHAR szFindText[MAX_PATH];
CHAR szFileName[MAX_PATH];
CHAR szFileTitle[MAX_PATH];
CHAR szFilter[2 * MAX_STRING_LEN + 100];
CHAR szMarginTop[MAX_PATH];
CHAR szMarginBottom[MAX_PATH];
CHAR szMarginLeft[MAX_PATH];
CHAR szMarginRight[MAX_PATH];
CHAR szHeader[MAX_PATH];
CHAR szFooter[MAX_PATH];
WCHAR szFindText[MAX_PATH];
WCHAR szFileName[MAX_PATH];
WCHAR szFileTitle[MAX_PATH];
WCHAR szFilter[2 * MAX_STRING_LEN + 100];
WCHAR szMarginTop[MAX_PATH];
WCHAR szMarginBottom[MAX_PATH];
WCHAR szMarginLeft[MAX_PATH];
WCHAR szMarginRight[MAX_PATH];
WCHAR szHeader[MAX_PATH];
WCHAR szFooter[MAX_PATH];
FINDREPLACE find;
} NOTEPAD_GLOBALS;
extern NOTEPAD_GLOBALS Globals;
#else /* RC_INVOKED */
#endif
VOID SetFileName(LPCWSTR szFileName);
......@@ -24,6 +24,20 @@
#include "commctrl.h"
#include "notepad_res.h"
ID_ACCEL ACCELERATORS
{
"^A", CMD_SELECT_ALL
"^C", CMD_COPY
"^F", CMD_SEARCH
"^O", CMD_OPEN
"^S", CMD_SAVE
"^V", CMD_PASTE
"^X", CMD_CUT
"^Z", CMD_UNDO
VK_F3, CMD_SEARCH_NEXT, VIRTKEY
VK_F5, CMD_TIME_DATE, VIRTKEY
}
#include "Da.rc"
#include "De.rc"
#include "En.rc"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment