Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 07:10 02 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : MMBasic 5.05.02 Beta 3

     Page 2 of 2    
Author Message
DaveJacko
Regular Member

Joined: 25/07/2019
Location: United Kingdom
Posts: 83
Posted: 08:33pm 13 Sep 2020
Copy link to clipboard 
Print this post

Could anyone kindly tell me the esc codes to induce Teraterm to report mouse clicks?
I've spent hours searching, to no avail.
It would be really whizzy to use mouse clicks in an MMBasic program!
Thanks so much to Geoff and Rob, the editor is now a pleasure to use!
Try swapping 2 and 3 over
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3292
Posted: 09:07pm 13 Sep 2020
Copy link to clipboard 
Print this post

The following code was provided by Rob Rozee as a means of demonstrating how to get mouse clicks.  I used the VT200 method in the MMBasic editor and it works perfectly.

Geoff

Const ESC=Chr$(27)

Print
Print
Print "select mouse reporting mode"
Print "  1) X10"
Print "  2) VT200"
Print "?";
Do: M$=Inkey$: Loop Until M$="1" Or M$="2"
Print Chr$(13) M$

Print
Print "select response protocol"
Print "  1) normal"
Print "  2) URXVT"
Print "  3) SGR"
Print "?";
Do: P$=Inkey$: Loop Until P$="1" Or P$="2" Or P$="3"
Print Chr$(13) P$

Print
Print "press ctrl-Z to exit"
Print

'
' NOTES:
' =====
' X10 only reports mouse down events, and does not encode shift, control, alt
' VT200 reports mouse down and up events, plus modifier keys that are pressed
'
' "normal" encoding always returns 6 characters: ESC [ M Cb Cx Cy
' URXVT encodes as ESC [ num ; num ; num M
' SGR encodes as ESC [ < num ; num ; num M/m   (M = mouse down, m = mouse up)
'
' general VT200 is more useful, as it lets you make use of modifier keys
' "normal" is a fixed length string, but limited to 223 x 223 screen size
' SGR is slightly more complicated to decode, but screen size is not limited
' URXVT is not favoured as it is no improvement over SGR
'

If M$="1" Then Print ESC "[?9h";         ' enable X10 mouse reporting
If M$="2" Then Print ESC "[?1000h";      ' enable VT200 mouse reporting
If P$="2" Then Print ESC "[?1015h";      ' select URXVT encoding (if available)
If P$="3" Then Print ESC "[?1006h";      ' select SGR encoding (if available)

Do
 Do: A$=Inkey$: Loop Until A$<>""
 If A$=Chr$(27) Then Print
 If Asc(A$)<32 Then Print "<" Str$(Asc(A$)) ">"; Else Print A$;
Loop Until A$=Chr$(26)

Print ESC "[?1006l";                     ' disable SGR encoding
Print ESC "[?1015l";                     ' disable URXVT encoding
Print ESC "[?1000l";                     ' disable VT200 mouse reporting
Print ESC "[?9l";                        ' disable X10 mouse reporting
Print

Geoff Graham - http://geoffg.net
 
DaveJacko
Regular Member

Joined: 25/07/2019
Location: United Kingdom
Posts: 83
Posted: 10:20pm 22 Nov 2020
Copy link to clipboard 
Print this post

Fantastic ! Thanks Geoff.

PS I still find people who look down on BASIC,
maybe it's the name.
Perhaps we could rename mmbasic as "geoff"..or just "G"

'program written in G' sounds cool eh?
Try swapping 2 and 3 over
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025