[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gentoo-user
Subject:    [gentoo-user] An annoyance in GPM, and a fix for it
From:       Alan Mackenzie <acm () muc ! de>
Date:       2023-10-04 18:11:00
Message-ID: ZR2qtMkLyBHP-sXq () ACM
[Download RAW message or body]

Hello, Gentoo.

In the GPM mouse utility in a tty, one can use a double click to select
a word (and by holding the button down and moving the mouse, select a
sequence of words).

Similarly, with a triple click, one can select a line, or a sequence of
lines.  This is all very fine, but GPM adds a CR after each line in the
sequnce, INCLUDING THE LAST ONE.  This makes it less useful for, say,
copying a shell script command from and editor onto a command line.
Because typically, you'd want to edit the command before executing it,
but with GPM's mechanism, the CR on the end immediately executes it, not
giving you a chance to edit it.

A solution to this problem is not to append the CR to the last line in a
sequence of lines selected by GPM.  This means patching the kernel.  To
apply the patch, first get the attached patch into the kernel's
directory, and do something like:

    # patch -p1 < 6.1.8-TRIPLE.20231004.diff

, then rebuild the kernel.  Install this kernel into your boot manager,
and voilą - the problem is solved.  :-)

The usual disclaimer applies.

-- 
Alan Mackenzie (Nuremberg, Germany).


["6.1.8-TRIPLE.20231004.diff" (text/plain)]

diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
index 6ef22f01cc51..e2a07b8759ed 100644
--- a/drivers/tty/vt/selection.c
+++ b/drivers/tty/vt/selection.c
@@ -217,7 +217,8 @@ static int vc_selection_store_chars(struct vc_data *vc, bool unicode)
 			   unless non-space at end of line. */
 			if (obp != bp) {
 				bp = obp;
-				*bp++ = '\r';
+				if ((i + 2) < vc_sel.end) /* Don't add \r to the last line. */
+					*bp++ = '\r';
 			}
 			obp = bp;
 		}


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic