diff -c -r -w xpilot-4.1.0_orig/src/client/talk.c xpilot-4.1.0_paste/src/client/talk.c *** xpilot-4.1.0_orig/src/client/talk.c Thu Apr 16 18:39:47 1998 --- xpilot-4.1.0_paste/src/client/talk.c Fri Mar 12 13:33:24 1999 *************** *** 429,434 **** --- 429,504 ---- return result; /* keep on talking if true, no more talking if false */ } + void Talk_paste(void){ + + int str_len = strlen(talk_str); /* current length */ + int max_len = MAX_CHARS - 2; /* absolute max */ + int new_len; /* after pasting */ + int char_width = XTextWidth(talkFont, " ", 1); + int max_width = (TALK_WINDOW_WIDTH - 2*TALK_INSIDE_BORDER - 5); + + int accept_len = (max_width / char_width) - str_len + 1 ; + /* for still matching the window */ + char paste_buf[MAX_CHARS - 2]; /* gets the XBuffer */ + int n_bytes; /* returned from XBuffer*/ + char tmp_str[MAX_CHARS - 2]; + + bool cursor_visible = talk_cursor.visible; + int i; + + accept_len = (accept_len+str_len>max_len) ? + (max_len - str_len) : accept_len; /* limit it anyway */ + if (!accept_len){ + XBell(dpy, 100); + return; + } + + strncpy(paste_buf, XFetchBytes(dpy, &n_bytes), accept_len); + /* XStoreBytes(dpy, "", 0); no spam? */ + if ( n_bytes > accept_len){ + n_bytes = accept_len; + XBell(dpy, 100); + } + paste_buf[accept_len] = '\0'; + + /* substitute unprintables */ + for(i = 0; i 126 && paste_buf[i] < 161) ){ + paste_buf[i] = ' '; + } + } + + /* append or insert */ + strcpy(tmp_str, talk_str); + strcpy(&tmp_str[talk_cursor.point], paste_buf); + strcpy(&tmp_str[talk_cursor.point + n_bytes], + &talk_str[talk_cursor.point]); + new_len = str_len + n_bytes; + + Talk_cursor(false); + /*s. Talk_do_event()*/ + if (talk_cursor.point < str_len) { + XSetForeground(dpy, talkGC, colors[BLACK].pixel); + XDrawString(dpy, talk_w, talkGC, + talk_cursor.point * char_width + TALK_INSIDE_BORDER, + talkFont->ascent + TALK_INSIDE_BORDER, + &talk_str[talk_cursor.point], + str_len - talk_cursor.point); + XSetForeground(dpy, talkGC, colors[WHITE].pixel); + } + XDrawString(dpy, talk_w, talkGC, + talk_cursor.point * char_width + TALK_INSIDE_BORDER, + talkFont->ascent + TALK_INSIDE_BORDER, + &tmp_str[talk_cursor.point], + new_len - talk_cursor.point); + talk_cursor.point += n_bytes; + Talk_cursor(cursor_visible); + + strcpy(talk_str, tmp_str); + return; + } + + void Talk_resize(void) { if (talk_created) { diff -c -r -w xpilot-4.1.0_orig/src/client/xevent.c xpilot-4.1.0_paste/src/client/xevent.c *** xpilot-4.1.0_orig/src/client/xevent.c Tue Oct 6 15:52:19 1998 --- xpilot-4.1.0_paste/src/client/xevent.c Fri Mar 12 14:05:34 1999 *************** *** 242,247 **** --- 242,249 ---- initialPointerControl = true; Pointer_control_set_state(false); } + XSelectInput(dpy, draw, PointerMotionMask | ButtonPressMask + | ButtonReleaseMask); /* cut'n'paste */ Talk_map_window(true); } else { *************** *** 659,664 **** --- 661,669 ---- if (Key_press(buttonDefs[event.xbutton.button-1])) { Net_key_change(); } + } + if (talk_mapped && event.xbutton.button == 2){ + Talk_paste(); } break; } diff -c -r -w xpilot-4.1.0_orig/src/client/xinit.h xpilot-4.1.0_paste/src/client/xinit.h *** xpilot-4.1.0_orig/src/client/xinit.h Fri Oct 2 19:39:22 1998 --- xpilot-4.1.0_paste/src/client/xinit.h Fri Mar 12 13:53:44 1999 *************** *** 71,76 **** --- 71,77 ---- extern void Talk_resize(void); extern void Talk_cursor(bool visible); extern void Talk_map_window(bool map); + extern void Talk_paste(void); extern int Talk_do_event(XEvent *event); extern void Quit(void); extern int FatalError(Display *dpy);