diff options
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | res/arg-help.txt | 19 | ||||
-rw-r--r-- | src/app.c | 50 |
3 files changed, 45 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ee6ea00..ea25183f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -47,6 +47,7 @@ set (EMBED_RESOURCES | |||
47 | res/about/lagrange.gmi | 47 | res/about/lagrange.gmi |
48 | res/about/license.gmi | 48 | res/about/license.gmi |
49 | res/about/version.gmi | 49 | res/about/version.gmi |
50 | res/arg-help.txt | ||
50 | res/fonts/Tinos-Regular.ttf | 51 | res/fonts/Tinos-Regular.ttf |
51 | res/fonts/Tinos-Italic.ttf | 52 | res/fonts/Tinos-Italic.ttf |
52 | res/fonts/Tinos-Bold.ttf | 53 | res/fonts/Tinos-Bold.ttf |
diff --git a/res/arg-help.txt b/res/arg-help.txt new file mode 100644 index 00000000..d8e8c76c --- /dev/null +++ b/res/arg-help.txt | |||
@@ -0,0 +1,19 @@ | |||
1 | Usage: lagrange [options] [URLs] [paths] | ||
2 | |||
3 | URLs and local files are opened in separate tabs. By default the first | ||
4 | URL/path opens in the currently open tab. | ||
5 | |||
6 | General options: | ||
7 | |||
8 | -E, --echo Print all internal app events to stdout. | ||
9 | --help Print these instructions. | ||
10 | --sw Disable hardware accelerated rendering. | ||
11 | -V, --version Print the application version. | ||
12 | |||
13 | Options that control a running instance of Lagrange: | ||
14 | |||
15 | --close-tab Close the current tab. | ||
16 | -L, --list-tab-urls Print the URLs of open tabs to stdout. If the app isn't | ||
17 | running, nothing is printed. | ||
18 | --new-tab [URL] Open a new tab. If the URL is omitted, the user's | ||
19 | homepage is opened. | ||
@@ -476,6 +476,29 @@ static void communicateWithRunningInstance_App_(iApp *d, iProcessId instance, | |||
476 | 476 | ||
477 | static void init_App_(iApp *d, int argc, char **argv) { | 477 | static void init_App_(iApp *d, int argc, char **argv) { |
478 | init_CommandLine(&d->args, argc, argv); | 478 | init_CommandLine(&d->args, argc, argv); |
479 | /* Where was the app started from? We ask SDL first because the command line alone is | ||
480 | not a reliable source of this information, particularly when it comes to different | ||
481 | operating systems. */ { | ||
482 | char *exec = SDL_GetBasePath(); | ||
483 | if (exec) { | ||
484 | d->execPath = newCStr_String(concatPath_CStr( | ||
485 | exec, cstr_Rangecc(baseName_Path(executablePath_CommandLine(&d->args))))); | ||
486 | } | ||
487 | else { | ||
488 | d->execPath = copy_String(executablePath_CommandLine(&d->args)); | ||
489 | } | ||
490 | SDL_free(exec); | ||
491 | } | ||
492 | #if defined (iHaveLoadEmbed) | ||
493 | /* Load the resources from a file. */ { | ||
494 | if (!load_Embed(concatPath_CStr(cstr_String(execPath_App()), EMB_BIN))) { | ||
495 | if (!load_Embed(concatPath_CStr(cstr_String(execPath_App()), EMB_BIN2))) { | ||
496 | fprintf(stderr, "failed to load resources: %s\n", strerror(errno)); | ||
497 | exit(-1); | ||
498 | } | ||
499 | } | ||
500 | } | ||
501 | #endif | ||
479 | /* Configure the valid command line options. */ { | 502 | /* Configure the valid command line options. */ { |
480 | defineValues_CommandLine(&d->args, "close-tab", 0); | 503 | defineValues_CommandLine(&d->args, "close-tab", 0); |
481 | defineValues_CommandLine(&d->args, "echo;E", 0); | 504 | defineValues_CommandLine(&d->args, "echo;E", 0); |
@@ -489,7 +512,7 @@ static void init_App_(iApp *d, int argc, char **argv) { | |||
489 | iStringList *openCmds = new_StringList(); | 512 | iStringList *openCmds = new_StringList(); |
490 | /* Handle command line options. */ { | 513 | /* Handle command line options. */ { |
491 | if (contains_CommandLine(&d->args, "help")) { | 514 | if (contains_CommandLine(&d->args, "help")) { |
492 | printf("Usage: lagrange [options] [URLs] [paths]\n"); | 515 | puts(cstr_Block(&blobArghelp_Embedded)); |
493 | terminate_App_(0); | 516 | terminate_App_(0); |
494 | } | 517 | } |
495 | if (contains_CommandLine(&d->args, "version;V")) { | 518 | if (contains_CommandLine(&d->args, "version;V")) { |
@@ -528,22 +551,9 @@ static void init_App_(iApp *d, int argc, char **argv) { | |||
528 | } | 551 | } |
529 | } | 552 | } |
530 | } | 553 | } |
531 | /* Where was the app started from? We ask SDL first because the command line alone is | ||
532 | not a reliable source of this information, particularly when it comes to different | ||
533 | operating systems. */ { | ||
534 | char *exec = SDL_GetBasePath(); | ||
535 | if (exec) { | ||
536 | d->execPath = newCStr_String(concatPath_CStr( | ||
537 | exec, cstr_Rangecc(baseName_Path(executablePath_CommandLine(&d->args))))); | ||
538 | } | ||
539 | else { | ||
540 | d->execPath = copy_String(executablePath_CommandLine(&d->args)); | ||
541 | } | ||
542 | SDL_free(exec); | ||
543 | } | ||
544 | init_Ipc(dataDir_App_()); | ||
545 | /* Only one instance is allowed to run at a time; the runtime files (bookmarks, etc.) | 554 | /* Only one instance is allowed to run at a time; the runtime files (bookmarks, etc.) |
546 | are not shareable. */ { | 555 | are not shareable. */ { |
556 | init_Ipc(dataDir_App_()); | ||
547 | const iProcessId instance = check_Ipc(); | 557 | const iProcessId instance = check_Ipc(); |
548 | if (instance) { | 558 | if (instance) { |
549 | communicateWithRunningInstance_App_(d, instance, openCmds); | 559 | communicateWithRunningInstance_App_(d, instance, openCmds); |
@@ -621,16 +631,6 @@ static void init_App_(iApp *d, int argc, char **argv) { | |||
621 | 0x1f306); | 631 | 0x1f306); |
622 | fetchRemote_Bookmarks(d->bookmarks); | 632 | fetchRemote_Bookmarks(d->bookmarks); |
623 | } | 633 | } |
624 | #if defined (iHaveLoadEmbed) | ||
625 | /* Load the resources from a file. */ { | ||
626 | if (!load_Embed(concatPath_CStr(cstr_String(execPath_App()), EMB_BIN))) { | ||
627 | if (!load_Embed(concatPath_CStr(cstr_String(execPath_App()), EMB_BIN2))) { | ||
628 | fprintf(stderr, "failed to load resources: %s\n", strerror(errno)); | ||
629 | exit(-1); | ||
630 | } | ||
631 | } | ||
632 | } | ||
633 | #endif | ||
634 | d->window = new_Window(d->initialWindowRect); | 634 | d->window = new_Window(d->initialWindowRect); |
635 | init_Feeds(dataDir_App_()); | 635 | init_Feeds(dataDir_App_()); |
636 | /* Widget state init. */ | 636 | /* Widget state init. */ |