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; }
int watch (int argc, char * argv []) { (void) argc; (void) argv; logi ("Running watch..."); struct watcher * W = watch_init (); for (;;) { watch_update (W, sample_callback, NULL); sleep (1); } watch_del (W); return 0; }
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 watch_periodic(int interval) { static time_t last_update; int delay = -1; if (watches && interval > 0) { time_t now = time(NULL); if (!last_update) last_update = now; if (last_update + interval <= now) { watch_update(WATCH_EVENT_PERIODIC); last_update = now; } delay = (now - last_update + interval) * 1000; } return delay; }