changeset 5628:81fee4aee9b6

text_width methods interface cleanup. -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2011-12-28 Didier Verna <didier@xemacs.org> * console-impl.h (struct console_methods): Have the text_width methods expect a frame instead of a window pointer. * console-stream.c (stream_text_width): * redisplay-msw.c (mswindows_text_width): * redisplay-tty.c (tty_text_width): * redisplay-xlike-inc.c (XLIKE_text_width): Update accordingly. * redisplay-msw.c (mswindows_output_string): * redisplay-xlike-inc.c (XLIKE_output_string): * redisplay.c (redisplay_window_text_width_ichar_string): * redisplay.c (redisplay_text_width_string): Update the callers. This also fixes an uncertainty about always getting a window from a domain.
author Didier Verna <didier@xemacs.org>
date Wed, 28 Dec 2011 11:21:38 +0100
parents 37fb945697f5
children 0d05accafc63
files src/ChangeLog src/console-impl.h src/console-stream.c src/redisplay-msw.c src/redisplay-tty.c src/redisplay-xlike-inc.c src/redisplay.c
diffstat 7 files changed, 28 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed Dec 28 10:53:38 2011 +0100
+++ b/src/ChangeLog	Wed Dec 28 11:21:38 2011 +0100
@@ -1,3 +1,18 @@
+2011-12-28  Didier Verna  <didier@xemacs.org>
+
+	* console-impl.h (struct console_methods): Have the text_width
+	methods expect a frame instead of a window pointer.
+	* console-stream.c (stream_text_width):
+	* redisplay-msw.c (mswindows_text_width):
+	* redisplay-tty.c (tty_text_width):
+	* redisplay-xlike-inc.c (XLIKE_text_width): Update accordingly.
+	* redisplay-msw.c (mswindows_output_string):
+	* redisplay-xlike-inc.c (XLIKE_output_string):
+	* redisplay.c (redisplay_window_text_width_ichar_string):
+	* redisplay.c (redisplay_text_width_string): Update the callers.
+	This also fixes an uncertainty about always getting a window from
+	a domain.
+
 2011-12-28  Didier Verna  <didier@xemacs.org>
 
 	* redisplay-xlike-inc.c (XLIKE_text_width_single_run): Get only
--- a/src/console-impl.h	Wed Dec 28 10:53:38 2011 +0100
+++ b/src/console-impl.h	Wed Dec 28 11:21:38 2011 +0100
@@ -143,7 +143,7 @@
   /* redisplay methods */
   int (*left_margin_width_method) (struct window *);
   int (*right_margin_width_method) (struct window *);
-  int (*text_width_method) (struct window *w, struct face_cachel *cachel,
+  int (*text_width_method) (struct frame *f, struct face_cachel *cachel,
 			    const Ichar *str, Charcount len);
   void (*output_display_block_method) (struct window *, struct display_line *,
 				       int, int, int, int, int, int, int);
--- a/src/console-stream.c	Wed Dec 28 10:53:38 2011 +0100
+++ b/src/console-stream.c	Wed Dec 28 11:21:38 2011 +0100
@@ -198,7 +198,7 @@
 
 
 static int
-stream_text_width (struct window *UNUSED (w),
+stream_text_width (struct frame *UNUSED (f),
 		   struct face_cachel *UNUSED (cachel),
 		   const Ichar *UNUSED (str), Charcount len)
 {
--- a/src/redisplay-msw.c	Wed Dec 28 10:53:38 2011 +0100
+++ b/src/redisplay-msw.c	Wed Dec 28 11:21:38 2011 +0100
@@ -467,7 +467,7 @@
 #if 0	/* #### FIXME? */
   /* We can't work out the width before we've set the font in the DC */
   if (width < 0)
-    width = mswindows_text_width (w, cachel, Dynarr_begin (buf),
+    width = mswindows_text_width (f, cachel, Dynarr_begin (buf),
 				  Dynarr_length (buf));
 #else
   assert (width >= 0);
@@ -1212,10 +1212,9 @@
  displayed in the font associated with the face.
  ****************************************************************************/
 static int
-mswindows_text_width (struct window *w, struct face_cachel *cachel,
+mswindows_text_width (struct frame *f, struct face_cachel *cachel,
 		      const Ichar *str, Charcount len)
 {
-  struct frame *f = WINDOW_XFRAME (w);
   HDC hdc = get_frame_dc (f, 0);
   int width_so_far = 0;
   textual_run *runs;
--- a/src/redisplay-tty.c	Wed Dec 28 10:53:38 2011 +0100
+++ b/src/redisplay-tty.c	Wed Dec 28 11:21:38 2011 +0100
@@ -104,10 +104,10 @@
  column, so we use ichar_string_displayed_columns().
  ****************************************************************************/
 static int
-tty_text_width (struct window *w, struct face_cachel *UNUSED (cachel),
+tty_text_width (struct frame *f, struct face_cachel *UNUSED (cachel),
 		const Ichar *str, Charcount len)
 {
-  struct console *c = WINDOW_XCONSOLE (w);
+  struct console *c = FRAME_XCONSOLE (f);
 
   if (CONSOLE_TTY_MULTIPLE_WIDTH (c))
     {
--- a/src/redisplay-xlike-inc.c	Wed Dec 28 10:53:38 2011 +0100
+++ b/src/redisplay-xlike-inc.c	Wed Dec 28 11:21:38 2011 +0100
@@ -517,16 +517,14 @@
    */
 
 static int
-XLIKE_text_width (struct window *w, struct face_cachel *cachel,
+XLIKE_text_width (struct frame *f, struct face_cachel *cachel,
 		  const Ichar *str, Charcount len)
 {
   /* !!#### Needs review */
   int width_so_far = 0;
   unsigned char *text_storage = (unsigned char *) ALLOCA (2 * len);
   struct textual_run *runs = alloca_array (struct textual_run, len);
-  struct frame *f = XFRAME (w->frame);
-  struct device *d = XDEVICE (f->device);
-  XLIKE_DISPLAY dpy = GET_XLIKE_DISPLAY (d);
+  XLIKE_DISPLAY dpy = GET_XLIKE_DISPLAY (XDEVICE (f->device));
   int nruns;
   int i;
 
@@ -1040,7 +1038,7 @@
 #endif /* USE_XFT */
 
   if (width < 0)
-    width = XLIKE_text_width (w, cachel, Dynarr_begin (buf),
+    width = XLIKE_text_width (f, cachel, Dynarr_begin (buf),
 			      Dynarr_length (buf));
 
   /* Regularize the variables passed in. */
--- a/src/redisplay.c	Wed Dec 28 10:53:38 2011 +0100
+++ b/src/redisplay.c	Wed Dec 28 11:21:38 2011 +0100
@@ -639,7 +639,8 @@
   ensure_face_cachel_complete (WINDOW_FACE_CACHEL (w, findex), window,
 			       charsets);
   return DEVMETH (WINDOW_XDEVICE (w),
-		  text_width, (w, WINDOW_FACE_CACHEL (w, findex), str,
+		  text_width, (WINDOW_XFRAME (w),
+			       WINDOW_FACE_CACHEL (w, findex), str,
 			       len));
 }
 
@@ -687,13 +688,8 @@
   ensure_face_cachel_complete (&cachel,
 			       NILP (window) ? frame : window,
 			       charsets);
-  return DEVMETH (XDEVICE (FRAME_DEVICE (XFRAME (frame))),
-		  /* #### Not clear if we're always passed a window, but
-		     I think so.  If not, we will get an abort here,
-		     and then we need to either fix the callers to pass in
-		     a window, or change *text_width() to take a domain
-		     argument. */
-		  text_width, (XWINDOW (window),
+  return DEVMETH (FRAME_XDEVICE (XFRAME (frame)),
+		  text_width, (XFRAME (frame),
 			       &cachel,
 			       Dynarr_begin (rtw_ichar_dynarr),
 			       Dynarr_length (rtw_ichar_dynarr)));