From 989b10e98c63397ad8210235d6e2f7da42ad3df4 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 22 Sep 2000 14:46:26 +0000 Subject: [PATCH] Enable copying the Event Log git-svn-id: svn://svn.tartarus.org/sgt/putty@619 cda61777-01e9-0310-a592-d414129be87e --- plink.c | 6 ++++++ scp.c | 13 ++++++------- win_res.h | 1 + win_res.rc | 7 ++++--- windlg.c | 42 +++++++++++++++++++++++++++++++++++++++++- 5 files changed, 58 insertions(+), 11 deletions(-) diff --git a/plink.c b/plink.c index 0a740622..6f979e5d 100644 --- 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 8c7df21a..b2ba5015 100644 --- 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) diff --git a/win_res.h b/win_res.h index 9e646c01..d9e50449 100644 --- 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 diff --git a/win_res.rc b/win_res.rc index 4d713f30..1bf3bb72 100644 --- a/win_res.rc +++ b/win_res.rc @@ -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 */ diff --git a/windlg.c b/windlg.c index 6967f4be..2a9516ff 100644 --- 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); } } -- 2.11.0