Changes in uspace/lib/ui/src/list.c [5e758e4:7cf5ddb] in mainline
- File:
-
- 1 edited
-
uspace/lib/ui/src/list.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/list.c
r5e758e4 r7cf5ddb 149 149 list->cb = cb; 150 150 list->cb_arg = arg; 151 }152 153 /** Get UI list callback argument.154 *155 * @param list UI list156 * @return Callback argument157 */158 void *ui_list_get_cb_arg(ui_list_t *list)159 {160 return list->cb_arg;161 151 } 162 152 … … 711 701 } 712 702 713 /** Destroy UI list entry. 714 * 715 * This is the quick way, but does not update cursor or page position. 703 /** Delete UI list entry. 716 704 * 717 705 * @param entry UI list entry 718 706 */ 719 void ui_list_entry_de stroy(ui_list_entry_t *entry)707 void ui_list_entry_delete(ui_list_entry_t *entry) 720 708 { 721 709 if (entry->list->cursor == entry) … … 730 718 } 731 719 732 /** Delete UI list entry.733 *734 * If required, update cursor and page position and repaint.735 *736 * @param entry UI list entry737 */738 void ui_list_entry_delete(ui_list_entry_t *entry)739 {740 ui_list_t *list = entry->list;741 742 /* Try to make sure entry does not disappear under cursor or page */743 if (entry->list->cursor == entry)744 ui_list_cursor_up(entry->list);745 if (entry->list->cursor == entry)746 ui_list_cursor_down(entry->list);747 if (entry->list->page == entry)748 ui_list_scroll_up(entry->list);749 if (entry->list->page == entry)750 ui_list_scroll_down(entry->list);751 752 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 first757 * 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 entry765 * 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 entry776 * was deleted.777 */778 list->cursor_idx = ui_list_entry_get_idx(list->cursor);779 }780 }781 782 720 /** Get entry argument. 783 721 * … … 790 728 } 791 729 792 /** Get containing list.793 *794 * @param entry UI list entry795 * @return Containing list796 */797 ui_list_t *ui_list_entry_get_list(ui_list_entry_t *entry)798 {799 return entry->list;800 }801 802 /** Change list entry caption.803 *804 * @param entry UI list entry805 * @param caption New caption806 *807 * @return EOK on success, ENOMEM if out of memory808 */809 errno_t ui_list_entry_set_caption(ui_list_entry_t *entry, const char *caption)810 {811 char *dcaption;812 813 dcaption = str_dup(caption);814 if (dcaption == NULL)815 return ENOMEM;816 817 free(entry->caption);818 entry->caption = dcaption;819 820 (void)ui_list_entry_paint(entry, ui_list_entry_get_idx(entry));821 return EOK;822 }823 824 730 /** Clear UI list entry list. 825 731 * … … 832 738 entry = ui_list_first(list); 833 739 while (entry != NULL) { 834 ui_list_entry_de stroy(entry);740 ui_list_entry_delete(entry); 835 741 entry = ui_list_first(list); 836 742 } … … 952 858 { 953 859 return list->cursor; 954 }955 956 /** Set new cursor position.957 *958 * O(N) in list size, use with caution.959 *960 * @param list UI list961 * @param entry New cursor position962 */963 void ui_list_set_cursor(ui_list_t *list, ui_list_entry_t *entry)964 {965 size_t idx;966 967 idx = ui_list_entry_get_idx(entry);968 ui_list_cursor_move(list, entry, idx);969 860 } 970 861 … … 1021 912 /* Find first page entry (go back rows - 1) */ 1022 913 e = entry; 1023 for (i = 0; i + 1 < rows; i++) {914 for (i = 0; i < rows - 1; i++) { 1024 915 e = ui_list_prev(e); 1025 916 } … … 1207 1098 ui_list_entry_t *prev; 1208 1099 1209 if (list->page == NULL)1210 return;1211 1212 1100 prev = ui_list_prev(list->page); 1213 1101 if (prev == NULL) … … 1232 1120 size_t i; 1233 1121 size_t rows; 1234 1235 if (list->page == NULL)1236 return;1237 1122 1238 1123 next = ui_list_next(list->page);
Note:
See TracChangeset
for help on using the changeset viewer.
