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

xterm: Changes to 'upstream-experimental'



 INSTALL                   |  100 
 Imakefile                 |   24 
 MANIFEST                  |   11 
 Makefile.in               |  223 +
 THANKS                    |   15 
 Tekproc.c                 |   44 
 VTPrsTbl.c                |  356 ++
 VTparse.def               |    7 
 VTparse.h                 |    8 
 XTerm.ad                  |    4 
 aclocal.m4                |  235 +
 button.c                  |  683 ++--
 cachedGCs.c               |   44 
 charclass.c               |    4 
 charproc.c                | 1388 +++++++--
 charsets.c                |  828 +++--
 config.guess              |  329 --
 config.sub                |   90 
 configure                 | 6681 +++++++++++++++++++++++++++++-----------------
 configure.in              |  128 
 ctlseqs.ms                |  228 +
 ctlseqs.txt               |  315 +-
 cursor.c                  |    6 
 data.c                    |    8 
 data.h                    |   14 
 doublechr.c               |   37 
 fontutils.c               |  713 +++-
 fontutils.h               |   40 
 graphics.c                | 1776 ++++++++++++
 graphics.h                |  126 
 graphics_regis.c          | 6313 +++++++++++++++++++++++++++++++++++++++++++
 graphics_regis.h          |   48 
 graphics_sixel.c          |  642 ++++
 graphics_sixel.h          |   48 
 input.c                   |   36 
 linedata.c                |   27 
 main.c                    |  368 +-
 main.h                    |    8 
 menu.c                    |  419 +-
 menu.h                    |   30 
 minstall.in               |   14 
 misc.c                    |  861 +++--
 package/debian/changelog  |  138 
 package/debian/control    |    2 
 package/debian/copyright  |    2 
 package/debian/postinst   |   25 
 package/debian/prerm      |   12 
 package/debian/rules      |    5 
 package/freebsd/Makefile  |  106 
 package/freebsd/pkg-plist |    7 
 package/xterm.spec        |  106 
 plink.sh                  |   33 
 precompose.c              |   10 
 print.c                   |   60 
 ptydata.c                 |   66 
 ptyx.h                    |  391 ++
 resize.c                  |   14 
 screen.c                  |  210 -
 scrollback.c              |   24 
 scrollbar.c               |   49 
 terminfo                  |    9 
 testxmc.c                 |   10 
 trace.c                   |  136 
 trace.h                   |   13 
 unicode/precompose.c.head |    1 
 util.c                    |  905 ++++--
 version.h                 |    8 
 vttests/256colors.pl      |   13 
 vttests/256colors2.pl     |   13 
 vttests/88colors.pl       |   11 
 vttests/88colors2.pl      |   13 
 vttests/dynamic.pl        |    7 
 vttests/paste64.pl        |    8 
 vttests/query-color.pl    |    7 
 vttests/query-fonts.pl    |    7 
 vttests/resize.pl         |   36 
 vttests/tcapquery.pl      |    7 
 xstrings.c                |   24 
 xterm.appdata.xml         |   25 
 xterm.h                   |  121 
 xterm.log.html            | 1128 ++++++-
 xterm.man                 |  587 +++-
 xterm_io.h                |   17 
 xtermcap.c                |   22 
 xtermcap.h                |    6 
 xtermcfg.hin              |   17 
 86 files changed, 21861 insertions(+), 5829 deletions(-)

New commits:
commit a62200be403ccf73318437f35a4804f9b1828a3d
Author: Sven Joachim <svenjoac@gmx.de>
Date:   Sat Nov 29 10:31:49 2014 +0100

    Imported Upstream version 313

diff --git a/INSTALL b/INSTALL
index 4d442d2..e285532 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,4 +1,4 @@
--- $XTermId: INSTALL,v 1.152 2014/07/12 22:40:36 Steve.Wall Exp $
+-- $XTermId: INSTALL,v 1.153 2014/10/15 00:49:56 tom Exp $
 -------------------------------------------------------------------------------
 -- Copyright 1997-2013,2014 by Thomas E. Dickey
 --
@@ -766,6 +766,9 @@ The options (in alphabetic order):
 	Use --without-xterm-symlink to disable a link to "xterm" if none
 	is wanted.
 
+	Corresponding links are also made for "resize", "uxterm" and
+	"koi8rxterm", as well as the xterm manpage.
+
   --with-terminal-id[=V]  set default decTerminalID (default: vt100)
 
   	Set the default emulation level.
diff --git a/MANIFEST b/MANIFEST
index e9068a6..b15fa82 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,4 +1,4 @@
-MANIFEST for xterm-312, version xterm-312
+MANIFEST for xterm-313, version xterm-313
 --------------------------------------------------------------------------------
 MANIFEST                        this file
 256colres.h                     resource-definitions for 256-color mode
@@ -150,6 +150,8 @@ package/debian/color.sed        build-script
 package/debian/compat           build-script
 package/debian/control          build-script
 package/debian/copyright        build-script
+package/debian/postinst         post-install script for update-alternatives
+package/debian/prerm            pre-remove script for update-alternatives
 package/debian/rules            build-script
 package/debian/source           subdirectory
 package/debian/source/format    build-script
diff --git a/Makefile.in b/Makefile.in
index 1dc71ef..5fce4b9 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,4 +1,4 @@
-## $XTermId: Makefile.in,v 1.225 2014/03/01 15:15:26 tom Exp $
+## $XTermId: Makefile.in,v 1.231 2014/10/23 00:21:17 tom Exp $
 # -----------------------------------------------------------------------------
 # this file is part of xterm
 #
@@ -181,11 +181,11 @@ resize$x : $(OBJS2)
 	@ECHO_LD@$(SHELL) $(srcdir)/plink.sh $(LINK) $(LDFLAGS) -o $@ $(OBJS2) $(LIBS)
 
 256colres.h :
-	-rm -f $@
+	-$(RM) $@
 	perl $(srcdir)/256colres.pl > $@
 
 88colres.h :
-	-rm -f $@
+	-$(RM) $@
 	perl $(srcdir)/88colres.pl > $@
 
 charproc$o : main.h @CHARPROC_DEPS@
@@ -224,42 +224,71 @@ install-full :: xterm$x resize$x $(BINDIR)
 
 EDIT_SCRIPT = sed -e s,=xterm,=\$$name, -e s,XTerm,$(CLASS),
 
+InstallLink = \
+	if test @XTERM_SYMLINK@ != NONE \
+	&& test \$$source != NONE \
+	&& test \$$source != \$$target ; then \
+		cd \$$TARGET && ( \
+			$(RM) \$$source ; \
+			$(LN_S) \$$target \$$source ; \
+			echo \"... created symbolic link:\" ; \
+			ls -l \$$target \$$source ) ; \
+	fi
+
+InstallBinLink = TARGET=$(BINDIR); $(InstallLink)
+InstallManLink = TARGET=$(MANDIR); $(InstallLink)
+
+InstallScript = \
+	echo \"... installing $(BINDIR)/\$$target\"; \
+	name=$(binary_xterm); \
+	$(EDIT_SCRIPT) $(srcdir)/\$$source >\$$source.tmp; \
+	$(INSTALL_SCRIPT) -m  755 \$$source.tmp $(BINDIR)/\$$target; \
+	$(RM) \$$source.tmp
+
 install \
 install-bin \
 install-scripts \
-install-full ::
-	@$(SHELL) -c "name=\"$(binary_xterm)\"; \
-		dest=\"$(binary_uxterm)\"; \
-		echo \"... installing $(BINDIR)/\$$dest\"; \
-		$(EDIT_SCRIPT) $(srcdir)/uxterm >uxterm.tmp; \
-		$(INSTALL_SCRIPT) -m  755 uxterm.tmp $(BINDIR)/\$$dest; \
-		rm -f uxterm.tmp"
-	@$(SHELL) -c "name=\"$(binary_xterm)\"; \
-		dest=\"$(binary_k8term)\"; \
-		echo \"... installing $(BINDIR)/\$$dest\"; \
-		$(EDIT_SCRIPT) $(srcdir)/koi8rxterm >k8term.tmp; \
-		$(INSTALL_SCRIPT) -m  755 k8term.tmp $(BINDIR)/\$$dest; \
-		rm -f k8term.tmp"
-	@-$(SHELL) -c "name=\"$(binary_xterm)\"; \
-		if test @XTERM_SYMLINK@ != NONE ; then \
-		cd $(BINDIR) && ( \
-			rm -f @XTERM_SYMLINK@ ; \
-			$(LN_S) \$$name @XTERM_SYMLINK@ ; \
-			echo \"... created symbolic link:\" ; \
-			ls -l \$$name @XTERM_SYMLINK@ ) ; \
-		fi"
+install-full :: $(BINDIR)
+	@$(SHELL) -c "source=\"@XTERM_SYMLINK@\"; \
+		target=\"$(binary_xterm)\"; \
+		$(InstallBinLink)"
+	@$(SHELL) -c "source=\"resize\"; \
+		target=\"$(binary_resize)\"; \
+		$(InstallBinLink)"
+	@$(SHELL) -c "source=\"uxterm\"; \
+		target=\"$(binary_uxterm)\"; \
+		$(InstallScript); \
+		$(InstallBinLink)"
+	@$(SHELL) -c "source=\"koi8rxterm\"; \
+		target=\"$(binary_k8term)\"; \
+		$(InstallScript); \
+		$(InstallBinLink)"
 
 install \
 install-man \
 install-full :: $(MANDIR)
-	@-$(SHELL) -c "for app in xterm resize uxterm koi8rxterm ; \
+	@-$(SHELL) -c "for source in xterm resize uxterm koi8rxterm ; \
 		do \
-			actual=\`echo \"\$$app\" | sed '@program_transform_name@'\`; \
-			$(SHELL) ./minstall \"$(INSTALL_DATA)\" $(srcdir)/\$$app.man  $(MANDIR)/\$$actual.$(manext) $(appsdir) $(CLASS) \$$app \$$actual $(pixmapdir); \
+			target=\`echo \"\$$source\" | sed '@program_transform_name@'\`; \
+			$(SHELL) ./minstall \"$(INSTALL_DATA)\" \
+				$(srcdir)/\$$source.man  \
+				$(MANDIR)/\$$target.$(manext) \
+				$(appsdir) \
+				$(CLASS) \
+				\$$source \
+				\$$target \
+				$(pixmapdir); \
 		done"
-	@-$(SHELL) -c "if test @XTERM_SYMLINK@ != NONE ; then cd $(MANDIR) && rm -f @XTERM_SYMLINK@.$(manext) ; fi"
-	@-$(SHELL) -c "if test @XTERM_SYMLINK@ != NONE ; then cd $(MANDIR) && $(LN_S) $(actual_xterm).$(manext) @XTERM_SYMLINK@.$(manext) ; fi"
-	@-$(SHELL) -c "if test @XTERM_SYMLINK@ != NONE ; then cd $(MANDIR) && echo '... created symbolic link:' && ls -l $(actual_xterm).$(manext) @XTERM_SYMLINK@.$(manext) ; fi"
+	@-$(SHELL) -c "if test @XTERM_SYMLINK@ != NONE ; then \
+		source=$(actual_xterm).$(manext); \
+		target=@XTERM_SYMLINK@.$(manext); \
+		cd $(MANDIR) && ( \
+			$(RM) \$$target ; \
+			$(LN_S) \$$source \$$target ; \
+			echo '... created symbolic link:' ; \
+			ls -l \$$source \$$target ; \
+			) \
+		fi"
 
 APP_NAMES = XTerm UXTerm KOI8RXTerm
 
@@ -277,7 +306,7 @@ APP_NAMES = XTerm UXTerm KOI8RXTerm
 @no_appsdir@		sed -e s/XTerm/$$d/ $(srcdir)/XTerm-col.ad >XTerm.tmp; \
 @no_appsdir@		$(INSTALL_DATA) XTerm.tmp $(APPSDIR)/$$d-color; \
 @no_appsdir@	done'
-@no_appsdir@	@rm -f XTerm.tmp
+@no_appsdir@	@$(RM) XTerm.tmp
 @no_icondir@	@echo "... installed app-defaults"
 
 @no_icondir@ICON_LIST = @ICON_LIST@
@@ -305,7 +334,7 @@ APP_NAMES = XTerm UXTerm KOI8RXTerm
 @no_icondir@				if test "$$r" != "$$t" ; then \
 @no_icondir@					if test "x$$b" = "x$(ICON_NAME)" ; then \
 @no_icondir@						echo "linking $$r -> $$t"; \
-@no_icondir@						( cd $$h; rm -f $$t; $(LN_S) $$r $$t; ) \
+@no_icondir@						( cd $$h; $(RM) $$t; $(LN_S) $$r $$t; ) \
 @no_icondir@					fi \
 @no_icondir@				fi \
 @no_icondir@			fi \
@@ -331,7 +360,7 @@ APP_NAMES = XTerm UXTerm KOI8RXTerm
 @no_pixmapdir@				if test "x$$r" != "$$t" ; then \
 @no_pixmapdir@					if test "x$$b" = "x$(ICON_NAME)" ; then \
 @no_pixmapdir@						echo "linking $$r -> $$t"; \
-@no_pixmapdir@						( cd $$h; rm -f $$t; $(LN_S) $$r $$t; ) \
+@no_pixmapdir@						( cd $$h; $(RM) $$t; $(LN_S) $$r $$t; ) \
 @no_pixmapdir@					fi \
 @no_pixmapdir@				fi \
 @no_pixmapdir@			fi \
@@ -356,28 +385,65 @@ install-tc ::
 
 installdirs : $(INSTALL_DIRS)
 ################################################################################
+
+UninstallLink = \
+	if test @XTERM_SYMLINK@ != NONE \
+	&& test \$$source != NONE \
+	&& test \$$source != \$$target \
+	&& test -h \$$TARGET/\$$source ; then \
+		echo \"... removing \$$TARGET/\$$source\"; \
+		cd \$$TARGET && \
+		$(RM) \$$source; \
+	fi
+
+UninstallBinLink = TARGET=$(BINDIR); $(UninstallLink)
+UninstallManLink = TARGET=$(MANDIR); $(UninstallLink)
+
+UninstallBinary = \
+	echo \"... removing $(BINDIR)/\$$target\"; \
+	$(RM) $(BINDIR)/\$$target
+
 uninstall \
 uninstall-bin \
 uninstall-full ::
-	-$(RM) $(BINDIR)/$(binary_xterm)
-	-$(RM) $(BINDIR)/$(binary_resize)
-	@-$(SHELL) -c "if test @XTERM_SYMLINK@ != NONE ; then cd $(BINDIR) && rm -f @XTERM_SYMLINK@; fi"
+	@-$(SHELL) -c "source=\"@XTERM_SYMLINK@\"; \
+		target=\"$(binary_xterm)\"; \
+		$(UninstallBinLink); \
+		$(UninstallBinary)"
+	@-$(SHELL) -c "source=\"resize\"; \
+		target=\"$(binary_resize)\"; \
+		$(UninstallBinLink); \
+		$(UninstallBinary)"
 
 uninstall \
 uninstall-bin \
 uninstall-scripts \
 uninstall-full ::
-	-$(RM) $(BINDIR)/$(binary_uxterm)
-	-$(RM) $(BINDIR)/$(binary_k8term)
+	@-$(SHELL) -c "source=\"uxterm\"; \
+		target=\"$(binary_uxterm)\"; \
+		$(UninstallBinLink); \
+		$(UninstallBinary)"
+	@-$(SHELL) -c "source=\"koi8rxterm\"; \
+		target=\"$(binary_k8term)\"; \
+		$(UninstallBinLink); \
+		$(UninstallBinary)"
 
 uninstall \
 uninstall-man \
 uninstall-full ::
-	-$(RM) $(MANDIR)/$(actual_xterm).$(manext)
-	-$(RM) $(MANDIR)/$(actual_resize).$(manext)
-	-$(RM) $(MANDIR)/$(actual_uxterm).$(manext)
-	-$(RM) $(MANDIR)/$(actual_k8term).$(manext)
-	@-$(SHELL) -c "if test @XTERM_SYMLINK@ != NONE ; then cd $(MANDIR) && rm -f @XTERM_SYMLINK@.$(manext); fi"
+	@-$(SHELL) -c "\
+		source=@XTERM_SYMLINK@.$(manext); \
+		target=$(actual_xterm).$(manext); \
+		$(UninstallManLink)"
+	@-$(SHELL) -c "for source in \
+		$(actual_xterm).$(manext) \
+		$(actual_resize).$(manext) \
+		$(actual_uxterm).$(manext) \
+		$(actual_k8term).$(manext); \
+		do \
+			echo \"... removing $(MANDIR)/\$$source\"; \
+			$(RM) $(MANDIR)/\$$source; \
+		done"
 
 @no_appsdir@uninstall \
 @no_appsdir@uninstall-app \
diff --git a/button.c b/button.c
index 8dd7390..30412c7 100644
--- a/button.c
+++ b/button.c
@@ -1,4 +1,4 @@
-/* $XTermId: button.c,v 1.482 2014/09/26 23:58:14 tom Exp $ */
+/* $XTermId: button.c,v 1.484 2014/11/13 01:00:26 tom Exp $ */
 
 /*
  * Copyright 1999-2013,2014 by Thomas E. Dickey
@@ -2841,10 +2841,10 @@ PointToCELL(TScreen *screen,
  * Find the last column at which text was drawn on the given row.
  */
 static int
-LastTextCol(TScreen *screen, LineData *ld, int row)
+LastTextCol(TScreen *screen, CLineData *ld, int row)
 {
     int i = -1;
-    IAttr *ch;
+    const IAttr *ch;
 
     if (ld != 0) {
 	if (okScrnRow(screen, row)) {
@@ -3170,7 +3170,7 @@ static void
 columnToCell(TScreen *screen, int row, int col, CELL *cell)
 {
     while (row < screen->max_row) {
-	LineData *ld = GET_LINEDATA(screen, row);
+	CLineData *ld = GET_LINEDATA(screen, row);
 	int last = LastTextCol(screen, ld, row);
 
 	/* TRACE(("last(%d) = %d, have %d\n", row, last, col)); */
@@ -3200,7 +3200,7 @@ columnToCell(TScreen *screen, int row, int col, CELL *cell)
 static int
 cellToColumn(TScreen *screen, CELL *cell)
 {
-    LineData *ld = 0;
+    CLineData *ld = 0;
     int col = cell->col;
     int row = firstRowOfLine(screen, cell->row, False);
     while (row < cell->row) {
@@ -4206,8 +4206,8 @@ Length(TScreen *screen,
        int scol,
        int ecol)
 {
-    LineData *ld = GET_LINEDATA(screen, row);
-    int lastcol = LastTextCol(screen, ld, row);
+    CLineData *ld = GET_LINEDATA(screen, row);
+    const int lastcol = LastTextCol(screen, ld, row);
 
     if (ecol > lastcol)
 	ecol = lastcol;
diff --git a/charproc.c b/charproc.c
index 67d07e6..1852642 100644
--- a/charproc.c
+++ b/charproc.c
@@ -1,4 +1,4 @@
-/* $XTermId: charproc.c,v 1.1370 2014/09/15 23:39:44 tom Exp $ */
+/* $XTermId: charproc.c,v 1.1379 2014/11/28 22:27:20 tom Exp $ */
 
 /*
  * Copyright 1999-2013,2014 by Thomas E. Dickey
@@ -674,6 +674,11 @@ static XtResource xterm_resources[] =
     Ires(XtNprintAttributes, XtCPrintAttributes, SPS.print_attributes, 1),
 #endif
 
+#if OPT_REGIS_GRAPHICS
+    Sres(XtNregisScreenSize, XtCRegisScreenSize, screen.regis_screensize,
+	 "800x1000"),
+#endif
+
 #if OPT_SHIFT_FONTS
     Bres(XtNshiftFonts, XtCShiftFonts, misc.shift_fonts, True),
 #endif
@@ -906,7 +911,7 @@ CheckBogusForeground(TScreen *screen, const char *tag)
     for (pass = 0; pass < 2; ++pass) {
 	row = screen->cur_row;
 	for (; isClear && (row <= screen->max_row); ++row) {
-	    LineData *ld = getLineData(screen, row)->;
+	    CLineData *ld = getLineData(screen, row);
 
 	    if (ld != 0) {
 		IAttr *attribs = ld->attribs;
@@ -4791,7 +4796,7 @@ PreeditPosition(XtermWidget xw)
 {
     TInput *input = lookupTInput(xw, (Widget) xw);
     TScreen *screen = TScreenOf(xw);
-    LineData *ld;
+    CLineData *ld;
     XPoint spot;
     XVaNestedList list;
 
@@ -4958,7 +4963,7 @@ dotext(XtermWidget xw,
 
     for (offset = 0; offset < len; offset += (Cardinal) this_col) {
 #if OPT_DEC_CHRSET
-	LineData *ld = getLineData(screen, screen->cur_row);
+	CLineData *ld = getLineData(screen, screen->cur_row);
 #endif
 
 	last_col = LineMaxCol(screen, ld);
@@ -4994,7 +4999,7 @@ dotext(XtermWidget xw,
 
 #if OPT_WIDE_CHARS
 unsigned
-visual_width(IChar *str, Cardinal len)
+visual_width(const IChar *str, Cardinal len)
 {
     /* returns the visual width of a string (doublewide characters count
        as 2, normalwide characters count as 1) */
@@ -5024,12 +5029,12 @@ HandleStructNotify(Widget w GCC_UNUSED,
 
     switch (event->type) {
     case MapNotify:
-	TRACE(("HandleStructNotify(MapNotify)\n"));
+	TRACE(("HandleStructNotify(MapNotify) %#lx\n", event->xmap.window));
 	resetZIconBeep(xw);
 	mapstate = !IsUnmapped;
 	break;
     case UnmapNotify:
-	TRACE(("HandleStructNotify(UnmapNotify)\n"));
+	TRACE(("HandleStructNotify(UnmapNotify) %#lx\n", event->xunmap.window));
 	mapstate = IsUnmapped;
 	break;
     case ConfigureNotify:
@@ -5040,7 +5045,8 @@ HandleStructNotify(Widget w GCC_UNUSED,
 	    height = event->xconfigure.height;
 	    width = event->xconfigure.width;
 #endif
-	    TRACE(("HandleStructNotify(ConfigureNotify) %d,%d %dx%d\n",
+	    TRACE(("HandleStructNotify(ConfigureNotify) %#lx %d,%d %dx%d\n",
+		   event->xconfigure.window,
 		   event->xconfigure.y, event->xconfigure.x,
 		   event->xconfigure.height, event->xconfigure.width));
 
@@ -5090,11 +5096,12 @@ HandleStructNotify(Widget w GCC_UNUSED,
 	}
 	break;
     case ReparentNotify:
-	TRACE(("HandleStructNotify(ReparentNotify)\n"));
+	TRACE(("HandleStructNotify(ReparentNotify) %#lx\n", event->xreparent.window));
 	break;
     default:
-	TRACE(("HandleStructNotify(event %s)\n",
-	       visibleEventType(event->type)));
+	TRACE(("HandleStructNotify(event %s) %#lx\n",
+	       visibleEventType(event->type),
+	       event->xany.window));
 	break;
     }
 }
@@ -6767,7 +6774,6 @@ ToAlternate(XtermWidget xw, Bool clearFirst)
 						    (unsigned) MaxCols(screen),
 						    &screen->editBuf_data[1]);
 	SwitchBufs(xw, 1, clearFirst);
-	screen->whichBuf = 1;
 #if OPT_SAVE_LINES
 	screen->visbuf = screen->editBuf_index[screen->whichBuf];
 #endif
@@ -6784,7 +6790,6 @@ FromAlternate(XtermWidget xw)
 	TRACE(("FromAlternate\n"));
 	if (screen->scroll_amt)
 	    FlushScroll(xw);
-	screen->whichBuf = 0;
 	SwitchBufs(xw, 0, False);
 #if OPT_SAVE_LINES
 	screen->visbuf = screen->editBuf_index[screen->whichBuf];
@@ -6799,6 +6804,7 @@ SwitchBufs(XtermWidget xw, int toBuf, Bool clearFirst)
     TScreen *screen = TScreenOf(xw);
     int rows, top;
 
+    screen->whichBuf = toBuf;
     if (screen->cursor_state)
 	HideCursor();
 
@@ -8322,6 +8328,58 @@ VTInitialize(Widget wrequest,
 	   BtoS(TScreenOf(wnew)->privatecolorregisters)));
 #endif
 
+#if OPT_REGIS_GRAPHICS
+    init_Sres(screen.regis_screensize);
+    TScreenOf(wnew)->regis_max_high = 800;
+    TScreenOf(wnew)->regis_max_wide = 1000;
+    if (!x_strcasecmp(TScreenOf(wnew)->regis_screensize, "auto")) {
+	TRACE(("setting ReGIS screensize based on terminal_id %d\n",
+	       TScreenOf(wnew)->terminal_id));
+	switch (TScreenOf(wnew)->terminal_id) {
+	case 125:
+	    TScreenOf(wnew)->regis_max_high = 768;
+	    TScreenOf(wnew)->regis_max_wide = 460;
+	    break;
+	case 240:
+	    TScreenOf(wnew)->regis_max_high = 800;
+	    TScreenOf(wnew)->regis_max_wide = 460;
+	    break;
+	case 241:
+	    TScreenOf(wnew)->regis_max_high = 800;
+	    TScreenOf(wnew)->regis_max_wide = 460;
+	    break;
+	case 330:
+	    TScreenOf(wnew)->regis_max_high = 800;
+	    TScreenOf(wnew)->regis_max_wide = 480;
+	    break;
+	case 340:
+	    TScreenOf(wnew)->regis_max_high = 800;
+	    TScreenOf(wnew)->regis_max_wide = 480;
+	    break;
+	case 382:
+	    TScreenOf(wnew)->regis_max_high = 960;
+	    TScreenOf(wnew)->regis_max_wide = 750;
+	    break;
+	}
+    } else {
+	int max_high;
+	int max_wide;
+	char ignore;
+
+	if (sscanf(TScreenOf(wnew)->regis_screensize,
+		   "%dx%d%c",
+		   &max_high,
+		   &max_wide,
+		   &ignore) == 2) {
+	    TScreenOf(wnew)->regis_max_high = (Dimension) max_high;
+	    TScreenOf(wnew)->regis_max_wide = (Dimension) max_wide;
+	}
+    }
+    TRACE(("maximum ReGIS screensize %dx%d\n",
+	   (int) TScreenOf(wnew)->regis_max_high,
+	   (int) TScreenOf(wnew)->regis_max_wide));
+#endif
+
 #if OPT_SIXEL_GRAPHICS
     init_Bres(screen.sixel_scrolls_right);
     TRACE(("initialized SIXEL_SCROLLS_RIGHT to resource default: %s\n",
@@ -9676,7 +9734,7 @@ ShowCursor(void)
     int my_col = 0;
 #endif
     int cursor_col;
-    LineData *ld = 0;
+    CLineData *ld = 0;
 
     if (screen->cursor_state == BLINKED_OFF)
 	return;
@@ -10040,7 +10098,7 @@ HideCursor(void)
     int my_col = 0;
 #endif
     int cursor_col;
-    LineData *ld = 0;
+    CLineData *ld = 0;
 #if OPT_WIDE_ATTRS
     unsigned attr_flags;
     int which_font = fNorm;
@@ -10180,7 +10238,7 @@ HideCursor(void)
 #endif
     resetXtermGC(xw, flags, in_selection);
 
-    refresh_displayed_graphics(screen,
+    refresh_displayed_graphics(xw,
 			       screen->cursorp.col,
 			       screen->cursorp.row,
 			       1, 1);
@@ -10219,7 +10277,7 @@ StopBlinking(TScreen *screen)
 
 #if OPT_BLINK_TEXT
 Bool
-LineHasBlinking(TScreen *screen, LineData *ld)
+LineHasBlinking(TScreen *screen, CLineData *ld)
 {
     int col;
     Bool result = False;
@@ -10332,7 +10390,7 @@ RestartBlinking(TScreen *screen GCC_UNUSED)
 	    int row;
 
 	    for (row = screen->max_row; row >= 0; row--) {
-		LineData *ld = getLineData(screen, ROW2INX(screen, row));
+		CLineData *ld = getLineData(screen, ROW2INX(screen, row));
 
 		if (ld != 0 && LineTstBlinked(ld)) {
 		    if (LineHasBlinking(screen, ld)) {
diff --git a/graphics.c b/graphics.c
index e880d76..434b4b0 100644
--- a/graphics.c
+++ b/graphics.c
@@ -1,4 +1,4 @@
-/* $XTermId: graphics.c,v 1.47 2014/07/13 01:19:45 Ross.Combs Exp $ */
+/* $XTermId: graphics.c,v 1.58 2014/11/28 21:00:04 tom Exp $ */
 
 /*
  * Copyright 2013,2014 by Ross Combs
@@ -48,10 +48,11 @@
 #undef DEBUG_PIXEL
 #undef DEBUG_REFRESH
 
-/* TODO:
+/*
+ * graphics TODO list
+ *
  * ReGIS:
  * - find a suitable default alphabet zero font instead of scaling Xft fonts
- * - load command extension to load by font name (via Xft)
  * - input and output cursors
  * - mouse input
  * - custom coordinate systems
@@ -62,6 +63,7 @@
  * - command display mode
  * - scaling/re-rasterization to fit screen
  * - macros
+ * - improved fills for narrow angles (track actual lines not just pixels)
  *
  * sixel:
  * - fix problem where new_row < 0 during sixel parsing (see FIXME)
@@ -79,25 +81,21 @@
  * - research other 41xx and 42xx extensions
  *
  * common graphics features:
- * - speed up drawing by using an XImage and/or better GC and color handling
  * - handle light/dark screen modes (CSI?5[hl])
  * - update text fg/bg color which overlaps images
- * - erase graphic when erasing screen
- * - handle graphic updates in scroll regions
+ * - handle graphic updates in scroll regions (verify effect on graphics)
  * - handle rectangular area copies (verify they work with graphics)
- * - maintain ordered list/array of graphics instead of qsort()
- * - erase text under graphic if bg not transparent to avoid flickering (or not: bad if the font changes or window resizes)
- * - erase graphics under graphic if same origin and bg not transparent to avoid flickering
- * - 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
- * - auto-convert color graphics in VT330 mode
+ * - invalidate graphics under graphic if same origin, at least as big, and bg not transparent
+ * - invalidate graphic if completely scrolled past end of scrollback
+ * - invalidate graphic if all pixels are transparent/erased
+ * - invalidate graphic if completely scrolled out of alt buffer
  * - posturize requested colors to match hardware palettes (e.g. only four possible shades on VT240)
  * - color register report/restore
  * - ability to select/copy graphics for pasting in other programs
- * - ability to show non-scrolled sixel graphics in a separate window
+ * - ability to show non-scroll-mode sixel graphics in a separate window
  * - ability to show ReGIS graphics in a separate window
  * - ability to show Tektronix graphics in VT100 window
+ * - truncate graphics at bottom edge of window?
  *
  * new escape sequences:
  * - way to query text font size without "window ops" (or make "window ops" permissions more fine grained)
@@ -107,21 +105,17 @@
  * - non-integer text scaling
  * - free distortionless text rotation
  * - font characteristics: bold/underline/italic
- * - font selection by name
- * - user fonts in larger sizes than 8x10
  * - remove/increase arbitrary limits (pattern size, pages, alphabets, stack size, font names, etc.)
  * - comment command
  * - shade/fill with borders
  * - sprites (copy portion of page into/out of buffer with scaling and rotation)
  * - ellipses
  * - 2D patterns
- * - option to set actual size (not just coordinates)
+ * - option to set actual graphic size (not just coordinate range)
  * - gradients (for lines and fills)
  * - line width (RLogin has this and it is mentioned in docs for the DEC ReGIS to Postscript converter)
- * - F option for screen command (mentioned in docs for the DEC ReGIS to Postscript converter)
  * - transparency
  * - background color as stackable write control
- * - RGB triplets
  * - true color (virtual color registers created upon lookup)
  * - anti-aliasing
  */
@@ -133,7 +127,16 @@
  *   10 x 13   6 x 13  26 lines + keyboard indicator line
  *   10 x 10   6 x 10  42 lines + keyboard indicator line
  *   10 x 8    6 x 8   53 lines + keyboard indicator line
-*/
+ */
+
+typedef struct allocated_color_register {
+    struct allocated_color_register *next;
+    Pixel pix;
+    short r, g, b;
+} AllocatedColorRegister;
+
+#define LOOKUP_WIDTH 16
+static AllocatedColorRegister *allocated_colors[LOOKUP_WIDTH][LOOKUP_WIDTH][LOOKUP_WIDTH];
 
 #define FOR_EACH_SLOT(ii) for (ii = 0U; ii < MAX_GRAPHICS; ii++)
 
@@ -161,11 +164,12 @@ freeGraphic(Graphic *obj)
 }
 
 static Graphic *
-allocGraphic(void)
+allocGraphic(const TScreen *screen)
 {
     Graphic *result = TypeCalloc(Graphic);
     if (result) {
-	if (!(result->pixels = TypeCallocN(RegisterNum, MAX_PIXELS))) {
+	size_t max_pixels = (size_t) (screen->regis_max_wide * screen->regis_max_high);
+	if (!(result->pixels = TypeCallocN(RegisterNum, max_pixels))) {
 	    result = freeGraphic(result);
 	} else if (!(result->private_color_registers = allocRegisters())) {
 	    result = freeGraphic(result);
@@ -186,13 +190,13 @@ getActiveSlot(unsigned n)
 }
 
 static Graphic *
-getInactiveSlot(unsigned n)
+getInactiveSlot(const TScreen *screen, unsigned n)
 {
     if (n < MAX_GRAPHICS &&
 	(!displayed_graphics[n] ||
 	 !displayed_graphics[n]->valid)) {
 	if (!displayed_graphics[n]) {
-	    displayed_graphics[n] = allocGraphic();
+	    displayed_graphics[n] = allocGraphic(screen);
 	}
 	return displayed_graphics[n];
     }
@@ -226,6 +230,11 @@ read_pixel(Graphic *graphic, int x, int y)
     return graphic->pixels[y * graphic->max_width + x];
 }
 
+#define _draw_pixel(G, X, Y, C) \
+    do { \
+        (G)->pixels[(Y) * (G)->max_width + (X)] = (RegisterNum) (C); \
+    } while (0)
+
 void
 draw_solid_pixel(Graphic *graphic, int x, int y, unsigned color)
 {
@@ -246,11 +255,9 @@ draw_solid_pixel(Graphic *graphic, int x, int y, unsigned color)
 #endif
     if (x >= 0 && x < graphic->actual_width &&
 	y >= 0 && y < graphic->actual_height) {
-	graphic->pixels[y * graphic->max_width + x] = (RegisterNum) color;
+	_draw_pixel(graphic, x, y, color);
 	if (color < MAX_COLOR_REGISTERS)
 	    graphic->color_registers_used[color] = 1;
-    } else {
-	TRACE(("pixel %d,%d out of bounds\n", x, y));
     }
 }
 
@@ -269,9 +276,24 @@ draw_solid_rectangle(Graphic *graphic, int x1, int y1, int x2, int y2, unsigned
 	EXCHANGE(y1, y2, tmp);
     }
 
+    if (x2 < 0 || x1 >= graphic->actual_width ||
+	y2 < 0 || y1 >= graphic->actual_height)
+	return;
+
+    if (x1 < 0)
+	x1 = 0;
+    if (x2 >= graphic->actual_width)
+	x2 = graphic->actual_width - 1;
+    if (y1 < 0)
+	y1 = 0;
+    if (y2 >= graphic->actual_height)
+	y2 = graphic->actual_height - 1;
+
+    if (color < MAX_COLOR_REGISTERS)
+	graphic->color_registers_used[color] = 1;
     for (y = y1; y <= y2; y++)
-	for (x = x1; x < x2; x++)
-	    draw_solid_pixel(graphic, x, y, color);
+	for (x = x1; x <= x2; x++)
+	    _draw_pixel(graphic, x, y, color);
 }
 
 void
@@ -404,7 +426,6 @@ set_color_register(ColorRegister *color_registers,
     reg->r = (short) r;
     reg->g = (short) g;
     reg->b = (short) b;
-    reg->allocated = 0;
 }
 
 /* Graphics which don't use private colors will act as if they are using a
@@ -466,7 +487,7 @@ find_color_register(ColorRegister const *color_registers, int r, int g, int b)
     /* I have no idea what algorithm DEC used for this.
      * The documentation warns that it is unpredictable, especially with values
      * far away from any allocated color so it is probably a very simple
-     * hueristic rather than something fancy like finding the minimum distance
+     * heuristic rather than something fancy like finding the minimum distance
      * in a linear perceptive color space.
      */
     closest_index = MAX_COLOR_REGISTERS;
@@ -594,11 +615,11 @@ init_color_registers(ColorRegister *color_registers, int terminal_id)
 	unsigned i;
 
 	for (i = 0U; i < MAX_COLOR_REGISTERS; i++) {
-	    printf("initial value for register %03u: %d,%d,%d\n",
+	    TRACE(("initial value for register %03u: %d,%d,%d\n",
 		   i,
 		   color_registers[i].r,
 		   color_registers[i].g,
-		   color_registers[i].b);
+		   color_registers[i].b));
 	}
     }
 #endif
@@ -652,7 +673,8 @@ get_color_register_count(TScreen const *screen)
 }
 
 static void
-init_graphic(Graphic *graphic,
+init_graphic(const TScreen *screen,
+	     Graphic *graphic,
 	     unsigned type,
 	     int terminal_id,
 	     int charrow,
@@ -660,12 +682,13 @@ init_graphic(Graphic *graphic,
 	     unsigned num_color_registers,
 	     int private_colors)
 {
+    size_t max_pixels = (size_t) (screen->regis_max_wide * screen->regis_max_high);
     unsigned i;
 
     TRACE(("initializing graphic object\n"));
 
     graphic->dirty = 1;
-    for (i = 0U; i < MAX_PIXELS; i++)
+    for (i = 0U; i < max_pixels; i++)
 	graphic->pixels[i] = COLOR_HOLE;
     memset(graphic->color_registers_used, 0, sizeof(graphic->color_registers_used));
 
@@ -688,8 +711,8 @@ init_graphic(Graphic *graphic,
      * VT382       960x750  sixel only
      * dxterm      ?x? ?x?  variable?
      */
-    graphic->max_width = BUFFER_WIDTH;
-    graphic->max_height = BUFFER_HEIGHT;
+    graphic->max_width = screen->regis_max_wide;
+    graphic->max_height = screen->regis_max_high;
 
     graphic->actual_width = 0;
     graphic->actual_height = 0;
@@ -726,7 +749,7 @@ get_new_graphic(XtermWidget xw, int charrow, int charcol, unsigned type)
     unsigned ii;
 
     FOR_EACH_SLOT(ii) {
-	if ((graphic = getInactiveSlot(ii))) {
+	if ((graphic = getInactiveSlot(screen, ii))) {
 	    TRACE(("using fresh graphic index=%u id=%u\n", ii, next_graphic_id));
 	    break;
 	}
@@ -755,7 +778,8 @@ get_new_graphic(XtermWidget xw, int charrow, int charcol, unsigned type)
 	graphic->xw = xw;
 	graphic->bufferid = bufferid;
 	graphic->id = next_graphic_id++;
-	init_graphic(graphic,
+	init_graphic(screen,
+		     graphic,
 		     type,
 		     terminal_id,
 		     charrow,
@@ -800,179 +824,243 @@ get_new_or_matching_graphic(XtermWidget xw,
     return graphic;
 }
 
-#define ScaleForXColor(s) (unsigned short) ((long)(s) * 65535 / 100)
-
-static Pixel
-color_register_to_xpixel(ColorRegister *reg, XtermWidget xw)
+static int
+lookup_allocated_color(const ColorRegister *reg, Pixel *pix)
 {
-    if (!reg->allocated) {
-	XColor def;
-
-	def.red = ScaleForXColor(reg->r);
-	def.green = ScaleForXColor(reg->g);
-	def.blue = ScaleForXColor(reg->b);
-	def.flags = DoRed | DoGreen | DoBlue;
-	if (!allocateBestRGB(xw, &def)) {
-	    TRACE(("unable to allocate xcolor for color register\n"));
-	    return 0UL;
+    unsigned const rr = ((unsigned) reg->r * (LOOKUP_WIDTH - 1)) / CHANNEL_MAX;
+    unsigned const gg = ((unsigned) reg->g * (LOOKUP_WIDTH - 1)) / CHANNEL_MAX;
+    unsigned const bb = ((unsigned) reg->b * (LOOKUP_WIDTH - 1)) / CHANNEL_MAX;
+    const AllocatedColorRegister *search;
+
+    for (search = allocated_colors[rr][gg][bb]; search; search = search->next) {
+	if (search->r == reg->r &&
+	    search->g == reg->g &&
+	    search->b == reg->b) {
+	    *pix = search->pix;
+	    return 1;
 	}
-	reg->pix = def.pixel;
-	reg->allocated = 1;
     }
 
+    *pix = 0UL;
+    return 0;
+}
+
+#define ScaleForXColor(s) (unsigned short) ((long)(s) * 65535 / CHANNEL_MAX)
+
+static int
+save_allocated_color(const ColorRegister *reg, XtermWidget xw, Pixel *pix)
+{
+    unsigned const rr = ((unsigned) reg->r * (LOOKUP_WIDTH - 1)) / CHANNEL_MAX;
+    unsigned const gg = ((unsigned) reg->g * (LOOKUP_WIDTH - 1)) / CHANNEL_MAX;
+    unsigned const bb = ((unsigned) reg->b * (LOOKUP_WIDTH - 1)) / CHANNEL_MAX;
+    XColor xcolor;
+    AllocatedColorRegister *new_color;
+
+    xcolor.pixel = 0UL;
+    xcolor.red = ScaleForXColor(reg->r);
+    xcolor.green = ScaleForXColor(reg->g);
+    xcolor.blue = ScaleForXColor(reg->b);
+    xcolor.flags = DoRed | DoGreen | DoBlue;
+    if (!allocateBestRGB(xw, &xcolor)) {
+	TRACE(("unable to allocate xcolor\n"));
+	*pix = 0UL;
+	return 0;
+    }
+
+    *pix = xcolor.pixel;
+
+    if (!(new_color = malloc(sizeof(*new_color)))) {
+	TRACE(("unable to save pixel %lu\n", (unsigned long) *pix));
+	return 0;
+    }
+    new_color->r = reg->r;
+    new_color->g = reg->g;
+    new_color->b = reg->b;
+    new_color->pix = *pix;
+    new_color->next = allocated_colors[rr][gg][bb];
+
+    allocated_colors[rr][gg][bb] = new_color;
+
+    return 1;
+}
+
+static Pixel
+color_register_to_xpixel(const ColorRegister *reg, XtermWidget xw)
+{
+    Pixel pix;
+
+    if (!lookup_allocated_color(reg, &pix))


Reply to: