X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/1709795fee167cc2d2d423df0161e7963376b910..514702987c9252fcb0ab98882a6603b3bd0505ce:/ldisc.c diff --git a/ldisc.c b/ldisc.c index e6a110b1..d7b6e40a 100644 --- a/ldisc.c +++ b/ldisc.c @@ -9,17 +9,20 @@ #include #include "putty.h" +#include "terminal.h" #define ECHOING (cfg.localecho == LD_YES || \ (cfg.localecho == LD_BACKEND && \ - (back->ldisc(LD_ECHO) || term_ldisc(LD_ECHO)))) + (back->ldisc(backhandle, LD_ECHO) || \ + term_ldisc(term, LD_ECHO)))) #define EDITING (cfg.localedit == LD_YES || \ (cfg.localedit == LD_BACKEND && \ - (back->ldisc(LD_EDIT) || term_ldisc(LD_EDIT)))) + (back->ldisc(backhandle, LD_EDIT) || \ + term_ldisc(term, LD_EDIT)))) static void c_write(char *buf, int len) { - from_backend(0, buf, len); + from_backend(term, 0, buf, len); } static char *term_buf = NULL; @@ -27,7 +30,7 @@ static int term_buflen = 0, term_bufsiz = 0, term_quotenext = 0; static int plen(unsigned char c) { - if ((c >= 32 && c <= 126) || (c >= 160 && !in_utf)) + if ((c >= 32 && c <= 126) || (c >= 160 && !in_utf(term))) return 1; else if (c < 128) return 2; /* ^x for some x */ @@ -37,7 +40,7 @@ static int plen(unsigned char c) static void pwrite(unsigned char c) { - if ((c >= 32 && c <= 126) || (c >= 160 && !in_utf)) { + if ((c >= 32 && c <= 126) || (c >= 160 && !in_utf(term))) { c_write(&c, 1); } else if (c < 128) { char cc[2]; @@ -70,8 +73,15 @@ void ldisc_send(char *buf, int len, int interactive) if (len == 0) { void ldisc_update(int echo, int edit); ldisc_update(ECHOING, EDITING); + return; } /* + * Notify the front end that something was pressed, in case + * it's depending on finding out (e.g. keypress termination for + * Close On Exit). + */ + frontend_keypress(); + /* * Less than zero means null terminated special string. */ if (len < 0) { @@ -130,7 +140,7 @@ void ldisc_send(char *buf, int len, int interactive) bsb(plen(term_buf[term_buflen - 1])); term_buflen--; } - back->special(TS_EL); + back->special(backhandle, TS_EL); /* * We don't send IP, SUSP or ABORT if the user has * configured telnet specials off! This breaks @@ -139,11 +149,11 @@ void ldisc_send(char *buf, int len, int interactive) if (!cfg.telnet_keyboard) goto default_case; if (c == CTRL('C')) - back->special(TS_IP); + back->special(backhandle, TS_IP); if (c == CTRL('Z')) - back->special(TS_SUSP); + back->special(backhandle, TS_SUSP); if (c == CTRL('\\')) - back->special(TS_ABORT); + back->special(backhandle, TS_ABORT); break; case CTRL('R'): /* redraw line */ if (ECHOING) { @@ -158,9 +168,9 @@ void ldisc_send(char *buf, int len, int interactive) break; case CTRL('D'): /* logout or send */ if (term_buflen == 0) { - back->special(TS_EOF); + back->special(backhandle, TS_EOF); } else { - back->send(term_buf, term_buflen); + back->send(backhandle, term_buf, term_buflen); term_buflen = 0; } break; @@ -196,13 +206,13 @@ void ldisc_send(char *buf, int len, int interactive) /* FALLTHROUGH */ case KCTRL('M'): /* send with newline */ if (term_buflen > 0) - back->send(term_buf, term_buflen); + back->send(backhandle, term_buf, term_buflen); if (cfg.protocol == PROT_RAW) - back->send("\r\n", 2); + back->send(backhandle, "\r\n", 2); else if (cfg.protocol == PROT_TELNET && cfg.telnet_newline) - back->special(TS_EOL); + back->special(backhandle, TS_EOL); else - back->send("\r", 1); + back->send(backhandle, "\r", 1); if (ECHOING) c_write("\r\n", 2); term_buflen = 0; @@ -224,7 +234,7 @@ void ldisc_send(char *buf, int len, int interactive) } } else { if (term_buflen != 0) { - back->send(term_buf, term_buflen); + back->send(backhandle, term_buf, term_buflen); while (term_buflen > 0) { bsb(plen(term_buf[term_buflen - 1])); term_buflen--; @@ -237,33 +247,33 @@ void ldisc_send(char *buf, int len, int interactive) switch (buf[0]) { case CTRL('M'): if (cfg.protocol == PROT_TELNET && cfg.telnet_newline) - back->special(TS_EOL); + back->special(backhandle, TS_EOL); else - back->send("\r", 1); + back->send(backhandle, "\r", 1); break; case CTRL('?'): case CTRL('H'): if (cfg.telnet_keyboard) { - back->special(TS_EC); + back->special(backhandle, TS_EC); break; } case CTRL('C'): if (cfg.telnet_keyboard) { - back->special(TS_IP); + back->special(backhandle, TS_IP); break; } case CTRL('Z'): if (cfg.telnet_keyboard) { - back->special(TS_SUSP); + back->special(backhandle, TS_SUSP); break; } default: - back->send(buf, len); + back->send(backhandle, buf, len); break; } } else - back->send(buf, len); + back->send(backhandle, buf, len); } } }