--- //home/zerodogg/tt/src/config.c~termwidth +++ //home/zerodogg/tt/src/config.c @@ -28,6 +28,40 @@ #include "tintin.h" +#ifdef ENABLE_TERMWIDTH +DO_CONFIG(config_termwidth) +{ + char str[BUFFER_SIZE]; + + if (!strcasecmp(arg, "OFF")||(is_number(arg) && atoi(arg) <= 0)) + { + ses->force_cols = 0; + } + else if (!is_number(arg)) + { + tintin_printf(ses, "#SYNTAX: #CONFIG {TERMWIDTH} "); + return NULL; + } + else if (atoi(arg) < 10 || atoi(arg) > 500) + { + tintin_printf(ses, "#CONFIG {TERMWIDTH}: REFUSING UNREASONABLE WIDTH NUMBER"); + return NULL; + } + else + { + ses->force_cols = atoi(arg); + } + + init_screen_size(ses); + + sprintf(str, "%d", index); + + updatenode_list(ses, config_table[index].name, capitalize(arg), str, LIST_CONFIG); + + return ses; +} +#endif + DO_COMMAND(do_configure) { --- //home/zerodogg/tt/src/main.c~termwidth +++ //home/zerodogg/tt/src/main.c @@ -302,6 +302,9 @@ printf("\033=\033[?1h"); +#ifdef ENABLE_TERMWIDTH + do_configure(gts, "{TERMWIDTH} {OFF}"); +#endif do_configure(gts, "{SPEEDWALK} {OFF}"); do_configure(gts, "{VERBATIM} {OFF}"); do_configure(gts, "{REPEAT ENTER} {OFF}"); --- //home/zerodogg/tt/src/session.c~termwidth +++ //home/zerodogg/tt/src/session.c @@ -203,6 +203,13 @@ newsession = calloc(1, sizeof(struct session)); +#ifdef ENABLE_TERMWIDTH + newsession->force_cols = 0; + if(ses->force_cols != 0) + { + newsession->force_cols = ses->force_cols; + } +#endif newsession->name = strdup(name); newsession->host = strdup(host); newsession->port = strdup(port); --- //home/zerodogg/tt/src/tables.c~termwidth +++ //home/zerodogg/tt/src/tables.c @@ -141,6 +141,16 @@ struct config_type config_table[] = { +#ifdef ENABLE_TERMWIDTH + + { + "TERMWIDTH", + "", + "Force text wrapping shorter than the terminal width", + config_termwidth + }, + +#endif { "SPEEDWALK", "Your input is scanned for speedwalk directions", --- //home/zerodogg/tt/src/terminal.c~termwidth +++ //home/zerodogg/tt/src/terminal.c @@ -128,6 +128,20 @@ ses->rows = screen.ws_row; ses->cols = screen.ws_col; } +#ifdef ENABLE_TERMWIDTH + if(ses->force_cols != 0) + { + if(ses->force_cols > ses->cols) + { + tintin_printf(ses, "#ERROR: TERMWIDTH can't be forced to be wider than your actual terminal width. (actual: %d, tried forcing: %d)", ses->cols, ses->force_cols); + ses->force_cols = 0; + } + else + { + ses->cols = ses->force_cols; + } + } +#endif ses->top_row = top; ses->bot_row = ses->rows - bot; --- //home/zerodogg/tt/src/tintin.h~termwidth +++ //home/zerodogg/tt/src/tintin.h @@ -522,6 +522,9 @@ int socket; int telopts; int flags; +#ifdef ENABLE_TERMWIDTH + int force_cols; +#endif char * host; char * port; long long connect_retry; @@ -1026,6 +1029,9 @@ #define __CONFIG_H__ extern DO_COMMAND(do_configure); +#ifdef ENABLE_TERMWIDTH +extern DO_CONFIG(config_termwidth); +#endif extern DO_CONFIG(config_speedwalk); extern DO_CONFIG(config_verbatim); extern DO_CONFIG(config_repeatenter); --- //home/zerodogg/tt/src/configure.in~termwidth +++ //home/zerodogg/tt/src/configure.in @@ -75,6 +75,13 @@ AC_HEADER_TIME AC_STRUCT_TM +# Termwidth +AC_ARG_ENABLE(termwidth, +[ --enable-termwidth enable configurable terminal width [default=no]], +,enable_termwidth=no) +if test x$enable_termwidth = xyes; then + AC_DEFINE(ENABLE_TERMWIDTH, 1, Configurable termwidth support) +fi # Checks for library functions.