diff --git a/doc/tigrc.5.adoc b/doc/tigrc.5.adoc index e48217342..c391a06bb 100644 --- a/doc/tigrc.5.adoc +++ b/doc/tigrc.5.adoc @@ -274,11 +274,18 @@ The following variables can be set: Hide the leading `+` and `-` signs in diff output. Copy-paste of lines from the diff view may be aided by this option. Enabling this only makes - sense when coloring is used to distinguish added and removed lines. - Removed and added lines are indicated in the first column by a space - highlighted by the color `diff-add-highlight` or `diff-del-highlight`, - respectively. Keeping the `standout` (reverse) property set for these is - suggested, as white space is otherwise invisible. Off by default. + sense when coloring is used to distinguish added and removed lines. Off + by default. + +'diff-column-highlight' (enum) [no|all|only-empty]:: + + Highlight the left-most column in diff views visually when the option + 'diff-hide-signs' is in effect. All added/removed lines can be + highlighted, or only empty lines. Changed lines are indicated in the + first column by a space highlighted by the color `diff-add-highlight` or + `diff-del-highlight`, respectively. Keeping the `standout` (reverse) + property set for these is suggested, as white space is otherwise + invisible. Default is to highlight all lines. 'diff-highlight' (mixed):: diff --git a/include/tig/options.h b/include/tig/options.h index 3226edd0d..60fb8abf5 100644 --- a/include/tig/options.h +++ b/include/tig/options.h @@ -38,6 +38,7 @@ typedef struct view_column *view_settings; _(diff_context, int, VIEW_DIFF_LIKE) \ _(diff_noprefix, bool, VIEW_NO_FLAGS) \ _(diff_hide_signs, bool, VIEW_NO_FLAGS) \ + _(diff_column_highlight, enum diff_column_highlight, VIEW_NO_FLAGS) \ _(diff_options, const char **, VIEW_DIFF_LIKE) \ _(diff_highlight, const char *, VIEW_DIFF_LIKE) \ _(diff_view, view_settings, VIEW_NO_FLAGS) \ diff --git a/include/tig/types.h b/include/tig/types.h index 6bc481af7..4f7ecbe8a 100644 --- a/include/tig/types.h +++ b/include/tig/types.h @@ -161,6 +161,11 @@ bool map_enum_do(const struct enum_map_entry *map, size_t map_size, int *value, _(REFRESH_MODE, AFTER_COMMAND), \ _(REFRESH_MODE, PERIODIC), +#define DIFF_COLUMN_HIGHLIGHT_ENUM(_) \ + _(DIFF_COLUMN_HIGHLIGHT, NO), \ + _(DIFF_COLUMN_HIGHLIGHT, ALL), \ + _(DIFF_COLUMN_HIGHLIGHT, ONLY_EMPTY) + #define ENUM_INFO(_) \ _(author, AUTHOR_ENUM) \ _(commit_order, COMMIT_ORDER_ENUM) \ @@ -176,6 +181,7 @@ bool map_enum_do(const struct enum_map_entry *map, size_t map_size, int *value, _(reference_type, REFERENCE_ENUM) \ _(refresh_mode, REFRESH_MODE_ENUM) \ _(status_label, STATUS_LABEL_ENUM) \ + _(diff_column_highlight, DIFF_COLUMN_HIGHLIGHT_ENUM) \ #define DEFINE_ENUMS(name, macro) DEFINE_ENUM(name, macro) ENUM_INFO(DEFINE_ENUMS) diff --git a/src/draw.c b/src/draw.c index d25f9b013..e0d4ce096 100644 --- a/src/draw.c +++ b/src/draw.c @@ -80,14 +80,15 @@ draw_chars(struct view *view, enum line_type type, const char *string, int lengt view->col == 0 && (type == LINE_DIFF_ADD || type == LINE_DIFF_DEL) ) { - /* Mark first column by color-only for add/del line */ - if (type == LINE_DIFF_ADD) - set_view_attr(view, LINE_DIFF_ADD_HIGHLIGHT); - else if (type == LINE_DIFF_DEL) - set_view_attr(view, LINE_DIFF_DEL_HIGHLIGHT); - waddnstr(view->win, " ", 1); - - /* Add the actual diff line */ + if (opt_diff_column_highlight != DIFF_COLUMN_HIGHLIGHT_NO) { + if (type == LINE_DIFF_ADD) + set_view_attr(view, LINE_DIFF_ADD_HIGHLIGHT); + else if (type == LINE_DIFF_DEL) + set_view_attr(view, LINE_DIFF_DEL_HIGHLIGHT); + if (opt_diff_column_highlight == DIFF_COLUMN_HIGHLIGHT_ALL || len == 1) { + waddnstr(view->win, " ", 1); + } + } set_view_attr(view, type); waddnstr(view->win, string+1, len-1); } else { diff --git a/tigrc b/tigrc index dc04ee5a4..e1588561e 100644 --- a/tigrc +++ b/tigrc @@ -115,6 +115,7 @@ set show-notes = yes # When non-bool passed as `--show-notes=...` (diff) #set diff-highlight = true # String (or bool): Path to diff-highlight script, # defaults to `diff-highlight`. set diff-hide-signs = no # Hide diff signs (+ and -) at the start of diff lines +set diff-column-highlight = all # Enum: no, all, only-empty #set blame-options = -C -C -C # User-defined options for `tig blame` (git-blame) #set log-options = --pretty=raw # User-defined options for `tig log` (git-log) #set main-options = -n 1000 # User-defined options for `tig` (git-log)