index ece56281d8bd07d0cf4ab0ab42f6122966f79620..413bd04b61a2766f7c1c6decde15fdfb578220fd 100644 (file)
--- a/tig.c
+++ b/tig.c
REQ_(PREVIOUS, "Move to previous"), \
REQ_(VIEW_NEXT, "Move focus to next view"), \
REQ_(REFRESH, "Reload and refresh"), \
+ REQ_(MAXIMIZE, "Maximize the current view"), \
REQ_(VIEW_CLOSE, "Close the current view"), \
REQ_(QUIT, "Close all views and quit"), \
\
{ KEY_UP, REQ_PREVIOUS },
{ KEY_DOWN, REQ_NEXT },
{ 'R', REQ_REFRESH },
+ { 'M', REQ_MAXIMIZE },
/* Cursor navigation */
{ 'k', REQ_MOVE_UP },
struct view_ops *ops; /* View operations */
enum keymap keymap; /* What keymap does this view have */
+ bool git_dir; /* Whether the view requires a git directory. */
char cmd[SIZEOF_STR]; /* Command buffer */
char ref[SIZEOF_REF]; /* Hovered commit reference */
static struct view_ops status_ops;
static struct view_ops stage_ops;
-#define VIEW_STR(name, cmd, env, ref, ops, map) \
- { name, cmd, #env, ref, ops, map}
+#define VIEW_STR(name, cmd, env, ref, ops, map, git) \
+ { name, cmd, #env, ref, ops, map, git }
-#define VIEW_(id, name, ops, ref) \
- VIEW_STR(name, TIG_##id##_CMD, TIG_##id##_CMD, ref, ops, KEYMAP_##id)
+#define VIEW_(id, name, ops, git, ref) \
+ VIEW_STR(name, TIG_##id##_CMD, TIG_##id##_CMD, ref, ops, KEYMAP_##id, git)
static struct view views[] = {
- VIEW_(MAIN, "main", &main_ops, ref_head),
- VIEW_(DIFF, "diff", &pager_ops, ref_commit),
- VIEW_(LOG, "log", &pager_ops, ref_head),
- VIEW_(TREE, "tree", &tree_ops, ref_commit),
- VIEW_(BLOB, "blob", &blob_ops, ref_blob),
- VIEW_(BLAME, "blame", &blame_ops, ref_commit),
- VIEW_(HELP, "help", &help_ops, ""),
- VIEW_(PAGER, "pager", &pager_ops, "stdin"),
- VIEW_(STATUS, "status", &status_ops, ""),
- VIEW_(STAGE, "stage", &stage_ops, ""),
+ VIEW_(MAIN, "main", &main_ops, TRUE, ref_head),
+ VIEW_(DIFF, "diff", &pager_ops, TRUE, ref_commit),
+ VIEW_(LOG, "log", &pager_ops, TRUE, ref_head),
+ VIEW_(TREE, "tree", &tree_ops, TRUE, ref_commit),
+ VIEW_(BLOB, "blob", &blob_ops, TRUE, ref_blob),
+ VIEW_(BLAME, "blame", &blame_ops, TRUE, ref_commit),
+ VIEW_(HELP, "help", &help_ops, FALSE, ""),
+ VIEW_(PAGER, "pager", &pager_ops, FALSE, "stdin"),
+ VIEW_(STATUS, "status", &status_ops, TRUE, ""),
+ VIEW_(STAGE, "stage", &stage_ops, TRUE, ""),
};
-#define VIEW(req) (&views[(req) - REQ_OFFSET - 1])
+#define VIEW(req) (&views[(req) - REQ_OFFSET - 1])
+#define VIEW_REQ(view) ((view) - views + REQ_OFFSET + 1)
#define foreach_view(view, i) \
for (i = 0; i < ARRAY_SIZE(views) && (view = &views[i]); i++)
return;
}
+ if (view->git_dir && !opt_git_dir[0]) {
+ report("The %s view is disabled in pager view", view->name);
+ return;
+ }
+
if (split) {
display[1] = view;
if (!backgrounded)
report("Refreshing is not yet supported for the %s view", view->name);
break;
+ case REQ_MAXIMIZE:
+ if (displayed_views() == 2)
+ open_view(view, VIEW_REQ(view), OPEN_DEFAULT);
+ break;
+
case REQ_TOGGLE_LINENO:
opt_line_number = !opt_line_number;
redraw_display();