How to catch the mouse in COBOL?

Post Reply

Topic author
fim
Active Contributor
Posts: 31
Joined: Wed Jan 04, 2023 5:14 am
Reputation: 0
Status: Offline

How to catch the mouse in COBOL?

Post by fim » Sun Feb 05, 2023 7:15 am

The only place where I can find anything about the mouse is SMG$READ_LOCATOR, but then you have to work with DECwindows workstation.
Is there any way in a COBOL program to get information about where the mouse pointer is when any of the mouse buttons are pressed?
I use PTTY as a terminal emulator.

/Fim W.


sms
Master
Posts: 310
Joined: Fri Aug 21, 2020 5:18 pm
Reputation: 0
Status: Offline

Re: How to catch the mouse in COBOL?

Post by sms » Mon Feb 06, 2023 2:32 am

Code: Select all

   My near-total ignorance spans both COBOL and terminals/emulators with
mice/pointers, but...

> The only place where I can find anything about the mouse is
> SMG$READ_LOCATOR, but then you have to work with DECwindows workstation.

   To me, that sounds more like an assumption/deduction than a reliable
fact.  A simple VT terminal didn't have a mouse/pointer, so I'd guess
that there was a time when the only (supported) terminal/emulator which
_did_ have a mouse/pointer would have been a DECterm, and that implied
DECwindows (which is approximately X Windows).  The documentation might
_say_ "DECterm" or "DECwindows", but I wouldn't bet that that's the only
thing which would work.

   If you're talking to any kind of terminal/emulator, then I'd expect
you to be sending and receiving characters, and I'd expect that to work
the same with any terminal/emulator which interprets those characters
the same.  If PuTTY (or xterm, or whatever) uses the same (ANSI?)
command/response strings (even if that requires some special emulator
configuration), then what could go wrong?

   See, for example (look for "mouse"):

      https://www.xfree86.org/current/ctlseqs.html

   Knowing as much as I do (that is, approximately nothing), the first
thing about which I'd worry is what happens to mouse/pointer events when
the focus is on the terminal emulator.  In my (limited) experience, the
local OS/windows system handles those events to deal with copy+paste,
and so those events are invisible to the application program to which
the terminal emulator is connected.  (But what do I know?)

   In any case, I wouldn't let some documentation reference to
DECwindows stop me from exploring further.  (But I also wouldn't
guarantee success.)


Topic author
fim
Active Contributor
Posts: 31
Joined: Wed Jan 04, 2023 5:14 am
Reputation: 0
Status: Offline

Re: How to catch the mouse in COBOL?

Post by fim » Mon Feb 06, 2023 5:29 am

I am reading https://www.xfree86.org/current/ctlseqs.html and there seems to be some about mouse.
Will do further research there.
Thanks for the tip.


tim.stegner
VSI Expert
Valued Contributor
Posts: 55
Joined: Wed Jul 21, 2021 9:14 am
Reputation: 0
Status: Offline

Re: How to catch the mouse in COBOL?

Post by tim.stegner » Mon Feb 06, 2023 8:33 am

There is info about mouse operations, but it's still related to XTerms, which is DECWindows.

In normal VT100* escape sequences, there is one to report the mouse position, but I'm unsure on how to capture the output programmatically.

One to features of OpenVMS is the ability to call routines from other installed languages. If you have any. Thus you could find a feature possibly in BASIC that would read the screen for mouse actions, and call those routines from COBOL.

I think your best bet is the SMG$ routines.


sms
Master
Posts: 310
Joined: Fri Aug 21, 2020 5:18 pm
Reputation: 0
Status: Offline

Re: How to catch the mouse in COBOL?

Post by sms » Mon Feb 06, 2023 10:34 pm

Code: Select all

   More guesswork:

> [...] the first thing about which I'd worry is what happens to
> mouse/pointer events when the focus is on the terminal emulator. [...]

   A quick Web search for:
      PuTTY mouse
found (among other things):

      https://superuser.com/questions/1209866/

      PuTTY: disable copy-paste on mouse selection

which seems to deal with that concern.  Perhaps that PuTTY configuration
suggestion will let the pointer-related escape sequences be transmitted.

   If the SMG stuff (about which I still know nothing) has a function
like SMG$READ_LOCATOR, then I'd guess that it keeps the terminal driver
from eating the related escape sequences.  Other, simpler, more
do-it-yourself programs might need to do something like:
      SET TERMINAL /PASTHRU
to let the escape sequences through to the application code.  (There's a
$QIO IO$_SETMODE method to do all that stuff from inside the program,
too.)

   If you run into unexpected behavior when using what the OS thinks is
a serial line, then you might want to investigate the Terminal Driver
section of the I/O User's Reference Manual.

      https://docs.vmssoftware.com/vsi-openvms-io-user-s-reference-manual/

It's a sure cure for any belief that terminal I/O is simple.


Topic author
fim
Active Contributor
Posts: 31
Joined: Wed Jan 04, 2023 5:14 am
Reputation: 0
Status: Offline

Re: How to catch the mouse in COBOL?

Post by fim » Tue Feb 07, 2023 11:07 am

Thanks for the tips,
I'll take a closer look at them.
/Fim W.

User avatar

volkerhalle
Master
Posts: 196
Joined: Fri Aug 14, 2020 11:31 am
Reputation: 0
Status: Offline

Re: How to catch the mouse in COBOL?

Post by volkerhalle » Tue Feb 07, 2023 11:45 am

Fim,

the description of SMG$READ_LOCATOR in the RTL Screen Management Manual explicitly states:

SMG$READ_LOCATOR reads information from a DECwindows workstation terminal's locator
device. (This routine does not read locator information from the VT300 series terminals.) A locator
device is a mouse or a tablet.

Volker.

Post Reply