1
0
mirror of https://github.com/wine-mirror/wine synced 2024-07-08 03:45:57 +00:00

Implemented parsing of file name, passed in command line, loading new

file on startup.
This commit is contained in:
Andriy Palamarchuk 2002-02-19 18:38:22 +00:00 committed by Alexandre Julliard
parent 55cc7d746c
commit be49563060
14 changed files with 143 additions and 35 deletions

View File

@ -91,6 +91,9 @@
/* FIXME: */
#define STRING_DOESNOTEXIST "File '%s'\ndoes not exist\n\n \
Do you want to create a new file ?"
#define STRING_NOTSAVED "Filen '%s'\n has been modified.\n\n \
Would you like to save the changes ?"

View File

@ -92,6 +92,11 @@ Benutzen Sie bitte einen anderen Editor, um diese Datei zu bearbeiten."
gespeichert\n werden könnte. Geben Sie Text ein, und versuchen Sie es \
\nerneut."
/* FIXME */
#define STRING_DOESNOTEXIST "File '%s'\ndoes not exist\n\n \
Do you want to create a new file ?"
#define STRING_NOTSAVED "Datei %s\n wurde geaendert.\n\n \
Moechten Sie die Aenderungen speichern ?"

View File

@ -91,6 +91,9 @@ Please use a different editor."
#define STRING_NOTEXT "You didn't enter any text. \
\nPlease type something and try again"
#define STRING_DOESNOTEXIST "File '%s'\ndoes not exist\n\n \
Do you want to create a new file ?"
#define STRING_NOTSAVED "File '%s'\nhas been modified\n\n \
Would you like to save the changes ?"

View File

@ -94,6 +94,9 @@ Use otro editor."
/* FIXME */
#define STRING_DOESNOTEXIST "File '%s'\ndoes not exist\n\n \
Do you want to create a new file ?"
#define STRING_NOTSAVED "El texto en el archivo '%s' ha cambiado\n\n \
¿Desea guardar los cambios?"

View File

@ -92,6 +92,9 @@ Please use a different editor."
/* FIXME */
#define STRING_DOESNOTEXIST "File '%s'\ndoes not exist\n\n \
Do you want to create a new file ?"
#define STRING_NOTSAVED "File '%s'\nhas been modified\n\n \
Would you like to save your changes ?"

View File

@ -93,6 +93,9 @@ Veuillez utiliser un autre
/* FIXME */
#define STRING_DOESNOTEXIST "File '%s'\ndoes not exist\n\n \
Do you want to create a new file ?"
#define STRING_NOTSAVED "Le fichier '%s'\n\n a change\n \
Would you like to save your changes ?"

View File

@ -90,6 +90,11 @@ Por favor use um editor diferente."
#define STRING_NOTEXT "Você não digitou nenhum texto. \
\nPor favor digite alguma coisa e tente novamente"
/* FIXME */
#define STRING_DOESNOTEXIST "File '%s'\ndoes not exist\n\n \
Do you want to create a new file ?"
#define STRING_NOTSAVED "Arquivo '%s'\nfoi modificado\n\n \
Gostaria de salvar as alteraçÕes ?"

View File

@ -91,6 +91,11 @@ Please use a different editor."
#define STRING_NOTEXT "Niè ste nenapísali. \
\nProsím, napíšte nejaký text a pokúste sa znovu."
/* FIXME */
#define STRING_DOESNOTEXIST "File '%s'\ndoes not exist\n\n \
Do you want to create a new file ?"
#define STRING_NOTSAVED "Súbor '%s'\nbol zmenenýn\n \
Prajete si uloži<C5BE> zmeny ?"

View File

@ -93,6 +93,9 @@ Anv
/* FIXME */
#define STRING_DOESNOTEXIST "File '%s'\ndoes not exist\n\n \
Do you want to create a new file ?"
#define STRING_NOTSAVED "Filen '%s'\nhas been modified\n\n \
Would you like to save your changes ?"

View File

@ -93,6 +93,11 @@ Eployoz on
#define STRING_NOTEXT "Vos n' avoz rén sicrît. \
\nTapez ene sacwe èt rasayez"
/* FIXME */
#define STRING_DOESNOTEXIST "File '%s'\ndoes not exist\n\n \
Do you want to create a new file ?"
#define STRING_NOTSAVED "Li fitchî '%s'\na candjî\n\n \
El voloz schaper ?"

View File

@ -89,7 +89,7 @@ VOID AlertOutOfMemory(void) {
}
BOOL ExistFile(LPCSTR szFilename) {
BOOL FileExists(LPCSTR szFilename) {
/*
* Returns: TRUE - if "szFileName" exists
* FALSE - if it does not
@ -206,7 +206,7 @@ VOID DIALOG_FileOpen(VOID)
if (GetOpenFileName(&openfilename)) {
if (ExistFile(openfilename.lpstrFile))
if (FileExists(openfilename.lpstrFile))
DoOpenFile(openfilename.lpstrFile);
else
AlertFileNotFound(openfilename.lpstrFile);

View File

@ -34,6 +34,7 @@
#include "dialog.h"
#include "language.h"
extern BOOL FileExists(LPCSTR szFilename);
extern BOOL DoCloseFile(void);
extern void DoOpenFile(LPCSTR szFileName);
@ -477,7 +478,6 @@ void LoadBufferFromFile(LPCSTR szFileName)
memmove(&pTemp[0],&pTemp[i], bytes_left);
}
CloseHandle(hFile);
MessageBox(Globals.hMainWnd, "Finished", "Info", MB_OK);
}
BOOL DoInput(HDC hDC, WPARAM wParam, LPARAM lParam)
@ -847,6 +847,94 @@ LRESULT WINAPI NOTEPAD_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
return 0l;
}
int AlertFileDoesNotExist(LPSTR szFileName) {
int nResult;
CHAR szMessage[MAX_STRING_LEN];
CHAR szRessource[MAX_STRING_LEN];
LoadString(Globals.hInstance, IDS_DOESNOTEXIST, szRessource,
sizeof(szRessource));
wsprintf(szMessage, szRessource, szFileName);
LoadString(Globals.hInstance, IDS_ERROR, szRessource, sizeof(szRessource));
nResult = MessageBox(Globals.hMainWnd, szMessage, szRessource,
MB_ICONEXCLAMATION | MB_YESNO);
return(nResult);
}
void HandleCommandLine(LPSTR cmdline)
{
while (*cmdline && (*cmdline == ' ' || *cmdline == '-'))
{
CHAR option;
if (*cmdline++ == ' ') continue;
option = *cmdline;
if (option) cmdline++;
while (*cmdline && *cmdline == ' ') cmdline++;
switch(option)
{
case 'p':
case 'P': printf("Print file: ");
/* Not yet able to print a file */
break;
}
}
if (*cmdline)
{
/* file name is passed in the command line */
char *file_name;
BOOL file_exists;
char buf[MAX_PATH];
if (FileExists(cmdline))
{
file_exists = TRUE;
file_name = cmdline;
}
else
{
/* try to find file with ".txt" extention */
if (!strcmp(".txt", cmdline + strlen(cmdline) - strlen(".txt")))
{
file_exists = FALSE;
file_name = cmdline;
}
else
{
strncpy(buf, cmdline, MAX_PATH - strlen(".txt") - 1);
strcat(buf, ".txt");
file_name = buf;
file_exists = FileExists(buf);
}
}
if (file_exists)
{
DoOpenFile(file_name);
InvalidateRect(Globals.hMainWnd, NULL, FALSE);
}
else
{
switch (AlertFileDoesNotExist(file_name)) {
case IDYES:
DoOpenFile(file_name);
break;
case IDNO:
break;
}
}
}
}
/***********************************************************************
@ -932,28 +1020,7 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show
"Error", MB_ICONEXCLAMATION);
}
/* now handle command line */
while (*cmdline && (*cmdline == ' ' || *cmdline == '-'))
{
CHAR option;
/* LPCSTR topic_id; */
if (*cmdline++ == ' ') continue;
option = *cmdline;
if (option) cmdline++;
while (*cmdline && *cmdline == ' ') cmdline++;
switch(option)
{
case 'p':
case 'P': printf("Print file: ");
/* Not yet able to print a file */
break;
}
}
HandleCommandLine(cmdline);
/* Set up Drag&Drop */

View File

@ -82,17 +82,18 @@ extern CHAR STRING_PAGESETUP_Xx[];
#define IDS_INFO STRINGID(07)
#define IDS_TOOLARGE STRINGID(08)
#define IDS_NOTEXT STRINGID(09)
#define IDS_NOTSAVED STRINGID(0A)
#define IDS_NOTFOUND STRINGID(0B)
#define IDS_OUT_OF_MEMORY STRINGID(0C)
#define IDS_UNTITLED STRINGID(0D)
#define IDS_DOESNOTEXIST STRINGID(0A)
#define IDS_NOTSAVED STRINGID(0B)
#define IDS_NOTFOUND STRINGID(0C)
#define IDS_OUT_OF_MEMORY STRINGID(0D)
#define IDS_UNTITLED STRINGID(0E)
#define IDS_PAGESETUP_HEADERVALUE STRINGID(0E)
#define IDS_PAGESETUP_FOOTERVALUE STRINGID(0F)
#define IDS_PAGESETUP_LEFTVALUE STRINGID(10)
#define IDS_PAGESETUP_RIGHTVALUE STRINGID(11)
#define IDS_PAGESETUP_TOPVALUE STRINGID(12)
#define IDS_PAGESETUP_BOTTOMVALUE STRINGID(13)
#define IDS_PAGESETUP_HEADERVALUE STRINGID(0F)
#define IDS_PAGESETUP_FOOTERVALUE STRINGID(10)
#define IDS_PAGESETUP_LEFTVALUE STRINGID(11)
#define IDS_PAGESETUP_RIGHTVALUE STRINGID(12)
#define IDS_PAGESETUP_TOPVALUE STRINGID(13)
#define IDS_PAGESETUP_BOTTOMVALUE STRINGID(14)
/* main menu */

View File

@ -102,6 +102,7 @@ ADDSTRING(WARNING)
ADDSTRING(INFO)
ADDSTRING(TOOLARGE)
ADDSTRING(NOTEXT)
ADDSTRING(DOESNOTEXIST)
ADDSTRING(NOTSAVED)
ADDSTRING(NOTFOUND)
ADDSTRING(OUT_OF_MEMORY)
@ -182,6 +183,7 @@ ADDSTRING(PAGESETUP_BOTTOMVALUE)
#undef STRING_TEXT_FILES_TXT
#undef STRING_TOOLARGE
#undef STRING_NOTEXT
#undef STRING_DOESNOTEXIST
#undef STRING_NOTSAVED
#undef STRING_NOTFOUND
#undef STRING_OUT_OF_MEMORY