This commit is contained in:
Ryan Gambord 2022-08-18 20:11:43 +00:00 committed by GitHub
commit 5c5f872690
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View File

@ -115,6 +115,9 @@ options.
Be quiet, do not print informative messages. Be quiet, do not print informative messages.
.It Fl r .It Fl r
Read-only session, user input is ignored. Read-only session, user input is ignored.
.IT F1 s
Silently Attach/Detach without switching to/from alternate buffer. Useful for automatically reconnecting
persistent SSH connections that don't want to alter terminal state when reconnecting.
.It Fl v .It Fl v
Print version information and exit. Print version information and exit.
.El .El

View File

@ -98,6 +98,7 @@ struct Client {
enum { enum {
CLIENT_READONLY = 1 << 0, CLIENT_READONLY = 1 << 0,
CLIENT_LOWPRIORITY = 1 << 1, CLIENT_LOWPRIORITY = 1 << 1,
CLIENT_NOALTBUF = 1 << 1,
} flags; } flags;
Client *next; Client *next;
}; };
@ -223,7 +224,7 @@ static void die(const char *s) {
} }
static void usage(void) { static void usage(void) {
fprintf(stderr, "usage: abduco [-a|-A|-c|-n] [-p] [-r] [-q] [-l] [-f] [-e detachkey] name command\n"); fprintf(stderr, "usage: abduco [-a|-A|-c|-n] [-p] [-r] [-q] [-l] [-f] [-s] [-e detachkey] name command\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -633,6 +634,9 @@ int main(int argc, char *argv[]) {
case 'r': case 'r':
client.flags |= CLIENT_READONLY; client.flags |= CLIENT_READONLY;
break; break;
case 's':
client.flags |= CLIENT_NOALTBUF;
break;
case 'l': case 'l':
client.flags |= CLIENT_LOWPRIORITY; client.flags |= CLIENT_LOWPRIORITY;
break; break;

View File

@ -25,7 +25,7 @@ static void client_restore_terminal(void) {
if (!has_term) if (!has_term)
return; return;
tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_term); tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_term);
if (alternate_buffer) { if (!(client.flags & CLIENT_NOALTBUF) && alternate_buffer) {
printf("\033[?25h\033[?1049l"); printf("\033[?25h\033[?1049l");
fflush(stdout); fflush(stdout);
alternate_buffer = false; alternate_buffer = false;
@ -48,7 +48,7 @@ static void client_setup_terminal(void) {
cur_term.c_cc[VTIME] = 0; cur_term.c_cc[VTIME] = 0;
tcsetattr(STDIN_FILENO, TCSANOW, &cur_term); tcsetattr(STDIN_FILENO, TCSANOW, &cur_term);
if (!alternate_buffer) { if (!(client.flags & CLIENT_NOALTBUF) && !alternate_buffer) {
printf("\033[?1049h\033[H"); printf("\033[?1049h\033[H");
fflush(stdout); fflush(stdout);
alternate_buffer = true; alternate_buffer = true;