Skip to content

Commit

Permalink
Use "select" as a term for selecting text
Browse files Browse the repository at this point in the history
This is a better term, as pointed out by @postsolar in #173
  • Loading branch information
walles committed Dec 19, 2023
1 parent d045cb6 commit 8ec3df7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions MOUSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions moar.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions moar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
)

Expand Down
6 changes: 3 additions & 3 deletions twin/screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8ec3df7

Please sign in to comment.