Add a configurable option to make Return in Telnet send an ordinary
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 29 Dec 2001 17:21:26 +0000 (17:21 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 29 Dec 2001 17:21:26 +0000 (17:21 +0000)
^M instead of the Telnet New Line code. Unix-type telnetds don't
care one way or the other; RDB claims some telnetds prefer Telnet
NL; and now someone has found one that can't deal with Telnet NL and
prefers ^M. Sigh.

git-svn-id: svn://svn.tartarus.org/sgt/putty@1520 cda61777-01e9-0310-a592-d414129be87e

doc/config.but
ldisc.c
putty.h
settings.c
windlg.c

index c237aa7..646b571 100644 (file)
@@ -1,4 +1,4 @@
-\versionid $Id: config.but,v 1.22 2001/12/15 12:15:24 simon Exp $
+\versionid $Id: config.but,v 1.23 2001/12/29 17:21:26 simon Exp $
 
 \C{config} Configuring PuTTY
 
@@ -1293,6 +1293,22 @@ the Telnet special backspace code, and Control-C will send the
 Telnet special interrupt code. You probably shouldn't enable this
 unless you know what you're doing.
 
+\S{config-telnetkey} \q{Return key sends telnet New Line instead of ^M}
+
+\cfg{winhelp-topic}{telnet.newline}
+
+Unlike most other remote login protocols, the Telnet protocol has a
+special \Q{new line} code that is not the same as the usual line
+endings of Control-M or Control-J. By default, PuTTY sends the
+Telnet New Line code when you press Return, instead of sending
+Control-M as it does in most other protocols.
+
+Most Unix-style Telnet servers don't mind whether they receive
+Telnet New Line or Control-M; some servers do expect New Line, and
+some servers prefer to see ^M. If you are seeing surprising
+behaviour when you press Return in a Telnet session, you might try
+turning this option off to see if it helps.
+
 \H{config-rlogin} The Rlogin panel
 
 The Rlogin panel allows you to configure options that only apply to
diff --git a/ldisc.c b/ldisc.c
index e464c13..131cc42 100644 (file)
--- a/ldisc.c
+++ b/ldisc.c
@@ -200,7 +200,7 @@ void ldisc_send(char *buf, int len, int interactive)
                        back->send(term_buf, term_buflen);
                    if (cfg.protocol == PROT_RAW)
                        back->send("\r\n", 2);
-                   else if (cfg.protocol == PROT_TELNET)
+                   else if (cfg.protocol == PROT_TELNET && cfg.telnet_newline)
                        back->special(TS_EOL);
                    else
                        back->send("\r", 1);
@@ -237,7 +237,10 @@ void ldisc_send(char *buf, int len, int interactive)
            if (keyflag && cfg.protocol == PROT_TELNET && len == 1) {
                switch (buf[0]) {
                  case CTRL('M'):
-                   back->special(TS_EOL);
+                   if (cfg.protocol == PROT_TELNET && cfg.telnet_newline)
+                       back->special(TS_EOL);
+                   else
+                       back->send("\r", 1);
                    break;
                  case CTRL('?'):
                  case CTRL('H'):
diff --git a/putty.h b/putty.h
index 266d6ac..b59703a 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -281,6 +281,7 @@ typedef struct {
     int app_keypad;
     int nethack_keypad;
     int telnet_keyboard;
+    int telnet_newline;
     int alt_f4;                               /* is it special? */
     int alt_space;                    /* is it special? */
     int alt_only;                     /* is it special? */
index 3ebcbb1..0340185 100644 (file)
@@ -198,6 +198,7 @@ void save_settings(char *section, int do_host, Config * cfg)
     write_setting_i(sesskey, "ComposeKey", cfg->compose_key);
     write_setting_i(sesskey, "CtrlAltKeys", cfg->ctrlaltkeys);
     write_setting_i(sesskey, "TelnetKey", cfg->telnet_keyboard);
+    write_setting_i(sesskey, "TelnetRet", cfg->telnet_newline);
     write_setting_i(sesskey, "LocalEcho", cfg->localecho);
     write_setting_i(sesskey, "LocalEdit", cfg->localedit);
     write_setting_s(sesskey, "Answerback", cfg->answerback);
@@ -388,6 +389,7 @@ void load_settings(char *section, int do_host, Config * cfg)
     gppi(sesskey, "ComposeKey", 0, &cfg->compose_key);
     gppi(sesskey, "CtrlAltKeys", 1, &cfg->ctrlaltkeys);
     gppi(sesskey, "TelnetKey", 0, &cfg->telnet_keyboard);
+    gppi(sesskey, "TelnetRet", 1, &cfg->telnet_newline);
     gppi(sesskey, "LocalEcho", LD_BACKEND, &cfg->localecho);
     gppi(sesskey, "LocalEdit", LD_BACKEND, &cfg->localedit);
     gpps(sesskey, "Answerback", "PuTTY", cfg->answerback,
index 78e237c..dc38728 100644 (file)
--- a/windlg.c
+++ b/windlg.c
@@ -437,6 +437,7 @@ enum { IDCX_ABOUT =
     IDC_TPASSIVE,
     IDC_TACTIVE,
     IDC_TELNETKEY,
+    IDC_TELNETRET,
     telnetpanelend,
 
     rloginpanelstart,
@@ -802,6 +803,7 @@ char *help_context_cmd(int id)
       case IDC_TACTIVE:
         return "JI(`',`telnet.passive')";
       case IDC_TELNETKEY:
+      case IDC_TELNETRET:
         return "JI(`',`telnet.specialkeys')";
 
       case IDC_R_TSSTATIC:
@@ -969,6 +971,7 @@ static void init_dlg_ctrls(HWND hwnd, int keepsess)
     CheckDlgButton(hwnd, IDC_COMPOSEKEY, cfg.compose_key);
     CheckDlgButton(hwnd, IDC_CTRLALTKEYS, cfg.ctrlaltkeys);
     CheckDlgButton(hwnd, IDC_TELNETKEY, cfg.telnet_keyboard);
+    CheckDlgButton(hwnd, IDC_TELNETRET, cfg.telnet_newline);
     CheckRadioButton(hwnd, IDC_ECHOBACKEND, IDC_ECHONO,
                     cfg.localecho == LD_BACKEND ? IDC_ECHOBACKEND :
                     cfg.localecho == LD_YES ? IDC_ECHOYES : IDC_ECHONO);
@@ -1580,6 +1583,8 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
            beginbox(&cp, "Adjust telnet session.", IDC_BOX_CONNECTION1);
            checkbox(&cp, "Keyboard sends telnet Backspace and Interrupt",
                     IDC_TELNETKEY);
+           checkbox(&cp, "Return key sends telnet New Line instead of ^M",
+                    IDC_TELNETRET);
            endbox(&cp);
        }
        beginbox(&cp, "Sending of null packets to keep session active",
@@ -1620,6 +1625,8 @@ static void create_controls(HWND hwnd, int dlgtype, int panel)
                      IDC_TACTIVE, NULL);
            checkbox(&cp, "&Keyboard sends telnet Backspace and Interrupt",
                     IDC_TELNETKEY);
+           checkbox(&cp, "Return key sends telnet New Line instead of ^M",
+                    IDC_TELNETRET);
            endbox(&cp);
        }
     }
@@ -2333,6 +2340,12 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg,
                        cfg.telnet_keyboard =
                        IsDlgButtonChecked(hwnd, IDC_TELNETKEY);
                break;
+             case IDC_TELNETRET:
+               if (HIWORD(wParam) == BN_CLICKED ||
+                   HIWORD(wParam) == BN_DOUBLECLICKED)
+                       cfg.telnet_newline =
+                       IsDlgButtonChecked(hwnd, IDC_TELNETRET);
+               break;
              case IDC_WRAPMODE:
                if (HIWORD(wParam) == BN_CLICKED ||
                    HIWORD(wParam) == BN_DOUBLECLICKED)