Skip to content

Instantly share code, notes, and snippets.

@zerodogg
Created October 5, 2009 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zerodogg/202215 to your computer and use it in GitHub Desktop.
Save zerodogg/202215 to your computer and use it in GitHub Desktop.
#
# Patch managed by http://www.holgerschurig.de/patcher.html
#
--- //home/zerodogg/tt/src/config.c~termwidth
+++ //home/zerodogg/tt/src/config.c
@@ -209,19 +209,35 @@
if (!strcasecmp(arg, "ON"))
{
SET_BIT(ses->flags, SES_FLAG_WORDWRAP);
+ ses->force_cols = 0;
}
else if (!strcasecmp(arg, "OFF"))
{
DEL_BIT(ses->flags, SES_FLAG_WORDWRAP);
+ ses->force_cols = 0;
}
+ else if(is_number(arg))
+ {
+ if (atoi(arg) < 10 || atoi(arg) > 500)
+ {
+ tintin_printf(ses, "#ERROR: #CONFIG {%s}: Refusing unreasonable width", config_table[index].name);
+ return NULL;
+ }
+ else
+ {
+ ses->force_cols = atoi(arg);
+ }
+ }
else
{
- tintin_printf(ses, "#SYNTAX: #CONFIG {%s} <ON|OFF>", config_table[index].name);
+ tintin_printf(ses, "#SYNTAX: #CONFIG {%s} <ON|OFF|NUMBER>", config_table[index].name);
return NULL;
}
sprintf(str, "%d", index);
+ init_screen_size(ses);
+
updatenode_list(ses, config_table[index].name, capitalize(arg), str, LIST_CONFIG);
return ses;
--- //home/zerodogg/tt/src/session.c~termwidth
+++ //home/zerodogg/tt/src/session.c
@@ -203,6 +203,15 @@
newsession = calloc(1, sizeof(struct session));
+ if(ses->force_cols != 0)
+ {
+ newsession->force_cols = ses->force_cols;
+ }
+ else
+ {
+ newsession->force_cols = 0;
+ }
+
newsession->name = strdup(name);
newsession->host = strdup(host);
newsession->port = strdup(port);
--- //home/zerodogg/tt/src/terminal.c~termwidth
+++ //home/zerodogg/tt/src/terminal.c
@@ -129,6 +129,19 @@
ses->cols = screen.ws_col;
}
+ if(ses->force_cols != 0)
+ {
+ if(ses->force_cols > ses->cols)
+ {
+ tintin_printf(ses, "#ERROR: WORDWRAP 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;
+ }
+ }
+
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,7 @@
int socket;
int telopts;
int flags;
+ int force_cols;
char * host;
char * port;
long long connect_retry;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment