From 3c1fbbd95c0772caf2ba564f8df5245988868247 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 10 Oct 2009 18:51:36 +0200 Subject: [PATCH] list_window: eliminate redundant code in list_window_fetch_cursor() Use list_window_move_cursor() to eliminate redundant code. --- src/list_window.c | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/src/list_window.c b/src/list_window.c index 2111edc..35522d5 100644 --- a/src/list_window.c +++ b/src/list_window.c @@ -203,35 +203,12 @@ list_window_move_cursor(struct list_window *lw, unsigned n) void list_window_fetch_cursor(struct list_window *lw) { - if (lw->selected < lw->start + options.scroll_offset) { - if (lw->start > 0) - lw->selected = lw->start + options.scroll_offset; - if (lw->range_selection) { - if (lw->selected > lw->range_base) { - lw->selected_end = lw->selected; - lw->selected_start = lw->range_base; - } else { - lw->selected_start = lw->selected; - } - } else { - lw->selected_start = lw->selected; - lw->selected_end = lw->selected; - } - } else if (lw->selected > lw->start + lw->rows - 1 - options.scroll_offset) { - if (lw->start + lw->rows < lw->length) - lw->selected = lw->start + lw->rows - 1 - options.scroll_offset; - if (lw->range_selection) { - if (lw->selected < lw->range_base) { - lw->selected_start = lw->selected; - lw->selected_end = lw->range_base; - } else { - lw->selected_end = lw->selected; - } - } else { - lw->selected_start = lw->selected; - lw->selected_end = lw->selected; - } - } + if (lw->start > 0 && + lw->selected < lw->start + options.scroll_offset) + list_window_move_cursor(lw, lw->start + options.scroll_offset); + else if (lw->start + lw->rows < lw->length && + lw->selected > lw->start + lw->rows - 1 - options.scroll_offset) + list_window_move_cursor(lw, lw->start + lw->rows - 1 - options.scroll_offset); } static void -- 2.30.2