aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib/unix
diff options
context:
space:
mode:
authorChris Luke <chrisy@flirble.org>2017-11-12 22:26:37 -0500
committerDamjan Marion <dmarion.lists@gmail.com>2017-11-13 14:33:32 +0000
commit2d8bf304230102a6d9b312b98315418617798175 (patch)
tree599f0fdb8340ae61b8a9c284699e06cf2e7ff9e4 /src/vlib/unix
parent192267d490e6f791073236e6e5b303c051cbab48 (diff)
Instead of a min term size, use a default (VPP-1061)
- In the bug report, Docker was sometimes giving shells a 0,0 terminal size. The minimum-term-size logic meant that VPP assumed the terminal had 1 row. The pager functioned, but of course overwrote the one line with its own prompt. - Instead of a minimum size, always use a default size when the either terminal dimension is 0. Change-Id: Iee5a465f0e4cbb618ef2222b40a52994aefa54bf Signed-off-by: Chris Luke <chrisy@flirble.org>
Diffstat (limited to 'src/vlib/unix')
-rw-r--r--src/vlib/unix/cli.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/vlib/unix/cli.c b/src/vlib/unix/cli.c
index 3eb1d9ee86c..d484a0336f2 100644
--- a/src/vlib/unix/cli.c
+++ b/src/vlib/unix/cli.c
@@ -88,18 +88,17 @@
#define ANSI_RESTCURSOR CSI "u"
/** Maximum depth into a byte stream from which to compile a Telnet
- * protocol message. This is a saftey measure. */
+ * protocol message. This is a safety measure. */
#define UNIX_CLI_MAX_DEPTH_TELNET 24
-/** Minimum terminal width we will accept */
-#define UNIX_CLI_MIN_TERMINAL_WIDTH 1
/** Maximum terminal width we will accept */
#define UNIX_CLI_MAX_TERMINAL_WIDTH 512
-/** Minimum terminal height we will accept */
-#define UNIX_CLI_MIN_TERMINAL_HEIGHT 1
/** Maximum terminal height we will accept */
#define UNIX_CLI_MAX_TERMINAL_HEIGHT 512
-
+/** Default terminal height */
+#define UNIX_CLI_DEFAULT_TERMINAL_HEIGHT 24
+/** Default terminal width */
+#define UNIX_CLI_DEFAULT_TERMINAL_WIDTH 80
/** A CLI banner line. */
typedef struct
@@ -1265,15 +1264,15 @@ unix_cli_process_telnet (unix_main_t * um,
clib_net_to_host_u16 (*((u16 *) (input_vector + 3)));
if (cf->width > UNIX_CLI_MAX_TERMINAL_WIDTH)
cf->width = UNIX_CLI_MAX_TERMINAL_WIDTH;
- if (cf->width < UNIX_CLI_MIN_TERMINAL_WIDTH)
- cf->width = UNIX_CLI_MIN_TERMINAL_WIDTH;
+ if (cf->width == 0)
+ cf->width = UNIX_CLI_DEFAULT_TERMINAL_WIDTH;
cf->height =
clib_net_to_host_u16 (*((u16 *) (input_vector + 5)));
if (cf->height > UNIX_CLI_MAX_TERMINAL_HEIGHT)
cf->height = UNIX_CLI_MAX_TERMINAL_HEIGHT;
- if (cf->height < UNIX_CLI_MIN_TERMINAL_HEIGHT)
- cf->height = UNIX_CLI_MIN_TERMINAL_HEIGHT;
+ if (cf->height == 0)
+ cf->height = UNIX_CLI_DEFAULT_TERMINAL_HEIGHT;
/* reindex pager buffer */
unix_cli_pager_reindex (cf);
@@ -2674,6 +2673,12 @@ unix_cli_listen_read_ready (clib_file_t * uf)
/* Setup the pager */
cf->no_pager = um->cli_no_pager;
+ /* Default terminal dimensions, should the terminal
+ * fail to provide any.
+ */
+ cf->width = UNIX_CLI_DEFAULT_TERMINAL_WIDTH;
+ cf->height = UNIX_CLI_DEFAULT_TERMINAL_HEIGHT;
+
/* Send the telnet options */
uf = pool_elt_at_index (fm->file_pool, cf->clib_file_index);
unix_vlib_cli_output_raw (cf, uf, charmode_option,
@@ -2713,14 +2718,14 @@ unix_cli_resize_interrupt (int signum)
cf->width = ws.ws_col;
if (cf->width > UNIX_CLI_MAX_TERMINAL_WIDTH)
cf->width = UNIX_CLI_MAX_TERMINAL_WIDTH;
- if (cf->width < UNIX_CLI_MIN_TERMINAL_WIDTH)
- cf->width = UNIX_CLI_MIN_TERMINAL_WIDTH;
+ if (cf->width == 0)
+ cf->width = UNIX_CLI_DEFAULT_TERMINAL_WIDTH;
cf->height = ws.ws_row;
if (cf->height > UNIX_CLI_MAX_TERMINAL_HEIGHT)
cf->height = UNIX_CLI_MAX_TERMINAL_HEIGHT;
- if (cf->height < UNIX_CLI_MIN_TERMINAL_HEIGHT)
- cf->height = UNIX_CLI_MIN_TERMINAL_HEIGHT;
+ if (cf->height == 0)
+ cf->height = UNIX_CLI_DEFAULT_TERMINAL_HEIGHT;
/* Reindex the pager buffer */
unix_cli_pager_reindex (cf);
@@ -2781,8 +2786,8 @@ unix_cli_config (vlib_main_t * vm, unformat_input_t * input)
* We have a tty, but no size. Use defaults.
* vpp "unix interactive" inside emacs + gdb ends up here.
*/
- cf->width = 80;
- cf->height = 24;
+ cf->width = UNIX_CLI_DEFAULT_TERMINAL_WIDTH;
+ cf->height = UNIX_CLI_DEFAULT_TERMINAL_HEIGHT;
}
/* Setup the history */