Changeset 97c3c59 in mainline for uspace/app/nav/panel.c
- Timestamp:
- 2021-10-25T00:32:45Z (2 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5bbb4453
- Parents:
- 01e9991
- git-author:
- Jiri Svoboda <jiri@…> (2021-10-19 19:48:40)
- git-committer:
- jxsvoboda <5887334+jxsvoboda@…> (2021-10-25 00:32:45)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nav/panel.c
r01e9991 r97c3c59 519 519 char *ndir = NULL; 520 520 panel_entry_attr_t attr; 521 panel_entry_t *next; 522 panel_entry_t *prev; 523 char *olddn; 524 size_t pg_size; 525 size_t i; 521 526 errno_t rc; 522 527 … … 582 587 panel->page = panel_first(panel); 583 588 panel->page_idx = 0; 589 590 /* Moving up? */ 591 if (str_cmp(dirname, "..") == 0) { 592 /* Get the last component of old path */ 593 olddn = str_rchr(panel->dir, '/'); 594 if (olddn != NULL && *olddn != '\0') { 595 /* Find corresponding entry */ 596 ++olddn; 597 next = panel_next(panel->cursor); 598 while (next != NULL && str_cmp(next->name, olddn) <= 0 && 599 next->isdir) { 600 panel->cursor = next; 601 ++panel->cursor_idx; 602 next = panel_next(panel->cursor); 603 } 604 605 /* Move page so that cursor is in the center */ 606 panel->page = panel->cursor; 607 panel->page_idx = panel->cursor_idx; 608 609 pg_size = panel_page_size(panel); 610 611 for (i = 0; i < pg_size / 2; i++) { 612 prev = panel_prev(panel->page); 613 if (prev == NULL) 614 break; 615 616 panel->page = prev; 617 --panel->page_idx; 618 } 619 } 620 } 621 584 622 free(panel->dir); 585 623 panel->dir = ndir; 624 586 625 return EOK; 587 626 error: … … 974 1013 { 975 1014 gfx_context_t *gc = ui_window_get_gc(panel->window); 1015 char *dirname; 976 1016 errno_t rc; 977 1017 978 1018 assert(entry->isdir); 979 1019 1020 /* 1021 * Need to copy out name before we free the entry below 1022 * via panel_clear_entries(). 1023 */ 1024 dirname = str_dup(entry->name); 1025 if (dirname == NULL) 1026 return ENOMEM; 1027 980 1028 panel_clear_entries(panel); 981 1029 982 rc = panel_read_dir(panel, entry->name); 983 if (rc != EOK) 984 return rc; 1030 rc = panel_read_dir(panel, dirname); 1031 if (rc != EOK) { 1032 free(dirname); 1033 return rc; 1034 } 1035 1036 free(dirname); 985 1037 986 1038 rc = panel_paint(panel);
Note:
See TracChangeset
for help on using the changeset viewer.