Skip to contentSkip to conversation

TIOCLINUX.2const: Document TIOCL_SETSEL selection modes

PATCH Superseded Günther Noack 4 participants 13 messages Mar 2, 2025 – Mar 30, 2025 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover TIOCLINUX.2const: Document TIOCL_SETSEL selection modes

Hi!

TIOCLINUX's TIOCL_SETSEL sub-code has another layer of sub-operations, called "selection modes" (even though not all of them actually deal with the mouse selection).

Going forward, the CAP_SYS_ADMIN requirement will be different for some of these selection modes, which prompted me to at least list the different selection modes with a short description. I am leaving CAP_SYS_ADMIN documentation as it is for now and will send another patch once these semantics are finalized [1] [2].

Thanks,
–Günther

[1] <https://lore.kernel.org/all/[email protected]/>
[2] <https://lore.kernel.org/all/[email protected]/>

History:

V2:
* Split into a "restructuring" and a "new documentation" commit
* Use non-breaking space \~
* Put URIs in <>
* Added a helpful link to console_codes(4) regarding mouse reporting

V3:
* Corrections and clarifications for various selection modes as suggested by Jared Finder. (Thanks!)

Günther Noack (2):
TIOCLINUX.2const: Restructure documentation for TIOCL_SETSEL selection
modes
TIOCLINUX.2const: Document missing TIOCL_SETSEL selection modes

 man/man2const/TIOCLINUX.2const | 59 +++++++++++++++++++++++++++++++---
 1 file changed, 54 insertions(+), 5 deletions(-)

Range-diff against v2:
1: 5eb2a603e ! 1: d07edb528 TIOCLINUX.2const: Restructure documentation for TIOCL_SETSEL selection modes
@@ Commit message

* Indent the documented selection modes into tagged paragraphs.
* Document constants from the header file (tiocl.h) instead of numbers.
+ * Clarify expansion semantics as suggested by Jared Finder.

@@ man/man2const/TIOCLINUX.2const: are the ending
+and saved in a kernel buffer.
+.TP
+.B TIOCL_SELWORD
-+Select word-by-word.
++Select word-by-word,
++expanding the selection outwards to align with word boundaries.
+The indicated screen characters are highlighted
+and saved in a kernel buffer.
+.TP
+.B TIOCL_SELLINE
-+Select line-by-line.
++Select line-by-line,
++expanding the selection outwards to select full lines.
+The indicated screen characters are highlighted
+and saved in a kernel buffer.
+.RE
2: 2f39d5cf9 ! 2: 59f217fb0 TIOCLINUX.2const: Document missing TIOCL_SETSEL selection modes
@@ Commit message
mode" is slightly misleading as not all of them actually manipulate the kernel's mouse selection buffer.

+ Includes clarified semantics pointed out by Jared Finder.
+
Cc: Jared Finder <[email protected]>
Cc: Hanno Böck <[email protected]>
Cc: Jann Horn <[email protected]>
@@ Commit message

## man/man2const/TIOCLINUX.2const ##
-@@ man/man2const/TIOCLINUX.2const: and saved in a kernel buffer.
- Select line-by-line.
+@@ man/man2const/TIOCLINUX.2const: Select line-by-line,
+ expanding the selection outwards to select full lines. The indicated screen characters are highlighted
and saved in a kernel buffer.
+.TP
+.B TIOCL_SELPOINTER
+Show the pointer at position
-+.RI ( xe ,\~ ye ).
++.RI ( xs ,\~ ys )
++or
++.RI ( xe ,\~ ye ),
++whichever is greater.
+.TP
+.B TIOCL_SELCLEAR
+Remove the current selection highlight, if any, +from the console holding the selection.
++.IP
++This does not affect the stored selected text.
+.TP
+.B TIOCL_SELMOUSEREPORT
+Make the terminal report

Signature · 1 line
2.48.1
#1 lore raw

PATCH v3 1/2 TIOCLINUX.2const: Restructure documentation for TIOCL_SETSEL selection modes

* Indent the documented selection modes into tagged paragraphs.
* Document constants from the header file (tiocl.h) instead of numbers.
* Clarify expansion semantics as suggested by Jared Finder.

---
 man/man2const/TIOCLINUX.2const | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)
man/man2const/TIOCLINUX.2const +20 -5
index c0acdd0ea..f2c8d0720 100644
@@ -65,11 +65,26 @@ are the ending
 column and row.
 (Upper left corner is row=column=1.)
 .I sel_mode
-is 0 for character-by-character selection,
-1 for word-by-word selection,
-or 2 for line-by-line selection.
-The indicated screen characters are highlighted and saved
-in a kernel buffer.
+may be one of the following operations:
+.RS
+.TP
+.B TIOCL_SELCHAR
+Select character-by-character.
+The indicated screen characters are highlighted
+and saved in a kernel buffer.
+.TP
+.B TIOCL_SELWORD
+Select word-by-word,
+expanding the selection outwards to align with word boundaries.
+The indicated screen characters are highlighted
+and saved in a kernel buffer.
+.TP
+.B TIOCL_SELLINE
+Select line-by-line,
+expanding the selection outwards to select full lines.
+The indicated screen characters are highlighted
+and saved in a kernel buffer.
+.RE
 .IP
 Since Linux 6.7, using this subcode requires the
 .B CAP_SYS_ADMIN
Signature · 1 line
2.48.1
#2 lore raw

Re: [PATCH man v3 1/2] TIOCLINUX.2const: Restructure documentation for TIOCL_SETSEL selection modes

Quoted 35 lines · Günther Noack

* Indent the documented selection modes into tagged paragraphs.
* Document constants from the header file (tiocl.h) instead of numbers.
* Clarify expansion semantics as suggested by Jared Finder.

---
 man/man2const/TIOCLINUX.2const | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)
man/man2const/TIOCLINUX.2const +13 -5
index c0acdd0ea..f2c8d0720 100644
@@ -65,11 +65,26 @@ are the ending
 column and row.
 (Upper left corner is row=column=1.)
 .I sel_mode
-is 0 for character-by-character selection,
-1 for word-by-word selection,
-or 2 for line-by-line selection.
-The indicated screen characters are highlighted and saved
-in a kernel buffer.
+may be one of the following operations:
+.RS
+.TP
+.B TIOCL_SELCHAR
+Select character-by-character.
+The indicated screen characters are highlighted
+and saved in a kernel buffer.
+.TP
+.B TIOCL_SELWORD
+Select word-by-word,
+expanding the selection outwards to align with word boundaries.
+The indicated screen characters are highlighted
+and saved in a kernel buffer.

man/man2const/TIOCLINUX.2const are the ending · line 90

Quoted 10 lines
man/man2const/TIOCLINUX.2const +7 -0
+.TP
+.B TIOCL_SELLINE
+Select line-by-line,
+expanding the selection outwards to select full lines.
+The indicated screen characters are highlighted
+and saved in a kernel buffer.
+.RE
 .IP
 Since Linux 6.7, using this subcode requires the
 .B CAP_SYS_ADMIN

No additional comments from me, this looks good.

-- MJF

#3 lore raw

Re: [PATCH man v3 1/2] TIOCLINUX.2const: Restructure documentation for TIOCL_SETSEL selection modes

Hi Jared,

Quoted 2 lines · Jared Finder

No additional comments from me, this looks good.

Do you want to send an explicit Acked-by, or Reviewed-by?

Have a lovely day!
Alex

Quoted 2 lines

-- MJF

Signature · 1 line
<https://www.alejandro-colomar.es/>
#4 lore raw

PATCH v3 2/2 TIOCLINUX.2const: Document missing TIOCL_SETSEL selection modes

In reply to Günther Noack

Documents the following TIOCL_SETSEL sub-operations:

* TIOCL_SELPOINTER
* TIOCL_SELCLEAR
* TIOCL_SELMOUSEREPORT

These previously undocumented selection modes for the Linux console are implemented in drivers/tty/vt/selection.c. The name "selection mode" is slightly misleading as not all of them actually manipulate the kernel's mouse selection buffer.

Includes clarified semantics pointed out by Jared Finder.

---
 man/man2const/TIOCLINUX.2const | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
man/man2const/TIOCLINUX.2const +34 -0
index f2c8d0720..f1021ce99 100644
@@ -84,6 +84,40 @@ Select line-by-line,
 expanding the selection outwards to select full lines.
 The indicated screen characters are highlighted
 and saved in a kernel buffer.
+.TP
+.B TIOCL_SELPOINTER
+Show the pointer at position
+.RI ( xs ,\~ ys )
+or
+.RI ( xe ,\~ ye ),
+whichever is greater.
+.TP
+.B TIOCL_SELCLEAR
+Remove the current selection highlight, if any,
+from the console holding the selection.
+.IP
+This does not affect the stored selected text.
+.TP
+.B TIOCL_SELMOUSEREPORT
+Make the terminal report
+.RI ( xs ,\~ ys )
+as the current mouse location
+using the
+.BR xterm (1)
+mouse tracking protocol
+(see
+.BR console_codes (4)).
+The lower 4 bits of
+.I sel_mode
+.RB ( TIOCL_SELBUTTONMASK )
+indicate the desired button press and
+modifier key information for the mouse event.
+.\" <https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Normal-tracking-mode>
+.IP
+If mouse reporting is not enabled for the terminal,
+this operation yields an
+.B EINVAL
+error.
 .RE
 .IP
 Since Linux 6.7, using this subcode requires the
Signature · 1 line
2.48.1
#5 lore raw

Re: [PATCH man v3 2/2] TIOCLINUX.2const: Document missing TIOCL_SETSEL selection modes

Quoted 62 lines · Günther Noack

Documents the following TIOCL_SETSEL sub-operations:

* TIOCL_SELPOINTER
* TIOCL_SELCLEAR
* TIOCL_SELMOUSEREPORT

These previously undocumented selection modes for the Linux console are implemented in drivers/tty/vt/selection.c. The name "selection mode" is slightly misleading as not all of them actually manipulate the kernel's mouse selection buffer.

Includes clarified semantics pointed out by Jared Finder.

---
 man/man2const/TIOCLINUX.2const | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
man/man2const/TIOCLINUX.2const +29 -0
index f2c8d0720..f1021ce99 100644
@@ -84,6 +84,40 @@ Select line-by-line,
 expanding the selection outwards to select full lines.
 The indicated screen characters are highlighted
 and saved in a kernel buffer.
+.TP
+.B TIOCL_SELPOINTER
+Show the pointer at position
+.RI ( xs ,\~ ys )
+or
+.RI ( xe ,\~ ye ),
+whichever is greater.
+.TP
+.B TIOCL_SELCLEAR
+Remove the current selection highlight, if any,
+from the console holding the selection.
+.IP
+This does not affect the stored selected text.
+.TP
+.B TIOCL_SELMOUSEREPORT
+Make the terminal report
+.RI ( xs ,\~ ys )
+as the current mouse location
+using the
+.BR xterm (1)
+mouse tracking protocol
+(see
+.BR console_codes (4)).
+The lower 4 bits of
+.I sel_mode
+.RB ( TIOCL_SELBUTTONMASK )
+indicate the desired button press and
+modifier key information for the mouse event.
+.\" 

<https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Normal-tracking-mode>
+.IP

man/man2const/TIOCLINUX.2const Select line-by-line, · line 123

Quoted 7 lines
man/man2const/TIOCLINUX.2const +4 -0
+If mouse reporting is not enabled for the terminal,
+this operation yields an
+.B EINVAL
+error.
 .RE
 .IP
 Since Linux 6.7, using this subcode requires the

No additional comments from me, this looks good.

-- MJF

#6 lore raw
In reply to Günther Noack

Hi Günther,

Quoted 6 lines · Günther Noack

-@@ man/man2const/TIOCLINUX.2const: and saved in a kernel buffer.
- Select line-by-line.
+@@ man/man2const/TIOCLINUX.2const: Select line-by-line,
+ expanding the selection outwards to select full lines. The indicated screen characters are highlighted
and saved in a kernel buffer.

Quoted 8 lines

+.TP
+.B TIOCL_SELPOINTER
+Show the pointer at position
-+.RI ( xe ,\~ ye ).
++.RI ( xs ,\~ ys )
++or
++.RI ( xe ,\~ ye ),
++whichever is greater.

Everything else looks good to me. But,

What's "greater" when you have two dimensions?

Have a lovely day!
Alex

Quoted 12 lines

+.TP
+.B TIOCL_SELCLEAR
+Remove the current selection highlight, if any, +from the console holding the selection.
++.IP
++This does not affect the stored selected text.
+.TP
+.B TIOCL_SELMOUSEREPORT
+Make the terminal report

Signature · 1 line
2.48.1
Signature · 1 line
<https://www.alejandro-colomar.es/>
#7 lore raw

[somewhat whimsical]

Quoted 10 lines · Alejandro Colomar
Quoted 8 lines · Günther Noack
     +.TP
     +.B TIOCL_SELPOINTER
     +Show the pointer at position
    -+.RI ( xe ,\~ ye ).
    ++.RI ( xs ,\~ ys )
    ++or
    ++.RI ( xe ,\~ ye ),
    ++whichever is greater.
Quoted 3 lines

Everything else looks good to me. But,

What's "greater" when you have two dimensions?

Since we can model the terminal display as an inner product space, the terminal driver can compute an orthographic projection of the plane onto a line and from there use routine arithmetic inequality operators.

The problem with the Linux kernel's terminal driver's lack of developer attention over the years is obviously a result of it presenting insufficient features of interest to the linear algebraist.

;-)

Regards,
Branden

#8 lore raw

Hi all,

Quoted 13 lines · G. Branden Robinson

[somewhat whimsical]

Quoted 10 lines · Alejandro Colomar
Quoted 8 lines · Günther Noack
     +.TP
     +.B TIOCL_SELPOINTER
     +Show the pointer at position
    -+.RI ( xe ,\~ ye ).
    ++.RI ( xs ,\~ ys )
    ++or
    ++.RI ( xe ,\~ ye ),
    ++whichever is greater.
Quoted 8 lines
Quoted 3 lines

Everything else looks good to me. But,

What's "greater" when you have two dimensions?

Since we can model the terminal display as an inner product space, the terminal driver can compute an orthographic projection of the plane onto a line and from there use routine arithmetic inequality operators.

In any case, this is going to be confusing. Can we get some wording that is obvious to a school student?

Have a lovely night!
Alex

Quoted 9 lines

The problem with the Linux kernel's terminal driver's lack of developer attention over the years is obviously a result of it presenting insufficient features of interest to the linear algebraist.

;-)

Regards,
Branden

Signature · 1 line
<https://www.alejandro-colomar.es/>
#9 lore raw
Quoted 20 lines · Alejandro Colomar

Hi all,

Quoted 17 lines · G. Branden Robinson

[somewhat whimsical]

Quoted 13 lines · Alejandro Colomar
Quoted 8 lines · Günther Noack
     +.TP
     +.B TIOCL_SELPOINTER
     +Show the pointer at position
    -+.RI ( xe ,\~ ye ).
    ++.RI ( xs ,\~ ys )
    ++or
    ++.RI ( xe ,\~ ye ),
    ++whichever is greater.

Everything else looks good to me. But,

What's "greater" when you have two dimensions?

Quoted 7 lines
Quoted 4 lines

Since we can model the terminal display as an inner product space, the terminal driver can compute an orthographic projection of the plane onto a line and from there use routine arithmetic inequality operators.

In any case, this is going to be confusing. Can we get some wording that is obvious to a school student?

How about something like "... whichever is greater. When the positions span multiple horizontal lines (ys != ye), characters are ordered left to right, top to bottom, similar to when writing English text".

-- MJF

#10 lore raw

Hi Jared,

Quoted 32 lines · Jared Finder
Quoted 20 lines · Alejandro Colomar

Hi all,

Quoted 17 lines · G. Branden Robinson

[somewhat whimsical]

Quoted 13 lines · Alejandro Colomar
Quoted 8 lines · Günther Noack
     +.TP
     +.B TIOCL_SELPOINTER
     +Show the pointer at position
    -+.RI ( xe ,\~ ye ).
    ++.RI ( xs ,\~ ys )
    ++or
    ++.RI ( xe ,\~ ye ),
    ++whichever is greater.

Everything else looks good to me. But,

What's "greater" when you have two dimensions?

Quoted 7 lines
Quoted 4 lines

Since we can model the terminal display as an inner product space, the terminal driver can compute an orthographic projection of the plane onto a line and from there use routine arithmetic inequality operators.

In any case, this is going to be confusing. Can we get some wording that is obvious to a school student?

How about something like "... whichever is greater.

Quoted 6 lines

When the positions span
multiple horizontal lines (ys != ye),

characters are ordered left to right,
top to bottom, similar to when writing English text".

And greater is a character ordered first or last?

Quoted 2 lines

-- MJF

Have a lovely day!
Alex

Signature · 1 line
<https://www.alejandro-colomar.es/>
#11 lore raw

Hello!

Quoted 33 lines · Alejandro Colomar
Quoted 30 lines · Jared Finder
Quoted 20 lines · Alejandro Colomar

Hi all,

Quoted 17 lines · G. Branden Robinson

[somewhat whimsical]

Quoted 13 lines · Alejandro Colomar
Quoted 8 lines · Günther Noack
     +.TP
     +.B TIOCL_SELPOINTER
     +Show the pointer at position
    -+.RI ( xe ,\~ ye ).
    ++.RI ( xs ,\~ ys )
    ++or
    ++.RI ( xe ,\~ ye ),
    ++whichever is greater.

Everything else looks good to me. But,

What's "greater" when you have two dimensions?

Quoted 7 lines
Quoted 4 lines

Since we can model the terminal display as an inner product space, the terminal driver can compute an orthographic projection of the plane onto a line and from there use routine arithmetic inequality operators.

In any case, this is going to be confusing. Can we get some wording that is obvious to a school student?

How about something like "... whichever is greater.

Quoted 8 lines
Quoted 6 lines

When the positions span
multiple horizontal lines (ys != ye),

characters are ordered left to right,
top to bottom, similar to when writing English text".

And greater is a character ordered first or last?

Thanks for your input! You are correct that saying "bigger" is unclear. The alternatives are entertaining in a nerdy way ;-) but I'm not sure that being mathematically exact here helps the purpose of this man page. ;-)

The elephant in the room is that in the big scheme of things, this API is pretty absurd: The API draws the mouse pointer at *one* position, but there are *two* places where users can specify the coordinates.

Noone in their right mind would actually pass two coordinates and would try to rely on the exact ordering semantics here. The only reasonable thing to do is to pass the coordinate in one of the two places and leave the other place blank (0, 0). The only ordering that *actually* matters to callers is that their passed coordinate is "bigger" than (0, 0).

These API semantics look like they happened by accident rather than by intentional planning. If the goal is to describe how an API *should* get used, then spending too many words on ordering semantics here would IMHO be distracting from the real thing that callers should do, which I think should be *to fill one of the two coordinates and leave the other blank*. :)

So if we describe this, I would like to make it as succinct as possible and not draw unnecessary attention to it.

To make a constructive proposal, how about this phrasing:

Show the pointer at position (xs, ys) or (xe, ye), whichever is later in text flow order.

? Does that sound reasonable?

Thanks,
–Günther

#12 lore raw

Hi Günther!

Quoted 26 lines · Günther Noack

Thanks for your input! You are correct that saying "bigger" is unclear. The alternatives are entertaining in a nerdy way ;-) but I'm not sure that being mathematically exact here helps the purpose of this man page. ;-)

The elephant in the room is that in the big scheme of things, this API is pretty absurd: The API draws the mouse pointer at *one* position, but there are *two* places where users can specify the coordinates.

Noone in their right mind would actually pass two coordinates and would try to rely on the exact ordering semantics here. The only reasonable thing to do is to pass the coordinate in one of the two places and leave the other place blank (0, 0). The only ordering that *actually* matters to callers is that their passed coordinate is "bigger" than (0, 0).

These API semantics look like they happened by accident rather than by intentional planning. If the goal is to describe how an API *should* get used, then spending too many words on ordering semantics here would IMHO be distracting from the real thing that callers should do, which I think should be *to fill one of the two coordinates and leave the other blank*. :)

So if we describe this, I would like to make it as succinct as possible and not draw unnecessary attention to it.

Quoted 6 lines

To make a constructive proposal, how about this phrasing:

Show the pointer at position (xs, ys) or (xe, ye), whichever is later in text flow order.

? Does that sound reasonable?

Yep, that sounds much better. Thanks!

Have a lovely day!
Alex

Signature · 1 line
<https://www.alejandro-colomar.es/>