From 908104fbb46e866572ca05e59ee51e9db8c94161 Mon Sep 17 00:00:00 2001 From: Robert de Bath Date: Sun, 17 Jan 2016 08:32:00 +0000 Subject: [PATCH] Add 'No ANSI terminal' option. --- attach.c | 8 ++++++-- dtach.h | 2 +- main.c | 5 +++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/attach.c b/attach.c index 41a696c..09a198d 100644 --- a/attach.c +++ b/attach.c @@ -40,8 +40,11 @@ restore_term(void) tcsetattr(0, TCSADRAIN, &orig_term); /* Make cursor visible. Assumes VT100. */ - printf("\033[?25h"); + if (!no_ansiterm) + printf("\033[?25h"); fflush(stdout); + if (no_ansiterm) + (void)system("tput init 2>/dev/null"); } /* Connects to a unix domain socket */ @@ -214,7 +217,8 @@ attach_main(int noerror) tcsetattr(0, TCSADRAIN, &cur_term); /* Clear the screen. This assumes VT100. */ - write(1, "\33[H\33[J", 6); + if (!no_ansiterm) + write(1, "\33[H\33[J", 6); /* Tell the master that we want to attach. */ memset(&pkt, 0, sizeof(struct packet)); diff --git a/dtach.h b/dtach.h index c4d39cb..534071c 100644 --- a/dtach.h +++ b/dtach.h @@ -81,7 +81,7 @@ #endif extern char *progname, *sockname; -extern int detach_char, no_suspend, redraw_method; +extern int detach_char, no_suspend, redraw_method, no_ansiterm; extern struct termios orig_term; extern int dont_have_tty; diff --git a/main.c b/main.c index 9fe78b8..2472d98 100644 --- a/main.c +++ b/main.c @@ -36,6 +36,8 @@ int detach_char = '\\' - 64; int no_suspend; /* The default redraw method. Initially set to unspecified. */ int redraw_method = REDRAW_UNSPEC; +/* 1 if we should not send ansi sequences to the terminal */ +int no_ansiterm = 0; /* ** The original terminal settings. Shared between the master and attach @@ -78,6 +80,7 @@ usage() "\t\t ctrl_l: Send a Ctrl L character to the program.\n" "\t\t winch: Send a WINCH signal to the program.\n" " -z\t\tDisable processing of the suspend key.\n" + " -t\t\tDisable VT100 assumptions.\n" "\nReport any bugs to <" PACKAGE_BUGREPORT ">.\n", PACKAGE_VERSION, __DATE__, __TIME__); exit(0); @@ -158,6 +161,8 @@ main(int argc, char **argv) detach_char = -1; else if (*p == 'z') no_suspend = 1; + else if (*p == 't') + no_ansiterm = 1; else if (*p == 'e') { ++argv; --argc;