summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Fonseca <jonas.fonseca@gmail.com>2014-03-14 17:57:34 -0400
committerJonas Fonseca <jonas.fonseca@gmail.com>2014-03-14 17:57:34 -0400
commita2558ba539e89af8e437059d101e72b554f35161 (patch)
treeb76ac6ff1c9c9f416ef3f418eefeb1ec2cea9ad9
parent3048381e91a18344d142210bff44b97199de3048 (diff)
Allow prompt toggle commands to both reset display and reload
When changing the vertical split setting the diff stat was not automatically updated to fit the full length of the view. By introducing a proper VIEW_RESET_DISPLAY flag and using that when toggling the vertical-split option the diff view is now automatically reloaded so that the diff stat has the correct width.
-rw-r--r--include/tig/options.h4
-rw-r--r--include/tig/view.h2
-rw-r--r--src/prompt.c18
3 files changed, 12 insertions, 12 deletions
diff --git a/include/tig/options.h b/include/tig/options.h
index 3884569f..699acc55 100644
--- a/include/tig/options.h
+++ b/include/tig/options.h
@@ -50,11 +50,11 @@
_(show_notes, bool, VIEW_NO_FLAGS) \
_(show_refs, bool, VIEW_NO_FLAGS) \
_(show_rev_graph, bool, VIEW_LOG_LIKE) \
- _(split_view_height, double, VIEW_FLAG_RESET_DISPLAY) \
+ _(split_view_height, double, VIEW_RESET_DISPLAY) \
_(status_untracked_dirs, bool, VIEW_STATUS_LIKE) \
_(tab_size, int, VIEW_NO_FLAGS) \
_(title_overflow, int, VIEW_NO_FLAGS) \
- _(vertical_split, enum vertical_split, VIEW_FLAG_RESET_DISPLAY) \
+ _(vertical_split, enum vertical_split, VIEW_RESET_DISPLAY | VIEW_DIFF_LIKE) \
_(wrap_lines, bool, VIEW_NO_FLAGS) \
#define DEFINE_OPTION_EXTERNS(name, type, flags) extern type opt_##name;
diff --git a/include/tig/view.h b/include/tig/view.h
index a3d202c9..64876869 100644
--- a/include/tig/view.h
+++ b/include/tig/view.h
@@ -53,6 +53,8 @@ enum view_flag {
VIEW_STATUS_LIKE = 1 << 12,
VIEW_REFRESH = 1 << 13,
VIEW_CUSTOM_DIGITS = 1 << 14,
+
+ VIEW_RESET_DISPLAY = 1 << 31,
};
#define view_has_flags(view, flag) ((view)->ops->flags & (flag))
diff --git a/src/prompt.c b/src/prompt.c
index 6aea5307..a2d01809 100644
--- a/src/prompt.c
+++ b/src/prompt.c
@@ -323,8 +323,6 @@ prompt_toggle_option(struct view *view, const char *argv[],
return toggle->flags;
}
-#define VIEW_FLAG_RESET_DISPLAY ((enum view_flag) -1)
-
static enum view_flag
prompt_toggle(struct view *view, const char *argv[], char msg[SIZEOF_STR])
{
@@ -416,16 +414,16 @@ run_prompt_command(struct view *view, const char *argv[])
enum view_flag flags = prompt_toggle(view, argv, action);
int i;
- if (flags == VIEW_FLAG_RESET_DISPLAY) {
+ if (flags & VIEW_RESET_DISPLAY) {
resize_display();
redraw_display(TRUE);
- } else {
- foreach_displayed_view(view, i) {
- if (view_has_flags(view, flags) && !view->unrefreshable)
- reload_view(view);
- else
- redraw_view(view);
- }
+ }
+
+ foreach_displayed_view(view, i) {
+ if (view_has_flags(view, flags) && !view->unrefreshable)
+ reload_view(view);
+ else
+ redraw_view(view);
}
if (*action)