Skip to content

Commit

Permalink
Minor cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
koutcher committed Jul 9, 2022
1 parent 10eb97a commit 162976f
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 48 deletions.
7 changes: 0 additions & 7 deletions src/blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@

/*
* Blame backend
*
* Loading the blame view is a two phase job:
*
* 1. File content is read either using argv_env.file from the
* filesystem or using git-cat-file.
* 2. Then blame information is incrementally added by
* reading output from git-blame.
*/

struct blame_history_state {
Expand Down
11 changes: 3 additions & 8 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,8 @@ update_views(void)

foreach_view (view, i) {
update_view(view);
if (view->pipe)
if (view->pipe ||
(view_is_displayed(view) && view->watch.changed))
is_loading = true;
}

Expand Down Expand Up @@ -785,13 +786,6 @@ get_input(int prompt_position, struct key *key)

if (update_views())
delay = 0;
else
/* Check there is no pending update after update_views() */
foreach_displayed_view (view, i)
if (view->watch.changed) {
delay = 0;
break;
}

/* Update the cursor position. */
if (prompt_position) {
Expand Down Expand Up @@ -850,6 +844,7 @@ get_input(int prompt_position, struct key *key)
* - Ctrl-Z is handled separately for job control.
* - Ctrl-m is the same as Return/Enter.
* - Ctrl-i is the same as Tab.
* - Ctrl-[ is the same as Esc.
*
* For all other key values in the range the Ctrl flag
* is set and the key value is updated to the proper
Expand Down
33 changes: 17 additions & 16 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,24 +579,25 @@ parse_option(struct option_info *option, const char *prefix, const char *arg)
if (!enum_name_prefixed(name, sizeof(name), prefix, option->name))
return error("Failed to parse option");

if (!strcmp("show-notes", name)) {
bool *value = option->value;
enum status_code res;

if (parse_bool(option->value, arg) == SUCCESS)
return SUCCESS;

*value = true;
string_copy(opt_notes_arg, NOTES_EQ_ARG);
res = parse_string(opt_notes_arg + STRING_SIZE(NOTES_EQ_ARG), arg,
sizeof(opt_notes_arg) - STRING_SIZE(NOTES_EQ_ARG));
if (res == SUCCESS && !opt_notes_arg[STRING_SIZE(NOTES_EQ_ARG)])
opt_notes_arg[STRING_SIZE(NOTES_ARG)] = 0;
return res;
}
if (!strcmp(option->type, "bool")) {
if (!strcmp("show-notes", name)) {
bool *value = option->value;
enum status_code res;

if (parse_bool(option->value, arg) == SUCCESS)
return SUCCESS;

*value = true;
string_copy(opt_notes_arg, NOTES_EQ_ARG);
res = parse_string(opt_notes_arg + STRING_SIZE(NOTES_EQ_ARG), arg,
sizeof(opt_notes_arg) - STRING_SIZE(NOTES_EQ_ARG));
if (res == SUCCESS && !opt_notes_arg[STRING_SIZE(NOTES_EQ_ARG)])
opt_notes_arg[STRING_SIZE(NOTES_ARG)] = 0;
return res;
}

if (!strcmp(option->type, "bool"))
return parse_bool(option->value, arg);
}

if (!strcmp(option->type, "double"))
return parse_step(option->value, arg);
Expand Down
7 changes: 0 additions & 7 deletions src/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,6 @@ strcmp_numeric(const char *s1, const char *s2)

/*
* Unicode / UTF-8 handling
*
* NOTE: Much of the following code for dealing with Unicode is derived from
* ELinks' UTF-8 code developed by Scrool <[email protected]>. Origin file is
* src/intl/charset.c from the UTF-8 branch commit elinks-0.11.0-g31f2c28.
*
* unicode_width() is driven by xterm's mk_wcwidth(), which is the work of
* Markus Kuhn and Thomas Dickey.
*/

int
Expand Down
8 changes: 2 additions & 6 deletions src/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,8 @@ file_finder_move(struct file_finder *finder, int direction)
else
finder->pos.lineno += direction;

if (finder->pos.lineno >= finder->lines) {
if (finder->lines > 0)
finder->pos.lineno = finder->lines - 1;
else
finder->pos.lineno = 0;
}
if (finder->pos.lineno >= finder->lines)
finder->pos.lineno = finder->lines > 0 ? finder->lines - 1 : 0;

if (finder->pos.offset + finder->height <= finder->pos.lineno)
finder->pos.offset = finder->pos.lineno - (finder->height / 2);
Expand Down
4 changes: 2 additions & 2 deletions src/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ split_view(struct view *prev, struct view *view)
}

if (view_has_flags(prev, VIEW_FLEX_WIDTH) && vsplit && nviews == 1)
load_view(prev, NULL, OPEN_RELOAD);
reload_view(prev);
}

void
Expand All @@ -794,7 +794,7 @@ maximize_view(struct view *view, bool redraw)
}

if (view_has_flags(view, VIEW_FLEX_WIDTH) && vsplit && nviews > 1)
load_view(view, NULL, OPEN_RELOAD);
reload_view(view);
}

void
Expand Down
6 changes: 4 additions & 2 deletions tigrc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ set start-on-head = no # Start with cursor on HEAD commit
set refresh-mode = auto # Enum: manual, auto, after-command, periodic
set refresh-interval = 10 # Interval in seconds between refreshes
set ignore-case = no # Enum: no, yes, smart-case
# Ignore case when searching? Smart-case option will
# Ignore case when searching?
set wrap-search = yes # Wrap around to top/bottom of view when searching
set focus-child = yes # Move focus to child view when opened?
set send-child-enter = yes # Propagate "enter" keypresses to child views?
Expand Down Expand Up @@ -298,12 +298,13 @@ bind generic i :toggle sort-field # Toggle field to sort by
bind generic <Hash> :toggle line-number # Toggle line numbers
bind generic D :toggle date # Toggle date display
bind generic A :toggle author # Toggle author display
#bind generic ??? :toggle commit-title-display
# bind generic ??? :toggle commit-title-display
# Toggle commit title display
bind generic ~ :toggle line-graphics # Toggle (line) graphics mode
bind generic F :toggle file-name # Toggle file name display
# bind generic ??? :toggle show-changes # Toggle local changes display in the main view
bind generic W :toggle ignore-space # Toggle ignoring whitespace in diffs
# bind generic ??? :toggle ignore-case # Toggle ignoring case when searching
# bind generic ??? :toggle commit-order # Toggle commit ordering
bind generic X :toggle id # Toggle commit ID display
bind generic $ :toggle commit-title-overflow
Expand All @@ -313,6 +314,7 @@ bind generic $ :toggle commit-title-overflow
# bind generic ??? :toggle status-show-untracked-dirs
# Toggle display of file in untracked directories
# bind generic ??? :toggle vertical-split # Toggle vertical split
# bind generic ??? :toggle word-diff # Toggle word diff
bind generic % :toggle file-filter # Toggle filtering by pathspecs in file-args
bind generic ^ :toggle rev-filter # Toggle filtering by revisions in rev-args

Expand Down

0 comments on commit 162976f

Please sign in to comment.