Implemented parsing of file name, passed in command line, loading new
file on startup.
This commit is contained in:
parent
55cc7d746c
commit
be49563060
|
@ -91,6 +91,9 @@
|
||||||
|
|
||||||
/* FIXME: */
|
/* 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 \
|
#define STRING_NOTSAVED "Filen '%s'\n has been modified.\n\n \
|
||||||
Would you like to save the changes ?"
|
Would you like to save the changes ?"
|
||||||
|
|
||||||
|
|
|
@ -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 \
|
gespeichert\n werden könnte. Geben Sie Text ein, und versuchen Sie es \
|
||||||
\nerneut."
|
\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 \
|
#define STRING_NOTSAVED "Datei %s\n wurde geaendert.\n\n \
|
||||||
Moechten Sie die Aenderungen speichern ?"
|
Moechten Sie die Aenderungen speichern ?"
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,9 @@ Please use a different editor."
|
||||||
#define STRING_NOTEXT "You didn't enter any text. \
|
#define STRING_NOTEXT "You didn't enter any text. \
|
||||||
\nPlease type something and try again"
|
\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 \
|
#define STRING_NOTSAVED "File '%s'\nhas been modified\n\n \
|
||||||
Would you like to save the changes ?"
|
Would you like to save the changes ?"
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,9 @@ Use otro editor."
|
||||||
|
|
||||||
/* FIXME */
|
/* 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 \
|
#define STRING_NOTSAVED "El texto en el archivo '%s' ha cambiado\n\n \
|
||||||
¿Desea guardar los cambios?"
|
¿Desea guardar los cambios?"
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,9 @@ Please use a different editor."
|
||||||
|
|
||||||
/* FIXME */
|
/* 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 \
|
#define STRING_NOTSAVED "File '%s'\nhas been modified\n\n \
|
||||||
Would you like to save your changes ?"
|
Would you like to save your changes ?"
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,9 @@ Veuillez utiliser un autre
|
||||||
|
|
||||||
/* FIXME */
|
/* 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 \
|
#define STRING_NOTSAVED "Le fichier '%s'\n\n a change\n \
|
||||||
Would you like to save your changes ?"
|
Would you like to save your changes ?"
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,11 @@ Por favor use um editor diferente."
|
||||||
#define STRING_NOTEXT "Você não digitou nenhum texto. \
|
#define STRING_NOTEXT "Você não digitou nenhum texto. \
|
||||||
\nPor favor digite alguma coisa e tente novamente"
|
\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 \
|
#define STRING_NOTSAVED "Arquivo '%s'\nfoi modificado\n\n \
|
||||||
Gostaria de salvar as alteraçÕes ?"
|
Gostaria de salvar as alteraçÕes ?"
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,11 @@ Please use a different editor."
|
||||||
#define STRING_NOTEXT "Niè ste nenapísali. \
|
#define STRING_NOTEXT "Niè ste nenapísali. \
|
||||||
\nProsím, napíšte nejaký text a pokúste sa znovu."
|
\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 \
|
#define STRING_NOTSAVED "Súbor '%s'\nbol zmenenýn\n \
|
||||||
Prajete si uloži<C5BE> zmeny ?"
|
Prajete si uloži<C5BE> zmeny ?"
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,9 @@ Anv
|
||||||
|
|
||||||
/* FIXME */
|
/* 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 \
|
#define STRING_NOTSAVED "Filen '%s'\nhas been modified\n\n \
|
||||||
Would you like to save your changes ?"
|
Would you like to save your changes ?"
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,11 @@ Eployoz on
|
||||||
#define STRING_NOTEXT "Vos n' avoz rén sicrît. \
|
#define STRING_NOTEXT "Vos n' avoz rén sicrît. \
|
||||||
\nTapez ene sacwe èt rasayez"
|
\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 \
|
#define STRING_NOTSAVED "Li fitchî '%s'\na candjî\n\n \
|
||||||
El voloz schaper ?"
|
El voloz schaper ?"
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ VOID AlertOutOfMemory(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL ExistFile(LPCSTR szFilename) {
|
BOOL FileExists(LPCSTR szFilename) {
|
||||||
/*
|
/*
|
||||||
* Returns: TRUE - if "szFileName" exists
|
* Returns: TRUE - if "szFileName" exists
|
||||||
* FALSE - if it does not
|
* FALSE - if it does not
|
||||||
|
@ -206,7 +206,7 @@ VOID DIALOG_FileOpen(VOID)
|
||||||
|
|
||||||
if (GetOpenFileName(&openfilename)) {
|
if (GetOpenFileName(&openfilename)) {
|
||||||
|
|
||||||
if (ExistFile(openfilename.lpstrFile))
|
if (FileExists(openfilename.lpstrFile))
|
||||||
DoOpenFile(openfilename.lpstrFile);
|
DoOpenFile(openfilename.lpstrFile);
|
||||||
else
|
else
|
||||||
AlertFileNotFound(openfilename.lpstrFile);
|
AlertFileNotFound(openfilename.lpstrFile);
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
|
|
||||||
|
extern BOOL FileExists(LPCSTR szFilename);
|
||||||
extern BOOL DoCloseFile(void);
|
extern BOOL DoCloseFile(void);
|
||||||
extern void DoOpenFile(LPCSTR szFileName);
|
extern void DoOpenFile(LPCSTR szFileName);
|
||||||
|
|
||||||
|
@ -477,7 +478,6 @@ void LoadBufferFromFile(LPCSTR szFileName)
|
||||||
memmove(&pTemp[0],&pTemp[i], bytes_left);
|
memmove(&pTemp[0],&pTemp[i], bytes_left);
|
||||||
}
|
}
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
MessageBox(Globals.hMainWnd, "Finished", "Info", MB_OK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL DoInput(HDC hDC, WPARAM wParam, LPARAM lParam)
|
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;
|
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);
|
"Error", MB_ICONEXCLAMATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now handle command line */
|
HandleCommandLine(cmdline);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set up Drag&Drop */
|
/* Set up Drag&Drop */
|
||||||
|
|
||||||
|
|
|
@ -82,17 +82,18 @@ extern CHAR STRING_PAGESETUP_Xx[];
|
||||||
#define IDS_INFO STRINGID(07)
|
#define IDS_INFO STRINGID(07)
|
||||||
#define IDS_TOOLARGE STRINGID(08)
|
#define IDS_TOOLARGE STRINGID(08)
|
||||||
#define IDS_NOTEXT STRINGID(09)
|
#define IDS_NOTEXT STRINGID(09)
|
||||||
#define IDS_NOTSAVED STRINGID(0A)
|
#define IDS_DOESNOTEXIST STRINGID(0A)
|
||||||
#define IDS_NOTFOUND STRINGID(0B)
|
#define IDS_NOTSAVED STRINGID(0B)
|
||||||
#define IDS_OUT_OF_MEMORY STRINGID(0C)
|
#define IDS_NOTFOUND STRINGID(0C)
|
||||||
#define IDS_UNTITLED STRINGID(0D)
|
#define IDS_OUT_OF_MEMORY STRINGID(0D)
|
||||||
|
#define IDS_UNTITLED STRINGID(0E)
|
||||||
|
|
||||||
#define IDS_PAGESETUP_HEADERVALUE STRINGID(0E)
|
#define IDS_PAGESETUP_HEADERVALUE STRINGID(0F)
|
||||||
#define IDS_PAGESETUP_FOOTERVALUE STRINGID(0F)
|
#define IDS_PAGESETUP_FOOTERVALUE STRINGID(10)
|
||||||
#define IDS_PAGESETUP_LEFTVALUE STRINGID(10)
|
#define IDS_PAGESETUP_LEFTVALUE STRINGID(11)
|
||||||
#define IDS_PAGESETUP_RIGHTVALUE STRINGID(11)
|
#define IDS_PAGESETUP_RIGHTVALUE STRINGID(12)
|
||||||
#define IDS_PAGESETUP_TOPVALUE STRINGID(12)
|
#define IDS_PAGESETUP_TOPVALUE STRINGID(13)
|
||||||
#define IDS_PAGESETUP_BOTTOMVALUE STRINGID(13)
|
#define IDS_PAGESETUP_BOTTOMVALUE STRINGID(14)
|
||||||
|
|
||||||
/* main menu */
|
/* main menu */
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,7 @@ ADDSTRING(WARNING)
|
||||||
ADDSTRING(INFO)
|
ADDSTRING(INFO)
|
||||||
ADDSTRING(TOOLARGE)
|
ADDSTRING(TOOLARGE)
|
||||||
ADDSTRING(NOTEXT)
|
ADDSTRING(NOTEXT)
|
||||||
|
ADDSTRING(DOESNOTEXIST)
|
||||||
ADDSTRING(NOTSAVED)
|
ADDSTRING(NOTSAVED)
|
||||||
ADDSTRING(NOTFOUND)
|
ADDSTRING(NOTFOUND)
|
||||||
ADDSTRING(OUT_OF_MEMORY)
|
ADDSTRING(OUT_OF_MEMORY)
|
||||||
|
@ -182,6 +183,7 @@ ADDSTRING(PAGESETUP_BOTTOMVALUE)
|
||||||
#undef STRING_TEXT_FILES_TXT
|
#undef STRING_TEXT_FILES_TXT
|
||||||
#undef STRING_TOOLARGE
|
#undef STRING_TOOLARGE
|
||||||
#undef STRING_NOTEXT
|
#undef STRING_NOTEXT
|
||||||
|
#undef STRING_DOESNOTEXIST
|
||||||
#undef STRING_NOTSAVED
|
#undef STRING_NOTSAVED
|
||||||
#undef STRING_NOTFOUND
|
#undef STRING_NOTFOUND
|
||||||
#undef STRING_OUT_OF_MEMORY
|
#undef STRING_OUT_OF_MEMORY
|
||||||
|
|
Loading…
Reference in New Issue