From 16f9664dc3626f0f30f6a680913e93b104cccca1 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Thu, 10 Mar 2011 23:34:05 -0500 Subject: [PATCH] Move view splitting code to separate split_view --- tig.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/tig.c b/tig.c index 8bed28e..16cfaa2 100644 --- a/tig.c +++ b/tig.c @@ -2717,6 +2717,29 @@ load_view(struct view *view, enum open_flags flags) #define refresh_view(view) load_view(view, OPEN_REFRESH) +static void +split_view(struct view *prev, struct view *view) +{ + display[1] = view; + current_view = 1; + view->parent = prev; + resize_display(); + + if (prev->lineno - prev->offset >= prev->height) { + /* Take the title line into account. */ + int lines = prev->lineno - prev->offset - prev->height + 1; + + /* Scroll the view that was split if the current line is + * outside the new limited view. */ + do_scroll_view(prev, lines); + } + + if (view != prev && view_is_displayed(prev)) { + /* "Blur" the previous view. */ + update_view_title(prev); + } +} + static void open_view(struct view *prev, enum request request, enum open_flags flags) { @@ -2738,24 +2761,7 @@ open_view(struct view *prev, enum request request, enum open_flags flags) } if (split) { - display[1] = view; - current_view = 1; - view->parent = prev; - resize_display(); - - if (prev->lineno - prev->offset >= prev->height) { - /* Take the title line into account. */ - int lines = prev->lineno - prev->offset - prev->height + 1; - - /* Scroll the view that was split if the current line is - * outside the new limited view. */ - do_scroll_view(prev, lines); - } - - if (view != prev && view_is_displayed(prev)) { - /* "Blur" the previous view. */ - update_view_title(prev); - } + split_view(prev, view); } else { maximize_view(view, FALSE); } -- 2.30.2