Changeset a77c722 in mainline


Ignore:
Timestamp:
2023-08-08T16:25:27Z (17 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
acd7ac2
Parents:
8a4ceaa
Message:

Update page_idx and cursor_idx after deleting UI list entry

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/src/list.c

    r8a4ceaa ra77c722  
    738738void ui_list_entry_delete(ui_list_entry_t *entry)
    739739{
    740         /* Try to make sure entry does not disappear between cursor and page */
     740        ui_list_t *list = entry->list;
     741
     742        /* Try to make sure entry does not disappear under cursor or page */
    741743        if (entry->list->cursor == entry)
    742744                ui_list_cursor_up(entry->list);
     
    749751
    750752        ui_list_entry_destroy(entry);
     753
     754        /*
     755         * But it could still happen if there are not enough entries.
     756         * In that case just move page and/or cursor to the first
     757         * entry.
     758         */
     759        if (list->page == NULL) {
     760                list->page = ui_list_first(list);
     761                list->page_idx = 0;
     762        } else {
     763                /*
     764                 * Entry index might have changed if earlier entry
     765                 * was deleted.
     766                 */
     767                list->page_idx = ui_list_entry_get_idx(list->page);
     768        }
     769
     770        if (list->cursor == NULL) {
     771                list->cursor = ui_list_first(list);
     772                list->cursor_idx = 0;
     773        } else {
     774                /*
     775                 * Entry index might have changed if earlier entry
     776                 * was deleted.
     777                 */
     778                list->cursor_idx = ui_list_entry_get_idx(list->cursor);
     779        }
    751780}
    752781
Note: See TracChangeset for help on using the changeset viewer.