summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ff26aa2)
raw | patch | inline | side by side (parent: ff26aa2)
author | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 21 May 2006 02:44:08 +0000 (04:44 +0200) | ||
committer | Jonas Fonseca <fonseca@antimatter.localdomain> | |
Sun, 21 May 2006 03:04:36 +0000 (05:04 +0200) |
This adds support for using these next/previous requests for changing the
current commit in the main view from the diff view, if the diff view has
the main view as it's parent.
Works for both split- and full-screen diff views by making redrawing
conditional when moving (and doing the lowlevel scrolling).
Replaces REQ_MOVE_{UP,DOWN}_ENTER.
current commit in the main view from the diff view, if the diff view has
the main view as it's parent.
Works for both split- and full-screen diff views by making redrawing
conditional when moving (and doing the lowlevel scrolling).
Replaces REQ_MOVE_{UP,DOWN}_ENTER.
tig.c | patch | blob | history |
index 53d477025f2422f70c3debf127dbdef8bcf87c83..bf5309254db1ac46aa89a25e4db7a545fbed16cb 100644 (file)
--- a/tig.c
+++ b/tig.c
REQ_TOGGLE_LINE_NUMBERS,
REQ_VIEW_NEXT,
REQ_VIEW_CLOSE,
+ REQ_NEXT,
+ REQ_PREVIOUS,
REQ_MOVE_UP,
- REQ_MOVE_UP_ENTER,
REQ_MOVE_DOWN,
- REQ_MOVE_DOWN_ENTER,
REQ_MOVE_PAGE_UP,
REQ_MOVE_PAGE_DOWN,
REQ_MOVE_FIRST_LINE,
/* Scrolling backend */
static void
-do_scroll_view(struct view *view, int lines)
+do_scroll_view(struct view *view, int lines, bool redraw)
{
/* The rendering expects the new offset. */
view->offset += lines;
assert(view->offset <= view->lineno && view->lineno < view->lines);
+ if (!redraw)
+ return;
+
redrawwin(view->win);
wrefresh(view->win);
report("");
die("request %d not handled in switch", request);
}
- do_scroll_view(view, lines);
+ do_scroll_view(view, lines, TRUE);
}
/* Cursor moving */
static void
-move_view(struct view *view, enum request request)
+move_view(struct view *view, enum request request, bool redraw)
{
int steps;
break;
case REQ_MOVE_UP:
- case REQ_MOVE_UP_ENTER:
steps = -1;
break;
case REQ_MOVE_DOWN:
- case REQ_MOVE_DOWN_ENTER:
steps = 1;
break;
}
}
- do_scroll_view(view, steps);
+ do_scroll_view(view, steps, redraw);
return;
}
/* Draw the current line */
view->ops->draw(view, view->lineno - view->offset);
+ if (!redraw)
+ return;
+
redrawwin(view->win);
wrefresh(view->win);
report("");
/* Scroll the view that was split if the current line is
* outside the new limited view. */
- do_scroll_view(prev, lines);
+ do_scroll_view(prev, lines, TRUE);
}
if (prev && view != prev) {
case REQ_MOVE_PAGE_DOWN:
case REQ_MOVE_FIRST_LINE:
case REQ_MOVE_LAST_LINE:
- move_view(view, request);
+ move_view(view, request, TRUE);
break;
case REQ_SCROLL_LINE_DOWN:
open_view(view, request, OPEN_DEFAULT);
break;
- case REQ_MOVE_UP_ENTER:
- case REQ_MOVE_DOWN_ENTER:
- move_view(view, request);
+ case REQ_NEXT:
+ case REQ_PREVIOUS:
+ request = request == REQ_NEXT ? REQ_MOVE_DOWN : REQ_MOVE_UP;
+
+ if (view == VIEW(REQ_VIEW_DIFF) &&
+ view->parent == VIEW(REQ_VIEW_MAIN)) {
+ bool redraw = display[0] == VIEW(REQ_VIEW_MAIN);
+
+ view = view->parent;
+ move_view(view, request, redraw);
+ update_view_title(view);
+ } else {
+ move_view(view, request, TRUE);
+ break;
+ }
/* Fall-through */
case REQ_ENTER:
static bool
main_enter(struct view *view)
{
- open_view(view, REQ_VIEW_DIFF, OPEN_SPLIT);
+ enum open_flags flags = display[0] == view ? OPEN_SPLIT : OPEN_DEFAULT;
+
+ open_view(view, REQ_VIEW_DIFF, flags);
return TRUE;
}
* Switch to pager view.
* h::
* Show man page.
+ **/
+ { 'm', REQ_VIEW_MAIN },
+ { 'd', REQ_VIEW_DIFF },
+ { 'l', REQ_VIEW_LOG },
+ { 'p', REQ_VIEW_PAGER },
+ { 'h', REQ_VIEW_HELP },
+
+ /**
+ * View manipulation
+ * ~~~~~~~~~~~~~~~~~
* q::
* Close view, if multiple views are open it will jump back to the
* previous view in the view stack. If it is the last open view it
* pressing Enter will simply scroll the view one line down.
* Tab::
* Switch to next view.
+ * Up::
+ * This key is "context sensitive" and will move the cursor one
+ * line up. However, uf you opened a diff view from the main view
+ * (split- or full-screen) it will change the cursor to point to
+ * the previous commit in the main view and update the diff view
+ * to display it.
+ * Down::
+ * Similar to 'Up' but will move down.
**/
- { 'm', REQ_VIEW_MAIN },
- { 'd', REQ_VIEW_DIFF },
- { 'l', REQ_VIEW_LOG },
- { 'p', REQ_VIEW_PAGER },
- { 'h', REQ_VIEW_HELP },
-
{ 'q', REQ_VIEW_CLOSE },
{ KEY_TAB, REQ_VIEW_NEXT },
{ KEY_RETURN, REQ_ENTER },
+ { KEY_UP, REQ_PREVIOUS },
+ { KEY_DOWN, REQ_NEXT },
/**
* Cursor navigation
* ~~~~~~~~~~~~~~~~~
- * Up::
+ * j::
* Move cursor one line up.
- * Down::
- * Move cursor one line down.
* k::
- * Move cursor one line up and enter. When used in the main view
- * this will always show the diff of the current commit in the
- * split diff view.
- * j::
- * Move cursor one line down and enter.
+ * Move cursor one line down.
* PgUp::
* b::
* -::
* End::
* Jump to last line.
**/
- { KEY_UP, REQ_MOVE_UP },
- { KEY_DOWN, REQ_MOVE_DOWN },
- { 'k', REQ_MOVE_UP_ENTER },
- { 'j', REQ_MOVE_DOWN_ENTER },
+ { 'k', REQ_MOVE_UP },
+ { 'j', REQ_MOVE_DOWN },
{ KEY_HOME, REQ_MOVE_FIRST_LINE },
{ KEY_END, REQ_MOVE_LAST_LINE },
{ KEY_NPAGE, REQ_MOVE_PAGE_DOWN },