-
Notifications
You must be signed in to change notification settings - Fork 628
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #659 from mitchellh/xterm-stuff
xterm audit: REP, XTSHIFTESCAPE
- Loading branch information
Showing
8 changed files
with
276 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import VTSequence from "@/components/VTSequence"; | ||
|
||
# Repeat Previous Character (REP) | ||
|
||
<VTSequence sequence={["CSI", "Pn", "b"]} /> | ||
|
||
Repeat the previously printed character `n` times. | ||
|
||
The parameter `n` must be an integer greater than or equal to 1. If `n` is less than | ||
or equal to 0, adjust `n` to be 1. If `n` is omitted, `n` defaults to 1. | ||
|
||
In xterm, only characters with single byte (less than decimal 256) are | ||
supported. In most other mainstream terminals, any character is supported. | ||
|
||
Each repeated character behaves identically to if it was manually typed in. | ||
Therefore, soft-wrapping, margins, etc. all behave the same as if the | ||
character was typed. | ||
|
||
The previously printed character is any character that is printed through | ||
any means. The previously printed character is not limited to characters | ||
a user manually types. If there is no previously typed character, this sequence | ||
does nothing. | ||
|
||
## Validation | ||
|
||
### REP V-1: Simple Usage | ||
|
||
```bash | ||
printf "\033[1;1H" # move to top-left | ||
printf "\033[0J" # clear screen | ||
printf "A" | ||
printf "\033[b" | ||
``` | ||
|
||
``` | ||
|AAc_______| | ||
``` | ||
|
||
### REP V-2: Soft-Wrap | ||
|
||
```bash | ||
cols=$(tput cols) | ||
printf "\033[1;1H" # move to top-left | ||
printf "\033[0J" # clear screen | ||
printf "\033[${cols}G" | ||
printf "A" | ||
printf "\033[b" | ||
``` | ||
|
||
``` | ||
|_________A| | ||
|Ac________| | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import VTSequence from "@/components/VTSequence"; | ||
|
||
# Set Shift-Escape (XTSHIFTESCAPE) | ||
|
||
<VTSequence sequence={["CSI", ">", "Pn", "s"]} /> | ||
|
||
Configure whether mouse reports are allowed to capture the `shift` modifier. | ||
|
||
The parameter `n` must be an integer equal to 0 or 1. If `n` is omitted, | ||
`n` defaults to 1. If `n` is an invalid value, this sequence does nothing. | ||
|
||
When a terminal program requests [mouse reporting](#TODO), some mouse | ||
reporting modes also report the modifier keys that are pressed (control, shift, | ||
etc.). This would disable the ability for a terminal user to natively select | ||
text if they typically select text using left-click and drag, since the | ||
left-click event is captured by the running program. | ||
|
||
To get around this limitation, many terminal emulators (including xterm) | ||
use the `shift` modifier to disable mouse reporting temporarily, allowing | ||
native text selection to work. In this scenario, however, the running | ||
terminal program cannot detect shift-clicks because the terminal emulator | ||
captures the event. | ||
|
||
This sequence (`XTSHIFTESCAPE`) allows configuring this behavior. If | ||
`n` is `0`, the terminal is allowed to override the shift key and not pass | ||
it through to the terminal program. If `n` is `1`, the terminal program | ||
is requesting that the shift modifier is sent using standard mouse | ||
reporting formats. | ||
|
||
In either case, the terminal emulator is not forced to respect this request. | ||
For example, `xterm` has a `never` and `always` terminal configuration | ||
to never allow terminal programs to capture shift or to always allow them, | ||
respectively. If either of these configurations are set, `XTSHIFTESCAPE` | ||
has zero effect. | ||
|
||
`xterm` also has `false` and `true` terminal configurations. In the `false` | ||
scenario, the terminal emulator will override `shift` (not allow the terminal | ||
program to see it) _unless it is explicitly requested_ via `XTSHIFTESCAPE`. | ||
The `true` scenario is the exact opposite: pass the shift modifier through | ||
to the running terminal program unless the terminal program explicitly states | ||
it doesn't need to know about it (`n = 0`). |