xterm-27.patch.txt

XFree86 3.1.2Ek - xterm patch #27 - T.Dickey
 
This patch fixes one of my long-term gripes:  xterm's selection doesn't clearly
show what's being selected (as per David's request, it's controlled by a
resource, which defaults to the older behavior).
 
--------------------------------------------------------------------------------
 charproc.c |    6 ++++++
 ptyx.h     |    1 +
 screen.c   |   22 ++++++++++++++++++++++
 xterm.man  |    9 ++++++++-
 4 files changed, 37 insertions, 1 deletion
--------------------------------------------------------------------------------
Index: charproc.c
--- xterm-26+/charproc.c        Tue Aug 20 15:08:28 1996
+++ xterm-27/charproc.c Wed Aug 21 21:15:31 1996
@@ -174,6 +174,7 @@
 #define XtNeightBitOutput "eightBitOutput"
 #define XtNeightBitControl "eightBitControl"
 #define XtNgeometry "geometry"
+#define XtNhighlightSelection "highlightSelection"
 #define XtNtekGeometry "tekGeometry"
 #define XtNinternalBorder "internalBorder"
 #define XtNjumpScroll "jumpScroll"
@@ -247,6 +248,7 @@
 #define XtCEightBitOutput "EightBitOutput"
 #define XtCEightBitControl "EightBitControl"
 #define XtCGeometry "Geometry"
+#define XtCHighlightSelection "HighlightSelection"
 #define XtCJumpScroll "JumpScroll"
 #ifdef ALLOWLOGGING
 #define XtCLogfile "Logfile"
@@ -439,6 +441,9 @@
 {XtNcutToBeginningOfLine, XtCCutToBeginningOfLine, XtRBoolean, sizeof(Boolean),
        XtOffsetOf(XtermWidgetRec, screen.cutToBeginningOfLine),
        XtRBoolean, (XtPointer) &defaultTRUE},
+{XtNhighlightSelection,XtCHighlightSelection,XtRBoolean,
+        sizeof(Boolean),XtOffsetOf(XtermWidgetRec, screen.highlight_selection),
+        XtRBoolean, (XtPointer) &defaultFALSE},
 {XtNbackground, XtCBackground, XtRPixel, sizeof(Pixel),
        XtOffsetOf(XtermWidgetRec, core.background_pixel),
        XtRString, "XtDefaultBackground"},
@@ -3119,6 +3124,7 @@
    new->screen.charClass = request->screen.charClass;
    new->screen.cutNewline = request->screen.cutNewline;
    new->screen.cutToBeginningOfLine = request->screen.cutToBeginningOfLine;
+   new->screen.highlight_selection = request->screen.highlight_selection;
    new->screen.always_highlight = request->screen.always_highlight;
    new->screen.pointer_cursor = request->screen.pointer_cursor;
    new->screen.input_eight_bits = request->screen.input_eight_bits;
Index: ptyx.h
--- xterm-26+/ptyx.h    Tue Aug 13 14:51:20 1996
+++ xterm-27/ptyx.h     Wed Aug 21 20:52:19 1996
@@ -506,6 +506,7 @@
        char            *charClass;     /* for overriding word selection */
        Boolean         cutNewline;     /* whether or not line cut has \n */
        Boolean         cutToBeginningOfLine;  /* line cuts to BOL? */
+       Boolean         highlight_selection; /* controls appearance of selection */
        char            *selection;     /* the current selection */
        int             selection_size; /* size of allocated buffer */
        int             selection_length; /* number of significant bytes */
Index: screen.c
--- xterm-26+/screen.c  Tue Aug 13 14:51:20 1996
+++ xterm-27/screen.c   Wed Aug 21 21:12:25 1996
@@ -500,6 +500,28 @@
                               maxcol - screen->endHCol + 1, force);
                   maxcol = screen->endHCol - 1;
               }
+
+              /*
+               * If we're highlighting because the user is doing cut/paste,
+               * trim the trailing blanks from the highlighted region so we're
+               * showing the actual extent of the text that'll be cut.  If
+               * we're selecting a blank line, we'll highlight one column
+               * anyway.
+               *
+               * We don't do this if the mouse-hilite mode is set because that
+               * would be too confusing.
+               *
+               * The default if the highlightSelection resource isn't set will
+               * highlight the whole width of the terminal, which is easy to
+               * see, but harder to use (because trailing blanks aren't as
+               * apparent).
+               */
+              if (screen->highlight_selection
+               && maxcol >= screen->max_col
+               && screen->send_mouse_pos != 3)
+                  while (maxcol > 0 && !(attrs[maxcol] & CHARDRAWN))
+                       maxcol--;
+
               /* remaining piece should be hilited */
               hilite = True;
           }
Index: xterm.man
--- xterm-26+/xterm.man Tue Aug 13 14:51:20 1996
+++ xterm-27/xterm.man  Wed Aug 21 21:08:26 1996
@@ -769,11 +769,18 @@
 .B "geometry (\fPclass\fB Geometry)"
 Specifies the preferred size and position of the VT102 window.
 .TP 8
+.B "highlightSelection (\fPclass\fB HighlightSelection)"
+If false, selecting with the mouse highlights all positions on the screen
+between the beginning of the selection and the current position.
+If true, \fIxterm\fP highlights only the positions that contain text that
+can be selected.
+The default is ``false.''
+.TP 8
 .B "hpLowerleftBugCompat (\fPclass\fB HpLowerleftBugCompat)"
 Specifies whether to work around a bug in HP's \fIxdb\fP,
 which ignores termcap and always sends
 ESC F to move to the lower left corner.
-``true'' causes xterm to interpret ESC F as a request to move to the
+``true'' causes \fIxterm\fP to interpret ESC F as a request to move to the
 lower left corner of the screen.  The default is ``false.''
 .TP 8
 .B "internalBorder (\fPclass\fB BorderWidth)"