tweak view organization in tog; add a fullscreen toggle
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906
diff --git a/tog/tog.1 b/tog/tog.1
index 4e27b78..49a3a39 100644
--- a/tog/tog.1
+++ b/tog/tog.1
@@ -31,14 +31,7 @@ This repository format is described in
.Xr git-repository 5 .
.Pp
.Nm
-supports several types of views which display repository data.
-An arbitrary number of views may be opened simultaneously by
-navigating the repository with
-.Nm .
-Sometimes, if one view is opened from another view, the child view
-is linked to its parent view and both views will keep their data
-display in sync.
-The supported views are:
+supports several types of views which display repository data:
.Bl -tag -width Ds
.It Cm log view
Displays commits in the repository's history.
@@ -63,11 +56,11 @@ Quit
.It Cm q
Quit the view which is in focus.
.It Cm Tab
-Switch focus to the next view.
-Cycles through all open views.
+Switch focus to the next view. Cycles through all views.
.It Cm ~
-Switch focus to the previous view.
-Cycles through all open views.
+Switch focus to the previous view. Cycles through all views.
+.It Cm f
+Toggle fullscreen mode for the view which is in focus.
.El
.Pp
Global options must precede the command name, and are as follows:
@@ -100,8 +93,6 @@ Move the selection cursor up.
Switch to the
.Cm diff
view showing file changes made in the currently selected commit.
-The diff view is linked to the log view so either view will be
-updated when the other switches to a different commit.
.It Cm t
Switch to the
.Cm tree
@@ -142,12 +133,6 @@ are as follows:
Scroll down.
.It Cm Up-arrow, k, Page-up
Scroll up.
-.It [
-Switch to the previous commit in parent
-.Cm log view .
-.It ]
-Switch to the next commit in parent
-.Cm log view .
.El
.It Cm blame [ Fl c Ar commit ] [ Fl r Ar repository-path ] Ar path
Display line-by-line history of a file at the specified path.
diff --git a/tog/tog.c b/tog/tog.c
index 049b067..d96917f 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -216,6 +216,8 @@ struct tog_view {
} state;
const struct got_error *(*show)(struct tog_view *);
+ const struct got_error *(*update_siblings)(int *, struct tog_view *,
+ struct tog_view*);
const struct got_error *(*input)(struct tog_view **,
struct tog_view **, struct tog_view *, int);
const struct got_error *(*set_child)(struct tog_view *,
@@ -226,6 +228,8 @@ struct tog_view {
static const struct got_error *open_diff_view(struct tog_view *,
struct got_object *, struct got_object *, struct got_repository *);
static const struct got_error *show_diff_view(struct tog_view *);
+static const struct got_error *update_siblings_diff_view(int *,
+ struct tog_view *, struct tog_view *);
static const struct got_error *input_diff_view(struct tog_view **,
struct tog_view **, struct tog_view *, int);
static const struct got_error* close_diff_view(struct tog_view *);
@@ -233,6 +237,8 @@ static const struct got_error* close_diff_view(struct tog_view *);
static const struct got_error *open_log_view(struct tog_view *,
struct got_object_id *, struct got_repository *, const char *);
static const struct got_error * show_log_view(struct tog_view *);
+static const struct got_error *update_siblings_log_view(int *,
+ struct tog_view *, struct tog_view *);
static const struct got_error *input_log_view(struct tog_view **,
struct tog_view **, struct tog_view *, int);
static const struct got_error *close_log_view(struct tog_view *);
@@ -242,6 +248,8 @@ static const struct got_error* set_child_log_view(struct tog_view *,
static const struct got_error *open_blame_view(struct tog_view *, char *,
struct got_object_id *, struct got_repository *);
static const struct got_error *show_blame_view(struct tog_view *);
+static const struct got_error *update_siblings_blame_view(int *,
+ struct tog_view *, struct tog_view *);
static const struct got_error *input_blame_view(struct tog_view **,
struct tog_view **, struct tog_view *, int);
static const struct got_error *close_blame_view(struct tog_view *);
@@ -249,6 +257,8 @@ static const struct got_error *close_blame_view(struct tog_view *);
static const struct got_error *open_tree_view(struct tog_view *,
struct got_tree_object *, struct got_object_id *, struct got_repository *);
static const struct got_error *show_tree_view(struct tog_view *);
+static const struct got_error *update_siblings_tree_view(int *,
+ struct tog_view *, struct tog_view *);
static const struct got_error *input_tree_view(struct tog_view **,
struct tog_view **, struct tog_view *, int);
static const struct got_error *close_tree_view(struct tog_view *);
@@ -258,10 +268,6 @@ view_close(struct tog_view *view)
{
const struct got_error *err = NULL;
- if (view->child)
- view->child->parent = NULL;
- if (view->parent)
- view->parent->child = NULL;
if (view->close)
err = view->close(view);
if (view->panel)
@@ -274,19 +280,13 @@ view_close(struct tog_view *view)
static struct tog_view *
view_open(int nlines, int ncols, int begin_y, int begin_x,
- struct tog_view *parent, enum tog_view_type type)
+ enum tog_view_type type)
{
struct tog_view *view = calloc(1, sizeof(*view));
if (view == NULL)
return NULL;
- if (begin_x == 0 && parent && parent->ncols - 80 > 10)
- begin_x = parent->ncols - 80;
-
- view->parent = parent;
- if (parent)
- parent->child = view;
view->type = type;
view->lines = LINES;
view->cols = COLS;
@@ -300,7 +300,8 @@ view_open(int nlines, int ncols, int begin_y, int begin_x,
return NULL;
}
view->panel = new_panel(view->window);
- if (view->panel == NULL) {
+ if (view->panel == NULL ||
+ set_panel_userptr(view->panel, view) != OK) {
view_close(view);
return NULL;
}
@@ -310,62 +311,106 @@ view_open(int nlines, int ncols, int begin_y, int begin_x,
}
static const struct got_error *
-view_show(struct tog_view *view)
+view_show(struct tog_view *view, struct tog_view_list_head *views)
{
const struct got_error *err;
-
- if (view->parent) {
- err = view->parent->show(view->parent);
- if (err)
- return err;
- show_panel(view->parent->panel);
- }
+ struct tog_view *v;
err = view->show(view);
if (err)
return err;
- show_panel(view->panel);
- if (view->child && view->child->begin_x > view->begin_x) {
- err = view->child->show(view->child);
+ if (!view->focussed)
+ return NULL;
+
+ TAILQ_FOREACH(v, views, entry) {
+ int updated = 0;
+ err = view->update_siblings(&updated, view, v);
if (err)
return err;
- show_panel(view->child->panel);
+ if (updated) {
+ err = v->show(v);
+ if (err)
+ return err;
+ }
}
- update_panels();
- doupdate();
-
return err;
}
+static int
+view_split_begin_x(int begin_x)
+{
+ if (begin_x > 0)
+ return 0;
+ return (COLS >= 120 ? COLS/2 : 0);
+}
+
static const struct got_error *
view_resize(struct tog_view *view)
{
int nlines, ncols;
- while (view) {
- if (view->lines > LINES)
- nlines = view->nlines - (view->lines - LINES);
- else
- nlines = view->nlines + (LINES - view->lines);
+ if (view->lines > LINES)
+ nlines = view->nlines - (view->lines - LINES);
+ else
+ nlines = view->nlines + (LINES - view->lines);
- if (view->cols > COLS)
- ncols = view->ncols - (view->cols - COLS);
- else
- ncols = view->ncols + (COLS - view->cols);
+ if (view->cols > COLS)
+ ncols = view->ncols - (view->cols - COLS);
+ else
+ ncols = view->ncols + (COLS - view->cols);
- if (wresize(view->window, nlines, ncols) == ERR)
- return got_error_from_errno();
- replace_panel(view->panel, view->window);
+ if (wresize(view->window, nlines, ncols) == ERR)
+ return got_error_from_errno();
+ replace_panel(view->panel, view->window);
- view->nlines = nlines;
- view->ncols = ncols;
- view->lines = LINES;
- view->cols = COLS;
+ view->nlines = nlines;
+ view->ncols = ncols;
+ view->lines = LINES;
+ view->cols = COLS;
- view = view->parent;
- }
+ return NULL;
+}
+
+static const struct got_error *
+view_splitscreen(struct tog_view *view)
+{
+ const struct got_error *err = NULL;
+
+ view->begin_y = 0;
+ view->begin_x = view_split_begin_x(0);
+ view->nlines = LINES;
+ view->ncols = COLS - view->begin_x;
+ view->lines = LINES;
+ view->cols = COLS;
+ err = view_resize(view);
+ if (err)
+ return err;
+
+ if (mvwin(view->window, view->begin_y, view->begin_x) == ERR)
+ return got_error_from_errno();
+
+ return NULL;
+}
+
+static const struct got_error *
+view_fullscreen(struct tog_view *view)
+{
+ const struct got_error *err = NULL;
+
+ view->begin_x = 0;
+ view->begin_y = 0;
+ view->nlines = LINES;
+ view->ncols = COLS;
+ view->lines = LINES;
+ view->cols = COLS;
+ err = view_resize(view);
+ if (err)
+ return err;
+
+ if (mvwin(view->window, view->begin_y, view->begin_x) == ERR)
+ return got_error_from_errno();
return NULL;
}
@@ -376,11 +421,12 @@ view_input(struct tog_view **new, struct tog_view **dead,
struct tog_view_list_head *views)
{
const struct got_error *err = NULL;
- struct tog_view *next, *prev;
+ struct tog_view *next, *prev, *v;
int ch;
*new = NULL;
*dead = NULL;
+ *focus = NULL;
nodelay(stdscr, FALSE);
ch = wgetch(view->window);
@@ -394,8 +440,6 @@ view_input(struct tog_view **new, struct tog_view **dead,
*focus = next;
else
*focus = TAILQ_FIRST(views);
- view->focussed = 0;
- (*focus)->focussed = 1;
break;
case '~':
prev = TAILQ_PREV(view, tog_view_list_head, entry);
@@ -403,8 +447,6 @@ view_input(struct tog_view **new, struct tog_view **dead,
*focus = prev;
else
*focus = TAILQ_LAST(views, tog_view_list_head);
- view->focussed = 0;
- (*focus)->focussed = 1;
break;
case 'q':
err = view->input(new, dead, view, ch);
@@ -413,11 +455,25 @@ view_input(struct tog_view **new, struct tog_view **dead,
case 'Q':
*done = 1;
break;
- case KEY_RESIZE:
- err = view_resize(view);
+ case 'f':
+ if (view->begin_x == 0)
+ err = view_splitscreen(view);
+ else
+ err = view_fullscreen(view);
if (err)
- return err;
- err = view->input(new, dead, view, ch);
+ break;
+ err = view->input(new, dead, view, KEY_RESIZE);
+ if (err)
+ break;
+ *focus = view;
+ break;
+ case KEY_RESIZE:
+ TAILQ_FOREACH(v, views, entry) {
+ err = view_resize(v);
+ if (err)
+ return err;
+ err = v->input(new, dead, v, ch);
+ }
break;
default:
err = view->input(new, dead, view, ch);
@@ -427,44 +483,44 @@ view_input(struct tog_view **new, struct tog_view **dead,
return err;
}
-static const struct got_error *
-view_set_child(struct tog_view *view, struct tog_view *child)
-{
- const struct got_error *err;
-
- if (view->set_child) {
- err = view->set_child(view, child);
- if (err)
- return err;
- }
-
- view->child = child;
- return NULL;
-}
-
void
view_vborder(struct tog_view *view)
{
- if (view->child == NULL)
+ PANEL *panel;
+ struct tog_view *view_above;
+
+ panel = panel_above(view->panel);
+ if (panel == NULL)
return;
- mvwvline(view->window, view->begin_y, view->child->begin_x - 1,
+ view_above = panel_userptr(panel);
+ mvwvline(view->window, view->begin_y, view_above->begin_x - 1,
got_locale_is_utf8() ? ACS_VLINE : '|', view->nlines);
}
int
view_needs_focus_indication(struct tog_view *view)
{
+ PANEL *panel;
+
if (!view->focussed)
return 0;
- if (view->child && view->child->begin_x > view->begin_x)
- return 1;
+ panel = panel_above(view->panel);
+ if (panel) {
+ struct tog_view *view_above = panel_userptr(panel);
+ if (view_above->begin_x > view->begin_x)
+ return 1;
+ }
- if (view->parent && view->begin_x > view->parent->begin_x)
- return 1;
+ panel = panel_below(view->panel);
+ if (panel) {
+ struct tog_view *view_below = panel_userptr(panel);
+ if (view->begin_x > view_below->begin_x)
+ return 1;
+ }
- return 0;
+ return 1;
}
static const struct got_error *
@@ -472,45 +528,41 @@ view_loop(struct tog_view *view)
{
const struct got_error *err = NULL;
struct tog_view_list_head views;
- struct tog_view *new_view, *dead_view;
+ struct tog_view *new_view, *dead_view, *focus_view, *v;
int done = 0;
TAILQ_INIT(&views);
TAILQ_INSERT_HEAD(&views, view, entry);
view->focussed = 1;
+ err = view_show(view, &views);
+ if (err)
+ return err;
+ update_panels();
+ doupdate();
while (!TAILQ_EMPTY(&views) && !done) {
- err = view_show(view);
- if (err)
- break;
- err = view_input(&new_view, &dead_view, &view, &done,
+ err = view_input(&new_view, &dead_view, &focus_view, &done,
view, &views);
if (err)
break;
if (dead_view) {
- struct tog_view *v, *t;
TAILQ_REMOVE(&views, dead_view, entry);
- TAILQ_FOREACH_SAFE(v, &views, entry, t) {
- if (v->parent == dead_view) {
- TAILQ_REMOVE(&views, v, entry);
- err = view_close(v);
- if (err)
- goto done;
- }
- }
- if (dead_view->parent)
- view = dead_view->parent;
- else
- view = TAILQ_LAST(&views, tog_view_list_head);
- if (view)
- view->focussed = 1;
err = view_close(dead_view);
if (err)
goto done;
+ if (view == dead_view) {
+ if (focus_view)
+ view = focus_view;
+ else if (!TAILQ_EMPTY(&views)) {
+ view = TAILQ_LAST(&views,
+ tog_view_list_head);
+ focus_view = view;
+ } else
+ view = NULL;
+ }
}
if (new_view) {
- struct tog_view *v, *t;
- view->focussed = 0;
+ struct tog_view *t;
/* Only allow one view per type. */
TAILQ_FOREACH_SAFE(v, &views, entry, t) {
if (v->type != new_view->type)
@@ -519,17 +571,32 @@ view_loop(struct tog_view *view)
err = view_close(v);
if (err)
goto done;
+ if (v == view)
+ view = new_view;
+ break;
}
TAILQ_INSERT_TAIL(&views, new_view, entry);
- if (new_view->parent) {
- err = view_set_child(new_view->parent, new_view);
- if (err)
- goto done;
- new_view->parent->focussed = 0;
+ focus_view = new_view;
+ }
+ if (focus_view) {
+ show_panel(focus_view->panel);
+ if (view) {
+ if (focus_view->begin_x == 0 &&
+ view->begin_x > 0 &&
+ focus_view != new_view)
+ show_panel(view->panel);
+ view->focussed = 0;
}
- view = new_view;
- view->focussed = 1;
+ focus_view->focussed = 1;
+ view = focus_view;
}
+ TAILQ_FOREACH(v, &views, entry) {
+ err = view_show(v, &views);
+ if (err)
+ break;
+ }
+ update_panels();
+ doupdate();
}
done:
while (!TAILQ_EMPTY(&views)) {
@@ -928,10 +995,10 @@ draw_commits(struct tog_view *view, struct commit_queue_entry **last,
while (entry) {
if (ncommits >= limit - 1)
break;
- if (ncommits == selected_idx)
+ if (view->focussed && ncommits == selected_idx)
wstandout(view->window);
err = draw_commit(view, entry->commit, entry->id);
- if (ncommits == selected_idx)
+ if (view->focussed && ncommits == selected_idx)
wstandend(view->window);
if (err)
break;
@@ -1005,9 +1072,8 @@ scroll_down(struct commit_queue_entry **first_displayed_entry, int maxscroll,
}
static const struct got_error *
-open_diff_view_for_commit(struct tog_view **new_view,
- struct tog_view *parent_view, struct got_object_id *commit_id,
- struct got_commit_object *commit,
+open_diff_view_for_commit(struct tog_view **new_view, int begin_x,
+ struct got_object_id *commit_id, struct got_commit_object *commit,
struct got_repository *repo)
{
const struct got_error *err;
@@ -1026,7 +1092,8 @@ open_diff_view_for_commit(struct tog_view **new_view,
goto done;
}
- diff_view = view_open(0, 0, 0, 0, parent_view, TOG_VIEW_DIFF);
+ diff_view = view_open(0, 0, 0, view_split_begin_x(begin_x),
+ TOG_VIEW_DIFF);
if (diff_view == NULL) {
err = got_error_from_errno();
goto done;
@@ -1044,7 +1111,7 @@ done:
}
static const struct got_error *
-browse_commit(struct tog_view **new_view, struct tog_view *parent_view,
+browse_commit(struct tog_view **new_view, int begin_x,
struct commit_queue_entry *entry, struct got_repository *repo)
{
const struct got_error *err = NULL;
@@ -1055,7 +1122,8 @@ browse_commit(struct tog_view **new_view, struct tog_view *parent_view,
if (err)
return err;
- tree_view = view_open(0, 0, 0, 0, parent_view, TOG_VIEW_TREE);
+ tree_view = view_open(0, 0, 0, view_split_begin_x(begin_x),
+ TOG_VIEW_TREE);
if (tree_view == NULL)
return got_error_from_errno();
@@ -1147,6 +1215,7 @@ open_log_view(struct tog_view *view, struct got_object_id *start_id,
}
view->show = show_log_view;
+ view->update_siblings = update_siblings_log_view;
view->input = input_log_view;
view->close = close_log_view;
view->set_child = set_child_log_view;
@@ -1213,16 +1282,30 @@ show_log_view(struct tog_view *view)
const struct got_error *err = NULL;
struct tog_log_view_state *s = &view->state.log;
- err = draw_commits(view, &s->last_displayed_entry,
+ return draw_commits(view, &s->last_displayed_entry,
&s->selected_entry, s->first_displayed_entry,
&s->commits, s->selected, view->nlines, s->graph,
s->repo, s->in_repo_path);
if (err)
return err;
+}
+
+static const struct got_error *
+update_siblings_log_view(int *updated, struct tog_view *view,
+ struct tog_view *sibling_view)
+{
+ const struct got_error *err = NULL;
+ struct tog_log_view_state *s = &view->state.log;
- if (view->child && view->child->type == TOG_VIEW_DIFF)
- err = update_diff_view(view->child, s->selected_entry->id,
+ switch (sibling_view->type) {
+ case TOG_VIEW_DIFF:
+ err = update_diff_view(sibling_view, s->selected_entry->id,
s->selected_entry->commit, s->repo);
+ *updated = 1;
+ break;
+ default:
+ break;
+ }
return err;
}
@@ -1299,13 +1382,13 @@ input_log_view(struct tog_view **new_view, struct tog_view **dead_view,
break;
case KEY_ENTER:
case '\r':
- err = open_diff_view_for_commit(new_view, view,
+ err = open_diff_view_for_commit(new_view, view->begin_x,
s->selected_entry->id, s->selected_entry->commit,
s->repo);
break;
case 't':
- err = browse_commit(new_view, view, s->selected_entry,
- s->repo);
+ err = browse_commit(new_view, view->begin_x,
+ s->selected_entry, s->repo);
break;
case KEY_BACKSPACE:
if (strcmp(s->in_repo_path, "/") == 0)
@@ -1313,7 +1396,8 @@ input_log_view(struct tog_view **new_view, struct tog_view **dead_view,
parent_path = dirname(s->in_repo_path);
if (parent_path && strcmp(parent_path, ".") != 0) {
struct tog_view *lv;
- lv = view_open(0, 0, 0, 0, NULL, TOG_VIEW_LOG);
+ lv = view_open(view->nlines, view->ncols,
+ view->begin_y, view->begin_x, TOG_VIEW_LOG);
if (lv == NULL)
return got_error_from_errno();
err = open_log_view(lv, s->start_id, s->repo,
@@ -1409,7 +1493,7 @@ cmd_log(int argc, char *argv[])
if (error != NULL)
goto done;
- view = view_open(0, 0, 0, 0, NULL, TOG_VIEW_LOG);
+ view = view_open(0, 0, 0, 0, TOG_VIEW_LOG);
if (view == NULL) {
error = got_error_from_errno();
goto done;
@@ -1557,6 +1641,7 @@ open_diff_view(struct tog_view *view, struct got_object *obj1,
view->state.diff.last_displayed_line = view->nlines;
view->show = show_diff_view;
+ view->update_siblings = update_siblings_diff_view;
view->input = input_diff_view;
view->close = close_diff_view;
@@ -1605,6 +1690,13 @@ show_diff_view(struct tog_view *view)
}
static const struct got_error *
+update_siblings_diff_view(int *updated, struct tog_view *view,
+ struct tog_view *sibling_view)
+{
+ return NULL;
+}
+
+static const struct got_error *
input_diff_view(struct tog_view **new_view, struct tog_view **dead_view,
struct tog_view *view, int ch)
{
@@ -1640,43 +1732,6 @@ input_diff_view(struct tog_view **new_view, struct tog_view **dead_view,
break;
}
break;
- case '[':
- case ']': {
- struct tog_log_view_state *ls;
- struct commit_queue_entry *entry;
- struct tog_view *diff_view;
-
- if (view->parent == NULL)
- break;
- if (view->parent->type != TOG_VIEW_LOG)
- break;
- ls = &view->parent->state.log;
-
- if (ch == '[') {
- entry = TAILQ_PREV(ls->selected_entry,
- commit_queue_head, entry);
- } else {
- entry = TAILQ_NEXT(ls->selected_entry, entry);
- if (entry == NULL) {
- err = fetch_next_commit(&entry,
- ls->selected_entry,
- &ls->commits, ls->graph,
- ls->repo, ls->in_repo_path);
- if (err)
- break;
- }
- }
- if (entry == NULL)
- break;
- err = open_diff_view_for_commit(&diff_view,
- view->parent, entry->id, entry->commit,
- ls->repo);
- if (err)
- break;
- *new_view = diff_view;
- *dead_view = view;
- break;
- }
default:
break;
}
@@ -1742,7 +1797,7 @@ cmd_diff(int argc, char *argv[])
if (error)
goto done;
- view = view_open(0, 0, 0, 0, NULL, TOG_VIEW_DIFF);
+ view = view_open(0, 0, 0, 0, TOG_VIEW_DIFF);
if (view == NULL) {
error = got_error_from_errno();
goto done;
@@ -1853,7 +1908,7 @@ draw_blame(struct tog_view *view, struct got_object_id *id, FILE *f,
return err;
}
- if (nprinted == selected_line - 1)
+ if (view->focussed && nprinted == selected_line - 1)
wstandout(view->window);
blame_line = &lines[lineno - 1];
@@ -1881,7 +1936,7 @@ draw_blame(struct tog_view *view, struct got_object_id *id, FILE *f,
waddch(view->window, ' ');
width++;
}
- if (nprinted == selected_line - 1)
+ if (view->focussed && nprinted == selected_line - 1)
wstandend(view->window);
if (++nprinted == 1)
*first_displayed_line = lineno;
@@ -2167,6 +2222,7 @@ open_blame_view(struct tog_view *view, char *path,
memset(&s->blame, 0, sizeof(s->blame));
view->show = show_blame_view;
+ view->update_siblings = update_siblings_blame_view;
view->input = input_blame_view;
view->close = close_blame_view;
@@ -2218,6 +2274,13 @@ show_blame_view(struct tog_view *view)
}
static const struct got_error *
+update_siblings_blame_view(int *updated, struct tog_view *view,
+ struct tog_view *sibling_view)
+{
+ return NULL;
+}
+
+static const struct got_error *
input_blame_view(struct tog_view **new_view, struct tog_view **dead_view,
struct tog_view *view, int ch)
{
@@ -2361,8 +2424,8 @@ input_blame_view(struct tog_view **new_view, struct tog_view **dead_view,
break;
if (pobj == NULL && obj == NULL)
break;
- diff_view = view_open(0, 0, 0, 0, view,
- TOG_VIEW_DIFF);
+ diff_view = view_open(0, 0, 0,
+ view_split_begin_x(view->begin_x), TOG_VIEW_DIFF);
if (diff_view == NULL) {
err = got_error_from_errno();
break;
@@ -2501,7 +2564,7 @@ cmd_blame(int argc, char *argv[])
if (error != NULL)
goto done;
- view = view_open(0, 0, 0, 0, NULL, TOG_VIEW_BLAME);
+ view = view_open(0, 0, 0, 0, TOG_VIEW_BLAME);
if (view == NULL) {
error = got_error_from_errno();
goto done;
@@ -2570,11 +2633,12 @@ draw_tree_entries(struct tog_view *view,
te = SIMPLEQ_FIRST(&entries->head);
if (*first_displayed_entry == NULL) {
if (selected == 0) {
- wstandout(view->window);
+ if (view->focussed)
+ wstandout(view->window);
*selected_entry = NULL;
}
waddstr(view->window, " ..\n"); /* parent directory */
- if (selected == 0)
+ if (selected == 0 && view->focussed)
wstandend(view->window);
(*ndisplayed)++;
if (--limit <= 0)
@@ -2606,13 +2670,14 @@ draw_tree_entries(struct tog_view *view,
break;
}
if (n == selected) {
- wstandout(view->window);
+ if (view->focussed)
+ wstandout(view->window);
*selected_entry = te;
}
waddwstr(view->window, wline);
if (width < view->ncols)
waddch(view->window, '\n');
- if (n == selected)
+ if (n == selected && view->focussed)
wstandend(view->window);
free(line);
free(wline);
@@ -2727,7 +2792,7 @@ done:
}
static const struct got_error *
-blame_tree_entry(struct tog_view **new_view, struct tog_view *parent_view,
+blame_tree_entry(struct tog_view **new_view, int begin_x,
struct got_tree_entry *te, struct tog_parent_trees *parents,
struct got_object_id *commit_id, struct got_repository *repo)
{
@@ -2739,7 +2804,7 @@ blame_tree_entry(struct tog_view **new_view, struct tog_view *parent_view,
if (err)
return err;
- blame_view = view_open(0, 0, 0, 0, parent_view, TOG_VIEW_BLAME);
+ blame_view = view_open(0, 0, 0, 0, TOG_VIEW_BLAME);
if (blame_view == NULL)
return got_error_from_errno();
@@ -2753,7 +2818,7 @@ blame_tree_entry(struct tog_view **new_view, struct tog_view *parent_view,
}
static const struct got_error *
-log_tree_entry(struct tog_view **new_view, struct tog_view *parent_view,
+log_tree_entry(struct tog_view **new_view,
struct got_tree_entry *te, struct tog_parent_trees *parents,
struct got_object_id *commit_id, struct got_repository *repo)
{
@@ -2761,7 +2826,7 @@ log_tree_entry(struct tog_view **new_view, struct tog_view *parent_view,
const struct got_error *err = NULL;
char *path;
- log_view = view_open(0, 0, 0, 0, parent_view, TOG_VIEW_LOG);
+ log_view = view_open(0, 0, 0, 0, TOG_VIEW_LOG);
if (log_view == NULL)
return got_error_from_errno();
@@ -2808,6 +2873,7 @@ open_tree_view(struct tog_view *view, struct got_tree_object *root,
s->repo = repo;
view->show = show_tree_view;
+ view->update_siblings = update_siblings_tree_view;
view->input = input_tree_view;
view->close = close_tree_view;
done:
@@ -2862,6 +2928,13 @@ show_tree_view(struct tog_view *view)
}
static const struct got_error *
+update_siblings_tree_view(int *updated, struct tog_view *view,
+ struct tog_view *sibling_view)
+{
+ return NULL;
+}
+
+static const struct got_error *
input_tree_view(struct tog_view **new_view, struct tog_view **dead_view,
struct tog_view *view, int ch)
{
@@ -2874,7 +2947,7 @@ input_tree_view(struct tog_view **new_view, struct tog_view **dead_view,
break;
case 'l':
if (s->selected_entry) {
- err = log_tree_entry(new_view, view,
+ err = log_tree_entry(new_view,
s->selected_entry, &s->parents,
s->commit_id, s->repo);
}
@@ -2965,7 +3038,7 @@ input_tree_view(struct tog_view **new_view, struct tog_view **dead_view,
s->selected = 0;
s->first_displayed_entry = NULL;
} else if (S_ISREG(s->selected_entry->mode)) {
- err = blame_tree_entry(new_view, view,
+ err = blame_tree_entry(new_view, view->begin_x,
s->selected_entry, &s->parents,
s->commit_id, s->repo);
if (err)
@@ -3065,7 +3138,7 @@ cmd_tree(int argc, char *argv[])
if (error != NULL)
goto done;
- view = view_open(0, 0, 0, 0, NULL, TOG_VIEW_TREE);
+ view = view_open(0, 0, 0, 0, TOG_VIEW_TREE);
if (view == NULL) {
error = got_error_from_errno();
goto done;