[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xterm: Changes to 'debian-unstable'



 MANIFEST                 |    2 
 aclocal.m4               |   10 +-
 configure                |   20 ++---
 debian/changelog         |    6 +
 graphics.c               |  164 ++++++++++++++++++++++++++++++++---------------
 graphics.h               |   16 ++--
 package/debian/changelog |    6 +
 package/freebsd/Makefile |    2 
 package/xterm.spec       |    4 -
 screen.c                 |   66 +++++++++---------
 util.c                   |   70 +++++++++++---------
 version.h                |    6 -
 xterm.log.html           |   20 +++++
 13 files changed, 250 insertions(+), 142 deletions(-)

New commits:
commit 736105b1db0522129a9e1bbffc049ed2c32a5ea1
Author: Sven Joachim <svenjoac@gmx.de>
Date:   Thu Jul 11 20:30:33 2013 +0200

    New upstream release

diff --git a/debian/changelog b/debian/changelog
index 50bc01a..5d24019 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+xterm (296-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- Sven Joachim <svenjoac@gmx.de>  Thu, 11 Jul 2013 20:30:29 +0200
+
 xterm (295-1) unstable; urgency=low
 
   * New upstream release.

commit a3928ced8a82ccb420c23b2caad32f758cbf4aab
Author: Sven Joachim <svenjoac@gmx.de>
Date:   Thu Jul 11 20:24:55 2013 +0200

    Imported Upstream version 296

diff --git a/MANIFEST b/MANIFEST
index 03fd848..5675bd8 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,4 +1,4 @@
-MANIFEST for xterm-295, version xterm-295
+MANIFEST for xterm-296, version xterm-296
 --------------------------------------------------------------------------------
 MANIFEST                        this file
 256colres.h                     resource-definitions for 256-color mode
diff --git a/aclocal.m4 b/aclocal.m4
index e32778e..da13727 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,4 +1,4 @@
-dnl $XTermId: aclocal.m4,v 1.368 2013/07/07 01:30:48 tom Exp $
+dnl $XTermId: aclocal.m4,v 1.369 2013/07/10 01:29:34 tom Exp $
 dnl
 dnl ---------------------------------------------------------------------------
 dnl
@@ -188,7 +188,7 @@ dnl $1 = libraries to add, with the "-l", etc.
 dnl $2 = variable to update (default $LIBS)
 AC_DEFUN([CF_ADD_LIBS],[ifelse($2,,LIBS,[$2])="$1 [$]ifelse($2,,LIBS,[$2])"])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_ADD_LIB_AFTER version: 2 updated: 2010/11/08 20:33:46
+dnl CF_ADD_LIB_AFTER version: 3 updated: 2013/07/09 21:27:22
 dnl ----------------
 dnl Add a given library after another, e.g., following the one it satisfies a
 dnl dependency for.
@@ -197,7 +197,7 @@ dnl $1 = the first library
 dnl $2 = its dependency
 AC_DEFUN([CF_ADD_LIB_AFTER],[
 CF_VERBOSE(...before $LIBS)
-LIBS=`echo "$LIBS" | sed -e "s/[[ 	]][[ 	]]*/ /g" -e "s,$1 ,$1 $2 ," -e 's/  / /g'`
+LIBS=`echo "$LIBS" | sed -e "s/[[ 	]][[ 	]]*/ /g" -e "s%$1 %$1 $2 %" -e 's%  % %g'`
 CF_VERBOSE(...after  $LIBS)
 ])dnl
 dnl ---------------------------------------------------------------------------
@@ -2322,7 +2322,7 @@ foo.c_ospeed = B9600;
 test "$cf_cv_termio_c_ispeed" = yes && AC_DEFINE(HAVE_TERMIO_C_ISPEED,1,[define 1 if we have IRIX 6.5 baud-rate redefinitions])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_TRIM_X_LIBS version: 1 updated: 2013/07/06 21:27:06
+dnl CF_TRIM_X_LIBS version: 2 updated: 2013/07/09 21:27:22
 dnl --------------
 dnl Trim extra base X libraries added as a workaround for inconsistent library
 dnl dependencies returned by "new" pkg-config files.
@@ -2331,7 +2331,7 @@ AC_DEFUN([CF_TRIM_X_LIBS],[
 	do
 		case "$LIBS" in
 		*-l$cf_trim_lib\ *-l$cf_trim_lib*)
-			LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's/-l'$cf_trim_lib' //' -e 's/ $//'`
+			LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
 			CF_VERBOSE(..trimmed $LIBS)
 			;;
 		esac
diff --git a/configure b/configure
index 1f4a5e6..1bfcb84 100755
--- a/configure
+++ b/configure
@@ -9225,7 +9225,7 @@ test -n "$verbose" && echo "	...before $LIBS" 1>&6
 
 echo "${as_me:-configure}:9226: testing ...before $LIBS ..." 1>&5
 
-LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s,-lXt ,-lXt -lX11 ," -e 's/  / /g'`
+LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s%-lXt %-lXt -lX11 %" -e 's%  % %g'`
 test -n "$verbose" && echo "	...after  $LIBS" 1>&6
 
 echo "${as_me:-configure}:9231: testing ...after  $LIBS ..." 1>&5
@@ -9497,7 +9497,7 @@ test -n "$verbose" && echo "	...before $LIBS" 1>&6
 
 echo "${as_me:-configure}:9498: testing ...before $LIBS ..." 1>&5
 
-LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s,-lXt ,-lXt $X_PRE_LIBS ," -e 's/  / /g'`
+LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s%-lXt %-lXt $X_PRE_LIBS %" -e 's%  % %g'`
 test -n "$verbose" && echo "	...after  $LIBS" 1>&6
 
 echo "${as_me:-configure}:9503: testing ...after  $LIBS ..." 1>&5
@@ -10267,7 +10267,7 @@ EOF
 	do
 		case "$LIBS" in
 		*-l$cf_trim_lib\ *-l$cf_trim_lib*)
-			LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's/-l'$cf_trim_lib' //' -e 's/ $//'`
+			LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
 			test -n "$verbose" && echo "	..trimmed $LIBS" 1>&6
 
 echo "${as_me:-configure}:10273: testing ..trimmed $LIBS ..." 1>&5
@@ -10436,7 +10436,7 @@ test -n "$verbose" && echo "	...before $LIBS" 1>&6
 
 echo "${as_me:-configure}:10437: testing ...before $LIBS ..." 1>&5
 
-LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s,$cf_first_lib ,$cf_first_lib $cf_pkgconfig_libs ," -e 's/  / /g'`
+LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s%$cf_first_lib %$cf_first_lib $cf_pkgconfig_libs %" -e 's%  % %g'`
 test -n "$verbose" && echo "	...after  $LIBS" 1>&6
 
 echo "${as_me:-configure}:10442: testing ...after  $LIBS ..." 1>&5
@@ -10449,7 +10449,7 @@ test -n "$verbose" && echo "	...before $LIBS" 1>&6
 
 echo "${as_me:-configure}:10450: testing ...before $LIBS ..." 1>&5
 
-LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s,$cf_first_lib ,$cf_first_lib -lXmu ," -e 's/  / /g'`
+LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s%$cf_first_lib %$cf_first_lib -lXmu %" -e 's%  % %g'`
 test -n "$verbose" && echo "	...after  $LIBS" 1>&6
 
 echo "${as_me:-configure}:10455: testing ...after  $LIBS ..." 1>&5
@@ -10460,7 +10460,7 @@ fi
 	do
 		case "$LIBS" in
 		*-l$cf_trim_lib\ *-l$cf_trim_lib*)
-			LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's/-l'$cf_trim_lib' //' -e 's/ $//'`
+			LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
 			test -n "$verbose" && echo "	..trimmed $LIBS" 1>&6
 
 echo "${as_me:-configure}:10466: testing ..trimmed $LIBS ..." 1>&5
@@ -10899,7 +10899,7 @@ test -n "$verbose" && echo "	...before $LIBS" 1>&6
 
 echo "${as_me:-configure}:10900: testing ...before $LIBS ..." 1>&5
 
-LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s,-lXt ,-lXt -lX11 ," -e 's/  / /g'`
+LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s%-lXt %-lXt -lX11 %" -e 's%  % %g'`
 test -n "$verbose" && echo "	...after  $LIBS" 1>&6
 
 echo "${as_me:-configure}:10905: testing ...after  $LIBS ..." 1>&5
@@ -11171,7 +11171,7 @@ test -n "$verbose" && echo "	...before $LIBS" 1>&6
 
 echo "${as_me:-configure}:11172: testing ...before $LIBS ..." 1>&5
 
-LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s,-lXt ,-lXt $X_PRE_LIBS ," -e 's/  / /g'`
+LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s%-lXt %-lXt $X_PRE_LIBS %" -e 's%  % %g'`
 test -n "$verbose" && echo "	...after  $LIBS" 1>&6
 
 echo "${as_me:-configure}:11177: testing ...after  $LIBS ..." 1>&5
@@ -15315,7 +15315,7 @@ test -n "$verbose" && echo "	...before $LIBS" 1>&6
 
 echo "${as_me:-configure}:15316: testing ...before $LIBS ..." 1>&5
 
-LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s,-lXft ,-lXft $cf_pkgconfig_libs ," -e 's/  / /g'`
+LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s%-lXft %-lXft $cf_pkgconfig_libs %" -e 's%  % %g'`
 test -n "$verbose" && echo "	...after  $LIBS" 1>&6
 
 echo "${as_me:-configure}:15321: testing ...after  $LIBS ..." 1>&5
@@ -15328,7 +15328,7 @@ test -n "$verbose" && echo "	...before $LIBS" 1>&6
 
 echo "${as_me:-configure}:15329: testing ...before $LIBS ..." 1>&5
 
-LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s,-lXft ,-lXft -lfontconfig ," -e 's/  / /g'`
+LIBS=`echo "$LIBS" | sed -e "s/[ 	][ 	]*/ /g" -e "s%-lXft %-lXft -lfontconfig %" -e 's%  % %g'`
 test -n "$verbose" && echo "	...after  $LIBS" 1>&6
 
 echo "${as_me:-configure}:15334: testing ...after  $LIBS ..." 1>&5
diff --git a/graphics.c b/graphics.c
index 341513d..9bdc50c 100644
--- a/graphics.c
+++ b/graphics.c
@@ -1,4 +1,4 @@
-/* $XTermId: graphics.c,v 1.11 2013/06/24 22:27:16 tom Exp $ */
+/* $XTermId: graphics.c,v 1.12 2013/07/10 22:35:28 Ross.Combs Exp $ */
 
 /*
  * Copyright 2013 by Ross Combs
@@ -35,6 +35,7 @@
 #include <stdio.h>
 #include <math.h>
 #include <ctype.h>
+#include <stdlib.h>
 
 #include <data.h>
 #include <VTparse.h>
@@ -51,17 +52,15 @@
  * - everything
  * sixel:
  * - erase graphic when erasing screen
- * - erase graphic overwritten by other graphic
+ * - maintain ordered list/array instead of qsort()
  * - erase text under graphics if bg not transparent
  * - erase scrolled portions of all graphics on alt buffer
  * - delete graphic if scrolled past end of scrollback
  * - delete graphic if all pixels are transparent/erased
- * - dynamic memory allocation (and limits)
- * - fix drawing over window border areas
+ * - dynamic memory allocation, add configurable limits
  * - auto convert color graphics in VT330 mode
  * - investigate second graphic framebuffer for ReGIS -- does this apply to text and sixel graphics?
  * - fix problem where new_row < 0 during sixel parsing (see FIXME)
- * - fix position of drawing of new graphic when terminal is displaying scrollback
  * VT55/VT105 waveform graphics
  * - everything
  * escape sequences
@@ -90,7 +89,7 @@
  *  #1;2;0;0;0    5
  */
 static void
-parse_prefixedtype_params(ANSI * params, const char **string)
+parse_prefixedtype_params(ANSI *params, const char **string)
 {
     const char *cp = *string;
     ParmType nparam = 0;
@@ -167,10 +166,13 @@ typedef struct {
     int row;			/* context used during parsing */
     int col;			/* context used during parsing */
     int bufferid;		/* which screen buffer the graphic is associated with */
+    unsigned int id;		/* sequential id used for preserving layering */
     int valid;			/* if the graphic has been initialized */
     int dirty;			/* if the graphic needs to be redrawn */
 } SixelGraphic;
 
+static unsigned int next_sixel_id = 0U;
+
 static ColorRegister shared_color_registers[MAX_COLOR_REGISTERS];
 
 #define MAX_SIXEL_GRAPHICS 16U
@@ -187,7 +189,7 @@ static SixelGraphic sixel_graphics[MAX_SIXEL_GRAPHICS];
  */
 
 static void
-init_sixel_background(SixelGraphic * graphic)
+init_sixel_background(SixelGraphic *graphic)
 {
     RegisterNum bgcolor = (RegisterNum) graphic->background;
     int r, c;
@@ -208,7 +210,7 @@ init_sixel_background(SixelGraphic * graphic)
 }
 
 static void
-set_sixel(SixelGraphic * graphic, int sixel)
+set_sixel(SixelGraphic *graphic, int sixel)
 {
     RegisterNum color;
     int pix;
@@ -247,7 +249,7 @@ set_sixel(SixelGraphic * graphic, int sixel)
 }
 
 static void
-set_sixel_color_register(ColorRegister * color_registers,
+set_sixel_color_register(ColorRegister *color_registers,
 			 RegisterNum color,
 			 short r,
 			 short g,
@@ -261,7 +263,7 @@ set_sixel_color_register(ColorRegister * color_registers,
 }
 
 static void
-init_color_registers(ColorRegister * color_registers, int terminal_id)
+init_color_registers(ColorRegister *color_registers, int terminal_id)
 {
     TRACE(("initializing colors for %d\n", terminal_id));
     {
@@ -354,7 +356,7 @@ init_color_registers(ColorRegister * color_registers, int terminal_id)
 }
 
 static void
-init_sixel_graphic(SixelGraphic * graphic, int terminal_id, int private_colors)
+init_sixel_graphic(SixelGraphic *graphic, int terminal_id, int private_colors)
 {
     TRACE(("initializing sixel graphic\n"));
 
@@ -380,14 +382,14 @@ init_sixel_graphic(SixelGraphic * graphic, int terminal_id, int private_colors)
 
     /*
      * When an application selects the monochrome map:  the terminal sets the
-     * 16 entries of the color map to the default monochrome gray level. 
+     * 16 entries of the color map to the default monochrome gray level.
      * Therefore, the original colors are lost when changing from the color map
      * to the monochrome map.
-     * 
+     *
      * If you change the color value (green, red, blue) using the Color Set-Up
      * screen or a ReGIS command, the VT340 sets the gray scale by using the
      * formula (2G + R)/3.
-     * 
+     *
      * When an application selects the color map:  the terminal sets the 16
      * entries of the color map to the default (color) color map.
      */
@@ -495,6 +497,7 @@ get_sixel_graphic(XtermWidget xw)
 
     graphic->xw = xw;
     graphic->bufferid = bufferid;
+    graphic->id = next_sixel_id++;
     init_sixel_graphic(graphic, terminal_id, private_colors);
     return graphic;
 }
@@ -567,17 +570,17 @@ set_shared_color_register(RegisterNum color, short r, short g, short b)
     }
 }
 
-#define SixelToPixel(s) (unsigned short) ((long)(s) * 65535 / 100)
+#define ScaleForXColor(s) (unsigned short) ((long)(s) * 65535 / 100)
 
 static Pixel
-sixel_register_to_xpixel(ColorRegister * reg, XtermWidget xw)
+sixel_register_to_xpixel(ColorRegister *reg, XtermWidget xw)
 {
     if (!reg->allocated) {
 	XColor def;
 
-	def.red = SixelToPixel(reg->r);
-	def.green = SixelToPixel(reg->g);
-	def.blue = SixelToPixel(reg->b);
+	def.red = ScaleForXColor(reg->r);
+	def.green = ScaleForXColor(reg->g);
+	def.blue = ScaleForXColor(reg->b);
 	def.flags = DoRed | DoGreen | DoBlue;
 	if (!allocateBestRGB(xw, &def)) {
 	    return 0UL;
@@ -586,12 +589,15 @@ sixel_register_to_xpixel(ColorRegister * reg, XtermWidget xw)
 	reg->allocated = 1;
     }
 
+    /* FIXME: with so many possible colors we need to determine
+     * when to free them to be nice to PseudoColor displays
+     */
     return reg->pix;
 }
 
 static void
 refresh_sixel_graphic(TScreen const *screen,
-		      SixelGraphic * graphic,
+		      SixelGraphic *graphic,
 		      int xbase,
 		      int ybase,
 		      int x,
@@ -660,9 +666,9 @@ refresh_sixel_graphic(TScreen const *screen,
 	    }
 
 	    if (color != old_fg) {
-		xgcv.foreground = sixel_register_to_xpixel(
-							      &graphic->color_registers[color],
-							      graphic->xw);
+		xgcv.foreground =
+		    sixel_register_to_xpixel(&graphic->color_registers[color],
+					     graphic->xw);
 		XChangeGC(display, graphics_gc, mask, &xgcv);
 		old_fg = color;
 	    }
@@ -809,7 +815,7 @@ hls2rgb(int h, int l, int s, short *r, short *g, short *b)
 }
 
 static void
-update_sixel_aspect(SixelGraphic * graphic)
+update_sixel_aspect(SixelGraphic *graphic)
 {
     /* We want to keep the ratio accurate but would like every pixel to have
      * the same size so keep these as whole numbers.
@@ -849,7 +855,7 @@ update_sixel_aspect(SixelGraphic * graphic)
  *  ftp://ftp.cs.utk.edu/pub/shuford/terminal/all_about_sixels.txt
  */
 extern void
-parse_sixel(XtermWidget xw, ANSI * params, char const *string)
+parse_sixel(XtermWidget xw, ANSI *params, char const *string)
 {
     TScreen *screen = TScreenOf(xw);
     SixelGraphic *graphic;
@@ -1065,7 +1071,7 @@ parse_sixel(XtermWidget xw, ANSI * params, char const *string)
 	    Pregister = color_params.a_param[0];
 	    if (Pregister >= graphic->valid_registers) {
 		TRACE(("DATA_WARNING: sixel color operator uses out-of-range register %d\n", Pregister));
-		/* FIXME: supposedly the DEC terminals wrapped register indicies */
+		/* FIXME: supposedly the DEC terminals wrapped register indicies -- verify */
 		while (Pregister >= graphic->valid_registers)
 		    Pregister -= graphic->valid_registers;
 		TRACE(("DATA_WARNING: converted to %d\n", Pregister));
@@ -1212,10 +1218,9 @@ parse_sixel(XtermWidget xw, ANSI * params, char const *string)
 	}
 
 	if (new_row < 0) {
-	    TRACE(("new row would have been be negative (%d), skipping!", new_row));	/* FIXME: this is not the right fix */
-	} else {
-	    set_cur_row(screen, new_row);
+	    TRACE(("new row is going to be negative (%d)!", new_row));	/* FIXME: this was triggering, now it isn't */
 	}
+	set_cur_row(screen, new_row);
 	set_cur_col(screen, new_col <= screen->rgt_marg ? new_col : screen->rgt_marg);
     }
 
@@ -1226,7 +1231,7 @@ parse_sixel(XtermWidget xw, ANSI * params, char const *string)
 }
 
 extern void
-parse_regis(XtermWidget xw, ANSI * params, char const *string)
+parse_regis(XtermWidget xw, ANSI *params, char const *string)
 {
     (void) xw;
     (void) string;
@@ -1240,17 +1245,15 @@ parse_regis(XtermWidget xw, ANSI * params, char const *string)
  * This is used to allow text to "erase" graphics underneath it.
  */
 static void
-erase_sixel_graphic(SixelGraphic * graphic, int x, int y, int w, int h)
+erase_sixel_graphic(SixelGraphic *graphic, int x, int y, int w, int h)
 {
-    RegisterNum hole;
+    RegisterNum hole = COLOR_HOLE;
     int pw, ph;
     int r, c;
 
     pw = graphic->pixw;
     ph = graphic->pixh;
 
-    hole = COLOR_HOLE;
-
     TRACE(("erasing sixel bitmap %d,%d %dx%d\n", x, y, w, h));
 
     for (r = 0; r < graphic->actual_height; r++) {
@@ -1266,6 +1269,20 @@ erase_sixel_graphic(SixelGraphic * graphic, int x, int y, int w, int h)
     }
 }
 
+static int
+compare_sixel_ids(const void *left, const void *right)
+{
+    const SixelGraphic *l = *(const SixelGraphic *const *) left;
+    const SixelGraphic *r = *(const SixelGraphic *const *) right;
+
+    if (!l->valid || !r->valid)
+	return 0;
+    if (l->id < r->id)
+	return -1;
+    else
+	return 1;
+}
+
 extern void
 refresh_displayed_graphics(TScreen const *screen,
 			   int leftcol,
@@ -1273,13 +1290,22 @@ refresh_displayed_graphics(TScreen const *screen,
 			   int ncols,
 			   int nrows)
 {
+    SixelGraphic *ordered_graphics[MAX_SIXEL_GRAPHICS];
     SixelGraphic *graphic;
     unsigned int ii;
     int x, y, w, h;
     int xbase, ybase;
 
     for (ii = 0U; ii < MAX_SIXEL_GRAPHICS; ii++) {
-	graphic = &sixel_graphics[ii];
+	ordered_graphics[ii] = &sixel_graphics[ii];
+    }
+    qsort(ordered_graphics,
+	  MAX_SIXEL_GRAPHICS,
+	  sizeof(ordered_graphics[0]),
+	  compare_sixel_ids);
+
+    for (ii = 0U; ii < MAX_SIXEL_GRAPHICS; ii++) {
+	graphic = ordered_graphics[ii];
 	if (!graphic->valid || graphic->bufferid != screen->whichBuf)
 	    continue;
 
@@ -1293,6 +1319,16 @@ refresh_displayed_graphics(TScreen const *screen,
 	ybase = (screen->border
 		 + (graphic->charrow - screen->topline) * FontHeight(screen));
 
+	if (xbase + x + w + screen->border > FullWidth(screen))
+	    w = FullWidth(screen) - (xbase + x + screen->border);
+	if (ybase + y + h + screen->border > FullHeight(screen))
+	    h = FullHeight(screen) - (ybase + y + screen->border);
+	else if (ybase + y < screen->border) {
+	    int diff = screen->border - (ybase + y);
+	    y += diff;
+	    h -= diff;
+	}
+
 	TRACE(("graphics refresh: screen->topline=%d leftcol=%d toprow=%d nrows=%d ncols=%d x=%d y=%d w=%d h=%d xbase=%d ybase=%d\n",
 	       screen->topline,
 	       leftcol, toprow,
@@ -1337,6 +1373,16 @@ refresh_modified_displayed_graphics(TScreen const *screen)
 	ybase = (screen->border
 		 + (graphic->charrow - screen->topline) * FontHeight(screen));
 
+	if (xbase + x + w + screen->border > FullWidth(screen))
+	    w = FullWidth(screen) - (xbase + x + screen->border);
+	if (ybase + y + h + screen->border > FullHeight(screen))
+	    h = FullHeight(screen) - (ybase + y + screen->border);
+	else if (ybase + y < screen->border) {
+	    int diff = screen->border - (ybase + y);
+	    y += diff;
+	    h -= diff;
+	}
+
 	TRACE(("full graphics refresh: screen->topline=%d leftcol=%d toprow=%d nrows=%d ncols=%d x=%d y=%d w=%d h=%d xbase=%d ybase=%d\n",
 	       screen->topline,
 	       leftcol, toprow,
@@ -1365,36 +1411,56 @@ scroll_displayed_graphics(int rows)
 }
 
 extern void
-erase_displayed_graphics(TScreen const *screen,
-			 int leftcol,
-			 int toprow,
-			 int ncols,
-			 int nrows)
+pixelarea_clear_displayed_graphics(TScreen const *screen,
+				   int winx,
+				   int winy,
+				   int w,
+				   int h)
 {
     SixelGraphic *graphic;
     unsigned int ii;
-    int x, y, w, h;
+    int x, y;
 
     for (ii = 0U; ii < MAX_SIXEL_GRAPHICS; ii++) {
 	graphic = &sixel_graphics[ii];
 	if (!graphic->valid)
 	    continue;
 
-	x = (leftcol - graphic->charcol) * FontWidth(screen);
-	y = (toprow - graphic->charrow) * FontHeight(screen);
-	w = ncols * FontWidth(screen);
-	h = nrows * FontHeight(screen);
+	x = winx - graphic->charcol * FontWidth(screen);
+	y = winy - graphic->charrow * FontHeight(screen);
 
-	TRACE(("graphics erase: screen->topline=%d leftcol=%d toprow=%d nrows=%d ncols=%d x=%d y=%d w=%d h=%d\n",
+	TRACE(("pixelarea graphics erase: screen->topline=%d winx=%d winy=%d w=%d h=%d x=%d y=%d\n",
 	       screen->topline,
-	       leftcol, toprow,
-	       nrows, ncols,
-	       x, y, w, h));
+	       winx, winy,
+	       w, h,
+	       x, y));
 	erase_sixel_graphic(graphic, x, y, w, h);
     }
 }
 
 extern void
+chararea_clear_displayed_graphics(TScreen const *screen,
+				  int leftcol,
+				  int toprow,
+				  int ncols,
+				  int nrows)
+{
+    int x, y, w, h;
+
+    x = leftcol * FontWidth(screen);
+    y = toprow * FontHeight(screen);
+    w = ncols * FontWidth(screen);
+    h = nrows * FontHeight(screen);
+
+    TRACE(("chararea clear graphics: screen->topline=%d leftcol=%d toprow=%d nrows=%d ncols=%d x=%d y=%d w=%d h=%d\n",
+	   screen->topline,
+	   leftcol, toprow,
+	   nrows, ncols,
+	   x, y, w, h));
+    pixelarea_clear_displayed_graphics(screen, x, y, w, h);
+}
+
+extern void
 reset_displayed_graphics(TScreen const *screen)
 {
     SixelGraphic *graphic;
diff --git a/graphics.h b/graphics.h
index d29e086..b258522 100644
--- a/graphics.h
+++ b/graphics.h
@@ -1,4 +1,4 @@
-/* $XTermId: graphics.h,v 1.5 2013/06/23 19:43:59 tom Exp $ */
+/* $XTermId: graphics.h,v 1.6 2013/07/10 08:28:55 Ross.Combs Exp $ */
 
 /*
  * Copyright 2013 by Ross Combs
@@ -41,23 +41,27 @@
 
 typedef unsigned short RegisterNum;
 
-extern void parse_sixel(XtermWidget xw, ANSI *params, char const *string);
+extern void chararea_clear_displayed_graphics(TScreen const *screen, int leftcol, int toprow, int ncols, int nrows);
 extern void parse_regis(XtermWidget xw, ANSI *params, char const *string);
+extern void parse_sixel(XtermWidget xw, ANSI *params, char const *string);
+extern void pixelarea_clear_displayed_graphics(TScreen const *screen, int winx, int winy, int w, int h);
 extern void refresh_displayed_graphics(TScreen const *screen, int leftcol, int toprow, int ncols, int nrows);
 extern void refresh_modified_displayed_graphics(TScreen const *screen);
-extern void update_displayed_graphics_color_registers(TScreen const *screen, RegisterNum color, short r, short g, short b);
-extern void scroll_displayed_graphics(int rows);
-extern void erase_displayed_graphics(TScreen const *screen, int leftcol, int toprow, int ncols, int nrows);
 extern void reset_displayed_graphics(TScreen const *screen);
+extern void scroll_displayed_graphics(int rows);
+extern void update_displayed_graphics_color_registers(TScreen const *screen, RegisterNum color, short r, short g, short b);
 
 #else
 
-#define erase_displayed_graphics(screen, leftcol, toprow, ncols, nrows) /* nothing */
+#define chararea_clear_displayed_graphics(screen, leftcol, toprow, ncols, nrows) /* nothing */
 #define parse_regis(xw, params, string) /* nothing */
 #define parse_sixel(xw, params, string) /* nothing */
+#define pixelarea_clear_displayed_graphics(screen, winx, winy, w, h) /* nothing */
 #define refresh_displayed_graphics(screen, leftcol, toprow, ncols, nrows) /* nothing */
+#define refresh_modified_displayed_graphics(screen) /* nothing */
 #define reset_displayed_graphics(screen) /* nothing */
 #define scroll_displayed_graphics(rows) /* nothing */
+#define update_displayed_graphics_color_registers(screen, color, r, g, b) /* nothing */
 
 #endif
 
diff --git a/package/debian/changelog b/package/debian/changelog
index 24dca7e..5fda61a 100644
--- a/package/debian/changelog
+++ b/package/debian/changelog
@@ -1,3 +1,9 @@
+xterm-dev (296) unstable; urgency=low
+
+  * Build-fix for #295 changes
+
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Tue, 09 Jul 2013 21:20:04 -0400
+
 xterm-dev (295) unstable; urgency=low
 
   * Workaround for problem with ld --as-needed option
diff --git a/package/freebsd/Makefile b/package/freebsd/Makefile
index 7c1804f..91d647b 100644
--- a/package/freebsd/Makefile
+++ b/package/freebsd/Makefile
@@ -5,7 +5,7 @@
 # and "make makesum".
 
 PORTNAME=	xterm
-PORTVERSION=	295
+PORTVERSION=	296
 CATEGORIES=	x11
 MASTER_SITES=	ftp://invisible-island.net/xterm/ \
 		CRITICAL
diff --git a/package/xterm.spec b/package/xterm.spec
index 8d4b6ce..22ed3b7 100644
--- a/package/xterm.spec
+++ b/package/xterm.spec
@@ -1,11 +1,11 @@
-# $XTermId: xterm.spec,v 1.53 2013/07/07 01:19:29 tom Exp $
+# $XTermId: xterm.spec,v 1.54 2013/07/10 01:19:30 tom Exp $
 Summary: X terminal emulator (development version)
 %global my_middle xterm
 %global my_suffix -dev
 %global fullname %{my_middle}%{my_suffix}
 %global my_class XTermDev
 Name: %{fullname}
-Version: 295
+Version: 296
 Release: 1
 License: X11
 Group: User Interface/X
diff --git a/screen.c b/screen.c
index 9b3559a..6f9ac60 100644
--- a/screen.c
+++ b/screen.c
@@ -1,4 +1,4 @@
-/* $XTermId: screen.c,v 1.483 2013/06/23 22:13:30 tom Exp $ */
+/* $XTermId: screen.c,v 1.485 2013/07/10 22:52:16 tom Exp $ */
 
 /*
  * Copyright 1999-2012,2013 by Thomas E. Dickey
@@ -136,7 +136,7 @@
 
 #if OPT_TRACE > 1
 static void
-traceScrnBuf(const char *tag, TScreen * screen, ScrnBuf sb, unsigned len)
+traceScrnBuf(const char *tag, TScreen *screen, ScrnBuf sb, unsigned len)
 {
     unsigned j;
 
@@ -156,7 +156,7 @@ traceScrnBuf(const char *tag, TScreen * screen, ScrnBuf sb, unsigned len)
 #endif
 
 static unsigned
-scrnHeadSize(TScreen * screen, unsigned count)
+scrnHeadSize(TScreen *screen, unsigned count)
 {
     unsigned result = SizeOfLineData;
 
@@ -173,7 +173,7 @@ scrnHeadSize(TScreen * screen, unsigned count)
 }
 
 ScrnBuf
-scrnHeadAddr(TScreen * screen, ScrnBuf base, unsigned offset)
+scrnHeadAddr(TScreen *screen, ScrnBuf base, unsigned offset)
 {
     unsigned size = scrnHeadSize(screen, offset);
     ScrnBuf result = ScrnBufAddr(base, size);
@@ -187,7 +187,7 @@ scrnHeadAddr(TScreen * screen, ScrnBuf base, unsigned offset)
  * Given a block of data, build index to it in the 'base' parameter.
  */
 void
-setupLineData(TScreen * screen, ScrnBuf base, Char * data, unsigned nrow, unsigned ncol)
+setupLineData(TScreen *screen, ScrnBuf base, Char *data, unsigned nrow, unsigned ncol)
 {
     unsigned i;
     unsigned offset = 0;
@@ -249,7 +249,7 @@ setupLineData(TScreen * screen, ScrnBuf base, Char * data, unsigned nrow, unsign
  * new copy of the screen buffer.
  */
 static void
-extractScrnData(TScreen * screen,
+extractScrnData(TScreen *screen,
 		ScrnBuf dstPtrs,
 		ScrnBuf srcPtrs,
 		unsigned nrows,
@@ -270,7 +270,7 @@ extractScrnData(TScreen * screen,
 }
 
 static ScrnPtr *
-allocScrnHead(TScreen * screen, unsigned nrow)
+allocScrnHead(TScreen *screen, unsigned nrow)
 {
     ScrnPtr *result;
     unsigned size = scrnHeadSize(screen, 1);
@@ -289,7 +289,7 @@ allocScrnHead(TScreen * screen, unsigned nrow)
  * Return the size of a line's data.
  */
 static unsigned
-sizeofScrnRow(TScreen * screen, unsigned ncol)
+sizeofScrnRow(TScreen *screen, unsigned ncol)
 {
     unsigned result;
     unsigned sizeAttribs;
@@ -322,7 +322,7 @@ sizeofScrnRow(TScreen * screen, unsigned ncol)
 }
 
 Char *
-allocScrnData(TScreen * screen, unsigned nrow, unsigned ncol)
+allocScrnData(TScreen *screen, unsigned nrow, unsigned ncol)
 {
     Char *result;
     size_t length;
@@ -331,7 +331,7 @@ allocScrnData(TScreen * screen, unsigned nrow, unsigned ncol)
     length = ((nrow + 1) * sizeofScrnRow(screen, ncol));
     if (length == 0
 	|| (result = (Char *) calloc(length, sizeof(Char))) == 0)
-	SysError(ERROR_SCALLOC2);
+	  SysError(ERROR_SCALLOC2);
 
     TRACE(("allocScrnData %ux%u -> %lu -> %p..%p\n",
 	   nrow, ncol, (unsigned long) length, result, result + length - 1));
@@ -352,7 +352,7 @@ allocScrnData(TScreen * screen, unsigned nrow, unsigned ncol)
  * We store it all as pointers, because of alignment considerations.
  */
 ScrnBuf
-allocScrnBuf(XtermWidget xw, unsigned nrow, unsigned ncol, Char ** addr)
+allocScrnBuf(XtermWidget xw, unsigned nrow, unsigned ncol, Char **addr)
 {
     TScreen *screen = TScreenOf(xw);
     ScrnBuf base = 0;
@@ -373,7 +373,7 @@ allocScrnBuf(XtermWidget xw, unsigned nrow, unsigned ncol, Char ** addr)
  * Copy line-data from the visible (edit) buffer to the save-lines buffer.
  */
 static void
-saveEditBufLines(TScreen * screen, ScrnBuf sb, unsigned n)
+saveEditBufLines(TScreen *screen, ScrnBuf sb, unsigned n)
 {
     unsigned j;
 
@@ -397,7 +397,7 @@ saveEditBufLines(TScreen * screen, ScrnBuf sb, unsigned n)
  * Copy line-data from the save-lines buffer to the visible (edit) buffer.
  */
 static void
-unsaveEditBufLines(TScreen * screen, ScrnBuf sb, unsigned n)
+unsaveEditBufLines(TScreen *screen, ScrnBuf sb, unsigned n)
 {
     unsigned j;
 
@@ -430,8 +430,8 @@ unsaveEditBufLines(TScreen * screen, ScrnBuf sb, unsigned n)
  */
 static int
 Reallocate(XtermWidget xw,
-	   ScrnBuf * sbuf,
-	   Char ** sbufaddr,
+	   ScrnBuf *sbuf,
+	   Char **sbufaddr,
 	   unsigned nrow,
 	   unsigned ncol,
 	   unsigned oldrow)
@@ -524,8 +524,8 @@ Reallocate(XtermWidget xw,
  */
 static void
 ReallocateBufOffsets(XtermWidget xw,
-		     ScrnBuf * sbuf,
-		     Char ** sbufaddr,
+		     ScrnBuf *sbuf,
+		     Char **sbufaddr,
 		     unsigned nrow,
 		     unsigned ncol)
 {
@@ -712,7 +712,7 @@ ChangeToWide(XtermWidget xw)
  * Copy cells, no side-effects.
  */
 void
-CopyCells(TScreen * screen, LineData * src, LineData * dst, int col, int len)
+CopyCells(TScreen *screen, LineData *src, LineData *dst, int col, int len)
 {
     if (len > 0) {
 	int n;
@@ -820,7 +820,7 @@ ScrnDisownSelection(XtermWidget xw)
  */
 void
 ScrnWriteText(XtermWidget xw,
-	      IChar * str,
+	      IChar *str,
 	      unsigned flags,
 	      unsigned cur_fg_bg,
 	      unsigned length)
@@ -942,10 +942,10 @@ ScrnWriteText(XtermWidget xw,
 	   screen->cur_col,
 	   screen->cur_row,
 	   real_width));
-    erase_displayed_graphics(screen,
-			     screen->cur_col,
-			     screen->cur_row,
-			     (int) real_width, 1);
+    chararea_clear_displayed_graphics(screen,
+				      screen->cur_col,
+				      screen->cur_row,
+				      (int) real_width, 1);
 
     if_OPT_XMC_GLITCH(screen, {
 	Resolve_XMC(xw);
@@ -1023,11 +1023,11 @@ ScrnClearLines(XtermWidget xw, ScrnBuf sb, int where, unsigned n, unsigned size)
 	   screen->savelines,
 	   n,
 	   screen->max_col));
-    erase_displayed_graphics(screen,
-			     where + screen->savelines,
-			     0,
-			     screen->max_col + 1,
-			     (int) n);
+    chararea_clear_displayed_graphics(screen,
+				      where + screen->savelines,
+				      0,
+				      screen->max_col + 1,
+				      (int) n);
 }
 
 /*
@@ -1085,7 +1085,7 @@ ScrnAllocBuf(XtermWidget xw)
 }
 
 size_t
-ScrnPointers(TScreen * screen, size_t len)
+ScrnPointers(TScreen *screen, size_t len)
 {
     size_t result = scrnHeadSize(screen, (unsigned) len);
 
@@ -1358,7 +1358,7 @@ ScrnDeleteChar(XtermWidget xw, unsigned n)
  * its line-wrapping state.
  */
 void
-ShowWrapMarks(XtermWidget xw, int row, LineData * ld)
+ShowWrapMarks(XtermWidget xw, int row, LineData *ld)
 {
     TScreen *screen = TScreenOf(xw);
     Boolean set = (Boolean) LineTstWrapped(ld);
@@ -2239,7 +2239,7 @@ ScreenResize(XtermWidget xw,
  * nonnull.
  */
 Bool
-non_blank_line(TScreen * screen,
+non_blank_line(TScreen *screen,
 	       int row,
 	       int col,
 	       int len)
@@ -2796,7 +2796,7 @@ unset_resize_increments(XtermWidget xw)
 }
 
 static void
-set_ewmh_hint(Display * dpy, Window window, int operation, _Xconst char *prop)
+set_ewmh_hint(Display *dpy, Window window, int operation, _Xconst char *prop)
 {
     XEvent e;
     Atom atom_fullscreen = XInternAtom(dpy, prop, False);
@@ -2827,7 +2827,7 @@ set_ewmh_hint(Display * dpy, Window window, int operation, _Xconst char *prop)
  * window.
  */
 static Boolean
-probe_netwm(Display * dpy, _Xconst char *propname)
+probe_netwm(Display *dpy, _Xconst char *propname)
 {
     Atom atom_fullscreen = XInternAtom(dpy, propname, False);
     Atom atom_supported = XInternAtom(dpy, "_NET_SUPPORTED", False);
diff --git a/util.c b/util.c
index 30d0f8e..b36db37 100644
--- a/util.c
+++ b/util.c
@@ -1,4 +1,4 @@
-/* $XTermId: util.c,v 1.604 2013/06/23 15:28:35 tom Exp $ */
+/* $XTermId: util.c,v 1.606 2013/07/10 22:52:14 tom Exp $ */
 
 /*
  * Copyright 1999-2012,2013 by Thomas E. Dickey
@@ -106,7 +106,7 @@ int (*my_wcwidth) (wchar_t);
  * that we should fill with blanks, return true if filling is needed.
  */
 int
-DamagedCells(TScreen * screen, unsigned n, int *klp, int *krp, int row, int col)
+DamagedCells(TScreen *screen, unsigned n, int *klp, int *krp, int row, int col)
 {
     LineData *ld = getLineData(screen, row);
     int result = False;
@@ -159,7 +159,7 @@ DamagedCells(TScreen * screen, unsigned n, int *klp, int *krp, int row, int col)
 }
 
 int
-DamagedCurCells(TScreen * screen, unsigned n, int *klp, int *krp)
+DamagedCurCells(TScreen *screen, unsigned n, int *klp, int *krp)
 {
     return DamagedCells(screen, n, klp, krp, screen->cur_row, screen->cur_col);
 }
@@ -1016,7 +1016,7 @@ resetZIconBeep(XtermWidget xw)
  * the current cursor position.  update cursor position.
  */
 void
-WriteText(XtermWidget xw, IChar * str, Cardinal len)
+WriteText(XtermWidget xw, IChar *str, Cardinal len)
 {
     TScreen *screen = TScreenOf(xw);
     LineData *ld = 0;
@@ -1489,7 +1489,11 @@ ClearAbove(XtermWidget xw)
 	    if ((height = screen->cur_row + top) > screen->max_row)
 		height = screen->max_row + 1;
 	    if ((height -= top) > 0) {
-		erase_displayed_graphics(screen, 0, top, MaxCols(screen), height);
+		chararea_clear_displayed_graphics(screen,
+						  0,
+						  top,
+						  MaxCols(screen),
+						  height);
 
 		ClearCurBackground(xw,
 				   top,
@@ -1529,11 +1533,11 @@ ClearBelow(XtermWidget xw)
 	    if (screen->scroll_amt)
 		FlushScroll(xw);
 	    if (++top <= screen->max_row) {
-		erase_displayed_graphics(screen,
-					 0,
-					 top,
-					 MaxCols(screen),
-					 (screen->max_row - top + 1));
+		chararea_clear_displayed_graphics(screen,
+						  0,
+						  top,
+						  MaxCols(screen),
+						  (screen->max_row - top + 1));
 		ClearCurBackground(xw,
 				   top,
 				   0,
@@ -1760,11 +1764,11 @@ ClearScreen(XtermWidget xw)
     if ((top = INX2ROW(screen, 0)) <= screen->max_row) {
 	if (screen->scroll_amt)
 	    FlushScroll(xw);
-	erase_displayed_graphics(screen,
-				 0,
-				 top,
-				 MaxCols(screen),
-				 (screen->max_row - top + 1));
+	chararea_clear_displayed_graphics(screen,
+					  0,
+					  top,
+					  MaxCols(screen),


Reply to: