Add SSH don't-allocate-pty option, and corresponding LF-implies-CR
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Fri, 15 Jan 1999 11:30:40 +0000 (11:30 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Fri, 15 Jan 1999 11:30:40 +0000 (11:30 +0000)
terminal setting

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

putty.h
ssh.c
terminal.c
win_res.h
win_res.rc
windlg.c
window.c

diff --git a/putty.h b/putty.h
index a456fdb..52a5061 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -95,6 +95,8 @@ typedef struct {
     int port;
     enum { PROT_TELNET, PROT_SSH } protocol;
     int close_on_exit;
+    /* SSH options */
+    int nopty;
     /* Telnet options */
     char termtype[32];
     char termspeed[32];
@@ -111,6 +113,7 @@ typedef struct {
     int savelines;
     int dec_om;
     int wrap_mode;
+    int lfhascr;
     int win_name_always;
     int width, height;
     char font[64];
diff --git a/ssh.c b/ssh.c
index 8092c98..3fae152 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -251,6 +251,7 @@ static int do_ssh_init(void) {
     sprintf(vstring, "SSH-%s-7.7.7\n",
            (strcmp(version, "1.5") <= 0 ? version : "1.5"));
     s_write(vstring, strlen(vstring));
+    return 1;
 }
 
 static void ssh_protocol(unsigned char *in, int inlen, int ispkt) {
@@ -433,30 +434,32 @@ static void ssh_protocol(unsigned char *in, int inlen, int ispkt) {
        }
     }
 
-    i = strlen(cfg.termtype);
-    s_wrpkt_start(10, i+5*4+1);
-    pktout.body[0] = (i >> 24) & 0xFF;
-    pktout.body[1] = (i >> 16) & 0xFF;
-    pktout.body[2] = (i >> 8) & 0xFF;
-    pktout.body[3] = i & 0xFF;
-    memcpy(pktout.body+4, cfg.termtype, i);
-    i += 4;
-    pktout.body[i++] = (rows >> 24) & 0xFF;
-    pktout.body[i++] = (rows >> 16) & 0xFF;
-    pktout.body[i++] = (rows >> 8) & 0xFF;
-    pktout.body[i++] = rows & 0xFF;
-    pktout.body[i++] = (cols >> 24) & 0xFF;
-    pktout.body[i++] = (cols >> 16) & 0xFF;
-    pktout.body[i++] = (cols >> 8) & 0xFF;
-    pktout.body[i++] = cols & 0xFF;
-    memset(pktout.body+i, 0, 9);       /* 0 pixwidth, 0 pixheight, 0.b endofopt */
-    s_wrpkt();
-    ssh_state = SSH_STATE_INTERMED;
-    do { crReturnV; } while (!ispkt);
-    if (pktin.type != 14 && pktin.type != 15) {
-       fatalbox("Protocol confusion");
-    } else if (pktin.type == 15) {
-       c_write("Server refused to allocate pty\r\n", 32);
+    if (!cfg.nopty) {
+        i = strlen(cfg.termtype);
+        s_wrpkt_start(10, i+5*4+1);
+        pktout.body[0] = (i >> 24) & 0xFF;
+        pktout.body[1] = (i >> 16) & 0xFF;
+        pktout.body[2] = (i >> 8) & 0xFF;
+        pktout.body[3] = i & 0xFF;
+        memcpy(pktout.body+4, cfg.termtype, i);
+        i += 4;
+        pktout.body[i++] = (rows >> 24) & 0xFF;
+        pktout.body[i++] = (rows >> 16) & 0xFF;
+        pktout.body[i++] = (rows >> 8) & 0xFF;
+        pktout.body[i++] = rows & 0xFF;
+        pktout.body[i++] = (cols >> 24) & 0xFF;
+        pktout.body[i++] = (cols >> 16) & 0xFF;
+        pktout.body[i++] = (cols >> 8) & 0xFF;
+        pktout.body[i++] = cols & 0xFF;
+        memset(pktout.body+i, 0, 9);       /* 0 pixwidth, 0 pixheight, 0.b endofopt */
+        s_wrpkt();
+        ssh_state = SSH_STATE_INTERMED;
+        do { crReturnV; } while (!ispkt);
+        if (pktin.type != 14 && pktin.type != 15) {
+            fatalbox("Protocol confusion");
+        } else if (pktin.type == 15) {
+            c_write("Server refused to allocate pty\r\n", 32);
+        }
     }
 
     s_wrpkt_start(12, 0);
@@ -670,17 +673,19 @@ static void ssh_size(void) {
        size_needed = TRUE;            /* buffer for later */
        break;
       case SSH_STATE_SESSION:
-       s_wrpkt_start(11, 16);
-       pktout.body[0] = (rows >> 24) & 0xFF;
-       pktout.body[1] = (rows >> 16) & 0xFF;
-       pktout.body[2] = (rows >> 8) & 0xFF;
-       pktout.body[3] = rows & 0xFF;
-       pktout.body[4] = (cols >> 24) & 0xFF;
-       pktout.body[5] = (cols >> 16) & 0xFF;
-       pktout.body[6] = (cols >> 8) & 0xFF;
-       pktout.body[7] = cols & 0xFF;
-       memset(pktout.body+8, 0, 8);
-       s_wrpkt();
+        if (!cfg.nopty) {
+            s_wrpkt_start(11, 16);
+            pktout.body[0] = (rows >> 24) & 0xFF;
+            pktout.body[1] = (rows >> 16) & 0xFF;
+            pktout.body[2] = (rows >> 8) & 0xFF;
+            pktout.body[3] = rows & 0xFF;
+            pktout.body[4] = (cols >> 24) & 0xFF;
+            pktout.body[5] = (cols >> 16) & 0xFF;
+            pktout.body[6] = (cols >> 8) & 0xFF;
+            pktout.body[7] = cols & 0xFF;
+            memset(pktout.body+8, 0, 8);
+            s_wrpkt();
+        }
     }
 }
 
index a935be7..b41eacd 100644 (file)
@@ -628,6 +628,8 @@ void term_out(void) {
                    scroll (marg_t, marg_b, 1, TRUE);
                else if (curs_y < rows-1)
                    curs_y++;
+                if (cfg.lfhascr)
+                    curs_x = 0;
                fix_cpos;
                wrapnext = FALSE;
                disptop = scrtop;
index 56c7a0c..d4925ab 100644 (file)
--- a/win_res.h
+++ b/win_res.h
@@ -73,6 +73,7 @@
 #define IDC2_VTOEMANSI  1015
 #define IDC2_VTOEMONLY  1016
 #define IDC2_VTPOORMAN  1017
+#define IDC2_LFHASCR    1018
 
 #define IDC3_TTSTATIC   1001
 #define IDC3_TTEDIT     1002
@@ -92,6 +93,8 @@
 #define IDC3_EMBSD      1016
 #define IDC3_EMRFC      1017
 
+#define IDC3_NOPTY      1018
+
 #define IDC4_MBSTATIC   1001
 #define IDC4_MBWINDOWS  1002
 #define IDC4_MBXTERM    1003
index de4216a..31ba00d 100644 (file)
@@ -14,7 +14,7 @@ BEGIN
     DEFPUSHBUTTON "&Close", IDOK, 82, 40, 48, 14
     PUSHBUTTON "View &Licence", IDA_LICENCE, 6, 40, 70, 14
     ICON IDI_MAINICON, IDA_ICON, 10, 10, 0, 0
-    LTEXT "PuTTY Beta 0.43\n\251 1997-8 Simon Tatham\nAll rights reserved.",
+    LTEXT "PuTTY Beta 0.44\n\251 1997-8 Simon Tatham\nAll rights reserved.",
           IDA_TEXT, 40, 6, 96, 24
 END
 
@@ -103,13 +103,14 @@ BEGIN
     AUTOCHECKBOX "Auto wrap mode initially on", IDC2_WRAPMODE, 3, 3, 162, 10
     AUTOCHECKBOX "DEC Origin Mode initially on", IDC2_DECOM, 3, 13, 162, 10
     AUTOCHECKBOX "Avoid ever using icon title", IDC2_WINNAME, 3, 23, 162, 10
-    LTEXT "Terminal screen dimensions:", IDC2_DIMSTATIC, 3, 33, 162, 8
-    RTEXT "Rows", IDC2_ROWSSTATIC, 20, 44, 90, 8
-    EDITTEXT IDC2_ROWSEDIT, 118, 42, 30, 12
-    RTEXT "Columns", IDC2_COLSSTATIC, 20, 59, 90, 8
-    EDITTEXT IDC2_COLSEDIT, 118, 57, 30, 12
-    RTEXT "Saved lines of scrollback", IDC2_SAVESTATIC, 20, 74, 90, 8
-    EDITTEXT IDC2_SAVEEDIT, 118, 72, 30, 12
+    AUTOCHECKBOX "Implicit CR in every LF", IDC2_LFHASCR, 3, 33, 162, 10
+    LTEXT "Terminal screen dimensions:", IDC2_DIMSTATIC, 3, 48, 162, 8
+    RTEXT "Rows", IDC2_ROWSSTATIC, 10, 59, 32, 8
+    EDITTEXT IDC2_ROWSEDIT, 50, 57, 30, 12
+    RTEXT "Columns", IDC2_COLSSTATIC, 95, 59, 32, 8
+    EDITTEXT IDC2_COLSEDIT, 135, 57, 30, 12
+    RTEXT "Saved lines of scrollback", IDC2_SAVESTATIC, 20, 74, 107, 8
+    EDITTEXT IDC2_SAVEEDIT, 135, 72, 30, 12
     LTEXT "Font:", IDC2_FONTSTATIC, 3, 93, 99, 8
     PUSHBUTTON "Change...", IDC2_CHOOSEFONT, 105, 90, 60, 14
     LTEXT "Handling of VT100 line drawing characters:",IDC2_VTSTATIC, 3, 111, 162, 8
@@ -153,6 +154,8 @@ FONT 8, "MS Sans Serif"
 BEGIN
     LTEXT "Terminal-type string", IDC3_TTSTATIC, 3, 5, 90, 8
     EDITTEXT IDC3_TTEDIT, 96, 3, 69, 12, ES_AUTOHSCROLL
+    AUTOCHECKBOX "Don't allocate a pseudo-terminal", IDC3_NOPTY,
+       3, 19, 162, 10
     LTEXT "Auto-login username", IDC3_LOGSTATIC, 3, 35, 90, 8
     EDITTEXT IDC3_LOGEDIT, 96, 33, 69, 12, ES_AUTOHSCROLL
 END
index b5d1b57..58b570f 100644 (file)
--- a/windlg.c
+++ b/windlg.c
@@ -153,6 +153,7 @@ static void save_settings (char *section, int do_host) {
        wpps (sesskey, "Environment", buf);
     }
     wpps (sesskey, "UserName", cfg.username);
+    wppi (sesskey, "NoPTY", cfg.nopty);
     wppi (sesskey, "RFCEnviron", cfg.rfc_environ);
     wppi (sesskey, "BackspaceIsDelete", cfg.bksp_is_delete);
     wppi (sesskey, "RXVTHomeEnd", cfg.rxvt_homeend);
@@ -162,6 +163,7 @@ static void save_settings (char *section, int do_host) {
     wppi (sesskey, "ScrollbackLines", cfg.savelines);
     wppi (sesskey, "DECOriginMode", cfg.dec_om);
     wppi (sesskey, "AutoWrapMode", cfg.wrap_mode);
+    wppi (sesskey, "LFImpliesCR", cfg.lfhascr);
     wppi (sesskey, "WinNameAlways", cfg.win_name_always);
     wppi (sesskey, "TermWidth", cfg.width);
     wppi (sesskey, "TermHeight", cfg.height);
@@ -264,6 +266,7 @@ static void load_settings (char *section, int do_host) {
        *q = '\0';
     }
     gpps (sesskey, "UserName", "", cfg.username, sizeof(cfg.username));
+    gppi (sesskey, "NoPTY", 0, &cfg.nopty);
     gppi (sesskey, "RFCEnviron", 0, &cfg.rfc_environ);
     gppi (sesskey, "BackspaceIsDelete", 1, &cfg.bksp_is_delete);
     gppi (sesskey, "RXVTHomeEnd", 0, &cfg.rxvt_homeend);
@@ -273,6 +276,7 @@ static void load_settings (char *section, int do_host) {
     gppi (sesskey, "ScrollbackLines", 200, &cfg.savelines);
     gppi (sesskey, "DECOriginMode", 0, &cfg.dec_om);
     gppi (sesskey, "AutoWrapMode", 1, &cfg.wrap_mode);
+    gppi (sesskey, "LFImpliesCR", 0, &cfg.lfhascr);
     gppi (sesskey, "WinNameAlways", 0, &cfg.win_name_always);
     gppi (sesskey, "TermWidth", 80, &cfg.width);
     gppi (sesskey, "TermHeight", 24, &cfg.height);
@@ -618,6 +622,7 @@ static int CALLBACK TerminalProc (HWND hwnd, UINT msg,
        CheckDlgButton (hwnd, IDC2_WRAPMODE, cfg.wrap_mode);
        CheckDlgButton (hwnd, IDC2_WINNAME, cfg.win_name_always);
        CheckDlgButton (hwnd, IDC2_DECOM, cfg.dec_om);
+       CheckDlgButton (hwnd, IDC2_LFHASCR, cfg.lfhascr);
        SetDlgItemInt (hwnd, IDC2_ROWSEDIT, cfg.height, FALSE);
        SetDlgItemInt (hwnd, IDC2_COLSEDIT, cfg.width, FALSE);
        SetDlgItemInt (hwnd, IDC2_SAVEEDIT, cfg.savelines, FALSE);
@@ -646,6 +651,11 @@ static int CALLBACK TerminalProc (HWND hwnd, UINT msg,
                HIWORD(wParam) == BN_DOUBLECLICKED)
                cfg.dec_om = IsDlgButtonChecked (hwnd, IDC2_DECOM);
            break;
+         case IDC2_LFHASCR:
+           if (HIWORD(wParam) == BN_CLICKED ||
+               HIWORD(wParam) == BN_DOUBLECLICKED)
+               cfg.lfhascr = IsDlgButtonChecked (hwnd, IDC2_LFHASCR);
+           break;
          case IDC2_ROWSEDIT:
            if (HIWORD(wParam) == EN_CHANGE)
                MyGetDlgItemInt (hwnd, IDC2_ROWSEDIT, &cfg.height);
@@ -824,6 +834,7 @@ static int CALLBACK SshProc (HWND hwnd, UINT msg,
       case WM_INITDIALOG:
        SetDlgItemText (hwnd, IDC3_TTEDIT, cfg.termtype);
        SetDlgItemText (hwnd, IDC3_LOGEDIT, cfg.username);
+       CheckDlgButton (hwnd, IDC3_NOPTY, cfg.nopty);
        break;
       case WM_COMMAND:
        switch (LOWORD(wParam)) {
@@ -837,6 +848,11 @@ static int CALLBACK SshProc (HWND hwnd, UINT msg,
                GetDlgItemText (hwnd, IDC3_LOGEDIT, cfg.username,
                                sizeof(cfg.username)-1);
            break;
+         case IDC3_NOPTY:
+           if (HIWORD(wParam) == BN_CLICKED ||
+               HIWORD(wParam) == BN_DOUBLECLICKED)
+               cfg.nopty = IsDlgButtonChecked (hwnd, IDC3_NOPTY);
+           break;
        }
        break;
     }
index 9210d15..098f39e 100644 (file)
--- a/window.c
+++ b/window.c
@@ -703,9 +703,9 @@ static int WINAPI WndProc (HWND hwnd, UINT message,
 #define Y_POS(l) ((int)(short)HIWORD(l))
 
       case WM_LBUTTONDOWN:
-        SetCapture(hwnd);
        click (MB_SELECT, X_POS(lParam) / font_width,
               Y_POS(lParam) / font_height);
+        SetCapture(hwnd);
        return 0;
       case WM_LBUTTONUP:
        term_mouse (MB_SELECT, MA_RELEASE, X_POS(lParam) / font_width,