delay initialization of curses in tog until after usage()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
diff --git a/tog/tog.c b/tog/tog.c
index 812afe0..5361782 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -1636,6 +1636,20 @@ apply_unveil(const char *repo_path, const char *worktree_path)
return NULL;
}
+static void
+init_curses(void)
+{
+ initscr();
+ cbreak();
+ halfdelay(1); /* Do fast refresh while initial view is loading. */
+ noecho();
+ nonl();
+ intrflush(stdscr, FALSE);
+ keypad(stdscr, TRUE);
+ curs_set(0);
+ signal(SIGWINCH, tog_sigwinch);
+}
+
static const struct got_error *
cmd_log(int argc, char *argv[])
{
@@ -1703,6 +1717,8 @@ cmd_log(int argc, char *argv[])
}
}
+ init_curses();
+
error = apply_unveil(repo_path, NULL);
if (error)
goto done;
@@ -2155,6 +2171,8 @@ cmd_diff(int argc, char *argv[])
} else
usage_diff();
+ init_curses();
+
error = apply_unveil(repo_path, NULL);
if (error)
goto done;
@@ -2856,6 +2874,8 @@ cmd_blame(int argc, char *argv[])
}
}
+ init_curses();
+
error = apply_unveil(repo_path, NULL);
if (error)
goto done;
@@ -3484,6 +3504,8 @@ cmd_tree(int argc, char *argv[])
} else
usage_log();
+ init_curses();
+
error = apply_unveil(repo_path, NULL);
if (error)
goto done;
@@ -3530,20 +3552,6 @@ done:
return error;
}
-static void
-init_curses(void)
-{
- initscr();
- cbreak();
- halfdelay(1); /* Do fast refresh while initial view is loading. */
- noecho();
- nonl();
- intrflush(stdscr, FALSE);
- keypad(stdscr, TRUE);
- curs_set(0);
- signal(SIGWINCH, tog_sigwinch);
-}
-
__dead static void
usage(void)
{
@@ -3655,8 +3663,6 @@ main(int argc, char *argv[])
}
}
- init_curses();
-
error = cmd->cmd_main(argc, cmd_argv ? cmd_argv : argv);
if (error)
goto done;