Skip to content

Commit 0db7959

Browse files
committed
Add color for cursor in backgrounded view
Closes #1374
1 parent 0199bab commit 0db7959

File tree

7 files changed

+30
-7
lines changed

7 files changed

+30
-7
lines changed

NEWS.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ Bug fixes:
88

99
- Initialise %(head) from command line arguments. (#1366)
1010
- Make `$GIT_EDITOR` value interpreted by the shell. (#1367)
11+
- Use correct line from recursively blamed commit. (#1369, #1370)
12+
- Use correct line when using `:parent` in blame view. (#1372)
13+
- Fix the incorrect line shift after stage file. (#1371)
14+
15+
Improvements:
16+
17+
- Add color for cursor in backgrounded view. (#1374)
1118

1219
tig-2.5.12
1320
----------

doc/tigrc.5.adoc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,8 @@ setting the *default* color option.
10601060
[frame="none",grid="none",cols="25<m,75<"]
10611061
|=============================================================================
10621062
|default |Override default terminal colors (see above).
1063-
|cursor |The cursor line.
1063+
|cursor |The cursor line for the current view.
1064+
|cursor-blur |The cursor line of any backgrounded view.
10641065
|status |The status window showing info messages.
10651066
|title-focus |The title window for the current view.
10661067
|title-blur |The title window of any backgrounded view.
@@ -1097,8 +1098,12 @@ setting the *default* color option.
10971098
|main-tracked |Label of the remote tracked by the current branch.
10981099
|main-tag |Label of a signed tag.
10991100
|main-local-tag |Label of a local tag.
1100-
|main-ref |Label of any other reference.
1101+
|main-ref |Label of a branch.
11011102
|main-replace |Label of replaced reference.
1103+
|main-stash |Label of the stash.
1104+
|main-note |Label of notes.
1105+
|main-prefetch |Label of reference prefetched by `git maintenance`.
1106+
|main-other |Label of any other reference.
11021107
|=============================================================================
11031108
11041109
.Status view

include/tig/line.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ struct ref;
5050
_(COMMITTER, "committer "), \
5151
_(DEFAULT, ""), \
5252
_(CURSOR, ""), \
53+
_(CURSOR_BLUR, ""), \
5354
_(STATUS, ""), \
5455
_(DELIMITER, ""), \
5556
_(DATE, ""), \

src/draw.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "tig/graph.h"
1616
#include "tig/draw.h"
1717
#include "tig/options.h"
18+
#include "tig/display.h"
1819
#include "compat/hashtab.h"
1920

2021
static const enum line_type palette_colors[] = {
@@ -667,7 +668,7 @@ draw_view_line(struct view *view, unsigned int lineno)
667668
line->dirty = line->cleareol = 0;
668669

669670
if (selected) {
670-
set_view_attr(view, LINE_CURSOR);
671+
set_view_attr(view, view == display[current_view] ? LINE_CURSOR : LINE_CURSOR_BLUR);
671672
line->selected = true;
672673
view->ops->select(view, line);
673674
}

src/tig.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,16 +244,22 @@ view_driver(struct view *view, enum request request)
244244
{
245245
int nviews = displayed_views();
246246
int next_view = nviews ? (current_view + 1) % nviews : current_view;
247+
struct view *next = display[next_view];
247248

248249
if (next_view == current_view) {
249250
report("Only one view is displayed");
250251
break;
251252
}
252253

253254
current_view = next_view;
254-
/* Blur out the title of the previous view. */
255+
/* Blur out the title and cursor of the previous view. */
255256
update_view_title(view);
257+
draw_view_line(view, view->pos.lineno - view->pos.offset);
258+
wnoutrefresh(view->win);
259+
/* Brighten the title and cursor of the next view. */
256260
report_clear();
261+
draw_view_line(next, next->pos.lineno - next->pos.offset);
262+
wnoutrefresh(next->win);
257263
break;
258264
}
259265
case REQ_REFRESH:
@@ -613,9 +619,6 @@ find_clicked_view(MEVENT *event)
613619

614620
if (beg_y <= event->y && event->y < beg_y + view->height
615621
&& beg_x <= event->x && event->x < beg_x + view->width) {
616-
if (i != current_view) {
617-
current_view = i;
618-
}
619622
return view;
620623
}
621624
}
@@ -636,6 +639,9 @@ handle_mouse_event(void)
636639
if (!view)
637640
return REQ_NONE;
638641

642+
if (view != display[current_view])
643+
return REQ_VIEW_NEXT;
644+
639645
#ifdef BUTTON5_PRESSED
640646
if (event.bstate & (BUTTON2_PRESSED | BUTTON5_PRESSED))
641647
#else

src/view.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,8 @@ split_view(struct view *prev, struct view *view)
766766
if (view != prev && view_is_displayed(prev)) {
767767
/* "Blur" the previous view. */
768768
update_view_title(prev);
769+
draw_view_line(prev, prev->pos.lineno - prev->pos.offset);
770+
wnoutrefresh(prev->win);
769771
}
770772

771773
if (view_has_flags(prev, VIEW_FLEX_WIDTH) && vsplit && nviews == 1)

tigrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ color " Original-patch-by:" yellow default
413413
color " Inspired-by:" yellow default
414414
color default default default normal
415415
color cursor white green bold
416+
color cursor-blur white green
416417
color status green default
417418
color delimiter magenta default
418419
color date blue default

0 commit comments

Comments
 (0)