Move omission of SSH protocol setting in PuTTYtel into windlg.c and
[sgt/putty] / windlg.c
index 47888f4..faa7199 100644 (file)
--- a/windlg.c
+++ b/windlg.c
@@ -354,6 +354,11 @@ static int CALLBACK LogProc (HWND hwnd, UINT msg,
                     char *clipdata;
                     static unsigned char sel_nl[] = SEL_NL;
 
+                    if (count == 0) {  /* can't copy zero stuff */
+                        MessageBeep(0);
+                        break;
+                    }
+
                     size = 0;
                     for (i = 0; i < count; i++)
                         size += strlen(events[selitems[i]]) + sizeof(sel_nl);
@@ -369,11 +374,14 @@ static int CALLBACK LogProc (HWND hwnd, UINT msg,
                             memcpy(p, sel_nl, sizeof(sel_nl));
                             p += sizeof(sel_nl);
                         }
-                        write_clip(clipdata, size);
-                        term_deselect();
+                        write_clip(clipdata, size, TRUE);
                         free(clipdata);
                     }
                     free(selitems);
+
+                    for (i = 0; i < nevents; i++)
+                        SendDlgItemMessage(hwnd, IDN_LIST, LB_SETSEL,
+                                           FALSE, i);
                 }
             }
             return 0;
@@ -457,7 +465,7 @@ struct ctlpos {
 };
 
 /* Used on self-constructed dialogs. */
-void ctlposinit(struct ctlpos *cp, HWND hwnd) {
+static void ctlposinit(struct ctlpos *cp, HWND hwnd) {
     RECT r;
     cp->hwnd = hwnd;
     cp->units = GetWindowLong(hwnd, GWL_USERDATA);
@@ -468,7 +476,7 @@ void ctlposinit(struct ctlpos *cp, HWND hwnd) {
 }
 
 /* Used on kosher dialogs. */
-void ctlposinit2(struct ctlpos *cp, HWND hwnd) {
+static void ctlposinit2(struct ctlpos *cp, HWND hwnd) {
     RECT r;
     cp->hwnd = hwnd;
     r.left = r.top = 0;
@@ -482,8 +490,9 @@ void ctlposinit2(struct ctlpos *cp, HWND hwnd) {
     cp->width = (r.right * 4) / (cp->units & 0xFFFF) - 2*GAPBETWEEN;
 }
 
-void doctl(struct ctlpos *cp, RECT r, char *wclass, int wstyle, int exstyle,
-           char *wtext, int wid) {
+static void doctl(struct ctlpos *cp, RECT r,
+                  char *wclass, int wstyle, int exstyle,
+                  char *wtext, int wid) {
     HWND ctl;
     /*
      * Note nonstandard use of RECT. This is deliberate: by
@@ -507,7 +516,7 @@ void doctl(struct ctlpos *cp, RECT r, char *wclass, int wstyle, int exstyle,
  * Some edit boxes. Each one has a static above it. The percentages
  * of the horizontal space are provided.
  */
-void multiedit(struct ctlpos *cp, ...) {
+static void multiedit(struct ctlpos *cp, ...) {
     RECT r;
     va_list ap;
     int percent, xpos;
@@ -549,7 +558,8 @@ void multiedit(struct ctlpos *cp, ...) {
  * needed to line up some 2s and some 3s to look good in the same
  * panel).
  */
-void radioline(struct ctlpos *cp, char *text, int id, int nacross, ...) {
+static void radioline(struct ctlpos *cp,
+                      char *text, int id, int nacross, ...) {
     RECT r;
     va_list ap;
     int group;
@@ -587,7 +597,7 @@ void radioline(struct ctlpos *cp, char *text, int id, int nacross, ...) {
  * A set of radio buttons on multiple lines, with a static above
  * them.
  */
-void radiobig(struct ctlpos *cp, char *text, int id, ...) {
+static void radiobig(struct ctlpos *cp, char *text, int id, ...) {
     RECT r;
     va_list ap;
     int group;
@@ -621,7 +631,7 @@ void radiobig(struct ctlpos *cp, char *text, int id, ...) {
 /*
  * A single standalone checkbox.
  */
-void checkbox(struct ctlpos *cp, char *text, int id) {
+static void checkbox(struct ctlpos *cp, char *text, int id) {
     RECT r;
 
     r.left = GAPBETWEEN; r.top = cp->ypos;
@@ -635,7 +645,8 @@ void checkbox(struct ctlpos *cp, char *text, int id) {
 /*
  * A button on the right hand side, with a static to its left.
  */
-void staticbtn(struct ctlpos *cp, char *stext, int sid, char *btext, int bid) {
+static void staticbtn(struct ctlpos *cp, char *stext, int sid,
+                      char *btext, int bid) {
     const int height = (PUSHBTNHEIGHT > STATICHEIGHT ?
                         PUSHBTNHEIGHT : STATICHEIGHT);
     RECT r;
@@ -662,7 +673,7 @@ void staticbtn(struct ctlpos *cp, char *stext, int sid, char *btext, int bid) {
 /*
  * An edit control on the right hand side, with a static to its left.
  */
-void staticedit(struct ctlpos *cp, char *stext, int sid, int eid) {
+static void staticedit(struct ctlpos *cp, char *stext, int sid, int eid) {
     const int height = (EDITHEIGHT > STATICHEIGHT ?
                         EDITHEIGHT : STATICHEIGHT);
     RECT r;
@@ -689,7 +700,8 @@ void staticedit(struct ctlpos *cp, char *stext, int sid, int eid) {
 /*
  * A tab-control substitute when a real tab control is unavailable.
  */
-void ersatztab(struct ctlpos *cp, char *stext, int sid, int lid, int s2id) {
+static void ersatztab(struct ctlpos *cp, char *stext, int sid,
+                      int lid, int s2id) {
     const int height = (COMBOHEIGHT > STATICHEIGHT ?
                         COMBOHEIGHT : STATICHEIGHT);
     RECT r;
@@ -727,8 +739,8 @@ void ersatztab(struct ctlpos *cp, char *stext, int sid, int lid, int s2id) {
  * A static line, followed by an edit control on the left hand side
  * and a button on the right.
  */
-void editbutton(struct ctlpos *cp, char *stext, int sid,
-                int eid, char *btext, int bid) {
+static void editbutton(struct ctlpos *cp, char *stext, int sid,
+                       int eid, char *btext, int bid) {
     const int height = (EDITHEIGHT > PUSHBTNHEIGHT ?
                         EDITHEIGHT : PUSHBTNHEIGHT);
     RECT r;
@@ -766,8 +778,8 @@ void editbutton(struct ctlpos *cp, char *stext, int sid,
  * that a list box. To the right of the list box, a column of
  * buttons.
  */
-void sesssaver(struct ctlpos *cp, char *text,
-               int staticid, int editid, int listid, ...) {
+static void sesssaver(struct ctlpos *cp, char *text,
+                      int staticid, int editid, int listid, ...) {
     RECT r;
     va_list ap;
     int lwid, rwid, rpos;
@@ -791,7 +803,7 @@ void sesssaver(struct ctlpos *cp, char *text,
     doctl(cp, r, "EDIT",
           WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL,
           WS_EX_CLIENTEDGE,
-          "", staticid);
+          "", editid);
 
     /*
      * The buttons (we should hold off on the list box until we
@@ -832,10 +844,11 @@ void sesssaver(struct ctlpos *cp, char *text,
  * static line first; then a pair of edit boxes with associated
  * statics, and two buttons; then a list box.
  */
-void envsetter(struct ctlpos *cp, char *stext, int sid,
-               char *e1stext, int e1sid, int e1id,
-               char *e2stext, int e2sid, int e2id,
-               int listid, char *b1text, int b1id, char *b2text, int b2id) {
+static void envsetter(struct ctlpos *cp, char *stext, int sid,
+                      char *e1stext, int e1sid, int e1id,
+                      char *e2stext, int e2sid, int e2id,
+                      int listid,
+                      char *b1text, int b1id, char *b2text, int b2id) {
     RECT r;
     const int height = (STATICHEIGHT > EDITHEIGHT && STATICHEIGHT > PUSHBTNHEIGHT ?
                         STATICHEIGHT :
@@ -899,8 +912,8 @@ void envsetter(struct ctlpos *cp, char *stext, int sid,
  * static, then a list, then a line containing a
  * button-and-static-and-edit. 
  */
-void charclass(struct ctlpos *cp, char *stext, int sid, int listid,
-               char *btext, int bid, int eid, char *s2text, int s2id) {
+static void charclass(struct ctlpos *cp, char *stext, int sid, int listid,
+                      char *btext, int bid, int eid, char *s2text, int s2id) {
     RECT r;
     const int height = (STATICHEIGHT > EDITHEIGHT && STATICHEIGHT > PUSHBTNHEIGHT ?
                         STATICHEIGHT :
@@ -959,8 +972,8 @@ void charclass(struct ctlpos *cp, char *stext, int sid, int listid,
  * then on the left, a list box, and on the right, a sequence of
  * two-part statics followed by a button.
  */
-void colouredit(struct ctlpos *cp, char *stext, int sid, int listid,
-                char *btext, int bid, ...) {
+static void colouredit(struct ctlpos *cp, char *stext, int sid, int listid,
+                       char *btext, int bid, ...) {
     RECT r;
     int y;
     va_list ap;
@@ -1078,15 +1091,22 @@ static int CALLBACK ConnectionProc (HWND hwnd, UINT msg,
         multiedit(&cp,
                   "Host &Name", IDC_HOSTSTATIC, IDC_HOST, 75,
                   "&Port", IDC_PORTSTATIC, IDC_PORT, 25, NULL);
-        radioline(&cp, "Protocol:", IDC_PROTSTATIC, 3,
-                  "&Raw", IDC_PROTRAW,
-                  "&Telnet", IDC_PROTTELNET,
+        if (backends[2].backend == NULL) {
+            /* this is PuTTYtel, so only two protocols available */
+            radioline(&cp, "Protocol:", IDC_PROTSTATIC, 3,
+                      "&Raw", IDC_PROTRAW,
+                      "&Telnet", IDC_PROTTELNET, NULL);
+        } else {
+            radioline(&cp, "Protocol:", IDC_PROTSTATIC, 3,
+                      "&Raw", IDC_PROTRAW,
+                      "&Telnet", IDC_PROTTELNET,
 #ifdef FWHACK
-                  "SS&H/hack",
+                      "SS&H/hack",
 #else
-                  "SS&H",
+                      "SS&H",
 #endif
-                  IDC_PROTSSH, NULL);
+                      IDC_PROTSSH, NULL);
+        }
         sesssaver(&cp, "Stor&ed Sessions",
                   IDC_SESSSTATIC, IDC_SESSEDIT, IDC_SESSLIST,
                   "&Load", IDC_SESSLOAD,