mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-03 06:39:39 +00:00
Adapt help to terminal size
If the error stream is a terminal, and we can retrieve the terminal size, wrap the lines at terminal boundaries.
This commit is contained in:
parent
740445f425
commit
d9dbee9993
1 changed files with 13 additions and 1 deletions
|
@ -11,6 +11,7 @@
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/strbuf.h"
|
#include "util/strbuf.h"
|
||||||
#include "util/str_util.h"
|
#include "util/str_util.h"
|
||||||
|
#include "util/term.h"
|
||||||
|
|
||||||
#define STR_IMPL_(x) #x
|
#define STR_IMPL_(x) #x
|
||||||
#define STR(x) STR_IMPL_(x)
|
#define STR(x) STR_IMPL_(x)
|
||||||
|
@ -741,7 +742,18 @@ print_shortcut(const struct sc_shortcut *shortcut, unsigned cols) {
|
||||||
|
|
||||||
void
|
void
|
||||||
scrcpy_print_usage(const char *arg0) {
|
scrcpy_print_usage(const char *arg0) {
|
||||||
const unsigned cols = 80; // For now, use an hardcoded value
|
#define SC_TERM_COLS_DEFAULT 80
|
||||||
|
unsigned cols;
|
||||||
|
|
||||||
|
if (!isatty(STDERR_FILENO)) {
|
||||||
|
// Not a tty, use a default value
|
||||||
|
cols = SC_TERM_COLS_DEFAULT;
|
||||||
|
} else {
|
||||||
|
bool ok = sc_term_get_size(NULL, &cols);
|
||||||
|
if (!ok) {
|
||||||
|
cols = SC_TERM_COLS_DEFAULT; // default value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(stderr, "Usage: %s [options]\n\n"
|
fprintf(stderr, "Usage: %s [options]\n\n"
|
||||||
"Options:\n", arg0);
|
"Options:\n", arg0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue