Skip to content

Commit

Permalink
Add line-graphics = auto
Browse files Browse the repository at this point in the history
Closes #834
  • Loading branch information
koutcher committed Jun 4, 2020
1 parent b878abf commit 7078ebb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ master
Improvements:

- Jump from blame to commit. (#355)
- Add line-graphics = auto. (#834)

Bug fixes:

Expand Down
5 changes: 3 additions & 2 deletions doc/tigrc.5.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,10 @@ The following variables can be set:
- replace : A replaced reference.
- branch : Any other reference.
'line-graphics' (mixed) [ascii|default|utf-8|<bool>]::
'line-graphics' (mixed) [ascii|default|utf-8|auto|<bool>]::
What type of character graphics for line drawing.
What type of character graphics for line drawing. "auto" means "utf-8"
if the locale is UTF-8, "default" otherwise.
'truncation-delimiter' (mixed) [utf-8|<string>]::
Expand Down
20 changes: 17 additions & 3 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,24 @@ parse_option(struct option_info *option, const char *prefix, const char *arg)
return parse_step(option->value, arg);

if (!strncmp(option->type, "enum", 4)) {
const char *type = option->type + STRING_SIZE("enum ");
const struct enum_map *map = find_enum_map(type);
if (!strcmp(name, "line-graphics") && !strcasecmp(arg, "auto")) {
const char *locale;
int *value = option->value;

return parse_enum(name, option->value, arg, map);
if ((((locale = getenv("LC_ALL")) && *locale) ||
((locale = getenv("LC_CTYPE")) && *locale) ||
((locale = getenv("LANG")) && *locale)) &&
(strstr(locale, "UTF") || strstr(locale, "utf")))
*value = GRAPHIC_UTF_8;
else
*value = GRAPHIC_DEFAULT;
return SUCCESS;
} else {
const char *type = option->type + STRING_SIZE("enum ");
const struct enum_map *map = find_enum_map(type);

return parse_enum(name, option->value, arg, map);
}
}

if (!strcmp(option->type, "int")) {
Expand Down
2 changes: 1 addition & 1 deletion tigrc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ set show-changes = yes # Show changes commits in the main view?
set show-untracked = yes # Show also untracked changes?
set wrap-lines = no # Wrap long lines in pager views?
set tab-size = 8 # Number of spaces to use when expanding tabs
set line-graphics = default # Enum: ascii, default, utf-8
set line-graphics = default # Enum: ascii, default, utf-8, auto
set truncation-delimiter = ~ # Character drawn for truncations, or "utf-8"

# Format reference names based on type.
Expand Down

0 comments on commit 7078ebb

Please sign in to comment.