Skip to content

Commit

Permalink
Add 'No ANSI terminal' option.
Browse files Browse the repository at this point in the history
  • Loading branch information
rdebath committed Jun 23, 2016
1 parent 70accb8 commit e14633c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 6 additions & 2 deletions attach.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion dtach.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 5 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e14633c

Please sign in to comment.