Skip to content

Conversation

@seyko2
Copy link

@seyko2 seyko2 commented Sep 25, 2014

an xterm-like mouse reporting. A bugs reports to [email protected]

getc()
{
stty raw
dd bs=1 count=1 2>/dev/null
stty cooked
}

handle_mouse()
{
local c
c="getc"
[ "$c" = "[" ] || return
c="getc"
[ "$c" = "M" ] || return
b="getc"
x="getc"
y="getc"
b=printf "%u" "'$b"
x=printf "%u" "'$x"
y=printf "%u" "'$y"
b=$(($b - 32))
x=$(($x - 32))
y=$(($y - 32))
echo "$b $x $y"
}

stty -echo
printf '\033[?1000h'
ESC="printf '\033'"
while true ; do
c="getc"
if [ "$c" = "$ESC" ] ; then
handle_mouse
fi
if [ "$c" = "q" ] ; then
break
fi
done
printf '\033[?1000l'
stty echo

echo

an xterm-like mouse reporting. A bugs reports to [email protected]

===============================================================

getc()
{
    stty raw
    dd bs=1 count=1 2>/dev/null
    stty cooked
}

handle_mouse()
{
    local c
    c="`getc`"
    [ "$c" = "[" ] || return
    c="`getc`"
    [ "$c" = "M" ] || return
    b="`getc`"
    x="`getc`"
    y="`getc`"
    b=`printf "%u" "'$b"`
    x=`printf "%u" "'$x"`
    y=`printf "%u" "'$y"`
    b=$(($b - 32))
    x=$(($x - 32))
    y=$(($y - 32))
    echo "$b $x $y"
}

stty -echo
printf '\033[?1000h'
ESC="`printf '\033'`"
while true ; do
    c="`getc`"
    if [ "$c" = "$ESC" ] ; then
        handle_mouse
    fi
    if [ "$c" = "q" ] ; then
        break
    fi
done
printf '\033[?1000l'
stty echo
echo
===============================================================
@telmich
Copy link
Owner

telmich commented Nov 17, 2014

Maybe a nice idea, but what about the documentation?

@seyko2
Copy link
Author

seyko2 commented Nov 18, 2014

What documentation is needed? Patch for gpm is developed to allow use
a mouse control in a turbo vision programs with pseudo terminal as
stdin/stdout. This feature can be tested with tmux or mc too. gpm
sends some mouse events using a TIOCLLINUX syscall to a program in the
current console which enabled a xterm-like mouse reporting (via
esc-sequence \033[?1000h)

linux kernel has a TIOCL_SELMOUSEREPORT (TIOCLINUX) support since a
version 2.2. But even current version of gpm don't support this.
https://googledrive.com/host/0B35PjbLHNzyqNS13R0M1aEctND is an archive
(with a real name gpm-xterm.tar.xz) on my google drive with a patch
for a current version of gpm to support a mouse position reporting.
Archive contain a patch, a test script, a binary of modified gpm and a
test program atvedit (an editor from a turbo vision). Start it from a
Midnigth commander (or a telnet session) to test a mouse reporting.
atvedit don't start from a bash prompt if gpm is running.

2014-11-17 15:09 GMT+04:00, Nico Schottelius [email protected]:

Maybe a nice idea, but what about the documentation?


Reply to this email directly or view it on GitHub:
#4 (comment)

@seyko2
Copy link
Author

seyko2 commented Oct 11, 2015

What the resolution about this pull request?

@telmich
Copy link
Owner

telmich commented Feb 14, 2016

How is anyone going to use this without being mentioned in the docs?

@seyko2
Copy link
Author

seyko2 commented Mar 28, 2016 via email

@egmontkob
Copy link

Please see #29 for a broader picture!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants