aboutsummaryrefslogtreecommitdiff
path: root/lib/libdpv
diff options
context:
space:
mode:
authorDevin Teske <dteske@FreeBSD.org>2016-01-26 23:56:27 +0000
committerDevin Teske <dteske@FreeBSD.org>2016-01-26 23:56:27 +0000
commit80f7300d7b70c869f82fe9df0b35807703914f5f (patch)
tree85d41b7dc90a558072188cd2dd18615f60d793d1 /lib/libdpv
parent10d72ffc7df6bb4607816d86f3ffe13906d0bcfa (diff)
downloadsrc-80f7300d7b70c869f82fe9df0b35807703914f5f.tar.gz
src-80f7300d7b70c869f82fe9df0b35807703914f5f.zip
Add keep_tite configuration option
Similar to dialog(3) keep_tite option used to prevent visually disturbing initialization or exit that could occur when run from a script using dpv(3) by way of dpv(1) in sequence with other dialog(1) invocations.
Notes
Notes: svn path=/head/; revision=294860
Diffstat (limited to 'lib/libdpv')
-rw-r--r--lib/libdpv/dpv.35
-rw-r--r--lib/libdpv/dpv.c5
-rw-r--r--lib/libdpv/dpv.h1
-rw-r--r--lib/libdpv/dpv_private.h1
4 files changed, 9 insertions, 3 deletions
diff --git a/lib/libdpv/dpv.3 b/lib/libdpv/dpv.3
index 8581279e1dc6..011ab8208d14 100644
--- a/lib/libdpv/dpv.3
+++ b/lib/libdpv/dpv.3
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2013-2015 Devin Teske
+.\" Copyright (c) 2013-2016 Devin Teske
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd Oct 22, 2015
+.Dd Jan 26, 2016
.Dt DPV 3
.Os
.Sh NAME
@@ -64,6 +64,7 @@ argument contains the following properties for configuring global display
features:
.Bd -literal -offset indent
struct dpv_config {
+ uint8_t keep_tite; /* Cleaner exit for scripts */
enum dpv_display display_type; /* Def. DPV_DISPLAY_LIBDIALOG */
enum dpv_output output_type; /* Default DPV_OUTPUT_NONE */
int debug; /* Enable debug on stderr */
diff --git a/lib/libdpv/dpv.c b/lib/libdpv/dpv.c
index d3506ca9d82d..edf75bd1dfe7 100644
--- a/lib/libdpv/dpv.c
+++ b/lib/libdpv/dpv.c
@@ -69,6 +69,7 @@ long long dpv_overall_read = 0;
static char pathbuf[PATH_MAX];
/* Extra display information */
+uint8_t keep_tite = FALSE; /* dpv_config.keep_tite */
uint8_t no_labels = FALSE; /* dpv_config.options & DPV_NO_LABELS */
uint8_t wide = FALSE; /* dpv_config.options & DPV_WIDE_MODE */
char *aprompt = NULL; /* dpv_config.aprompt */
@@ -150,6 +151,7 @@ dpv(struct dpv_config *config, struct dpv_file_node *file_list)
dialog_updates_per_second = DIALOG_UPDATES_PER_SEC;
display_limit = DISPLAY_LIMIT_DEFAULT;
display_type = DPV_DISPLAY_LIBDIALOG;
+ keep_tite = FALSE;
label_size = LABEL_SIZE_DEFAULT;
msg_done = NULL;
msg_fail = NULL;
@@ -193,6 +195,7 @@ dpv(struct dpv_config *config, struct dpv_file_node *file_list)
dialog_updates_per_second = config->dialog_updates_per_second;
display_limit = config->display_limit;
display_type = config->display_type;
+ keep_tite = config->keep_tite;
label_size = config->label_size;
msg_done = (char *)config->msg_done;
msg_fail = (char *)config->msg_fail;
@@ -695,7 +698,7 @@ dpv(struct dpv_config *config, struct dpv_file_node *file_list)
close(dialog_out);
waitpid(pid, (int *)NULL, 0);
}
- if (!dpv_interrupt)
+ if (!keep_tite && !dpv_interrupt)
printf("\n");
} else
warnx("%s: %lli overall read", __func__, dpv_overall_read);
diff --git a/lib/libdpv/dpv.h b/lib/libdpv/dpv.h
index 03768a7ced40..67d7bc11e9a8 100644
--- a/lib/libdpv/dpv.h
+++ b/lib/libdpv/dpv.h
@@ -97,6 +97,7 @@ struct dpv_file_node {
* Anatomy of config option to pass as dpv() config argument
*/
struct dpv_config {
+ uint8_t keep_tite; /* Prevent visually distracting exit */
enum dpv_display display_type; /* Display (default TYPE_LIBDIALOG) */
enum dpv_output output_type; /* Output (default TYPE_NONE) */
int debug; /* Enable debugging output on stderr */
diff --git a/lib/libdpv/dpv_private.h b/lib/libdpv/dpv_private.h
index 5164eb321ed2..1bebba643f18 100644
--- a/lib/libdpv/dpv_private.h
+++ b/lib/libdpv/dpv_private.h
@@ -38,6 +38,7 @@ extern uint8_t debug;
extern unsigned int dpv_nfiles;
/* Extra display information */
+extern uint8_t keep_tite;
extern uint8_t no_labels;
extern uint8_t wide;
extern char *msg_done, *msg_fail, *msg_pending;