diff --git a/attach.c b/attach.c index 034e277..b3415e3 100644 --- a/attach.c +++ b/attach.c @@ -41,8 +41,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 */ @@ -215,7 +218,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 d0ba87e..5a55a30 100644 --- a/dtach.h +++ b/dtach.h @@ -82,7 +82,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 5fd7bcc..8b0f30d 100644 --- a/main.c +++ b/main.c @@ -37,6 +37,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 @@ -79,6 +81,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); @@ -159,6 +162,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;