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

xterm: Changes to 'upstream-unstable'



 INSTALL        |   15 
 Imakefile      |    6 
 MANIFEST       |    4 
 Makefile.in    |    8 
 Tekproc.c      |   61 -
 button.c       |  328 ++++---
 cachedGCs.c    |   50 -
 charproc.c     |  607 +++++++-------
 configure      | 2401 +++++++++++++++++++++++++++++----------------------------
 configure.in   |   25 
 ctlseqs.ms     |    4 
 ctlseqs.txt    |    2 
 cursor.c       |   23 
 data.c         |    4 
 data.h         |    4 
 doublechr.c    |   72 -
 error.h        |   10 
 fontutils.c    |  125 +-
 fontutils.h    |   30 
 input.c        |   11 
 linedata.c     |  251 +++++
 main.c         |   32 
 menu.c         |   39 
 menu.h         |    3 
 misc.c         |  194 ++--
 os2main.c      |    6 
 print.c        |  217 ++---
 ptydata.c      |   76 -
 ptyx.h         |  318 ++++---
 resize.c       |   12 
 resize.man     |   17 
 screen.c       | 1779 +++++++++++++++++++++++++++---------------
 scrollback.c   |  118 ++
 scrollbar.c    |   36 
 tabs.c         |   10 
 termcap        |   27 
 testxmc.c      |   27 
 trace.c        |  192 ++--
 trace.h        |    7 
 util.c         |  658 +++++++--------
 version.h      |    4 
 xterm.h        |  130 +--
 xterm.log.html |   80 +
 xterm.man      |  663 ++++++++-------
 xtermcfg.hin   |   12 
 45 files changed, 5030 insertions(+), 3668 deletions(-)

New commits:
commit d817c5d758a3bc71ff371662c45e37900b186a8e
Author: Julien Cristau <jcristau@debian.org>
Date:   Mon Aug 10 10:53:08 2009 +0200

    Import xterm 244

diff --git a/INSTALL b/INSTALL
index 1485bfb..2f85f3a 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,4 +1,4 @@
--- $XTermId: INSTALL,v 1.118 2008/12/30 11:43:45 tom Exp $
+-- $XTermId: INSTALL,v 1.121 2009/08/06 00:39:09 tom Exp $
 -------------------------------------------------------------------------------
 -- Copyright 1997-2007,2008 by Thomas E. Dickey
 --
@@ -146,6 +146,12 @@ The options (in alphabetic order):
 	not shown.  This makes it simpler to read a build log and see the
 	actual warning messages.
 
+  --disable-fifo-lines    enable FIFO-storage for saved-lines
+
+	With patch #244, xterm by default stores saved-lines in a FIFO
+	(circular buffer), which improves performance when the number of saved
+	lines is large.  Disable this option to revert to the pre-244 layout.
+
   --disable-freetype      disable freetype library-support
 
  	Do not use freetype libraries if they are found.  Normally they will
@@ -311,6 +317,13 @@ The options (in alphabetic order):
 	Do not compile-in code that modifies the icon's title and sounds a
 	beep when they receive output.
 
+  --enable-16bit-chars    enable 16-bit characters support
+
+	Enable wide-character support, but store only 16-bits for each wide
+	character.  Unicode values can be larger than 16-bits, up to 21-bits.
+	This uses less memory, but is less complete.  However, most languages
+	are covered by the 16-bit encoding.
+
   --enable-256-color      enable 256-color support
 
   	Compile-in code that interprets SGR 38 and 48 for 256-colors.
diff --git a/Imakefile b/Imakefile
index 4646e2b..57a7fd0 100644
--- a/Imakefile
+++ b/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XTermId: Imakefile,v 1.101 2007/03/18 21:06:18 tom Exp $
+XCOMM $XTermId: Imakefile,v 1.102 2009/04/27 19:26:34 tom Exp $
 XCOMM
 XCOMM                         Attention xterm porters
 XCOMM
@@ -194,13 +194,13 @@ module.o: ; $(CC) -c defines $(CFLAGS) module.c
 #endif
           SRCS1 = button.c cachedGCs.c charproc.c charsets.c cursor.c \
 		  data.c doublechr.c fontutils.c input.c \
-		  menu.c misc.c print.c ptydata.c \
+		  linedata.c menu.c misc.c print.c ptydata.c scrollback.c \
 		  screen.c scrollbar.c tabs.c util.c xstrings.c xtermcap.c \
 		  TekPrsTbl.c Tekproc.c VTPrsTbl.c \
 		  $(MAINSRC) $(EXTRASRC) $(UTF8SRC) $(TRACESRC)
           OBJS1 = button.o cachedGCs.o charproc.o charsets.o cursor.o \
 		  data.o doublechr.o fontutils.o input.o \
-		  menu.o misc.o print.o ptydata.o \
+		  linedata.o menu.o misc.o print.o ptydata.o scrollback.o \
 		  screen.o scrollbar.o tabs.o util.o xstrings.o xtermcap.o \
 		  TekPrsTbl.o Tekproc.o VTPrsTbl.o \
 		  $(MAINOBJ) $(EXTRAOBJ) $(UTF8OBJ) $(TRACEOBJ)
diff --git a/MANIFEST b/MANIFEST
index 0a8ae68..d311717 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,4 +1,4 @@
-MANIFEST for xterm-243, version xterm-243
+MANIFEST for xterm-244, version xterm-244
 --------------------------------------------------------------------------------
 MANIFEST                        this file
 256colres.h                     resource-definitions for 256-color mode
@@ -52,6 +52,7 @@ keysym2ucs.c                    lookup-table for UTF-8 to keysyms
 keysym2ucs.h                    interface of keysym2ucs.c
 koi8rxterm                      KOI-8 wrapper from Debian (originally me)
 koi8rxterm.man                  manpage for koi8rxterm
+linedata.c                      manage all line-data for VT100 widget
 link_axp.com                    build-script for VMS port of xterm
 main.c                          main program of 'xterm'
 main.h                          default definitions for 'xterm'
@@ -73,6 +74,7 @@ resize.c                        program to compute/modify xterm's window size
 resize.man                      manual page for 'resize'
 run-tic.sh                      run tic, filtering out harmless messages
 screen.c                        VT100 screen update functions
+scrollback.c                    manage scrollback (a big FIFO)
 scrollbar.c                     VT100 scrollbar support functions
 sinstall.sh                     install setuid if existing program was
 tabs.c                          VT100 tabstop support-functions
diff --git a/Makefile.in b/Makefile.in
index 62a2882..671c6e3 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,4 +1,4 @@
-## $XTermId: Makefile.in,v 1.157 2009/01/25 16:39:24 tom Exp $
+## $XTermId: Makefile.in,v 1.158 2009/04/27 19:29:31 tom Exp $
 ##
 ## Copyright 2002-2008,2009 by Thomas E. Dickey
 ##
@@ -83,12 +83,14 @@ EXTRAOBJ	= @EXTRAOBJS@
 
           SRCS1 = button.c cachedGCs.c charproc.c charsets.c cursor.c \
 	  	  data.c doublechr.c fontutils.c input.c \
-		  $(MAINSRC) menu.c misc.c print.c ptydata.c \
+		  linedata.c main.c menu.c misc.c \
+		  print.c ptydata.c scrollback.c \
 		  screen.c scrollbar.c tabs.c util.c xstrings.c xtermcap.c \
 		  VTPrsTbl.c $(EXTRASRC)
           OBJS1 = button$o cachedGCs$o charproc$o charsets$o cursor$o \
 	  	  data$o doublechr$o fontutils$o input$o \
-		  main$o menu$o misc$o print$o ptydata$o \
+		  linedata$o main$o menu$o misc$o \
+		  print$o ptydata$o scrollback$o \
 		  screen$o scrollbar$o tabs$o util$o xstrings$o xtermcap$o \
 		  VTPrsTbl$o $(EXTRAOBJ)
           SRCS2 = resize.c xstrings.c
diff --git a/Tekproc.c b/Tekproc.c
index 6edcee0..478393c 100644
--- a/Tekproc.c
+++ b/Tekproc.c
@@ -1,9 +1,8 @@
-/* $XTermId: Tekproc.c,v 1.167 2009/03/28 17:03:35 tom Exp $ */
+/* $XTermId: Tekproc.c,v 1.172 2009/08/09 17:22:34 tom Exp $ */
 
 /*
  * Warning, there be crufty dragons here.
  */
-/* $XFree86: xc/programs/xterm/Tekproc.c,v 3.57 2006/02/13 01:14:57 dickey Exp $ */
 
 /*
 
@@ -596,7 +595,7 @@ Tekparse(TekWidget tw)
 
 	case CASE_CHAR_SIZE:
 	    TRACE(("case: character size selector\n"));
-	    TekSetFontSize(tw, (int) (c & 03));
+	    TekSetFontSize(tw, False, (int) (c & 03));
 	    Tparsestate = curstate;
 	    break;
 
@@ -795,7 +794,7 @@ Tinput(TekWidget tw)
 	    tekRefreshList = tek;
 	    rptr = tek->data;
 	    rcnt = tek->count - 1;
-	    TekSetFontSize(tw, tek->fontsize);
+	    TekSetFontSize(tw, False, tek->fontsize);
 	    return (IChar) (*rptr++);
 	}
 	tekRefreshList = (TekLink *) 0;
@@ -938,7 +937,7 @@ TekExpose(Widget w,
 	tekscr->cur_X = 0;
 	tekscr->cur_Y = TEKHOME;
 	tekscr->cur = tekscr->page;
-	TekSetFontSize(tw, tekscr->cur.fontsize);
+	TekSetFontSize(tw, False, tekscr->cur.fontsize);
 	tekscr->margin = MARGIN1;
 	if (tekscr->TekGIN) {
 	    tekscr->TekGIN = NULL;
@@ -1392,9 +1391,10 @@ TekRealize(Widget gw,
     int border = 2 * screen->border;
     int pr;
     XGCValues gcv;
-    int winX, winY, width, height;
+    int winX, winY;
+    unsigned width, height;
     char Tdefault[32];
-    unsigned TEKgcFontMask;
+    unsigned long TEKgcFontMask;
 
     TRACE(("TekRealize\n"));
     memset(tekscr, 0, sizeof(tekscr));
@@ -1440,22 +1440,22 @@ TekRealize(Widget gw,
 
     winX = 1;
     winY = 1;
-    width = TEKDEFWIDTH + border;
-    height = TEKDEFHEIGHT + border;
+    width = (unsigned) (TEKDEFWIDTH + border);
+    height = (unsigned) (TEKDEFHEIGHT + border);
 
     TRACE(("parsing T_geometry %s\n", NonNull(term->misc.T_geometry)));
     pr = XParseGeometry(term->misc.T_geometry,
 			&winX,
 			&winY,
-			(unsigned int *) &width,
-			(unsigned int *) &height);
+			&width,
+			&height);
     TRACE(("... position %d,%d size %dx%d\n", winY, winX, height, width));
     if ((pr & XValue) && (pr & XNegative))
 	winX += DisplayWidth(XtDisplay(tw), DefaultScreen(XtDisplay(tw)))
-	    - width - (BorderWidth(SHELL_OF(term)) * 2);
+	    - (int) width - (BorderWidth(SHELL_OF(term)) * 2);
     if ((pr & YValue) && (pr & YNegative))
 	winY += DisplayHeight(XtDisplay(tw), DefaultScreen(XtDisplay(tw)))
-	    - height - (BorderWidth(SHELL_OF(term)) * 2);
+	    - (int) height - (BorderWidth(SHELL_OF(term)) * 2);
 
     /* set up size hints */
     tw->hints.min_width = TEKMINWIDTH + border;
@@ -1486,15 +1486,15 @@ TekRealize(Widget gw,
 	/* set a default size, but do *not* set position */
 	tw->hints.flags |= PSize;
     }
-    tw->hints.width = width;
-    tw->hints.height = height;
+    tw->hints.width = (int) width;
+    tw->hints.height = (int) height;
     if ((WidthValue & pr) || (HeightValue & pr))
 	tw->hints.flags |= USSize;
     else
 	tw->hints.flags |= PSize;
 
     (void) REQ_RESIZE((Widget) tw,
-		      width, height,
+		      (Dimension) width, (Dimension) height,
 		      &tw->core.width, &tw->core.height);
 
     /* XXX This is bogus.  We are parsing geometries too late.  This
@@ -1523,8 +1523,8 @@ TekRealize(Widget gw,
 
     TFullWidth(tekscr) = (Dimension) width;
     TFullHeight(tekscr) = (Dimension) height;
-    TWidth(tekscr) = width - border;
-    THeight(tekscr) = height - border;
+    TWidth(tekscr) = (int) width - border;
+    THeight(tekscr) = (int) height - border;
     TekScale(tekscr) = (double) TWidth(tekscr) / TEKWIDTH;
     if ((d = (double) THeight(tekscr) / (TEKHEIGHT + TEKTOPPAD +
 					 TEKBOTTOMPAD)) < TekScale(tekscr))
@@ -1556,7 +1556,7 @@ TekRealize(Widget gw,
     /* if font wasn't successfully opened, then gcv.font will contain
        the Default GC's ID, meaning that we must use the server default font.
      */
-    TEKgcFontMask = (gcv.font == DefaultGCID) ? 0 : GCFont;
+    TEKgcFontMask = (unsigned long) ((gcv.font == DefaultGCID) ? 0 : GCFont);
     tekscr->TnormalGC = XCreateGC(XtDisplay(tw), TWindow(tekscr),
 				  (TEKgcFontMask | GCGraphicsExposures |
 				   GCForeground | GCBackground),
@@ -1649,7 +1649,7 @@ TekGetFontSize(const char *param)
 }
 
 void
-TekSetFontSize(TekWidget tw, int newitem)
+TekSetFontSize(TekWidget tw, Bool fromMenu, int newitem)
 {
     if (tw != 0) {
 	TekScreen *tekscr = TekScreenOf(tw);
@@ -1666,7 +1666,8 @@ TekSetFontSize(TekWidget tw, int newitem)
 	    set_tekfont_menu_item(oldsize, False);
 
 	    tekscr->cur.fontsize = newsize;
-	    tekscr->page.fontsize = newsize;
+	    if (fromMenu)
+		tekscr->page.fontsize = newsize;
 
 	    fid = tw->tek.Tfont[newsize]->fid;
 	    if (fid == DefaultGCID) {
@@ -1683,11 +1684,13 @@ TekSetFontSize(TekWidget tw, int newitem)
 	    if (!Ttoggled)
 		TCursorToggle(tw, TOGGLE);
 
-	    /* we'll get an exposure event after changing fontsize, so we
-	     * have to clear the screen to avoid painting over the previous
-	     * text.
-	     */
-	    TekClear(tw);
+	    if (fromMenu) {
+		/* we'll get an exposure event after changing fontsize, so we
+		 * have to clear the screen to avoid painting over the previous
+		 * text.
+		 */
+		TekClear(tw);
+	    }
 	}
     }
 }
@@ -1843,7 +1846,7 @@ TekSimulatePageButton(TekWidget tw, Bool reset)
 	TekScreen *tekscr = TekScreenOf(tw);
 
 	if (reset) {
-	    bzero((char *) &tekscr->cur, sizeof tekscr->cur);
+	    memset(&tekscr->cur, 0, sizeof tekscr->cur);
 	}
 	tekRefreshList = (TekLink *) 0;
 	TekPage(tw);
@@ -1884,10 +1887,10 @@ TekCopy(TekWidget tw)
 	    sprintf(initbuf, "%c%c%c%c",
 		    ANSI_ESC, (char) (tekscr->page.fontsize + '8'),
 		    ANSI_ESC, (char) (tekscr->page.linetype + '`'));
-	    write(tekcopyfd, initbuf, 4);
+	    write(tekcopyfd, initbuf, (size_t) 4);
 	    Tp = &Tek0;
 	    do {
-		write(tekcopyfd, Tp->data, Tp->count);
+		write(tekcopyfd, Tp->data, (size_t) Tp->count);
 		Tp = Tp->next;
 	    } while (Tp);
 	    close(tekcopyfd);
diff --git a/button.c b/button.c
index 86e7392..526a902 100644
--- a/button.c
+++ b/button.c
@@ -1,4 +1,4 @@
-/* $XTermId: button.c,v 1.320 2009/03/27 00:00:56 tom Exp $ */
+/* $XTermId: button.c,v 1.349 2009/08/07 23:24:10 tom Exp $ */
 
 /*
  * Copyright 1999-2008,2009 by Thomas E. Dickey
@@ -94,12 +94,22 @@ button.c	Handles button events in the terminal emulator.
 	charClass[value & ((sizeof(charClass)/sizeof(charClass[0]))-1)]
 #endif
 
-      /*
-       * We reserve shift modifier for cut/paste operations.  In principle we
-       * can pass through control and meta modifiers, but in practice, the
-       * popup menu uses control, and the window manager is likely to use meta,
-       * so those events are not delivered to SendMousePosition.
-       */
+    /*
+     * We'll generally map rows to indices when doing selection.
+     * Simplify that with a macro.
+     *
+     * Note that ROW2INX() is safe to use with auto increment/decrement for
+     * the row expression since that is evaluated once.
+     */
+#define GET_LINEDATA(screen, row) \
+	getLineData(screen, ROW2INX(screen, row))
+
+    /*
+     * We reserve shift modifier for cut/paste operations.  In principle we
+     * can pass through control and meta modifiers, but in practice, the
+     * popup menu uses control, and the window manager is likely to use meta,
+     * so those events are not delivered to SendMousePosition.
+     */
 #define OurModifiers (ShiftMask | ControlMask | Mod1Mask)
 #define AllModifiers (ShiftMask | LockMask | ControlMask | Mod1Mask | \
 		      Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask)
@@ -732,23 +742,29 @@ rowOnCurrentLine(TScreen * screen,
 		 int line,
 		 int *deltap)	/* must be XButtonEvent */
 {
+    int result = 1;
     int l1, l2;
 
     *deltap = 0;
-    if (line == screen->cur_row)
-	return 1;
-
-    if (line < screen->cur_row)
-	l1 = line, l2 = screen->cur_row;
-    else
-	l2 = line, l1 = screen->cur_row;
-    l1--;
-    while (++l1 < l2)
-	if (!ScrnTstWrapped(screen, l1))
-	    return 0;
-    /* Everything is on one "wrapped line" now */
-    *deltap = line - screen->cur_row;
-    return 1;
+    if (line != screen->cur_row) {
+	if (line < screen->cur_row)
+	    l1 = line, l2 = screen->cur_row;
+	else
+	    l2 = line, l1 = screen->cur_row;
+	l1--;
+	while (++l1 < l2) {
+	    LineData *ld = GET_LINEDATA(screen, l1);
+	    if (!LineTstWrapped(ld)) {
+		result = 0;
+		break;
+	    }
+	}
+	if (result) {
+	    /* Everything is on one "wrapped line" now */
+	    *deltap = line - screen->cur_row;
+	}
+    }
+    return result;
 }
 
 static int
@@ -867,20 +883,8 @@ ReadLineButton(Widget w,
 		goto finish;	/* All this work for this... */
 	}
 	line = (event->xbutton.y - screen->border) / FontHeight(screen);
-	if (line != screen->cur_row) {
-	    int l1, l2;
-
-	    if (line < screen->cur_row)
-		l1 = line, l2 = screen->cur_row;
-	    else
-		l2 = line, l1 = screen->cur_row;
-	    l1--;
-	    while (++l1 < l2)
-		if (!ScrnTstWrapped(screen, l1))
-		    goto finish;
-	    /* Everything is on one "wrapped line" now */
-	    ldelta = line - screen->cur_row;
-	}
+	if (!rowOnCurrentLine(screen, line, &ldelta))
+	    goto finish;
 	/* Correct by half a width - we are acting on a boundary, not on a cell. */
 	col = (event->xbutton.x - OriginX(screen) + (FontWidth(screen) - 1)
 	       / 2)
@@ -1264,7 +1268,7 @@ allocUtf8Targets(Widget w, TScreen * screen)
 	Atom *result;
 
 	if (!overrideTargets(w, screen->utf8_select_types, &result)) {
-	    result = (Atom *) XtMalloc(5 * sizeof(Atom));
+	    result = (Atom *) XtMalloc((Cardinal) (5 * sizeof(Atom)));
 	    if (result == NULL) {
 		TRACE(("Couldn't allocate utf-8 selection targets\n"));
 	    } else {
@@ -1298,7 +1302,7 @@ alloc8bitTargets(Widget w, TScreen * screen)
 	Atom *result = 0;
 
 	if (!overrideTargets(w, screen->eightbit_select_types, &result)) {
-	    result = (Atom *) XtMalloc(5 * sizeof(Atom));
+	    result = (Atom *) XtMalloc((Cardinal) (5 * sizeof(Atom)));
 	    if (result == NULL) {
 		TRACE(("Couldn't allocate 8bit selection targets\n"));
 	    } else {
@@ -1571,7 +1575,7 @@ GettingSelection(Display * dpy, Atom type, Char * line, unsigned long len)
 
     TRACE(("Getting %s (%ld)\n", name, (long int) type));
     for (cp = line; cp < line + len; cp++) {
-	TRACE(("[%d:%lu]", cp + 1 - line, len));
+	TRACE(("[%d:%lu]", (int) (cp + 1 - line), len));
 	if (isprint(*cp)) {
 	    TRACE(("%c\n", *cp));
 	} else {
@@ -2467,19 +2471,20 @@ PointToCELL(TScreen * screen,
  * Find the last column at which text was drawn on the given row.
  */
 static int
-LastTextCol(TScreen * screen, int row)
+LastTextCol(TScreen * screen, LineData * ld, int row)
 {
-    int inx = ROW2INX(screen, row);
     int i;
     Char *ch;
 
-    if (inx + screen->savedlines >= 0) {
+    if (okScrnRow(screen, row)) {
 	for (i = screen->max_col,
-	     ch = SCRN_BUF_ATTRS(screen, inx) + i;
+	     ch = ld->attribs + i;
 	     i >= 0 && !(*ch & CHARDRAWN);
-	     ch--, i--) ;
+	     ch--, i--) {
+	    ;
+	}
 #if OPT_DEC_CHRSET
-	if (CSET_DOUBLE(SCRN_BUF_CSETS(screen, inx)[0])) {
+	if (CSET_DOUBLE(GetLineDblCS(ld))) {
 	    i *= 2;
 	}
 #endif
@@ -2587,56 +2592,58 @@ SetCharacterClassRange(int low,	/* in range of [0..255] */
 
 #if OPT_WIDE_CHARS
 static int
-class_of(TScreen * screen, CELL * cell)
+class_of(TScreen * screen, LineData * ld, CELL * cell)
 {
     CELL temp = *cell;
     int value;
 
 #if OPT_DEC_CHRSET
-    if (CSET_DOUBLE(SCRN_BUF_CSETS(screen, ROW2INX(screen, temp.row))[0])) {
+    if (CSET_DOUBLE(GetLineDblCS(ld))) {
 	temp.col /= 2;
     }
 #endif
 
     value = (int) XTERM_CELL(temp.row, temp.col);
-    if_OPT_WIDE_CHARS(screen, {
-	return CharacterClass(value);
-    });
     return CharacterClass(value);
 }
-#define ClassSelects(screen, cell, cclass) \
-	 (class_of(screen, cell) == cclass \
-	 || XTERM_CELL((cell)->row, (cell)->col) == HIDDEN_CHAR)
+#define CClassSelects(name, cclass) \
+	 (CClassOf(name) == cclass \
+	 || XTERM_CELL(screen->name.row, screen->name.col) == HIDDEN_CHAR)
 #else
-#define class_of(screen, cell) charClass[XTERM_CELL((cell)->row, (cell)->col)]
-#define ClassSelects(screen, cell, cclass) \
-	 (class_of(screen, (cell)) == cclass)
+#define class_of(screen, ld, cell) charClass[XTERM_CELL((cell)->row, (cell)->col)]
+#define CClassSelects(name, cclass) \
+	 (class_of(screen, ld.name, &((screen->name))) == cclass)
 #endif
 
+#define CClassOf(name) class_of(screen, ld.name, &((screen->name)))
+
 /*
  * If the given column is past the end of text on the given row, bump to the
  * beginning of the next line.
  */
 static Boolean
 okPosition(TScreen * screen,
+	   LineData ** ld,
 	   CELL * cell)
 {
-    if (cell->col > (LastTextCol(screen, cell->row) + 1)) {
+    if (cell->col > (LastTextCol(screen, *ld, cell->row) + 1)) {
 	cell->col = 0;
-	cell->row += 1;
+	*ld = GET_LINEDATA(screen, ++cell->row);
 	return False;
     }
     return True;
 }
 
 static void
-trimLastLine(TScreen * screen, CELL * last)
+trimLastLine(TScreen * screen,
+	     LineData ** ld,
+	     CELL * last)
 {
     if (screen->cutNewline) {
 	last->col = 0;
-	++last->row;
+	*ld = GET_LINEDATA(screen, ++last->row);
     } else {
-	last->col = LastTextCol(screen, last->row) + 1;
+	last->col = LastTextCol(screen, *ld, last->row) + 1;
     }
 }
 
@@ -2647,11 +2654,14 @@ trimLastLine(TScreen * screen, CELL * last)
 static int
 firstRowOfLine(TScreen * screen, int row, Bool visible)
 {
+    LineData *ld = 0;
     int limit = visible ? 0 : -screen->savedlines;
 
     while (row > limit &&
-	   ScrnTstWrapped(screen, row - 1))
+	   (ld = GET_LINEDATA(screen, row - 1)) != 0 &&
+	   LineTstWrapped(ld)) {
 	--row;
+    }
     return row;
 }
 
@@ -2661,9 +2671,13 @@ firstRowOfLine(TScreen * screen, int row, Bool visible)
 static int
 lastRowOfLine(TScreen * screen, int row)
 {
+    LineData *ld;
+
     while (row < screen->max_row &&
-	   ScrnTstWrapped(screen, row))
+	   (ld = GET_LINEDATA(screen, row)) != 0 &&
+	   LineTstWrapped(ld)) {
 	++row;
+    }
     return row;
 }
 
@@ -2677,7 +2691,8 @@ lengthOfLines(TScreen * screen, int firstRow, int lastRow)
     int n;
 
     for (n = firstRow; n <= lastRow; ++n) {
-	int value = LastTextCol(screen, n);
+	LineData *ld = GET_LINEDATA(screen, n);
+	int value = LastTextCol(screen, ld, n);
 	if (value >= 0)
 	    length += (unsigned) (value + 1);
     }
@@ -2700,16 +2715,17 @@ make_indexed_text(TScreen * screen, int row, unsigned length, int *indexed)
      * string were UTF-8.
      */
     if_OPT_WIDE_CHARS(screen, {
-	need *= (unsigned) (MAX_PTRS * 6);
+	need *= ((screen->lineExtra + 1) * 6);
     });
 
     if ((result = TypeCallocN(Char, need + 1)) != 0) {
+	LineData *ld = GET_LINEDATA(screen, row);
 	unsigned used = 0;
 	Char *last = result;
 
 	do {
 	    int col = 0;
-	    int limit = LastTextCol(screen, row);
+	    int limit = LastTextCol(screen, ld, row);
 
 	    while (col <= limit) {
 		Char *next = last;
@@ -2727,9 +2743,10 @@ make_indexed_text(TScreen * screen, int row, unsigned length, int *indexed)
 		});
 
 		if_OPT_WIDE_CHARS(screen, {
-		    int off;
-		    for (off = OFF_FINAL; off < MAX_PTRS; off += 2) {
-			if ((data = XTERM_CELLC(row, col, off)) == 0)
+		    size_t off;
+		    for_each_combData(off, ld) {
+			data = XTERM_CELLC(row, col, off);
+			if (data == 0)
 			    break;
 			next = convertToUTF8(next, data);
 		    }
@@ -2744,8 +2761,9 @@ make_indexed_text(TScreen * screen, int row, unsigned length, int *indexed)
 		indexed[used] = next - result;
 	    }
 	} while (used < length &&
-		 ScrnTstWrapped(screen, row) &&
-		 ++row < screen->max_row);
+		 LineTstWrapped(ld) &&
+		 (ld = GET_LINEDATA(screen, ++row)) != 0 &&
+		 row < screen->max_row);
     }
     /* TRACE(("result:%s\n", result)); */
     return (char *) result;
@@ -2775,7 +2793,8 @@ static void
 columnToCell(TScreen * screen, int row, int col, CELL * cell)
 {
     while (row < screen->max_row) {
-	int last = LastTextCol(screen, row);
+	LineData *ld = GET_LINEDATA(screen, row);
+	int last = LastTextCol(screen, ld, row);
 
 	/* TRACE(("last(%d) = %d, have %d\n", row, last, col)); */
 	if (col <= last) {
@@ -2785,7 +2804,7 @@ columnToCell(TScreen * screen, int row, int col, CELL * cell)
 	 * Stop if the current row does not wrap (does not continue the current
 	 * line).
 	 */
-	if (!ScrnTstWrapped(screen, row)) {
+	if (!LineTstWrapped(ld)) {
 	    col = last + 1;
 	    break;
 	}
@@ -2804,17 +2823,26 @@ columnToCell(TScreen * screen, int row, int col, CELL * cell)
 static int
 cellToColumn(TScreen * screen, CELL * cell)
 {
+    LineData *ld = 0;
     int col = cell->col;
     int row = firstRowOfLine(screen, cell->row, False);
     while (row < cell->row) {
-	col += LastTextCol(screen, row++);
+	ld = GET_LINEDATA(screen, row);
+	col += LastTextCol(screen, ld, row++);
     }
+#if OPT_DEC_CHRSET
+    if (ld == 0)
+	ld = GET_LINEDATA(screen, row);
+    if (CSET_DOUBLE(GetLineDblCS(ld)))
+	col /= 2;
+#endif
     return col;
 }
 
 static void
 do_select_regex(TScreen * screen, CELL * startc, CELL * endc)
 {
+    LineData *ld = GET_LINEDATA(screen, startc->row);
     int inx = ((screen->numberOfClicks - 1) % screen->maxClicks);
     char *expr = screen->selectExpr[inx];
     regex_t preg;
@@ -2823,7 +2851,7 @@ do_select_regex(TScreen * screen, CELL * startc, CELL * endc)
     int *indexed;
 
     TRACE(("Select_REGEX:%s\n", NonNull(expr)));
-    if (okPosition(screen, startc) && expr != 0) {
+    if (okPosition(screen, &ld, startc) && expr != 0) {
 	if (regcomp(&preg, expr, REG_EXTENDED) == 0) {
 	    int firstRow = firstRowOfLine(screen, startc->row, True);
 	    int lastRow = lastRowOfLine(screen, firstRow);
@@ -2877,9 +2905,7 @@ do_select_regex(TScreen * screen, CELL * startc, CELL * endc)
 			TRACE(("matched:%d:%s\n",
 			       indexed[best_nxt] + 1 -
 			       indexed[best_col],
-			       visibleChars(PAIRED_CHARS((Char *) (search +
-								   indexed[best_col]),
-							 0),
+			       visibleChars((Char *) (search + indexed[best_col]),
 					    (unsigned) (indexed[best_nxt] +
 							1 -
 							indexed[best_col]))));
@@ -2887,6 +2913,16 @@ do_select_regex(TScreen * screen, CELL * startc, CELL * endc)
 		    free(search);
 		}
 		free(indexed);
+#if OPT_DEC_CHRSET
+		if ((ld = GET_LINEDATA(screen, startc->row)) != 0) {
+		    if (CSET_DOUBLE(GetLineDblCS(ld)))
+			startc->col *= 2;
+		}
+		if ((ld = GET_LINEDATA(screen, endc->row)) != 0) {
+		    if (CSET_DOUBLE(GetLineDblCS(ld)))
+			endc->col *= 2;
+		}
+#endif
 	    }
 	    regfree(&preg);
 	}
@@ -2894,6 +2930,20 @@ do_select_regex(TScreen * screen, CELL * startc, CELL * endc)
 }
 #endif /* OPT_SELECT_REGEX */
 
+#define InitRow(name) \
+	ld.name = GET_LINEDATA(screen, screen->name.row)
+
+#define NextRow(name) \
+	ld.name = GET_LINEDATA(screen, ++screen->name.row)
+
+#define PrevRow(name) \
+	ld.name = GET_LINEDATA(screen, --screen->name.row)
+
+#define isPrevWrapped(name) \
+	(screen->name.row > 0 \
+	   && (ltmp = GET_LINEDATA(screen, screen->name.row - 1)) != 0 \
+	   && LineTstWrapped(ltmp))
+
 /*
  * sets startSel endSel
  * ensuring that they have legal values
@@ -2905,10 +2955,18 @@ ComputeSelect(XtermWidget xw,
 	      Bool extend)
 {
     TScreen *screen = TScreenOf(xw);
+
     int length;
     int cclass;
     CELL first = *startc;
     CELL last = *endc;
+    Boolean ignored = False;
+
+    struct {
+	LineData *startSel;
+	LineData *endSel;
+    } ld;
+    LineData *ltmp;
 
     TRACE(("ComputeSelect(startRow=%d, startCol=%d, endRow=%d, endCol=%d, %sextend)\n",
 	   first.row, first.col,
@@ -2940,26 +2998,28 @@ ComputeSelect(XtermWidget xw,
 	screen->endSel = screen->endRaw = first;
     }
 
+    InitRow(startSel);
+    InitRow(endSel);
+
     switch (screen->selectUnit) {
     case Select_CHAR:
-	(void) okPosition(screen, &(screen->startSel));
-	(void) okPosition(screen, &(screen->endSel));
+	(void) okPosition(screen, &(ld.startSel), &(screen->startSel));
+	(void) okPosition(screen, &(ld.endSel), &(screen->endSel));
 	break;
 
     case Select_WORD:
 	TRACE(("Select_WORD\n"));
-	if (okPosition(screen, &(screen->startSel))) {
-	    cclass = class_of(screen, &(screen->startSel));
+	if (okPosition(screen, &(ld.startSel), &(screen->startSel))) {
+	    cclass = CClassOf(startSel);
 	    do {
 		--screen->startSel.col;
-		if (screen->startSel.row > 0
-		    && screen->startSel.col < 0
-		    && ScrnTstWrapped(screen, screen->startSel.row - 1)) {
-		    --screen->startSel.row;
-		    screen->startSel.col = LastTextCol(screen, screen->startSel.row);
+		if (screen->startSel.col < 0
+		    && isPrevWrapped(startSel)) {
+		    PrevRow(startSel);
+		    screen->startSel.col = LastTextCol(screen, ld.startSel, screen->startSel.row);
 		}
 	    } while (screen->startSel.col >= 0
-		     && ClassSelects(screen, &(screen->startSel), cclass));
+		     && CClassSelects(startSel, cclass));
 	    ++screen->startSel.col;
 	}
 #if OPT_WIDE_CHARS
@@ -2969,26 +3029,26 @@ ComputeSelect(XtermWidget xw,
 	    screen->startSel.col++;
 #endif
 
-	if (okPosition(screen, &(screen->endSel))) {
-	    length = LastTextCol(screen, screen->endSel.row);
-	    cclass = class_of(screen, &(screen->endSel));
+	if (okPosition(screen, &(ld.endSel), &(screen->endSel))) {
+	    length = LastTextCol(screen, ld.endSel, screen->endSel.row);
+	    cclass = CClassOf(endSel);
 	    do {
 		++screen->endSel.col;
 		if (screen->endSel.col > length
-		    && ScrnTstWrapped(screen, screen->endSel.row)) {
+		    && LineTstWrapped(ld.endSel)) {
 		    screen->endSel.col = 0;
-		    ++screen->endSel.row;
-		    length = LastTextCol(screen, screen->endSel.row);
+		    NextRow(endSel);
+		    length = LastTextCol(screen, ld.endSel, screen->endSel.row);
 		}
 	    } while (screen->endSel.col <= length
-		     && ClassSelects(screen, &(screen->endSel), cclass));
+		     && CClassSelects(endSel, cclass));
 	    /* Word-select selects if pointing to any char in "word",
 	     * especially note that it includes the last character in a word.
 	     * So we do no --endSel.col and do special eol handling.
 	     */
 	    if (screen->endSel.col > length + 1) {
 		screen->endSel.col = 0;
-		++screen->endSel.row;
+		NextRow(endSel);
 	    }
 	}
 #if OPT_WIDE_CHARS
@@ -3003,49 +3063,49 @@ ComputeSelect(XtermWidget xw,
 
     case Select_LINE:
 	TRACE(("Select_LINE\n"));
-	while (ScrnTstWrapped(screen, screen->endSel.row)) {
-	    ++screen->endSel.row;
+	while (LineTstWrapped(ld.endSel)) {
+	    NextRow(endSel);
 	}
 	if (screen->cutToBeginningOfLine
 	    || screen->startSel.row < screen->saveStartW.row) {
 	    screen->startSel.col = 0;
-	    while (screen->startSel.row > 0
-		   && ScrnTstWrapped(screen, screen->startSel.row - 1)) {
-		--screen->startSel.row;
+	    while (isPrevWrapped(startSel)) {
+		PrevRow(startSel);
 	    }
 	} else if (!extend) {
 	    if ((first.row < screen->saveStartW.row)
 		|| (isSameRow(&first, &(screen->saveStartW))
 		    && first.col < screen->saveStartW.col)) {
 		screen->startSel.col = 0;
-		while (screen->startSel.row > 0
-		       && ScrnTstWrapped(screen, screen->startSel.row - 1)) {
-		    --screen->startSel.row;
+		while (isPrevWrapped(startSel)) {
+		    PrevRow(startSel);
 		}
 	    } else {
 		screen->startSel = screen->saveStartW;
 	    }
 	}
-	trimLastLine(screen, &(screen->endSel));
+	trimLastLine(screen, &(ld.endSel), &(screen->endSel));
 	break;
 
     case Select_GROUP:		/* paragraph */
 	TRACE(("Select_GROUP\n"));
-	if (okPosition(screen, &(screen->startSel))) {
+	if (okPosition(screen, &(ld.startSel), &(screen->startSel))) {
 	    /* scan backward for beginning of group */
 	    while (screen->startSel.row > 0 &&
-		   (LastTextCol(screen, screen->startSel.row - 1) > 0 ||
-		    ScrnTstWrapped(screen, screen->startSel.row - 1))) {
-		--screen->startSel.row;
+		   (LastTextCol(screen, ld.startSel, screen->startSel.row -
+				1) > 0 ||
+		    isPrevWrapped(startSel))) {
+		PrevRow(startSel);
 	    }
 	    screen->startSel.col = 0;
 	    /* scan forward for end of group */
 	    while (screen->endSel.row < screen->max_row &&
-		   (LastTextCol(screen, screen->endSel.row + 1) > 0 ||
-		    ScrnTstWrapped(screen, screen->endSel.row))) {
-		++screen->endSel.row;
+		   (LastTextCol(screen, ld.endSel, screen->endSel.row + 1) >
+		    0 ||
+		    LineTstWrapped(ld.endSel))) {
+		NextRow(endSel);
 	    }
-	    trimLastLine(screen, &(screen->endSel));
+	    trimLastLine(screen, &(ld.endSel), &(screen->endSel));
 	}
 	break;
 
@@ -3072,13 +3132,16 @@ ComputeSelect(XtermWidget xw,
 #endif
 
     case NSELECTUNITS:		/* always ignore */
-	return;
+	ignored = True;
+	break;
     }
 
-    /* check boundaries */
-    ScrollSelection(screen, 0, False);
+    if (!ignored) {
+	/* check boundaries */
+	ScrollSelection(screen, 0, False);
+	TrackText(xw, &(screen->startSel), &(screen->endSel));
+    }
 
-    TrackText(xw, &(screen->startSel), &(screen->endSel));
     return;
 }
 
@@ -3249,8 +3312,8 @@ SaltTextAway(XtermWidget xw,
     }
     *lp = '\0';			/* make sure we have end marked */
 
-    TRACE(("Salted TEXT:%d:%s\n", lp - line,
-	   visibleChars(PAIRED_CHARS(line, 0), (unsigned) (lp - line))));
+    TRACE(("Salted TEXT:%d:%s\n", (int) (lp - line),
+	   visibleChars(line, (unsigned) (lp - line))));
 
     screen->selection_length = (unsigned long) (lp - line);
     _OwnSelection(xw, params, num_params);
@@ -3452,7 +3515,7 @@ ConvertSelection(Widget w,
 	    std_targets = (Atom *) (std_return);
 	    *length = std_length + 6;
 
-	    targetP = (Atom *) XtMalloc(sizeof(Atom) * (*length));
+	    targetP = (Atom *) XtMalloc((Cardinal) (sizeof(Atom) * (*length)));
 	    allocP = targetP;
 
 	    *value = (XtPointer) targetP;
@@ -3635,7 +3698,7 @@ _OwnSelection(XtermWidget xw,
 
     if (count > screen->sel_atoms_size) {
 	XtFree((char *) atoms);
-	atoms = (Atom *) XtMalloc(count * sizeof(Atom));
+	atoms = (Atom *) XtMalloc((Cardinal) (count * sizeof(Atom)));
 	screen->selection_atoms = atoms;
 	screen->sel_atoms_size = count;
     }
@@ -3743,12 +3806,13 @@ UnhiliteSelection(XtermWidget xw)
 /* returns number of chars in line from scol to ecol out */
 /* ARGSUSED */
 static int
-Length(TScreen * screen GCC_UNUSED,
+Length(TScreen * screen,
        int row,
        int scol,
        int ecol)
 {


Reply to: