Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add line-graphics = auto #1019

Merged
merged 1 commit into from
Dec 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Improvements:

- Jump from blame to commit. (#355)
- Start blame of an uncommitted deleted line from HEAD so the line's origin can be traced. (#1008)
- 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