Ignore:
File:
1 edited

Legend:

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

    rf9c4c433 r28ca31ed  
    11/*
    2  * Copyright (c) 2025 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    16521652}
    16531653
    1654 /** Save list position for later.
    1655  *
    1656  * The position will be valid even if the list is cleaned and re-populated
    1657  * (it just counts position from the top.)
    1658  *
    1659  * @param list UI list
    1660  * @param pos Place to store position
    1661  */
    1662 void ui_list_save_pos(ui_list_t *list, ui_list_pos_t *pos)
    1663 {
    1664         pos->page_idx = list->page_idx;
    1665         pos->cursor_idx = list->cursor_idx;
    1666 }
    1667 
    1668 /** Restore saved list position.
    1669  *
    1670  * The position will be valid even if the list is cleaned and re-populated
    1671  * (it just counts position from the top.)
    1672  *
    1673  * @param list UI list
    1674  * @param pos Saved list position
    1675  */
    1676 void ui_list_restore_pos(ui_list_t *list, ui_list_pos_t *pos)
    1677 {
    1678         size_t idx, i;
    1679         ui_list_entry_t *entry, *next;
    1680 
    1681         idx = 0;
    1682         entry = ui_list_first(list);
    1683 
    1684         for (i = 0; i < pos->cursor_idx; i++) {
    1685                 next = ui_list_next(entry);
    1686                 if (next != NULL) {
    1687                         entry = next;
    1688                         ++idx;
    1689                 }
    1690         }
    1691 
    1692         list->cursor = entry;
    1693         list->cursor_idx = idx;
    1694 
    1695         idx = 0;
    1696         entry = ui_list_first(list);
    1697 
    1698         for (i = 0; i < pos->page_idx; i++) {
    1699                 next = ui_list_next(entry);
    1700                 if (next != NULL) {
    1701                         entry = next;
    1702                         ++idx;
    1703                 }
    1704         }
    1705 
    1706         list->page = entry;
    1707         list->page_idx = idx;
    1708 }
    1709 
    17101654/** @}
    17111655 */
Note: See TracChangeset for help on using the changeset viewer.