SETUP() { view_setup(&lwin); view_setup(&rwin); /* Emulate proper history initialization (must happen after view * initialization). */ cfg_resize_histories(5); cfg_resize_histories(0); curr_view = &lwin; other_view = &rwin; init_commands(); }
/* Checks that history has at least one more empty slot or extends history by * one more element. */ static void ensure_history_not_full(hist_t *hist) { if(hist->pos + 1 == cfg.history_len) { cfg_resize_histories(cfg.history_len + 1); assert(hist->pos + 1 != cfg.history_len && "Failed to resize history."); } }
TEST(unfinished_scope_is_terminated_after_external_editing, IF(not_windows)) { FILE *fp; char path[PATH_MAX + 1]; char *const saved_cwd = save_cwd(); assert_success(chdir(SANDBOX_PATH)); /* Emulate proper history initialization (must happen after view * initialization). */ cfg_resize_histories(10); cfg_resize_histories(0); cfg_resize_histories(10); update_string(&cfg.shell, "/bin/sh"); stats_update_shell_type(cfg.shell); fp = fopen("./script", "w"); fputs("#!/bin/sh\n", fp); fputs("echo \"if 'a' == 'b'\" > $3\n", fp); fclose(fp); assert_success(chmod("script", 0777)); curr_stats.exec_env_type = EET_EMULATOR; make_abs_path(path, sizeof(path), SANDBOX_PATH, "script", saved_cwd); update_string(&cfg.vi_command, path); (void)vle_keys_exec_timed_out(WK_C_g); update_string(&cfg.vi_command, NULL); update_string(&cfg.shell, NULL); assert_success(unlink(path)); restore_cwd(saved_cwd); cfg_resize_histories(0); assert_true(cmds_scoped_empty()); }
TEARDOWN() { int i; cfg_resize_histories(0); for(i = 0; i < lwin.list_rows; i++) free(lwin.dir_entry[i].name); free(lwin.dir_entry); for(i = 0; i < rwin.list_rows; i++) free(rwin.dir_entry[i].name); free(rwin.dir_entry); }
/* Loads single history entry from vifminfo into the view. */ static void get_history(FileView *view, int reread, const char *dir, const char *file, int pos) { const int list_rows = view->list_rows; if(view->history_num == cfg.history_len) { cfg_resize_histories(cfg.history_len + 1); } if(!reread) { view->list_rows = 1; } save_view_history(view, dir, file, pos); if(!reread) { view->list_rows = list_rows; } }
SETUP() { /* lwin */ strcpy(lwin.curr_dir, "/lwin"); lwin.list_rows = 1; lwin.list_pos = 0; lwin.dir_entry = calloc(lwin.list_rows, sizeof(*lwin.dir_entry)); lwin.dir_entry[0].name = strdup("lfile0"); lwin.dir_entry[0].origin = &lwin.curr_dir[0]; /* rwin */ strcpy(rwin.curr_dir, "/rwin"); rwin.list_rows = 1; rwin.list_pos = 0; rwin.dir_entry = calloc(rwin.list_rows, sizeof(*rwin.dir_entry)); rwin.dir_entry[0].name = strdup("rfile0"); rwin.dir_entry[0].origin = &rwin.curr_dir[0]; cfg_resize_histories(INITIAL_SIZE); }
void vifm_restart(void) { view_t *tmp_view; curr_stats.restart_in_progress = 1; /* All user mappings in all modes. */ vle_keys_user_clear(); /* User defined commands. */ vle_cmds_run("comclear"); /* Autocommands. */ vle_aucmd_remove(NULL, NULL); /* All kinds of histories. */ cfg_resize_histories(0); /* Session status. Must be reset _before_ options, because options take some * of values from status. */ (void)stats_reset(&cfg); /* Options of current pane. */ vle_opts_restore_defaults(); /* Options of other pane. */ tmp_view = curr_view; curr_view = other_view; load_view_options(other_view); vle_opts_restore_defaults(); curr_view = tmp_view; /* File types and viewers. */ ft_reset(curr_stats.exec_env_type == EET_EMULATOR_WITH_X); /* Undo list. */ un_reset(); /* Directory stack. */ dir_stack_clear(); /* Registers. */ regs_reset(); /* Clear all marks and bookmarks. */ clear_all_marks(); bmarks_clear(); /* Reset variables. */ clear_envvars(); init_variables(); /* This update is needed as clear_variables() will reset $PATH. */ update_path_env(1); reset_views(); read_info_file(1); flist_hist_save(&lwin, NULL, NULL, -1); flist_hist_save(&rwin, NULL, NULL, -1); /* Color schemes. */ if(stroscmp(curr_stats.color_scheme, DEF_CS_NAME) != 0 && cs_exists(curr_stats.color_scheme)) { cs_load_primary(curr_stats.color_scheme); } else { cs_load_defaults(); } cs_load_pairs(); cfg_load(); /* Reloading of tabs needs to happen after configuration is read so that new * values from lwin and rwin got propagated. */ tabs_reload(); exec_startup_commands(&vifm_args); curr_stats.restart_in_progress = 0; /* Trigger auto-commands for initial directories. */ (void)vifm_chdir(flist_get_dir(&lwin)); vle_aucmd_execute("DirEnter", flist_get_dir(&lwin), &lwin); (void)vifm_chdir(flist_get_dir(&rwin)); vle_aucmd_execute("DirEnter", flist_get_dir(&rwin), &rwin); update_screen(UT_REDRAW); }