If an empty format string is supplied, such as -F "", make that imply -q and cancel -c, so that -F "" -F "%b %t %r %p %e" -M both will monitor both sides but only display the output side - which will be useful when ratio is added (#67).
This commit is contained in:
@@ -240,6 +240,7 @@ extern void pv_state_output_set(pvstate_t, int, const char *);
|
||||
extern void pv_state_average_rate_window_set(pvstate_t, unsigned int);
|
||||
extern void pv_state_set_terminal_supports_utf8(pvstate_t, bool);
|
||||
extern void pv_state_othermonitor_set(pvstate_t, pid_t, int, int);
|
||||
extern void pv_state_cancel_output_if_empty_format_string(pvstate_t);
|
||||
|
||||
extern void pv_state_inputfiles(pvstate_t, unsigned int, const char **);
|
||||
extern void pv_state_watchfds(pvstate_t, unsigned int, const pid_t *, const int *);
|
||||
|
||||
@@ -325,6 +325,7 @@ static int pv__run_monitor(const char *program_name, pvstate_t state, pvside_t s
|
||||
/*@+observertrans@ */
|
||||
pv_state_inputfiles(state, 1, dummy_argv);
|
||||
|
||||
pv_state_cancel_output_if_empty_format_string(state);
|
||||
return pv_main_loop(state);
|
||||
}
|
||||
|
||||
@@ -892,10 +893,12 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
case PV_ACTION_TRANSFER:
|
||||
/* Normal "transfer data" mode. */
|
||||
pv_state_cancel_output_if_empty_format_string(state);
|
||||
retcode = pv_main_loop(state);
|
||||
break;
|
||||
case PV_ACTION_STORE_AND_FORWARD:
|
||||
/* Store-and-forward transfer mode. */
|
||||
pv_state_cancel_output_if_empty_format_string(state);
|
||||
retcode = pv__store_and_forward(state, opts, can_have_eta);
|
||||
break;
|
||||
case PV_ACTION_WATCHFD:
|
||||
|
||||
@@ -185,10 +185,6 @@ int pv_main_loop(pvstate_t state)
|
||||
unsigned int file_idx;
|
||||
bool output_is_pipe;
|
||||
|
||||
/* TODO: treat "-F ''" as "-q" so there's no extra blank line. */
|
||||
/* TODO: if "-q", turn off "-c", again so there's no blank line. */
|
||||
/* May need local no_display and cursor flags for this. */
|
||||
|
||||
/*
|
||||
* "written" is ALWAYS bytes written by the last transfer.
|
||||
*
|
||||
|
||||
@@ -779,6 +779,18 @@ void pv_state_othermonitor_set(pvstate_t state, pid_t pid, int read_fd, int writ
|
||||
state->control.othermonitor_write_fd = write_fd;
|
||||
}
|
||||
|
||||
/* If the format string is set to an empty string, stop all display output. */
|
||||
void pv_state_cancel_output_if_empty_format_string(pvstate_t state)
|
||||
{
|
||||
if (NULL == state->control.format_string)
|
||||
return;
|
||||
if ('\0' != state->control.format_string[0])
|
||||
return;
|
||||
debug("%s", "empty format string - setting no_display and turning off cursor positioning");
|
||||
state->control.no_display = true;
|
||||
state->control.cursor = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the array of input files.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user