Skip to contentSkip to conversation

TIOCLINUX.2const: Document TIOCL_SETSEL selection modes

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

lore
Share & tools
lore
#0 lore raw

v4 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!)

V4:
* Clarified how TIOCL_SELPOINTER selects the coordinate to use

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 v3:

1:  d07edb528 = 1:  828c5189a TIOCLINUX.2const: Restructure documentation for TIOCL_SETSEL selection modes
2:  59f217fb0 ! 2:  bffc3e550 TIOCLINUX.2const: Document missing TIOCL_SETSEL selection modes

@@ man/man2const/TIOCLINUX.2const: Select line-by-line,
+.RI ( xs ,\~ ys )
+or
+.RI ( xe ,\~ ye ),
-+whichever is greater.
++whichever is later in text flow order.
+.TP
+.B TIOCL_SELCLEAR
+Remove the current selection highlight, if any,

Signature · 1 line
2.49.0
#1 lore raw

PATCH v4 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.49.0
#2 lore raw

PATCH v4 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..61f1c596d 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 later in text flow order.
+.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.49.0
#3 lore raw
In reply to Günther Noack

Hi Günther, Jared,

Quoted 12 lines · Günther Noack

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].

Quoted 5 lines

Thanks,
–Günther

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

Thanks! I've applied both patches. I've added Acked-by tags for Jared, since there was a mail saying LGTM in the previos version, and it hasn't changed significantly.

Have a lovely day!
Alex

Quoted 39 lines

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!)

V4:
* Clarified how TIOCL_SELPOINTER selects the coordinate to use

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 v3:

1:  d07edb528 = 1:  828c5189a TIOCLINUX.2const: Restructure documentation for TIOCL_SETSEL selection modes
2:  59f217fb0 ! 2:  bffc3e550 TIOCLINUX.2const: Document missing TIOCL_SETSEL selection modes

@@ man/man2const/TIOCLINUX.2const: Select line-by-line,
+.RI ( xs ,\~ ys )
+or
+.RI ( xe ,\~ ye ),
-+whichever is greater.
++whichever is later in text flow order.
+.TP
+.B TIOCL_SELCLEAR
+Remove the current selection highlight, if any,

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