summaryrefslogtreecommitdiff
blob: bf837a6f3d9002c2f32ce99f47398f12ee533a7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
diff -Naur aterm-orig/configure aterm-0.4.2/configure
--- aterm-orig/configure	2001-09-06 18:38:07.000000000 +0200
+++ aterm-0.4.2/configure	2004-03-29 19:38:49.923263224 +0200
@@ -2609,7 +2609,7 @@
     ; \
 do
   ac_save_LIBS=$LIBS
-  LIBS="-L$ac_dir -lXpm $LIBS -lX11"
+  LIBS="-L$ac_dir -lXpm $LIBS -lX11 -lXmu"
   cat > conftest.$ac_ext <<EOF
 #line 2615 "configure"
 #include "confdefs.h"
diff -Naur aterm-orig/src/command.c aterm-0.4.2/src/command.c
--- aterm-orig/src/command.c	2001-09-06 18:38:07.000000000 +0200
+++ aterm-0.4.2/src/command.c	2004-03-29 19:38:49.928262464 +0200
@@ -2653,7 +2653,7 @@
 		switch (ev->xbutton.button) {
 		case Button1:
 		case Button3:
-		    selection_make(ev->xbutton.time);
+		    selection_make(ev->xbutton.time, ev->xbutton.state);
 		    break;
 
 		case Button2:
diff -Naur aterm-orig/src/screen.c aterm-0.4.2/src/screen.c
--- aterm-orig/src/screen.c	2004-03-29 19:38:25.944908488 +0200
+++ aterm-0.4.2/src/screen.c	2004-03-29 19:28:56.000000000 +0200
@@ -44,7 +44,7 @@
 
 #include <X11/Xatom.h>
 #include <X11/Xmd.h>		/* get the typedef for CARD32 */
-
+#include <X11/Xmu/Atoms.h>
 
 static screen_t    screen;
 
@@ -2759,21 +2759,88 @@
     long            nread;
     unsigned long   bytes_after, nitems;
     unsigned char  *data;
+    XTextProperty   ct;
     Atom            actual_type;
     int             actual_fmt;
-
+    int             dummy_count;
+    char          **cl;
+    XEvent          ev;
+    XWindowAttributes wa;
+    int             setpropertyevent = 0;
+    
     if (prop == None)
 	return;
+
     for (nread = 0, bytes_after = 1; bytes_after > 0; nread += nitems) {
 	if ((XGetWindowProperty(Xdisplay, win, prop, (nread / 4), PROP_SIZE,
-				Delete, AnyPropertyType, &actual_type,
-				&actual_fmt, &nitems, &bytes_after,
-				&data) != Success)) {
-	    XFree(data);
+				False, AnyPropertyType, &ct.encoding, &ct.format,
+				&ct.nitems, &bytes_after, &ct.value) != Success)) {
+	    XFree(ct.value);
 	    return;
 	}
-	PasteIt(data, nitems);
-	XFree(data);
+	
+	if (ct.encoding == XInternAtom(Xdisplay, "INCR", False)) {
+		/*
+		* This is an INCR (incremental large) paste
+		*/
+		XGetWindowAttributes(Xdisplay, win, &wa);
+		if ((wa.your_event_mask | PropertyChangeMask) != wa.your_event_mask) {
+			/* We need to register the PropertyNotify event */
+			XSelectInput(Xdisplay, win, (wa.your_event_mask | PropertyChangeMask) );
+			setpropertyevent = 1;
+		}
+		XDeleteProperty(Xdisplay, win, prop);
+		while (1) {
+			XWindowEvent(Xdisplay, win, PropertyChangeMask, &ev);
+			if (ev.xproperty.state != PropertyNewValue)
+				continue;
+			if ((XGetWindowProperty(Xdisplay, win, prop, 0, PROP_SIZE,
+				True, AnyPropertyType, &ct.encoding, &ct.format,
+				&ct.nitems, &bytes_after, &ct.value) != Success)) {
+				XFree(ct.value);
+				/* error */
+				break;
+			}
+
+			if (ct.nitems == 0) {
+				/* end of INCR transfer */
+				XFree(ct.value);
+				break;
+			}
+			else {
+				if (XmbTextPropertyToTextList(Xdisplay, &ct, &cl, &dummy_count) == Success && cl) {
+			            PasteIt(cl[0], strlen(cl[0]));
+				    XFreeStringList(cl);
+				} else {
+				    PasteIt(ct.value, (unsigned int)ct.nitems);
+				}
+				
+				XFree(ct.value);
+			}
+		}
+		if (setpropertyevent == 1) {
+			/* We need to unregister the PropertyNotify event */
+			XGetWindowAttributes(Xdisplay, win, &wa);
+			XSelectInput(Xdisplay, win, (wa.your_event_mask ^ PropertyChangeMask));
+			setpropertyevent = 0;
+		}
+    	} else {
+		/*
+		* This is a normal 1-time paste
+		*/
+		if (XmbTextPropertyToTextList(Xdisplay, &ct, &cl, &dummy_count) == Success && cl) {
+	            PasteIt(cl[0], strlen(cl[0]));
+		    XFreeStringList(cl);
+		} else {
+		    PasteIt(ct.value, (unsigned int)ct.nitems);
+		}
+
+		if (Delete) {
+			XDeleteProperty(Xdisplay, win, prop);
+		}
+		
+		XFree(ct.value);
+	}
     }
 }
 
@@ -2787,6 +2854,9 @@
 selection_request(Time tm, int x, int y)
 {
     Atom            prop;
+    Atom            xa;
+
+    xa = XInternAtom(Xdisplay, "COMPOUND_TEXT", False);
 
     if (!(Options & Opt_pasteMouseOutside))
         if (x < 0 || x >= TermWin.width || y < 0 || y >= TermWin.height)
@@ -2798,8 +2868,11 @@
 	selection_paste(Xroot, XA_CUT_BUFFER0, False);
     } else {
 	prop = XInternAtom(Xdisplay, "VT_SELECTION", False);
-	XConvertSelection(Xdisplay, XA_PRIMARY, XA_STRING, prop, TermWin.vt,
-			  tm);
+	if (XConvertSelection(Xdisplay, XA_PRIMARY, xa, prop, TermWin.vt,tm) != Success) {
+	    if (XConvertSelection(Xdisplay, XA_PRIMARY, XA_UTF8_STRING(Xdisplay), prop, TermWin.vt,tm) != Success) {;
+	        XConvertSelection(Xdisplay, XA_PRIMARY, XA_STRING, prop, TermWin.vt,tm);
+	    }
+	}
     }
 }
 
@@ -2828,7 +2901,7 @@
  */
 /* PROTO */
 void
-selection_make(Time tm)
+selection_make(Time tm, unsigned int key_state)
 {
     int             i, col, end_col, row, end_row;
     unsigned char  *new_selection_text;
@@ -2895,7 +2968,13 @@
 	FREE(selection.text);
     selection.text = new_selection_text;
 
-    XSetSelectionOwner(Xdisplay, XA_PRIMARY, TermWin.vt, tm);
+    // selecting with ALT will put the text to clipboard
+    if (key_state & Mod1Mask) {
+        XSetSelectionOwner(Xdisplay, XA_CLIPBOARD(Xdisplay), TermWin.vt, tm);
+    } else {
+        XSetSelectionOwner(Xdisplay, XA_PRIMARY, TermWin.vt, tm);
+    }
+	
     if (XGetSelectionOwner(Xdisplay, XA_PRIMARY) != TermWin.vt)
 	print_error("can't get primary selection");
     XChangeProperty(Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8,