Mercurial > hg > xemacs-beta
annotate src/gtk-xemacs.c @ 5493:f62141fe007d
Sync paragraphs.el to FSF 23.1.92
-------------------- ChangeLog entries follow: --------------------
lisp/ChangeLog addition:
2010-02-19 Ben Wing <ben@xemacs.org>
* paragraphs.el:
* paragraphs.el (use-hard-newlines):
* paragraphs.el (paragraph-start):
* paragraphs.el (paragraph-separate):
* paragraphs.el (sentence-end-double-space):
* paragraphs.el (sentence-end-without-period):
* paragraphs.el (sentence-end-without-space): New.
* paragraphs.el (sentence-end):
* paragraphs.el (sentence-end-base): New.
* paragraphs.el (page-delimiter):
* paragraphs.el (paragraph-ignore-fill-prefix):
* paragraphs.el (forward-paragraph):
* paragraphs.el (backward-paragraph):
* paragraphs.el (mark-paragraph):
* paragraphs.el (forward-sentence):
* paragraphs.el (repunctuate-sentences): New.
Sync with FSF 23.1.92.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Fri, 19 Feb 2010 22:41:03 -0600 |
parents | e813cf16c015 |
children | d0c14ea98592 |
rev | line source |
---|---|
462 | 1 /* gtk-xemacs.c |
2 ** | |
3 ** Description: A widget to encapsulate a XEmacs 'text widget' | |
4 ** | |
5 ** Created by: William M. Perry | |
6 ** Copyright (c) 2000 William M. Perry <wmperry@gnu.org> | |
7 ** | |
4709
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
3087
diff
changeset
|
8 ** This file is part of XEmacs. |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
3087
diff
changeset
|
9 ** |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
3087
diff
changeset
|
10 ** XEmacs is free software; you can redistribute it and/or modify it |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
3087
diff
changeset
|
11 ** under the terms of the GNU General Public License as published by the |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
3087
diff
changeset
|
12 ** Free Software Foundation; either version 2, or (at your option) any |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
3087
diff
changeset
|
13 ** later version. |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
3087
diff
changeset
|
14 ** |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
3087
diff
changeset
|
15 ** XEmacs is distributed in the hope that it will be useful, but WITHOUT |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
3087
diff
changeset
|
16 ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
3087
diff
changeset
|
17 ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
3087
diff
changeset
|
18 ** for more details. |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
3087
diff
changeset
|
19 ** |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
3087
diff
changeset
|
20 ** You should have received a copy of the GNU General Public License |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
3087
diff
changeset
|
21 ** along with XEmacs; see the file COPYING. If not, write to |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
3087
diff
changeset
|
22 ** the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, |
db7068430402
Add explicit GPL v2 or later notices to Bill Perry's code, where such notices
Jerry James <james@xemacs.org>
parents:
3087
diff
changeset
|
23 ** Boston, MA 02111-1301, USA. */ |
462 | 24 |
25 #include <config.h> | |
26 | |
27 #include "lisp.h" | |
4908
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4709
diff
changeset
|
28 |
809 | 29 #include "device.h" |
4908
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4709
diff
changeset
|
30 #include "faces.h" |
809 | 31 #include "glyphs.h" |
462 | 32 #include "window.h" |
4908
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4709
diff
changeset
|
33 |
876 | 34 #include "frame-impl.h" |
35 #include "console-gtk-impl.h" | |
36 #include "device-impl.h" | |
4908
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4709
diff
changeset
|
37 #include "gtk-xemacs.h" |
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4709
diff
changeset
|
38 #include "objects-gtk.h" |
462 | 39 |
40 extern Lisp_Object Vmodeline_face; | |
41 extern Lisp_Object Vscrollbar_on_left_p; | |
42 | |
43 EXFUN (Fmake_image_instance, 4); | |
44 | |
45 static void gtk_xemacs_class_init (GtkXEmacsClass *klass); | |
46 static void gtk_xemacs_init (GtkXEmacs *xemacs); | |
47 static void gtk_xemacs_size_allocate (GtkWidget *widget, GtkAllocation *allocaction); | |
48 static void gtk_xemacs_draw (GtkWidget *widget, GdkRectangle *area); | |
49 static void gtk_xemacs_paint (GtkWidget *widget, GdkRectangle *area); | |
50 static void gtk_xemacs_size_request (GtkWidget *widget, GtkRequisition *requisition); | |
51 static void gtk_xemacs_realize (GtkWidget *widget); | |
52 static void gtk_xemacs_style_set (GtkWidget *widget, GtkStyle *previous_style); | |
53 static gint gtk_xemacs_expose (GtkWidget *widget, GdkEventExpose *event); | |
54 | |
55 guint | |
56 gtk_xemacs_get_type (void) | |
57 { | |
58 static guint xemacs_type = 0; | |
59 | |
60 if (!xemacs_type) | |
61 { | |
62 static const GtkTypeInfo xemacs_info = | |
63 { | |
64 "GtkXEmacs", | |
65 sizeof (GtkXEmacs), | |
66 sizeof (GtkXEmacsClass), | |
67 (GtkClassInitFunc) gtk_xemacs_class_init, | |
68 (GtkObjectInitFunc) gtk_xemacs_init, | |
69 /* reserved_1 */ NULL, | |
70 /* reserved_2 */ NULL, | |
71 (GtkClassInitFunc) NULL, | |
72 }; | |
73 | |
74 xemacs_type = gtk_type_unique (gtk_fixed_get_type (), &xemacs_info); | |
75 } | |
76 | |
77 return xemacs_type; | |
78 } | |
79 | |
80 static GtkWidgetClass *parent_class; | |
81 | |
82 static void | |
1204 | 83 gtk_xemacs_class_init (GtkXEmacsClass *class_) |
462 | 84 { |
85 GtkWidgetClass *widget_class; | |
86 | |
1204 | 87 widget_class = (GtkWidgetClass*) class_; |
462 | 88 parent_class = (GtkWidgetClass *) gtk_type_class (gtk_fixed_get_type ()); |
89 | |
90 widget_class->size_allocate = gtk_xemacs_size_allocate; | |
91 widget_class->size_request = gtk_xemacs_size_request; | |
92 widget_class->draw = gtk_xemacs_draw; | |
93 widget_class->expose_event = gtk_xemacs_expose; | |
94 widget_class->realize = gtk_xemacs_realize; | |
95 widget_class->button_press_event = emacs_gtk_button_event_handler; | |
96 widget_class->button_release_event = emacs_gtk_button_event_handler; | |
97 widget_class->key_press_event = emacs_gtk_key_event_handler; | |
98 widget_class->key_release_event = emacs_gtk_key_event_handler; | |
99 widget_class->motion_notify_event = emacs_gtk_motion_event_handler; | |
100 widget_class->style_set = gtk_xemacs_style_set; | |
101 } | |
102 | |
103 static void | |
104 gtk_xemacs_init (GtkXEmacs *xemacs) | |
105 { | |
106 GTK_WIDGET_SET_FLAGS (xemacs, GTK_CAN_FOCUS); | |
107 } | |
108 | |
109 GtkWidget* | |
110 gtk_xemacs_new (struct frame *f) | |
111 { | |
112 GtkXEmacs *xemacs; | |
113 | |
2054 | 114 xemacs = (GtkXEmacs*) gtk_type_new (gtk_xemacs_get_type ()); |
462 | 115 xemacs->f = f; |
116 | |
117 return GTK_WIDGET (xemacs); | |
118 } | |
119 | |
120 static void | |
121 __nuke_background_items (GtkWidget *widget) | |
122 { | |
123 /* This bit of voodoo is here to get around the annoying flicker | |
124 when GDK tries to futz with our background pixmap as well as | |
125 XEmacs doing it | |
126 | |
127 We do NOT set the background of this widget window, that way | |
128 there is NO flickering, etc. The downside is the XEmacs frame | |
129 appears as 'seethru' when XEmacs is too busy to redraw the | |
130 frame. | |
131 | |
132 Well, wait, we do... otherwise there sre weird 'seethru' areas | |
133 even when XEmacs does a full redisplay. Most noticable in some | |
134 areas of the modeline, or in the right-hand-side of the window | |
135 between the scrollbar ad n the edge of the window. | |
136 */ | |
137 if (widget->window) | |
138 { | |
139 gdk_window_set_back_pixmap (widget->window, NULL, 0); | |
140 gdk_window_set_back_pixmap (widget->parent->window, NULL, 0); | |
141 gdk_window_set_background (widget->parent->window, | |
142 &widget->style->bg[GTK_STATE_NORMAL]); | |
143 gdk_window_set_background (widget->window, | |
144 &widget->style->bg[GTK_STATE_NORMAL]); | |
145 } | |
146 } | |
147 | |
148 extern Lisp_Object xemacs_gtk_convert_color(GdkColor *c, GtkWidget *w); | |
149 | |
150 /* From objects-gtk.c */ | |
151 extern Lisp_Object __get_gtk_font_truename (GdkFont *gdk_font, int expandp); | |
152 | |
153 #define convert_font(f) __get_gtk_font_truename (f, 0) | |
154 | |
778 | 155 #ifdef SMASH_FACE_FALLBACKS |
462 | 156 static void |
157 smash_face_fallbacks (struct frame *f, GtkStyle *style) | |
158 { | |
159 #define FROB(face,prop,slot) do { \ | |
160 Lisp_Object fallback = Qnil; \ | |
161 Lisp_Object specifier = Fget (face, prop, Qnil); \ | |
162 struct Lisp_Specifier *sp = NULL; \ | |
163 if (NILP (specifier)) continue; \ | |
164 sp = XSPECIFIER (specifier); \ | |
165 fallback = sp->fallback; \ | |
166 if (EQ (Fcar (Fcar (Fcar (fallback))), Qgtk)) \ | |
167 fallback = XCDR (fallback); \ | |
168 if (! NILP (slot)) \ | |
169 fallback = acons (list1 (Qgtk), \ | |
170 slot, \ | |
171 fallback); \ | |
172 set_specifier_fallback (specifier, fallback); \ | |
173 } while (0); | |
174 #define FROB_FACE(face,fg_slot,bg_slot) \ | |
175 do { \ | |
176 FROB (face, Qforeground, xemacs_gtk_convert_color (&style->fg_slot[GTK_STATE_NORMAL], FRAME_GTK_SHELL_WIDGET (f))); \ | |
177 FROB (face, Qbackground, xemacs_gtk_convert_color (&style->bg_slot[GTK_STATE_NORMAL], FRAME_GTK_SHELL_WIDGET (f))); \ | |
178 if (style->rc_style && style->rc_style->bg_pixmap_name[GTK_STATE_NORMAL]) \ | |
179 { \ | |
180 FROB (Vdefault_face, Qbackground_pixmap, \ | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4709
diff
changeset
|
181 Fmake_image_instance (build_cistring (style->rc_style->bg_pixmap_name[GTK_STATE_NORMAL]), \ |
462 | 182 f->device, Qnil, make_int (5))); \ |
183 } \ | |
184 else \ | |
185 { \ | |
186 FROB (Vdefault_face, Qbackground_pixmap, Qnil); \ | |
187 } \ | |
188 } while (0) | |
189 | |
190 FROB (Vdefault_face, Qfont, convert_font (style->font)); | |
191 FROB_FACE (Vdefault_face, fg, bg); | |
192 FROB_FACE (Vgui_element_face, text, mid); | |
193 | |
194 #undef FROB | |
195 #undef FROB_FACE | |
196 } | |
778 | 197 #endif /* SMASH_FACE_FALLBACKS */ |
462 | 198 |
199 #ifdef HAVE_SCROLLBARS | |
200 static void | |
201 smash_scrollbar_specifiers (struct frame *f, GtkStyle *style) | |
202 { | |
203 Lisp_Object frame; | |
204 int slider_size = 0; | |
205 int hsize, vsize; | |
206 GtkRangeClass *klass; | |
207 | |
793 | 208 frame = wrap_frame (f); |
462 | 209 |
210 klass = (GtkRangeClass *) gtk_type_class (GTK_TYPE_SCROLLBAR); | |
211 slider_size = klass->slider_width; | |
212 hsize = slider_size + (style->klass->ythickness * 2); | |
213 vsize = slider_size + (style->klass->xthickness * 2); | |
214 | |
215 style = gtk_style_attach (style, | |
216 GTK_WIDGET (DEVICE_GTK_APP_SHELL (XDEVICE (FRAME_DEVICE (f))))->window); | |
217 | |
218 Fadd_spec_to_specifier (Vscrollbar_width, make_int (vsize), frame, Qnil, Qnil); | |
219 Fadd_spec_to_specifier (Vscrollbar_height, make_int (hsize), frame, Qnil, Qnil); | |
220 } | |
221 #endif /* HAVE_SCROLLBARS */ | |
222 | |
744 | 223 #ifdef HAVE_TOOLBARS |
224 extern Lisp_Object Vtoolbar_shadow_thickness; | |
225 | |
226 static void | |
227 smash_toolbar_specifiers(struct frame *f, GtkStyle *style) | |
228 { | |
229 Lisp_Object frame; | |
230 GtkStyleClass *klass = (GtkStyleClass *) style->klass; | |
231 | |
793 | 232 frame = wrap_frame (f); |
744 | 233 |
234 Fadd_spec_to_specifier (Vtoolbar_shadow_thickness, make_int (klass->xthickness), | |
235 Qnil, list2 (Qgtk, Qdefault), Qprepend); | |
236 } | |
237 #endif /* HAVE_TOOLBARS */ | |
238 | |
462 | 239 static void |
240 gtk_xemacs_realize (GtkWidget *widget) | |
241 { | |
242 parent_class->realize (widget); | |
243 gtk_xemacs_style_set (widget, gtk_widget_get_style (widget)); | |
244 } | |
245 | |
246 static void | |
247 gtk_xemacs_style_set (GtkWidget *widget, GtkStyle *previous_style) | |
248 { | |
249 GtkStyle *new_style = gtk_widget_get_style (widget); | |
250 GtkXEmacs *x = GTK_XEMACS (widget); | |
251 | |
252 parent_class->style_set (widget, previous_style); | |
253 | |
254 if (x->f) | |
255 { | |
256 __nuke_background_items (widget); | |
778 | 257 #ifdef SMASH_FACE_FALLBACKS |
462 | 258 smash_face_fallbacks (x->f, new_style); |
259 #endif | |
744 | 260 #ifdef HAVE_SCROLLBARS |
462 | 261 smash_scrollbar_specifiers (x->f, new_style); |
744 | 262 #endif |
263 #ifdef HAVE_TOOLBARS | |
264 smash_toolbar_specifiers (x->f, new_style); | |
265 #endif | |
462 | 266 } |
267 } | |
268 | |
269 static void | |
270 gtk_xemacs_size_request (GtkWidget *widget, GtkRequisition *requisition) | |
271 { | |
272 GtkXEmacs *x = GTK_XEMACS (widget); | |
273 struct frame *f = GTK_XEMACS_FRAME (x); | |
274 int width, height; | |
275 | |
276 if (f) | |
277 { | |
278 char_to_pixel_size (f, FRAME_WIDTH (f), FRAME_HEIGHT (f), | |
279 &width, &height); | |
280 requisition->width = width; | |
281 requisition->height = height; | |
282 } | |
283 else | |
284 { | |
285 parent_class->size_request (widget, requisition); | |
286 } | |
287 } | |
288 | |
2168 | 289 /* Assign a size and position to the child widgets. This differs from the |
290 super class method in that for all widgets except the scrollbars the size | |
291 and position are not caclulated here. This is because these widgets have | |
292 this function performed for them by the redisplay code (see | |
293 gtk_map_subwindow()). If the superclass method is called then the widgets | |
294 can change size and position as the two pieces of code move the widgets at | |
295 random. | |
296 */ | |
462 | 297 static void |
298 gtk_xemacs_size_allocate (GtkWidget *widget, GtkAllocation *allocation) | |
299 { | |
300 GtkXEmacs *x = GTK_XEMACS (widget); | |
2168 | 301 GtkFixed *fixed = GTK_FIXED (widget); |
462 | 302 struct frame *f = GTK_XEMACS_FRAME (x); |
303 int columns, rows; | |
2168 | 304 GList *children; |
305 guint16 border_width; | |
462 | 306 |
2168 | 307 widget->allocation = *allocation; |
308 if (GTK_WIDGET_REALIZED (widget)) | |
309 gdk_window_move_resize (widget->window, | |
310 allocation->x, | |
311 allocation->y, | |
312 allocation->width, | |
313 allocation->height); | |
314 | |
315 border_width = GTK_CONTAINER (fixed)->border_width; | |
316 | |
317 children = fixed->children; | |
318 while (children) | |
319 { | |
2336 | 320 GtkFixedChild* child = (GtkFixedChild*) children->data; |
2168 | 321 children = children->next; |
322 | |
323 /* | |
324 Scrollbars are the only widget that is managed by GTK. See | |
325 comments in gtk_create_scrollbar_instance(). | |
326 */ | |
327 if (GTK_WIDGET_VISIBLE (child->widget) && | |
328 gtk_type_is_a(GTK_OBJECT_TYPE(child->widget), GTK_TYPE_SCROLLBAR)) | |
329 { | |
330 GtkAllocation child_allocation; | |
331 GtkRequisition child_requisition; | |
332 | |
333 gtk_widget_get_child_requisition (child->widget, &child_requisition); | |
334 child_allocation.x = child->x + border_width; | |
335 child_allocation.y = child->y + border_width; | |
336 child_allocation.width = child_requisition.width; | |
337 child_allocation.height = child_requisition.height; | |
338 gtk_widget_size_allocate (child->widget, &child_allocation); | |
339 } | |
340 } | |
462 | 341 |
342 if (f) | |
343 { | |
344 f->pixwidth = allocation->width; | |
345 f->pixheight = allocation->height; | |
346 | |
347 pixel_to_char_size (f, | |
348 allocation->width, | |
349 allocation->height, &columns, &rows); | |
350 | |
351 change_frame_size (f, rows, columns, 1); | |
352 } | |
353 } | |
354 | |
355 static void | |
356 gtk_xemacs_paint (GtkWidget *widget, GdkRectangle *area) | |
357 { | |
358 GtkXEmacs *x = GTK_XEMACS (widget); | |
359 struct frame *f = GTK_XEMACS_FRAME (x); | |
2195 | 360 |
361 if (GTK_WIDGET_DRAWABLE (widget)) | |
362 redisplay_redraw_exposed_area (f, area->x, area->y, area->width, | |
363 area->height); | |
462 | 364 } |
365 | |
366 static void | |
367 gtk_xemacs_draw (GtkWidget *widget, GdkRectangle *area) | |
368 { | |
369 GtkFixed *fixed = GTK_FIXED (widget); | |
370 GtkFixedChild *child; | |
371 GdkRectangle child_area; | |
372 GList *children; | |
373 | |
374 /* I need to manually iterate over the children instead of just | |
375 chaining to parent_class->draw() because it calls | |
376 gtk_fixed_paint() directly, which clears the background window, | |
377 which causes A LOT of flashing. */ | |
378 | |
2195 | 379 if (GTK_WIDGET_DRAWABLE (widget)) |
380 { | |
381 gtk_xemacs_paint (widget, area); | |
462 | 382 |
2195 | 383 children = fixed->children; |
462 | 384 |
2195 | 385 while (children) |
386 { | |
387 child = (GtkFixedChild*) children->data; | |
388 children = children->next; | |
389 /* #### This is what causes the scrollbar flickering! | |
390 Evidently the scrollbars pretty much take care of drawing | |
391 themselves in most cases. Then we come along and tell them | |
392 to redraw again! | |
462 | 393 |
2195 | 394 But if we just leave it out, then they do not get drawn |
395 correctly the first time! | |
462 | 396 |
2195 | 397 Scrollbar flickering has been greatly helped by the |
398 optimizations in scrollbar-gtk.c / | |
399 gtk_update_scrollbar_instance_status (), so this is not that | |
400 big a deal anymore. | |
401 */ | |
402 if (gtk_widget_intersect (child->widget, area, &child_area)) | |
403 { | |
404 gtk_widget_draw (child->widget, &child_area); | |
405 } | |
406 } | |
407 } | |
462 | 408 } |
409 | |
410 static gint | |
411 gtk_xemacs_expose (GtkWidget *widget, GdkEventExpose *event) | |
412 { | |
413 GtkXEmacs *x = GTK_XEMACS (widget); | |
414 struct frame *f = GTK_XEMACS_FRAME (x); | |
415 GdkRectangle *a = &event->area; | |
416 | |
2195 | 417 if (GTK_WIDGET_DRAWABLE (widget)) |
418 { | |
419 /* This takes care of drawing the scrollbars, etc */ | |
420 parent_class->expose_event (widget, event); | |
462 | 421 |
2195 | 422 /* Now draw the actual frame data */ |
423 if (!check_for_ignored_expose (f, a->x, a->y, a->width, a->height) && | |
424 !find_matching_subwindow (f, a->x, a->y, a->width, a->height)) | |
425 redisplay_redraw_exposed_area (f, a->x, a->y, a->width, a->height); | |
426 return (TRUE); | |
427 } | |
3087 | 428 |
429 return FALSE; | |
462 | 430 } |
431 | |
432 Lisp_Object | |
2286 | 433 xemacs_gtk_convert_color(GdkColor *c, GtkWidget *UNUSED (w)) |
462 | 434 { |
435 char color_buf[255]; | |
436 | |
437 sprintf (color_buf, "#%04x%04x%04x", c->red, c->green, c->blue); | |
438 | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4709
diff
changeset
|
439 return (build_cistring (color_buf)); |
462 | 440 } |