comparison src/redisplay-gtk.c @ 4881:a4322ac49e37

break out common separate-into-runs routines into redisplay-xlike-inc.c -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2010-01-18 Ben Wing <ben@xemacs.org> * redisplay-xlike-inc.c: * redisplay-xlike-inc.c (separate_textual_runs_nomule): * redisplay-xlike-inc.c (separate_textual_runs_xft_nomule): * redisplay-xlike-inc.c (separate_textual_runs_xft_mule): * redisplay-xlike-inc.c (separate_textual_runs_mule): Break separate_textual_runs_* functions from redisplay-x.c. (Code in redisplay-gtk.c should have been identical but was bit-rotted.) * redisplay-gtk.c: * redisplay-x.c: Delete code, replace with include statement. * depend: Regenerate.
author Ben Wing <ben@xemacs.org>
date Mon, 18 Jan 2010 06:21:05 -0600
parents 2b84dd8eb906
children eab9498ecc0e
comparison
equal deleted inserted replaced
4880:ae81a2c00f4f 4881:a4322ac49e37
85 85
86 #if 0 86 #if 0
87 static void __describe_gc (GdkGC *); 87 static void __describe_gc (GdkGC *);
88 #endif 88 #endif
89 89
90 struct textual_run 90 #include "redisplay-xlike-inc.c"
91 {
92 Lisp_Object charset;
93 unsigned char *ptr;
94 int len;
95 int dimension;
96 };
97
98 /* Separate out the text in DYN into a series of textual runs of a
99 particular charset. Also convert the characters as necessary into
100 the format needed by XDrawImageString(), XDrawImageString16(), et
101 al. (This means converting to one or two byte format, possibly
102 tweaking the high bits, and possibly running a CCL program.) You
103 must pre-allocate the space used and pass it in. (This is done so
104 you can ALLOCA () the space.) You need to allocate (2 * len) bytes
105 of TEXT_STORAGE and (len * sizeof (struct textual_run)) bytes of
106 RUN_STORAGE, where LEN is the length of the dynarr.
107
108 Returns the number of runs actually used. */
109
110 static int
111 separate_textual_runs (unsigned char *text_storage,
112 struct textual_run *run_storage,
113 CONST Ichar *str, Charcount len)
114 {
115 Lisp_Object prev_charset = Qunbound; /* not Qnil because that is a
116 possible valid charset when
117 MULE is not defined */
118 int runs_so_far = 0;
119 int i;
120 #ifdef MULE
121 struct ccl_program char_converter;
122 int need_ccl_conversion = 0;
123 #endif
124
125 for (i = 0; i < len; i++)
126 {
127 Ichar ch = str[i];
128 Lisp_Object charset;
129 int byte1, byte2;
130 int dimension;
131 int graphic;
132
133 BREAKUP_ICHAR (ch, charset, byte1, byte2);
134 dimension = XCHARSET_DIMENSION (charset);
135 graphic = XCHARSET_GRAPHIC (charset);
136
137 if (!EQ (charset, prev_charset))
138 {
139 run_storage[runs_so_far].ptr = text_storage;
140 run_storage[runs_so_far].charset = charset;
141 run_storage[runs_so_far].dimension = dimension;
142
143 if (runs_so_far)
144 {
145 run_storage[runs_so_far - 1].len =
146 text_storage - run_storage[runs_so_far - 1].ptr;
147 if (run_storage[runs_so_far - 1].dimension == 2)
148 run_storage[runs_so_far - 1].len >>= 1;
149 }
150 runs_so_far++;
151 prev_charset = charset;
152 #ifdef MULE
153 {
154 Lisp_Object ccl_prog = XCHARSET_CCL_PROGRAM (charset);
155 need_ccl_conversion = !NILP (ccl_prog);
156 if (need_ccl_conversion)
157 setup_ccl_program (&char_converter, ccl_prog);
158 }
159 #endif
160 }
161
162 if (graphic == 0)
163 {
164 byte1 &= 0x7F;
165 byte2 &= 0x7F;
166 }
167 else if (graphic == 1)
168 {
169 byte1 |= 0x80;
170 byte2 |= 0x80;
171 }
172 #ifdef MULE
173 if (need_ccl_conversion)
174 {
175 char_converter.reg[0] = XCHARSET_ID (charset);
176 char_converter.reg[1] = byte1;
177 char_converter.reg[2] = byte2;
178 ccl_driver (&char_converter, 0, 0, 0, 0, CCL_MODE_ENCODING);
179 byte1 = char_converter.reg[1];
180 byte2 = char_converter.reg[2];
181 }
182 #endif
183 *text_storage++ = (unsigned char) byte1;
184 if (dimension == 2)
185 *text_storage++ = (unsigned char) byte2;
186 }
187
188 if (runs_so_far)
189 {
190 run_storage[runs_so_far - 1].len =
191 text_storage - run_storage[runs_so_far - 1].ptr;
192 if (run_storage[runs_so_far - 1].dimension == 2)
193 run_storage[runs_so_far - 1].len >>= 1;
194 }
195
196 return runs_so_far;
197 }
198 91
199 /****************************************************************************/ 92 /****************************************************************************/
200 /* */ 93 /* */
201 /* Gtk output routines */ 94 /* Gtk output routines */
202 /* */ 95 /* */