M README.md => README.md +3 -0
@@ 76,6 76,7 @@ No. Besides the ambiguity problem, it will also introduce huge external dependen
- Go back: b or right mouse click anywhere (if supported)
- Refresh the page: r
- Stash the link to the currently open resource: S (shift+s)
+- Toggle mouse support (always on when starting): m
- Quit the browser: q
## What is the link stash?
@@ 110,6 111,8 @@ Bopher-NG's mouse input is supported on any terminals that support the 1000 **an
Note that, unlike clipboard, this support is required at the client side only. For instance, you can safely run `bopher-ng.sh` on any compatible Bash version in an SSH session on your terminal and still be able to use mouse there.
+If you don't want to use mouse capture (for instance, to be able to select and copy things with the terminal app itself), you can temporarily turn off mouse support (and then turn it back on) using the m key.
+
## What is the license on this?
Fully public domain.
M bopher-ng.sh => bopher-ng.sh +6 -4
@@ 60,6 60,7 @@ ALTBUFON="${ESC}[?47h" # use the alternative screen buffer
ALTBUFOFF="${ESC}[?47l" # return to the default screen buffer
# mouse event support switches
+MOUSE_ENABLED=1
MOUSEON="${ESC}[?1000;1006h" # term command to start sending mouse input events as control sequences (semi-long format, no drag)
MOUSEOFF="${ESC}[?1000;1006l" # term command to stop sending mouse input events as control sequences (semi-long format, no drag)
# in the semi-long format without drag, every mouse control sequence starts with "${ESC}[<" and then has three fields:
@@ 365,7 366,7 @@ mouseY=''
mouseStatus='M'
while true; do
mousecmd='' # mouse command buffer
- printf '%s' "$MOUSEON" # enable mouse events before reading
+ [[ "$MOUSE_ENABLED" == '1' ]] && printf '%s' "$MOUSEON" # enable mouse events before reading
read -n 1 -s cmdbuf # read the character, tildas will be ignored
if [[ "$cmdbuf" == $'\x1b' ]]; then # here's the control character
read -n 2 -s cmdbuf # read 2 additional characters
@@ 373,7 374,7 @@ while true; do
read -r -s mousecmd mouseX mouseY mouseStatus < <(readmouseinput)
fi
fi
- printf '%s' "$MOUSEOFF" # don't generate mouse events outside the input sequence
+ [[ "$MOUSE_ENABLED" == '1' ]] && printf '%s' "$MOUSEOFF" # don't generate mouse events outside the input sequence
[[ "$mousecmd" == '2' && "$mouseStatus" == 'M' ]] && cmdbuf='b' # right click is automatically assigned to back command
[[ "$cmdbuf" == '[A' || "$cmdbuf" == 'k' || "$mousecmd" == '64' ]] && scroll -1
[[ "$cmdbuf" == '[B' || "$cmdbuf" == 'j' || "$mousecmd" == '65' ]] && scroll 1
@@ 387,6 388,7 @@ while true; do
[[ "$cmdbuf" == 'd' ]] && clicklink 1 # same as click but with force-download flag
[[ "$cmdbuf" == 'b' ]] && goback
[[ "$cmdbuf" == 'S' ]] && stashlink
- [[ "$mousecmd" == '0' && "$mouseStatus" == 'M' ]] && mouseclick $mouseX $mouseY # we only process left click with coordinates here
- [[ "$mousecmd" == '1' && "$mouseStatus" == 'M' ]] && mouseclick $mouseX $mouseY 1 # we only process middle click with coordinates here
+ [[ "$cmdbuf" == 'm' ]] && MOUSE_ENABLED=$(( 1 - MOUSE_ENABLED ))
+ [[ "$MOUSE_ENABLED" == '1' && "$mousecmd" == '0' && "$mouseStatus" == 'M' ]] && mouseclick $mouseX $mouseY # we only process left click with coordinates here
+ [[ "$MOUSE_ENABLED" == '1' && "$mousecmd" == '1' && "$mouseStatus" == 'M' ]] && mouseclick $mouseX $mouseY 1 # we only process middle click with coordinates here
done