xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit 8fc717a4ebfaf6226b3af15265e0a64cca8d85b7

Update view when switching to a different menu
This doesn't make difference during regular use as current view can't be
changed from menu mode, but Lua API can already change active view and
will be able to reload menu with a possibly different view.
Author: xaizek
Author date (UTC): 2024-12-02 15:28
Committer name: xaizek
Committer date (UTC): 2024-12-02 15:28
Parent(s): 1291d352eec4d318f62991cc39d7b65a8152a60a
Signing key: 99DC5E4DB05F6BE2
Tree: 03e8b665586bcb283bf66e94a665b7dd45facbd2
File Lines added Lines deleted
src/menus/menus.c 9 4
src/modes/menu.c 9 2
src/modes/menu.h 4 1
File src/menus/menus.c changed (mode: 100644) (index 3e61356ff..c1d30bf18)
... ... static void draw_menu_frame(const menu_state_t *ms);
78 78 static void output_handler(const char line[], void *arg); static void output_handler(const char line[], void *arg);
79 79 static void append_to_string(char **str, const char suffix[]); static void append_to_string(char **str, const char suffix[]);
80 80 static char * expand_tabulation_a(const char line[], size_t tab_stops); static char * expand_tabulation_a(const char line[], size_t tab_stops);
81 static void init_menu_state(menu_state_t *ms, menu_data_t *m, view_t *view);
81 static void init_menu_state(menu_state_t *ms, menu_data_t *m);
82 82 static void replace_menu_data(menu_data_t *m); static void replace_menu_data(menu_data_t *m);
83 83 static int can_stash_menu(const menu_data_t *m); static int can_stash_menu(const menu_data_t *m);
84 84 static void stash_menu(menu_data_t *m); static void stash_menu(menu_data_t *m);
 
... ... menus_enter(menu_data_t *m, view_t *view)
687 687 return 1; return 1;
688 688 } }
689 689
690 /* The view should be set regardless whether we're already in the menu
691 * mode. */
692 menu_state.view = view;
693
690 694 if(vle_mode_is(MENU_MODE)) if(vle_mode_is(MENU_MODE))
691 695 { {
692 696 menus_switch_to(m); menus_switch_to(m);
 
... ... menus_enter(menu_data_t *m, view_t *view)
694 698 } }
695 699
696 700 /* This moves data out of `m`, so don't use it below. */ /* This moves data out of `m`, so don't use it below. */
697 init_menu_state(&menu_state, m, view);
701 init_menu_state(&menu_state, m);
698 702
699 703 ui_setup_for_menu_like(); ui_setup_for_menu_like();
700 704 term_title_update(menu_state.d->title); term_title_update(menu_state.d->title);
 
... ... menus_enter(menu_data_t *m, view_t *view)
706 710
707 711 /* Initializes menu state structure with default/initial values. */ /* Initializes menu state structure with default/initial values. */
708 712 static void static void
709 init_menu_state(menu_state_t *ms, menu_data_t *m, view_t *view)
713 init_menu_state(menu_state_t *ms, menu_data_t *m)
710 714 { {
711 715 free(ms->regexp); free(ms->regexp);
712 716 free(ms->matches); free(ms->matches);
 
... ... init_menu_state(menu_state_t *ms, menu_data_t *m, view_t *view)
724 728 ms->matches = NULL; ms->matches = NULL;
725 729 ms->regexp = NULL; ms->regexp = NULL;
726 730 ms->search_repeat = 0; ms->search_repeat = 0;
727 ms->view = view;
728 731 } }
729 732
730 733 void void
 
... ... replace_menu_data(menu_data_t *m)
765 768 move_menu_data(&menu_state.data_storage, m); move_menu_data(&menu_state.data_storage, m);
766 769 menu_state.d = &menu_state.data_storage; menu_state.d = &menu_state.data_storage;
767 770
771 modmenu_reenter(menu_state.view);
772
768 773 menus_partial_redraw(m->state); menus_partial_redraw(m->state);
769 774 menus_set_pos(m->state, m->pos); menus_set_pos(m->state, m->pos);
770 775 ui_refresh_win(menu_win); ui_refresh_win(menu_win);
File src/modes/menu.c changed (mode: 100644) (index 4bed2d586..fcc075f7b)
... ... key_handler(wchar_t key)
338 338 } }
339 339
340 340 void void
341 modmenu_enter(menu_data_t *m, view_t *active_view)
341 modmenu_enter(menu_data_t *m, view_t *target_view)
342 342 { {
343 343 if(curr_stats.load_stage >= 0 && curr_stats.load_stage < 2) if(curr_stats.load_stage >= 0 && curr_stats.load_stage < 2)
344 344 { {
 
... ... modmenu_enter(menu_data_t *m, view_t *active_view)
350 350 ui_hide_graphics(); ui_hide_graphics();
351 351 werase(status_bar); werase(status_bar);
352 352
353 view = active_view;
353 view = target_view;
354 354 menu = m; menu = m;
355 355 vle_mode_set(MENU_MODE, VMT_PRIMARY); vle_mode_set(MENU_MODE, VMT_PRIMARY);
356 356 stats_refresh_later(); stats_refresh_later();
 
... ... modmenu_enter(menu_data_t *m, view_t *active_view)
359 359 vle_cmds_init(0, &cmds_conf); vle_cmds_init(0, &cmds_conf);
360 360 } }
361 361
362 void
363 modmenu_reenter(view_t *target_view)
364 {
365 assert(vle_mode_is(MENU_MODE) && "Menu mode must be active!");
366 view = target_view;
367 }
368
362 369 void void
363 370 modmenu_abort(void) modmenu_abort(void)
364 371 { {
File src/modes/menu.h changed (mode: 100644) (index 7db1dface..f44278067)
... ... struct view_t;
30 30 void modmenu_init(void); void modmenu_init(void);
31 31
32 32 /* Enters menu mode. */ /* Enters menu mode. */
33 void modmenu_enter(menu_data_t *m, struct view_t *active_view);
33 void modmenu_enter(menu_data_t *m, struct view_t *target_view);
34
35 /* Updates an already active menu mode. */
36 void modmenu_reenter(struct view_t *target_view);
34 37
35 38 /* Aborts menu mode. */ /* Aborts menu mode. */
36 39 void modmenu_abort(void); void modmenu_abort(void);
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master