1
1
mirror of https://github.com/walles/moar.git synced 2024-11-22 11:45:50 +03:00

Use "select" as a term for selecting text

This is a better term, as pointed out by @postsolar in #173
This commit is contained in:
Johan Walles 2023-12-19 09:20:02 +01:00
parent d045cb6d37
commit 8ec3df792a
4 changed files with 14 additions and 14 deletions

View File

@ -5,8 +5,8 @@
- `scroll` makes `moar` process mouse events from your terminal, thus enabling mouse scrolling work,
but disabling the ability to select text with mouse in the usual way. Selecting text will require using your terminal's capability to bypass mouse protocol.
Most terminals support this capability, see [Selection workarounds for `scroll` mode](#mouse-selection-workarounds-for-scroll-mode) for details.
- `mark` makes `moar` not process mouse events. This makes selecting and copying text work, but scrolling might not be possible, depending on your terminal and its configuration.
- `auto` uses `mark` on terminals where we know it won't break scrolling, and
- `select` makes `moar` not process mouse events. This makes selecting and copying text work, but scrolling might not be possible, depending on your terminal and its configuration.
- `auto` uses `select` on terminals where we know it won't break scrolling, and
`scroll` on all others. [The white list lives in the
`mouseTrackingRecommended()` function in
`screen.go`](https://github.com/walles/moar/blob/master/twin/screen.go).
@ -15,9 +15,9 @@ The reason these tradeoffs exist is that if `moar` requests mouse events from th
it should process _all_ mouse events, including attempts to select text. This is the case with every console application.
However, some terminals can send "fake" arrow key presses to applications which _do not_ request processing mouse events.
This means that on those terminals, you will be better off using `--mousemode mark` option, given that you also have this feature enabled (it's usually on by default).
This means that on those terminals, you will be better off using `--mousemode select` option, given that you also have this feature enabled (it's usually on by default).
With this setup, both scrolling and text selecting in the usual way will work.
To check whether this could work, simply run `moar` with option `--mousemode mark` and see if scrolling still works.
To check whether this could work, simply run `moar` with option `--mousemode select` and see if scrolling still works.
## Mouse Selection Workarounds for `scroll` Mode

6
moar.1
View File

@ -45,9 +45,9 @@ Print debug logs after exiting, less verbose than
Scrolls automatically to follow piped input, just like
.B tail \-f
.TP
\fB\-\-mousemode\fR={\fBauto\fR | \fBmark\fR | \fBscroll\fR}
Guarantee marking text with the mouse works but maybe not mouse scrolling.
Or guarantee mouse scrolling works but marking requiring extra effort.
\fB\-\-mousemode\fR={\fBauto\fR | \fBselect\fR | \fBscroll\fR}
Guarantee selecting text with the mouse works but maybe not mouse scrolling.
Or guarantee mouse scrolling works but selecting text requiring extra effort.
Details here: https://github.com/walles/moar/blob/master/MOUSE.md
.TP
\fB\-\-no\-clear\-on\-exit\fR

View File

@ -245,13 +245,13 @@ func parseMouseMode(mouseMode string) (twin.MouseMode, error) {
switch mouseMode {
case "auto":
return twin.MouseModeAuto, nil
case "mark":
return twin.MouseModeMark, nil
case "select", "mark":
return twin.MouseModeSelect, nil
case "scroll":
return twin.MouseModeScroll, nil
}
return twin.MouseModeAuto, fmt.Errorf("Valid modes are auto, mark and scroll")
return twin.MouseModeAuto, fmt.Errorf("Valid modes are auto, select and scroll")
}
func pumpToStdout(inputFilename *string) error {
@ -408,7 +408,7 @@ func main() {
flagSet,
"mousemode",
twin.MouseModeAuto,
"Mouse mode: auto, mark or scroll: https://github.com/walles/moar/blob/master/MOUSE.md",
"Mouse mode: auto, select or scroll: https://github.com/walles/moar/blob/master/MOUSE.md",
parseMouseMode,
)

View File

@ -17,10 +17,10 @@ type MouseMode int
const (
MouseModeAuto MouseMode = iota
// Don't capture mouse events. This makes marking with the mouse work. On
// Don't capture mouse events. This makes selecting with the mouse work. On
// some terminals mouse scrolling will work using arrow keys emulation, and
// on some not.
MouseModeMark
MouseModeSelect
// Capture mouse events. This makes mouse scrolling work. Special gymnastics
// will be required for marking with the mouse to copy text.
@ -142,7 +142,7 @@ func NewScreenWithMouseModeAndColorType(mouseMode MouseMode, terminalColorCount
if mouseMode == MouseModeAuto {
screen.enableMouseTracking(!terminalHasArrowKeysEmulation())
} else if mouseMode == MouseModeMark {
} else if mouseMode == MouseModeSelect {
screen.enableMouseTracking(false)
} else if mouseMode == MouseModeScroll {
screen.enableMouseTracking(true)