diff options
author | Samuel Mendoza-Jonas <sam@mendozajonas.com> | 2017-02-15 14:47:45 +1100 |
---|---|---|
committer | Samuel Mendoza-Jonas <sam@mendozajonas.com> | 2017-08-15 13:38:17 +1000 |
commit | d90efe9e2bbfb18ee05ec2032b5723dbfa902d82 (patch) | |
tree | c576ccae13ca2f9264f18c9777a9f275f9a74cef /ui/ncurses | |
parent | 37feda62bd2835eabc779d275301a9b763521f7a (diff) | |
download | talos-petitboot-d90efe9e2bbfb18ee05ec2032b5723dbfa902d82.tar.gz talos-petitboot-d90efe9e2bbfb18ee05ec2032b5723dbfa902d82.zip |
ui/ncurses: Update cui_run_cmd() to pass display to command
Update cui_run_cmd() to setup a process that uses 'raw_stdout' so that
output is displayed on the screen instead of being caught in the log.
Also update cui_run_cmd() to take a more generic list of arguments, and
add a cui_run_cmd_from_item() wrapper for the existing user.
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'ui/ncurses')
-rw-r--r-- | ui/ncurses/nc-cui.c | 28 | ||||
-rw-r--r-- | ui/ncurses/nc-cui.h | 3 |
2 files changed, 26 insertions, 5 deletions
diff --git a/ui/ncurses/nc-cui.c b/ui/ncurses/nc-cui.c index fbc02b9..84e4bf0 100644 --- a/ui/ncurses/nc-cui.c +++ b/ui/ncurses/nc-cui.c @@ -155,19 +155,29 @@ void cui_on_exit(struct pmenu *menu) * cui_run_cmd - A generic cb to run the supplied command. */ -int cui_run_cmd(struct pmenu_item *item) +int cui_run_cmd(struct cui *cui, const char **cmd_argv) { + struct process *process; int result; - struct cui *cui = cui_from_item(item); - const char **cmd_argv = item->data; + + process = process_create(cui); + if (!process) + return -1; + + process->path = cmd_argv[0]; + process->argv = cmd_argv; + process->raw_stdout = true; nc_scr_status_printf(cui->current, _("Running %s..."), cmd_argv[0]); def_prog_mode(); + endwin(); - result = process_run_simple_argv(item, cmd_argv); + result = process_run_sync(process); reset_prog_mode(); + refresh(); + redrawwin(cui->current->main_ncw); if (result) { @@ -176,9 +186,19 @@ int cui_run_cmd(struct pmenu_item *item) cmd_argv[0]); } + process_release(process); + return result; } +int cui_run_cmd_from_item(struct pmenu_item *item) +{ + struct cui *cui = cui_from_item(item); + const char **cmd_argv = item->data; + + return cui_run_cmd(cui, cmd_argv); +} + /** * cui_boot - A generic cb to run kexec. */ diff --git a/ui/ncurses/nc-cui.h b/ui/ncurses/nc-cui.h index 418df71..d8a5f8b 100644 --- a/ui/ncurses/nc-cui.h +++ b/ui/ncurses/nc-cui.h @@ -98,7 +98,8 @@ void cui_abort(struct cui *cui); void cui_resize(struct cui *cui); void cui_on_exit(struct pmenu *menu); void cui_on_open(struct pmenu *menu); -int cui_run_cmd(struct pmenu_item *item); +int cui_run_cmd(struct cui *cui, const char **cmd_argv); +int cui_run_cmd_from_item(struct pmenu_item *item); static inline struct cui *cui_from_arg(void *arg) { |