/* Ensures that terminal is in proper state for a loop iteration. Returns * non-zero if so, otherwise zero is returned. */ static int ensure_term_is_ready(void) { ui_update_term_state(); update_terminal_settings(); if(curr_stats.term_state == TS_TOO_SMALL) { ui_display_too_small_term_msg(); wait_for_signal(); return 0; } if(curr_stats.term_state == TS_BACK_TO_NORMAL) { ui_drain_input(); curr_stats.term_state = TS_NORMAL; modes_redraw(); curr_stats.save_msg = 0; ui_sb_msg(""); } return 1; }
/* Ensures that terminal is in proper state for a loop iteration. Returns * non-zero if so, otherwise zero is returned. */ static int ensure_term_is_ready(void) { ui_update_term_state(); update_terminal_settings(); if(curr_stats.term_state == TS_TOO_SMALL) { ui_display_too_small_term_msg(); wait_for_signal(); return 0; } if(curr_stats.term_state == TS_BACK_TO_NORMAL) { wint_t c; wtimeout(status_bar, 0); while(compat_wget_wch(status_bar, &c) != ERR); curr_stats.term_state = TS_NORMAL; modes_redraw(); wtimeout(status_bar, cfg.timeout_len); curr_stats.save_msg = 0; ui_sb_msg(""); } return 1; }
void menu_post(void) { if(curr_stats.need_update != UT_NONE) { menu_full_redraw(); curr_stats.need_update = UT_NONE; } ui_sb_msg(curr_stats.save_msg ? NULL : ""); }
/* Returns non-zero on error. */ static int source_file_internal(FILE *fp, const char filename[]) { char line[MAX_VIFMRC_LINE_LEN + 1]; char *next_line = NULL; int line_num; int encoutered_errors = 0; if(fgets(line, sizeof(line), fp) == NULL) { /* File is empty. */ return 0; } chomp(line); commands_scope_start(); line_num = 1; for(;;) { char *p; int line_num_delta = 0; while((p = next_line = read_line(fp, next_line)) != NULL) { line_num_delta++; p = skip_whitespace(p); if(*p == '"') continue; else if(*p == '\\') strncat(line, p + 1, sizeof(line) - strlen(line) - 1); else break; } /* Clear statusbar message. */ ui_sb_msg(""); if(exec_commands(line, curr_view, CIT_COMMAND) < 0) { show_sourcing_error(filename, line_num); encoutered_errors = 1; } if(curr_stats.sourcing_state == SOURCING_FINISHING) break; if(p == NULL) { /* Artificially increment line number to simulate as if all that happens * after the loop relates to something past end of the file. */ line_num++; break; } copy_str(line, sizeof(line), p); line_num += line_num_delta; } free(next_line); /* Clear statusbar message. */ ui_sb_msg(""); if(commands_scope_finish() != 0) { show_sourcing_error(filename, line_num); encoutered_errors = 1; } return encoutered_errors; }