summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 82bac86)
raw | patch | inline | side by side (parent: 82bac86)
author | Max Kellermann <max@duempel.org> | |
Sat, 10 Oct 2009 16:51:36 +0000 (18:51 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Sat, 10 Oct 2009 16:51:36 +0000 (18:51 +0200) |
Use list_window_move_cursor() to eliminate redundant code.
src/list_window.c | patch | blob | history |
diff --git a/src/list_window.c b/src/list_window.c
index 2111edc4eb4838dcb07c3cf1da3df5566f7defae..35522d53f1c4d1af62f68ca46a832d3284f7ba0d 100644 (file)
--- a/src/list_window.c
+++ b/src/list_window.c
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