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:
parent
b46ce44f2b
commit
3338175675
@ -9,6 +9,7 @@
|
|||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <objbase.h>
|
#include <objbase.h>
|
||||||
#include <commdlg.h>
|
#include <commdlg.h>
|
||||||
|
#include <shellapi.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
@ -673,7 +674,17 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/,
|
|||||||
if (NULL == hwnd)
|
if (NULL == hwnd)
|
||||||
die("Window Creation Failed!");
|
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));
|
HACCEL accel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR));
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user