From 66e1baec77313ba82904eff8e700bd8e1d4f10fa Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Tue, 8 Jul 2008 08:57:30 +0000 Subject: [PATCH] Fix hierbox line characters WRT item visibility Hierarchical listboxes draw items with upper-left corner, lower-left corner, or horizontal border characters to indicate whether a given item is the first item in a listbox, the last, or any other, respectively. However, the wrong character can be drawn if there are invisible items: if an item is the first (or last) visible item but there is an invisible item before (or after) it, it will be drawn with a horizontal border character, not a corner. This patch fixes that problem using traverse_listbox_items_list in display_listbox_item to ignore invisible items when determining whether an item is either the first or the last among its siblings. --- src/bfu/listbox.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/bfu/listbox.c b/src/bfu/listbox.c index 851b2c11..2664c49d 100644 --- a/src/bfu/listbox.c +++ b/src/bfu/listbox.c @@ -401,18 +401,26 @@ display_listbox_item(struct listbox_item *item, void *data_, int *offset) case BI_LEAF: case BI_SEPARATOR: { - struct listbox_item *root = data->box->ops->get_root(item); + const struct listbox_item *const prev; - if (root) { - if (item == root->child.prev) { - str[1] = BORDER_SDLCORNER; - } + prev = traverse_listbox_items_list(item, data->box, + -1, 1, NULL, NULL); + + if (item == prev) { + /* There is no visible item before @item, so it + * must be the first item in the listbox. */ + str[1] = BORDER_SULCORNER; } else { - LIST_OF(struct listbox_item) *p = data->box->items; + const struct listbox_item *const next; - if (p->next == item) { - str[1] = BORDER_SULCORNER; - } else if (p->prev == item) { + next == traverse_listbox_items_list(item, + data->box, 1, 1, NULL, NULL); + + if (item == next + || item->depth != next->depth) { + /* There is no visible item after @item + * at the same depth, so it must be the + * last in its folder. */ str[1] = BORDER_SDLCORNER; } }