Enable copying the Event Log
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Fri, 22 Sep 2000 14:46:26 +0000 (14:46 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Fri, 22 Sep 2000 14:46:26 +0000 (14:46 +0000)
git-svn-id: svn://svn.tartarus.org/sgt/putty@619 cda61777-01e9-0310-a592-d414129be87e

plink.c
scp.c
win_res.h
win_res.rc
windlg.c

diff --git a/plink.c b/plink.c
index 0a74062..6f979e5 100644 (file)
--- a/plink.c
+++ b/plink.c
@@ -33,6 +33,12 @@ void connection_fatal (char *p, ...) {
     exit(1);
 }
 
+/*
+ * Stubs for linking with other modules.
+ */
+void write_clip (void *data, int len) { }
+void term_deselect(void) { }
+
 HANDLE outhandle;
 DWORD orig_console_mode;
 
diff --git a/scp.c b/scp.c
index 8c7df21..b2ba501 100644 (file)
--- a/scp.c
+++ b/scp.c
@@ -74,14 +74,13 @@ static void send_str_msg(unsigned int msg_id, char *str);
 static void gui_update_stats(char *name, unsigned long size, int percentage, time_t elapsed);
 
 /*
- * These functions are needed to link with ssh.c, but never get called.
+ * These functions are needed to link with other modules, but
+ * (should) never get called.
  */
-void term_out(void)
-{
-    abort();
-}
-void begin_session(void) {
-}
+void term_out(void) { abort(); }
+void begin_session(void) { }
+void write_clip (void *data, int len) { }
+void term_deselect(void) { }
 
 /* GUI Adaptation - Sept 2000 */
 void send_msg(HWND h, UINT message, WPARAM wParam)
index 9e646c0..d9e5044 100644 (file)
--- a/win_res.h
+++ b/win_res.h
@@ -18,6 +18,7 @@
 #define IDD_LICENCEBOX   113
 
 #define IDN_LIST        1001
+#define IDN_COPY        1002
 
 #define IDA_ICON        1001
 #define IDA_TEXT1       1002
index 4d713f3..1bf3bb7 100644 (file)
@@ -340,14 +340,15 @@ BEGIN
     
 END
 
-/* Accelerators used: c */
+/* Accelerators used: co */
 IDD_LOGBOX DIALOG DISCARDABLE 100, 20, 160, 119
 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
 CAPTION "PuTTY Event Log"
 FONT 8, "MS Sans Serif"
 BEGIN
-    DEFPUSHBUTTON "&Close", IDOK, 58, 102, 44, 14
-    LISTBOX IDN_LIST, 3, 3, 154, 95, LBS_HASSTRINGS | LBS_USETABSTOPS | WS_VSCROLL
+    DEFPUSHBUTTON "&Close", IDOK, 85, 102, 44, 14
+    PUSHBUTTON "C&opy", IDN_COPY, 31, 102, 44, 14
+    LISTBOX IDN_LIST, 3, 3, 154, 95, LBS_HASSTRINGS | LBS_USETABSTOPS | WS_VSCROLL | LBS_EXTENDEDSEL
 END
 
 /* No accelerators used */
index 6967f4b..2a9516f 100644 (file)
--- a/windlg.c
+++ b/windlg.c
@@ -431,6 +431,46 @@ static int CALLBACK LogProc (HWND hwnd, UINT msg,
            logbox = NULL;
            DestroyWindow (hwnd);
            return 0;
+          case IDN_COPY:
+           if (HIWORD(wParam) == BN_CLICKED ||
+               HIWORD(wParam) == BN_DOUBLECLICKED) {
+                int selcount;
+                int *selitems;
+                selcount = SendDlgItemMessage(hwnd, IDN_LIST,
+                                              LB_GETSELCOUNT, 0, 0);
+                selitems = malloc(selcount * sizeof(int));
+                if (selitems) {
+                    int count = SendDlgItemMessage(hwnd, IDN_LIST,
+                                                   LB_GETSELITEMS,
+                                                   selcount, (LPARAM)selitems);
+                    int i;
+                    int size;
+                    char *clipdata;
+                    static unsigned char sel_nl[] = SEL_NL;
+
+                    size = 0;
+                    for (i = 0; i < count; i++)
+                        size += strlen(events[selitems[i]]) + sizeof(sel_nl);
+
+                    clipdata = malloc(size);
+                    if (clipdata) {
+                        char *p = clipdata;
+                        for (i = 0; i < count; i++) {
+                            char *q = events[selitems[i]];
+                            int qlen = strlen(q);
+                            memcpy(p, q, qlen);
+                            p += qlen;
+                            memcpy(p, sel_nl, sizeof(sel_nl));
+                            p += sizeof(sel_nl);
+                        }
+                        write_clip(clipdata, size);
+                        term_deselect();
+                        free(clipdata);
+                    }
+                    free(selitems);
+                }
+            }
+            return 0;
        }
        return 0;
       case WM_CLOSE:
@@ -1584,7 +1624,7 @@ void logevent (char *string) {
        SendDlgItemMessage (logbox, IDN_LIST, LB_ADDSTRING,
                            0, (LPARAM)string);
        count = SendDlgItemMessage (logbox, IDN_LIST, LB_GETCOUNT, 0, 0);
-       SendDlgItemMessage (logbox, IDN_LIST, LB_SETCURSEL, count-1, 0);
+       SendDlgItemMessage (logbox, IDN_LIST, LB_SETTOPINDEX, count-1, 0);
     }
 }