editor: support loading from argv

It's sometimes useful to be able to load a rocket-file by dragging
it onto the editor executable, or even registering the editor as
an open-handler for the rocket-filetype

Support this by accepting an optional argument that specifies the
file to load.
This commit is contained in:
Thor Arne Gald Semb 2012-10-19 17:29:32 +02:00 committed by Erik Faye-Lund
parent b46ce44f2b
commit 3338175675

View File

@ -9,6 +9,7 @@
#include <commctrl.h>
#include <objbase.h>
#include <commdlg.h>
#include <shellapi.h>
#include <stdio.h>
#include <stdarg.h>
@ -673,7 +674,17 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/,
if (NULL == hwnd)
die("Window Creation Failed!");
fileNew();
LPWSTR *argv;
int argc;
if ((argv = CommandLineToArgvW(GetCommandLineW(), &argc)) && argc > 1) {
if (argc > 2) {
char prog[MAX_PATH];
GetModuleFileNameA(NULL, prog, sizeof(prog));
die("usage: %s [filename.rocket]", prog);
}
loadDocument(argv[1]);
} else
fileNew();
HACCEL accel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR));