int get_input(int prompt_position, struct key *key, bool modifiers) { struct view *view; int i, key_value, cursor_y, cursor_x; if (prompt_position) input_mode = TRUE; memset(key, 0, sizeof(*key)); while (TRUE) { int delay = -1; if (opt_refresh_mode == REFRESH_MODE_PERIODIC) { delay = watch_periodic(opt_refresh_interval); foreach_displayed_view (view, i) { if (view_can_refresh(view) && watch_dirty(&view->watch)) refresh_view(view); } } foreach_view (view, i) { update_view(view); if (view_is_displayed(view) && view->has_scrolled && use_scroll_redrawwin) redrawwin(view->win); view->has_scrolled = FALSE; if (view->pipe) delay = 0; }
bool open_external_viewer(const char *argv[], const char *dir, bool confirm, bool refresh, const char *notice) { bool ok; def_prog_mode(); /* save current tty modes */ endwin(); /* restore original tty modes */ ok = io_run_fg(argv, dir); if (confirm || !ok) { if (!ok && *notice) fprintf(stderr, "%s", notice); fprintf(stderr, "Press Enter to continue"); getc(opt_tty); } reset_prog_mode(); if (watch_update(WATCH_EVENT_AFTER_EXTERNAL) && refresh) { struct view *view; int i; foreach_displayed_view (view, i) { if (watch_dirty(&view->watch)) refresh_view(view); } } redraw_display(TRUE); return ok; }
bool open_external_viewer(const char *argv[], const char *dir, bool silent, bool confirm, bool refresh, const char *notice) { bool ok; if (silent) { ok = io_run_bg(argv, dir); } else { endwin(); /* restore original tty modes */ ok = io_run_fg(argv, dir); if (confirm || !ok) { if (!ok && *notice) fprintf(stderr, "%s", notice); if (!is_script_executing()) { fprintf(stderr, "Press Enter to continue"); getc(opt_tty); } } } if (watch_update(WATCH_EVENT_AFTER_COMMAND) && refresh) { struct view *view; int i; foreach_displayed_view (view, i) { if (watch_dirty(&view->watch)) refresh_view(view); } } redraw_display(true); return ok; }
static enum request open_run_request(struct view *view, enum request request) { struct run_request *req = get_run_request(request); const char **argv = NULL; bool confirmed = FALSE; request = REQ_NONE; if (!req) { report("Unknown run request"); return request; } if (!argv_format(view->env, &argv, req->argv, FALSE, TRUE)) { report("Failed to format arguments"); return REQ_NONE; } if (req->flags.internal) { request = run_prompt_command(view, argv); } else { confirmed = !req->flags.confirm; if (req->flags.confirm) { char cmd[SIZEOF_STR], prompt[SIZEOF_STR]; const char *and_exit = req->flags.exit ? " and exit" : ""; if (argv_to_string(argv, cmd, sizeof(cmd), " ") && string_format(prompt, "Run `%s`%s?", cmd, and_exit) && prompt_yesno(prompt)) { confirmed = TRUE; } } if (confirmed && argv_remove_quotes(argv)) open_external_viewer(argv, NULL, req->flags.silent, !req->flags.exit, FALSE, ""); } if (argv) argv_free(argv); free(argv); if (request == REQ_NONE) { if (req->flags.confirm && !confirmed) request = REQ_NONE; else if (req->flags.exit) request = REQ_QUIT; else if (!req->flags.internal && watch_dirty(&view->watch)) request = REQ_REFRESH; } return request; }
bool open_external_viewer(const char *argv[], const char *dir, bool silent, bool confirm, bool echo, bool refresh, const char *notice) { bool ok; if (echo) { char buf[SIZEOF_STR] = ""; io_run_buf(argv, buf, sizeof(buf), dir, false); if (*buf) { report("%s", buf); return true; } else { report("No output"); return false; } } else if (silent || is_script_executing()) { ok = io_run_bg(argv, dir); } else { clear(); refresh(); endwin(); /* restore original tty modes */ ok = io_run_fg(argv, dir); if (confirm || !ok) { if (!ok && *notice) fprintf(stderr, "%s", notice); fprintf(stderr, "Press Enter to continue"); getc(opt_tty); fseek(opt_tty, 0, SEEK_END); } set_terminal_modes(); } if (watch_update(WATCH_EVENT_AFTER_COMMAND) && refresh) { struct view *view; int i; foreach_displayed_view (view, i) { if (watch_dirty(&view->watch)) refresh_view(view); } } redraw_display(true); return ok; }
int get_input(int prompt_position, struct key *key) { struct view *view; int i, key_value, cursor_y, cursor_x; if (prompt_position > 0) input_mode = true; memset(key, 0, sizeof(*key)); while (true) { int delay = -1; if (opt_refresh_mode == REFRESH_MODE_PERIODIC) { delay = watch_periodic(opt_refresh_interval); bool refs_refreshed = false; foreach_displayed_view (view, i) { if (view_can_refresh(view) && watch_dirty(&view->watch)) { if (!refs_refreshed) { load_refs(true); refs_refreshed = true; } refresh_view(view); } } } foreach_view (view, i) { update_view(view); if (view_is_displayed(view) && view->has_scrolled && use_scroll_redrawwin) redrawwin(view->win); view->has_scrolled = false; if (view->pipe) delay = 0; }