commit - 3d8c2326ed9a64ab1c48af6e5bd057ae8b3dd888
commit + 941b3761caf7ad45b24b9556161424d183021d97
blob - 76dfc8347db50cbb03bd085d30afe700a4ea9226
blob + 1404d6ee3e645292a65ee33d7afb83cc92cf241f
--- telescope.c
+++ telescope.c
}
int
-main(void)
+main(int argc, char **argv)
{
struct imsgbuf network_ibuf, fs_ibuf;
int net_fds[2], fs_fds[2];
event_set(&fsev, fsibuf->fd, EV_READ | EV_PERSIST, handle_dispatch_imsg, fsibuf);
event_add(&fsev, NULL);
- ui_init();
-
- sandbox_ui_process();
-
- event_dispatch();
+ if (ui_init(argc, argv)) {
+ sandbox_ui_process();
+ event_dispatch();
+ ui_end();
+ }
imsg_compose(netibuf, IMSG_QUIT, 0, 0, -1, NULL, 0);
imsg_flush(netibuf);
imsg_compose(fsibuf, IMSG_QUIT, 0, 0, -1, NULL, 0);
imsg_flush(fsibuf);
- ui_end();
-
return 0;
}
blob - e2832ad89223268a6cf04b4c834b19187fb671e6
blob + 690933f8d7ccea28dedb9434becc39ee5fd5ee74
--- telescope.h
+++ telescope.h
void textplain_initparser(struct parser*);
/* ui.c */
-int ui_init(void);
+int ui_init(int, const char**);
void ui_on_tab_loaded(struct tab*);
void ui_on_tab_refresh(struct tab*);
void ui_require_input(struct tab*, int);
blob - e240653612f5732871f10d6d675377072efdfd6a
blob + afd5af58bc6dc398d89430885b0d128426610962
--- ui.c
+++ ui.c
static void exit_minibuffer(void);
static void switch_to_tab(struct tab*);
static struct tab *new_tab(const char*);
+static void usage(void);
static struct { int meta, key; } thiskey;
return tab;
}
-int
-ui_init(void)
+static void
+usage(void)
{
+ fprintf(stderr, "USAGE: %s [url]\n", getprogname());
+}
+
+int
+ui_init(int argc, const char **argv)
+{
+ const char *url = NEW_TAB_URL;
+ int ch;
+
+ while ((ch = getopt(argc, argv, "")) != -1) {
+ switch (ch) {
+ default:
+ usage();
+ return 0;
+ }
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (argc != 0)
+ url = argv[0];
+
setlocale(LC_ALL, "");
TAILQ_INIT(&global_map.m);
signal_set(&winchev, SIGWINCH, handle_resize, NULL);
signal_add(&winchev, NULL);
- new_tab(NEW_TAB_URL);
+ new_tab(url);
return 1;
}