This program activates the mouse and displays some mouse events.
If a key was pressed, which mouse button was pressed (right, left, central).
If a mouse button is held down while the mouse is being moved, it displays the "mouse move" event and the coordinates (row and column) of the mouse position while the mouse is moved.
I think this program shows some bugs.
BUG1. I press a mouse button and hold it down. The program correctly displays the key pressed. Now, while the key is pressed the mouse is moved.
When the button is released, the system DOES NOT display the "key released" event.
BUG2.
If I use the ACCEPT OMITTED statement instead of ACCEPT WDUMMY, the system does not activate the mouse.
BUG3.
left doubleclick on any position returns 0000 and row / col = 25/79.
right doubleclick or middle doubleclick does not works.
>>SOURCEFORMATISFREEREPLACE==:BCOL:==BY==withBACKGROUND-COLOR====:FCOL:==BY==FOREGROUND-COLOR==.IDENTIFICATIONDIVISION.Program-Id.GCMOUSETEST.*>**************************************************************>COBOLTESTTHEMOUSE*>Tectonics:compilewithGnuCOBOL3.1*>Usage:GCMOUSETEST*>Parameters:none*>*>Author:EugenioDiLorenzo-Italia(DILO)-eugenio.dilo@gmail.com*>License:Copyright2019E.DiLorenzo-LGPL,3.0(orgreater)*>Version:1.02019.12.09*>Changelog:1.0firstrelease.*>*************************************************************ENVIRONMENTDIVISION.CONFIGURATIONSECTION.SPECIAL-NAMES.CRTSTATUSISwRetCode.*>ReturnCodefromAccept(es.PFKeys,MouseKeys)CURSORISwRowCol.*>CursorPositionDATADIVISION.FILESECTION.WORKING-STORAGESECTION.*>mousemask,applytoCOB-MOUSE-FLAGS78COB-AUTO-MOUSE-HANDLINGVALUE1.78COB-ALLOW-LEFT-DOWNVALUE2.78COB-ALLOW-LEFT-UPVALUE4.78COB-ALLOW-LEFT-DOUBLEVALUE8.78COB-ALLOW-MIDDLE-DOWNVALUE16.78COB-ALLOW-MIDDLE-UPVALUE32.78COB-ALLOW-MIDDLE-DOUBLEVALUE64.78COB-ALLOW-RIGHT-DOWNVALUE128.78COB-ALLOW-RIGHT-UPVALUE256.78COB-ALLOW-RIGHT-DOUBLEVALUE512.78COB-ALLOW-MOUSE-MOVEVALUE1024.78COB-ALLOW-ALL-SCREEN-ACTIONSVALUE16384.*>reserved*>ValuesthatmaybereturnedinCRTSTATUS(orCOB-CRT-STATUS)*>Functionkeys-Values1xxx78COB-SCR-F3VALUE1003.*>Exceptionkeysformousehandling78COB-SCR-MOUSE-MOVEVALUE2040.78COB-SCR-LEFT-PRESSEDVALUE2041.78COB-SCR-LEFT-RELEASEDVALUE2042.78COB-SCR-LEFT-DBL-CLICKVALUE2043.78COB-SCR-MID-PRESSEDVALUE2044.78COB-SCR-MID-RELEASEDVALUE2045.78COB-SCR-MID-DBL-CLICKVALUE2046.78COB-SCR-RIGHT-PRESSEDVALUE2047.78COB-SCR-RIGHT-RELEASEDVALUE2048.78COB-SCR-RIGHT-DBL-CLICKVALUE2049.01wDummyPICXXX.01MOUSE-FLAGSPIC9(4).01wRetCodePIC9(4)value0000.01wRetCodeDescrpicx(20).01wRowColPIC9(6)value0000.01redefineswRowCol.05wRowRPic9(3).05wColRPic9(3).01blackconstantas0.01blueconstantas1.01greenconstantas2.01cyanconstantas3.01redconstantas4.01magentaconstantas5.01yellowconstantas6.*>orBrown01whiteconstantas7.01wIntBINARY-SHORTSIGNED.01wDashes1picx(80)value"1...+....10...+....20...+....30...+....40...+....50...+....60...+....70...+....0".01wTitlepicx(80)value' - GnuCOBOL MOUSE TEST - '.01wRowpic9(02)value0.01wRow2pic9(02)value0.01wColpic9(02)value0.01wCol2pic9(02)value0.01wClickedpic9(02)value0.*>***************************************************************>PROCEDUREDIVISION*>**************************************************************PROCEDUREDIVISION.MAIN1.performInitialSettingsthruInitialSettingsEx*>thisisaninfiniteLOOP.theprogramdetectifamousebuttonisclickedperformforeveracceptwDummyat025080:BCOL:2:FCOL:6*>acceptomittedat025080:BCOL:2:FCOL:6*>thisdoesnotwork!computewRow=wRowRcomputewCol=wColR+1*>(wColRisfrom000to079!)display'Return Code...:'at004037:BCOL:green:FCOL:whiteend-displaydisplaywRetCodeat004053:BCOL:green:FCOL:whiteend-displayevaluatewRetCodewhen2040move'Mouse moved'towRetCodeDescrwhen2041move'Left Button'towRetCodeDescrwhen2047move'Right button'towRetCodeDescrwhen2044move'Middle button'towRetCodeDescrwhenothermove'Unknown Ret.code 'towRetCodeDescrend-evaluatedisplaywRetCodeDescrat004059:BCOL:green:FCOL:whiteend-displaydisplay'Row & Col.....:'at005037:BCOL:green:FCOL:whiteend-displaydisplaywRowRat005053:BCOL:green:FCOL:whiteend-displaydisplaywColRat005059:BCOL:green:FCOL:whiteend-displayifwRetCode=COB-SCR-F3acceptomittedgotoENDPROGend-if*>testifmousewasontheOKbuttonif(wRow>=21andwRow<=23)and(wCol>=60andwCol<=70)thengotoENDPROGend-ifend-performcontinue.ENDPROG.*>display(1,1)' 'ERASEdisplay' 'at0101withblankscreenend-display.goback.*>***************************************************************>**>**>**************************************************************InitialSettings.*>setsinordertodetectthePgUp,PgDn,PrtSc(screenprint),Esckeys,setenvironment'COB_SCREEN_EXCEPTIONS'TO'Y'.setenvironment'COB_SCREEN_ESC'TO'Y'.display' 'at0101withblankscreenend-display.*>initializepdcurses*>makemouseactiveCOMPUTEMOUSE-FLAGS=COB-AUTO-MOUSE-HANDLING+COB-ALLOW-LEFT-DOWN+COB-ALLOW-MIDDLE-DOWN+COB-ALLOW-RIGHT-DOWN+COB-ALLOW-MOUSE-MOVESETenvironment"COB_MOUSE_FLAGS"toMOUSE-FLAGS.performHideCursorthruHideCursorExDISPLAY(1,1)' 'ERASEdisplaywTitleat001001:BCOL:Red:FCOL:whitedisplaywDashes1at002001:BCOL:Green:FCOL:Whitemove'10'towDashes1(1:2)displaywDashes1at010001:BCOL:Green:FCOL:Whitemove'15'towDashes1(1:2)displaywDashes1at015001:BCOL:Green:FCOL:Whitemove'20'towDashes1(1:2)displaywDashes1at020001:BCOL:Green:FCOL:White*>buttonareatoclickforEXITdisplay(21,60)'+---------+'display(22,60)'| EXIT |'display(23,60)'+---------+'display'Press F3 or click on the EXIT button to exit'at025001:BCOL:Green:FCOL:Whitecontinue.InitialSettingsEx.exit.HideCursor.*>hidethecursormove0towIntcallstatic"curs_set"usingbyvaluewIntend-callcontinue.HideCursorEx.exit.ENDPROGRAMGCMOUSETEST.
But I think you're avoiding the inevitable using an ACCEPT to get control of the mouse. You did it, but while pressing a button key. So far, so good. But you need the "getch" macro to take full control of the mouse movement (whether you want it or not). The problem is that "getch" is already taken by "screenio.c" and what you want to do is bypass it anyway, Even you can exploit the "weaknesses" of the system, one day or other this will change and you will not be able to do it again. But one can always try :-). In my point of view, the only way to do the "thing" is, someday, someone disable the mouse control and pass to the programmer an ENTRY point (address) using a "CALL" -or- "ENTRY" statement where you can do what you want without restrictions. (I'm guessing "soon(ish)"). Anyway ... :-)
By the way, the MOUSE RELEASE does not exist. We can only deduce it by the inactivity of any mouse buttons after they were changed (pressed). This is similar to pressing CTRL/SHIFT/ALT key and then release it (and yes, you can use these with the mouse). You can see it in "demos/testcurs,c" (feel free to see "void inputTest(WINDOW *win") part of the source code.
This is the piece of code that explains the procedure:
if(MOUSE_MOVED)waddstr(win,"moved: ");elseif(MOUSE_POS_REPORT)waddstr(win,"Posn report: ");elseif(MOUSE_WHEEL_UP)waddstr(win,"wheel up: ");elseif(MOUSE_WHEEL_DOWN)waddstr(win,"wheel dn: ");\#ifdefMOUSE_WHEEL_LEFTelseif(MOUSE_WHEEL_LEFT)waddstr(win,"wheel lt: ");\#endif\#ifdefMOUSE_WHEEL_RIGHTelseif(MOUSE_WHEEL_RIGHT)waddstr(win,"wheel rt: ");\#endifelseif((status&BUTTON_ACTION_MASK)==BUTTON_PRESSED)waddstr(win,"pressed: ");elseif((status&BUTTON_ACTION_MASK)==BUTTON_CLICKED)waddstr(win,"clicked: ");elseif((status&BUTTON_ACTION_MASK)==BUTTON_DOUBLE_CLICKED)waddstr(win,"double: ");elseif((status&BUTTON_ACTION_MASK)==BUTTON_TRIPLE_CLICKED)waddstr(win,"triple: ");elseif(button)/**/waddstr(win,"released: ");/**/wprintw(win,"Posn: Y: %d X: %d",MOUSE_Y_POS,MOUSE_X_POS);if(!button)/* just to get shift/alt/ctrl status */status=Mouse_status.button[0];if(status&BUTTON_SHIFT)waddstr(win," SHIFT");if(status&BUTTON_CONTROL)waddstr(win," CONTROL");if(status&BUTTON_ALT)waddstr(win," ALT");}elseif(PDC_get_key_modifiers()){waddstr(win," Modifier(s):");if(PDC_get_key_modifiers()&PDC_KEY_MODIFIER_SHIFT)waddstr(win," SHIFT");if(PDC_get_key_modifiers()&PDC_KEY_MODIFIER_CONTROL)waddstr(win," CONTROL");if(PDC_get_key_modifiers()&PDC_KEY_MODIFIER_ALT)waddstr(win," ALT");if(PDC_get_key_modifiers()&PDC_KEY_MODIFIER_NUMLOCK)waddstr(win," NUMLOCK");\#ifdefPDC_KEY_MODIFIER_REPEATif(PDC_get_key_modifiers()&PDC_KEY_MODIFIER_REPEAT)waddstr(win," REPEAT");\#endif\#endif/* end of mouse display */
I'm hopping to make some sense !!!
Well met, Eugenio :-)
Cheers,
MM
Last edit: Simon Sobisch 2019-12-10
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Mario,
I'm trying to understand the situation regarding the use of the mouse with GnuCOBOL but it's not easy. From what cdg has written and from the available documentation, the GnuCOBOL compiler (like other COBOL compilers) now supports the use of the mouse without having to call components in C. Is this correct or not?
I think it's correct.
Infact I developed the test program I posted above.
It works well for left, right, middle (key pressed), mouse move ... I move the mouse and in real time the system shows me the position of the mouse while I move it! It's perfect !
Please, try to compile and run the source I posted ..
I indicated that it doesn't work for "released" and that I think it's a bug. Now I expect it can be verified and corrected.
I don't understand why others are proceeding to develop pieces of C code just to handle mouse events. At most it would have been interesting to "call" the mouse functions of pdcurses library. It was my request some time ago, but I didn't understand why it seems impossible. Many posts followed, but no one made it clear why I can't use a "call static somemousefunction (xxxxxxx)"
Ciao.
Last edit: Eugenio Di Lorenzo 2019-12-10
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't understand why others are proceeding to develop pieces of C code just to handle mouse events. At most it would have been interesting to "call" the mouse functions of pdcurses library. It was my request some time ago, but I didn't understand why it seems impossible. Many posts followed, but no one made it clear why I can't use a "call static somemousefunction (xxxxxxx)"
In my case, it is because the GC "ACCEPT" doesn't do what I need it to do, or would have required extensive modification of the 265 programs I was converting, so I used my "termio" subroutine (written 30 years ago, and modified many times over the years), and modified it to use "getch" (rather than an MS-DOS interrupt) to read and interpret single keystrokes from the keyboard.
Similarly, the GC mouse interface doesn't provide detection of mouse clicks, which is the only thing that I need from the mouse. So I modified the mouse interface in my termio program to use pdcurses as well. And, while I was doing that, I added additional mouse functions, so that others might benefit from it if they needed.
The reason why we can't call the mouse functions of pdcurses (or getch) directly from a Cobol program (and thus need a C "wrapper") is that they are macros, or they require macros. Macros invoke multiple functions and other macros, which invoke multiple functions and other macros, and use data types that are alien to Cobol. It would theoretically be possible to call them from a Cobol program, but it would take multiple function calls, with various data manipulations, and thus is not practical.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
For the program: the double-click is returned as enter with zero position because:
double-click COB-ALLOW-LEFT-DOUBLE action was not specified and in this case screenio does an auto-translation to "enter"
this "enter" does not change the program's cursor position which gets initialized by your ACCEPT at pos
similar you don't get a release because you did not included the COB-ALLOW-LEFT-UP
note to the code: ACCEPT OMITTED may raise errors in the future if you specify a color
The bad offset in the row/col are fixed in more current versions of GnuCOBOL than the one you currently use. Expect it to start from 1/1.
I've patched screenio.c to also handle the mouse on ACCEPT OMITTED I did not take care of this part when implementing the mouse handling in the first place.
I've played a little bit around and would suggest to auto-hide the cursor for ACCEPT OMITTED, what is the general thought on this?
General note: anyone willing to add W$MOUSE and CBL_MOUSE_ library calls to GnuCOBOL? I've tried to ensure that anything is already setup to provide these - without conflicting with the current ACCEPT implementation.
Last edit: Simon Sobisch 2019-12-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Simon,
wonderful !
simple and clear.
no bugs !
all the buttons and all the mouse events works wonderfully!
Without any use of C wrappers. Only pure COBOL.
New SOURCE with corrections and some enhancements (move the mouse & paint the screen)
>>SOURCEFORMATISFREEREPLACE==:BCOL:==BY==withBACKGROUND-COLOR====:FCOL:==BY==FOREGROUND-COLOR==.IDENTIFICATIONDIVISION.Program-Id.GCMOUSETEST.*>**************************************************************>COBOLTESTTHEMOUSE*>Tectonics:compilewithGnuCOBOL3.1*>Usage:GCMOUSETEST*>Parameters:none*>*>Author:EugenioDiLorenzo-Italia(DILO)-eugenio.dilo@gmail.com*>License:Copyright2019E.DiLorenzo-LGPL,3.0(orgreater)*>Version:1.02019.12.09*>Changelog:1.0firstrelease.*>*************************************************************ENVIRONMENTDIVISION.CONFIGURATIONSECTION.SPECIAL-NAMES.CRTSTATUSISwRetCode.*>ReturnCodefromAccept(es.PFKeys,MouseKeys)CURSORISwRowCol.*>CursorPositionDATADIVISION.FILESECTION.WORKING-STORAGESECTION.*>mousemask,applytoCOB-MOUSE-FLAGS78COB-AUTO-MOUSE-HANDLINGVALUE1.78COB-ALLOW-LEFT-DOWNVALUE2.78COB-ALLOW-LEFT-UPVALUE4.78COB-ALLOW-LEFT-DOUBLEVALUE8.78COB-ALLOW-MIDDLE-DOWNVALUE16.78COB-ALLOW-MIDDLE-UPVALUE32.78COB-ALLOW-MIDDLE-DOUBLEVALUE64.78COB-ALLOW-RIGHT-DOWNVALUE128.78COB-ALLOW-RIGHT-UPVALUE256.78COB-ALLOW-RIGHT-DOUBLEVALUE512.78COB-ALLOW-MOUSE-MOVEVALUE1024.78COB-ALLOW-ALL-SCREEN-ACTIONSVALUE16384.*>reserved*>ValuesthatmaybereturnedinCRTSTATUS(orCOB-CRT-STATUS)*>Functionkeys-Values1xxx78COB-SCR-F3VALUE1003.*>Exceptionkeysformousehandling78COB-SCR-MOUSE-MOVEVALUE2040.78COB-SCR-LEFT-PRESSEDVALUE2041.78COB-SCR-LEFT-RELEASEDVALUE2042.78COB-SCR-LEFT-DBL-CLICKVALUE2043.78COB-SCR-MID-PRESSEDVALUE2044.78COB-SCR-MID-RELEASEDVALUE2045.78COB-SCR-MID-DBL-CLICKVALUE2046.78COB-SCR-RIGHT-PRESSEDVALUE2047.78COB-SCR-RIGHT-RELEASEDVALUE2048.78COB-SCR-RIGHT-DBL-CLICKVALUE2049.01wTTTpic9(15)value0.01wDummyPICXXX.01MOUSE-FLAGSPIC9(4).01wRetCodePIC9(4)value0000.01wRetCodeDescrpicx(23).01wRowColPIC9(6)value0000.01redefineswRowCol.05wRowRPic9(3).05wColRPic9(3).01blackconstantas0.01blueconstantas1.01greenconstantas2.01cyanconstantas3.01redconstantas4.01magentaconstantas5.01yellowconstantas6.*>orBrown01whiteconstantas7.01wIntBINARY-SHORTSIGNED.01wDashes1picx(80)value"1...+....10...+....20...+....30...+....40...+....50...+....60...+....70...+....0".01wTitlepicx(80)value' - GnuCOBOL MOUSE TEST - '.01wRowpic9(02)value0.01wRow2pic9(02)value0.01wColpic9(02)value0.01wCol2pic9(02)value0.01wClickedpic9(02)value0.*>***************************************************************>PROCEDUREDIVISION*>**************************************************************PROCEDUREDIVISION.MAIN1.performInitialSettingsthruInitialSettingsEx*>thisisaninfiniteLOOP.theprogramdetectifamousebuttonisclickedperformforeveracceptwDummyat025080:BCOL:2:FCOL:6*>acceptomittedat025080:BCOL:2:FCOL:6*>thisdoesnotwork!computewRow=wRowRcomputewCol=wColR+1*>(wColRisfrom000to079!)display'Return Code...:'at004037:BCOL:green:FCOL:whiteend-displaydisplaywRetCodeat004053:BCOL:green:FCOL:whiteend-displayevaluatewRetCodewhen2040move'Mouse moved'towRetCodeDescrwhen2041move'Left Button pressed'towRetCodeDescrwhen2042move'Left Button released'towRetCodeDescrwhen2043move'Left Button doubleclick'towRetCodeDescrwhen2044move'Middle button pressed'towRetCodeDescrwhen2045move'Middle button released'towRetCodeDescrwhen2046move'Middle button doubleclick'towRetCodeDescrwhen2047move'Right button pressed'towRetCodeDescrwhen2048move'Right button released'towRetCodeDescrwhen2049move'Right button doubleclick'towRetCodeDescrwhenothermove'Unknown Ret.code 'towRetCodeDescrend-evaluatedisplaywRetCodeDescrat004058:BCOL:green:FCOL:whiteend-displaydisplay'Row & Col.....:'at005037:BCOL:green:FCOL:whiteend-displaydisplaywRowRat005053:BCOL:green:FCOL:whiteend-displaydisplaywColRat005058:BCOL:green:FCOL:whiteend-display*>displayasimbol(paint)thescreenonmousemoveifwRetCode=2040display'*'atlinewRowRcolwColR:BCOL:red:FCOL:whiteend-displayend-ififwRetCode=COB-SCR-F3acceptomittedgotoENDPROGend-if*>testifmousewasontheOKbuttonif(wRow>=21andwRow<=23)and(wCol>=60andwCol<=70)display'+---------+'at021060:BCOL:red:FCOL:whiteend-displaydisplay'| EXIT |'at022060:BCOL:red:FCOL:whiteend-displaydisplay'+---------+'at023060:BCOL:red:FCOL:whiteend-display*>performvaryingwTTTfrom1by1untilwTTT=1000000continueend-performgotoENDPROGend-ifend-performcontinue.ENDPROG.*>display(1,1)' 'ERASE*>display' 'at0101withblankscreenend-display.goback.*>***************************************************************>**>**>**************************************************************InitialSettings.*>setsinordertodetectthePgUp,PgDn,PrtSc(screenprint),Esckeys,setenvironment'COB_SCREEN_EXCEPTIONS'TO'Y'.setenvironment'COB_SCREEN_ESC'TO'Y'.display' 'at0101withblankscreenend-display.*>initializepdcurses*>makemouseactiveCOMPUTEMOUSE-FLAGS=COB-AUTO-MOUSE-HANDLING+COB-ALLOW-LEFT-DOWN+COB-ALLOW-MIDDLE-DOWN+COB-ALLOW-RIGHT-DOWN+COB-ALLOW-LEFT-UP+COB-ALLOW-MIDDLE-UP+COB-ALLOW-RIGHT-UP+COB-ALLOW-LEFT-DOUBLE+COB-ALLOW-MIDDLE-DOUBLE+COB-ALLOW-RIGHT-DOUBLE+COB-ALLOW-MOUSE-MOVESETenvironment"COB_MOUSE_FLAGS"toMOUSE-FLAGS.performHideCursorthruHideCursorExDISPLAY(1,1)' 'ERASEdisplaywTitleat001001:BCOL:Red:FCOL:whitedisplaywDashes1at002001:BCOL:Green:FCOL:Whitemove'10'towDashes1(1:2)displaywDashes1at010001:BCOL:Green:FCOL:Whitemove'15'towDashes1(1:2)displaywDashes1at015001:BCOL:Green:FCOL:Whitemove'20'towDashes1(1:2)displaywDashes1at020001:BCOL:Green:FCOL:White*>buttonareatoclickforEXITdisplay'+---------+'at021060:BCOL:green:FCOL:whiteend-displaydisplay'| EXIT |'at022060:BCOL:green:FCOL:whiteend-displaydisplay'+---------+'at023060:BCOL:green:FCOL:whiteend-displaydisplay'Press F3 or click on the EXIT button to exit'at025001:BCOL:Green:FCOL:Whitecontinue.InitialSettingsEx.exit.HideCursor.*>hidethecursormove0towIntcallstatic"curs_set"usingbyvaluewIntend-callcontinue.HideCursorEx.exit.ENDPROGRAMGCMOUSETEST.
Last edit: Eugenio Di Lorenzo 2019-12-10
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I cannot get the GCMousetest program to compile in MinGW GnuCOBOL. The compile fails on the call to the "curs_set" subprogram. Where or how do you get this subprogram?
Kind regards,
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I suggest to add a note in the source header how to compile/run it, like CBL_OC_DUMP has:
*>---------------------------------------------------------------- *> Authors: Brian Tiffin, Asger Kjelstrup, Simon Sobisch, *> Roger While *> Purpose: Hex Dump display *> Tectonics: cobc -m -std=mf -O2 CBL_OC_DUMP.cob *> Usage: export OC_DUMP_EXT=1 for explanatory text on dumps *> (memory address and dump length) *> export OC_DUMP_EXT=Y for extended explanatory text *> (architecture and endian-order plus above) *>----------------------------------------------------------------
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is the GCMOUSETEST in contrib already? @dilodilo If not - can you please add it with a "tectonics" note?
BTW: I've recheck with the GC31-r3577-VB build using cobc -xj -debug -lpdcurses GCMOUSETEST.cob and on WSL featuring Debian and latest GC 3.1-dev using cobc -xj -debug -lncursesw GCMOUSETEST.cob, both compile and work - but the wsl version does not raise the mouse move events (not sure what part is to blame for this).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Simon, GCMOUSETEST is not in the " contrib " because it is just a "test".
I am waiting for a GnuCOBOL release that correctly manages the "MOVE" event because I am developing a working "drag & drop" program in a TUI screen
(mouse MOVE works fine with PDCURSES 4.1 but not with PDCURSES 3.9)
but Unfortunately pdcurses 4.1 has other problems on colors .
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It seems to me that the colors issues were only because of "wrong built" GnuCOBOL with PDcurses 4.1. @arn79 Can you produce a newer one in one or two days allowing others to verify before both PDcurses has its 4.2 release and GC its 3.1rc?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
See my other posting. It looks like there is a problem with the newest GC31-dev tarball. I can try PDCurses 4.1.99 (2020-06-10) with a version of GC3-devl that is a few days older, but that's probably not ideal...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Arnold - I've just (this morning) downloaded the latest 3.1 dev - together with the latest 4.1.99 and provided I don't try CHTYPE_64=Y in the gui mode it all works fine,
So - CHT 32 in console & gui & CHT64 in console all work fine.
The ./configure I've already told you about so that should be ok & the -lpdcurses in the cobc command is shown above.
What 'other' problems are there ??.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
DiLo, 4.1.99 works fine for me with colours - provided 'at present' it's built with either CHTYPE_32=Y in console or graphic mode - OR - CHTYPE_64=Y in console mode only.
There 'does' seem to be a problem with CHTYPE_64 in graphic mode (no display at all) - but I've reported that to Bill Gray - #152.
I haven't investigated using WIDE=Y or UTF8=Y yet - because I don't use those modes.
I'm out at present (wife in hospital) but hope to be home later today & will try & drop a basic version somewhere useable.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This program activates the mouse and displays some mouse events.
If a key was pressed, which mouse button was pressed (right, left, central).
If a mouse button is held down while the mouse is being moved, it displays the "mouse move" event and the coordinates (row and column) of the mouse position while the mouse is moved.
I think this program shows some bugs.
BUG1. I press a mouse button and hold it down. The program correctly displays the key pressed. Now, while the key is pressed the mouse is moved.
When the button is released, the system DOES NOT display the "key released" event.
BUG2.
If I use the ACCEPT OMITTED statement instead of ACCEPT WDUMMY, the system does not activate the mouse.
BUG3.
left doubleclick on any position returns 0000 and row / col = 25/79.
right doubleclick or middle doubleclick does not works.
Last edit: Eugenio Di Lorenzo 2019-12-09
Well met, Eugenio
But I think you're avoiding the inevitable using an ACCEPT to get control of the mouse. You did it, but while pressing a button key. So far, so good. But you need the "getch" macro to take full control of the mouse movement (whether you want it or not). The problem is that "getch" is already taken by "screenio.c" and what you want to do is bypass it anyway, Even you can exploit the "weaknesses" of the system, one day or other this will change and you will not be able to do it again. But one can always try :-). In my point of view, the only way to do the "thing" is, someday, someone disable the mouse control and pass to the programmer an ENTRY point (address) using a "CALL" -or- "ENTRY" statement where you can do what you want without restrictions. (I'm guessing "soon(ish)"). Anyway ... :-)
By the way, the MOUSE RELEASE does not exist. We can only deduce it by the inactivity of any mouse buttons after they were changed (pressed). This is similar to pressing CTRL/SHIFT/ALT key and then release it (and yes, you can use these with the mouse). You can see it in "demos/testcurs,c" (feel free to see "void inputTest(WINDOW *win") part of the source code.
This is the piece of code that explains the procedure:
I'm hopping to make some sense !!!
Well met, Eugenio :-)
Cheers,
MM
Last edit: Simon Sobisch 2019-12-10
Hi Mario,
I'm trying to understand the situation regarding the use of the mouse with GnuCOBOL but it's not easy. From what cdg has written and from the available documentation, the GnuCOBOL compiler (like other COBOL compilers) now supports the use of the mouse without having to call components in C. Is this correct or not?
I think it's correct.
Infact I developed the test program I posted above.
It works well for left, right, middle (key pressed), mouse move ... I move the mouse and in real time the system shows me the position of the mouse while I move it! It's perfect !
Please, try to compile and run the source I posted ..
I indicated that it doesn't work for "released" and that I think it's a bug. Now I expect it can be verified and corrected.
I don't understand why others are proceeding to develop pieces of C code just to handle mouse events. At most it would have been interesting to "call" the mouse functions of pdcurses library. It was my request some time ago, but I didn't understand why it seems impossible. Many posts followed, but no one made it clear why I can't use a "call static somemousefunction (xxxxxxx)"
Ciao.
Last edit: Eugenio Di Lorenzo 2019-12-10
Ciao Eugenio,
In my case, it is because the GC "ACCEPT" doesn't do what I need it to do, or would have required extensive modification of the 265 programs I was converting, so I used my "termio" subroutine (written 30 years ago, and modified many times over the years), and modified it to use "getch" (rather than an MS-DOS interrupt) to read and interpret single keystrokes from the keyboard.
Similarly, the GC mouse interface doesn't provide detection of mouse clicks, which is the only thing that I need from the mouse. So I modified the mouse interface in my termio program to use pdcurses as well. And, while I was doing that, I added additional mouse functions, so that others might benefit from it if they needed.
The reason why we can't call the mouse functions of pdcurses (or getch) directly from a Cobol program (and thus need a C "wrapper") is that they are macros, or they require macros. Macros invoke multiple functions and other macros, which invoke multiple functions and other macros, and use data types that are alien to Cobol. It would theoretically be possible to call them from a Cobol program, but it would take multiple function calls, with various data manipulations, and thus is not practical.
A general note to the missing description (in the hope the cdg and Dave read along), you may want to check ACUCOBOL's Unmasking mouse actions and Microfocus mouse handling, along with the entries from screenio.cpy and runtime.cfg
double-click
COB-ALLOW-LEFT-DOUBLEaction was not specified and in this case screenio does an auto-translation to "enter"ACCEPT at posCOB-ALLOW-LEFT-UPACCEPT OMITTEDmay raise errors in the future if you specify a colorACCEPT OMITTEDI did not take care of this part when implementing the mouse handling in the first place.ACCEPT OMITTED, what is the general thought on this?General note: anyone willing to add
W$MOUSEandCBL_MOUSE_library calls to GnuCOBOL? I've tried to ensure that anything is already setup to provide these - without conflicting with the currentACCEPTimplementation.Last edit: Simon Sobisch 2019-12-11
Thanks Simon,
wonderful !
simple and clear.
no bugs !
all the buttons and all the mouse events works wonderfully!
Without any use of C wrappers. Only pure COBOL.
New SOURCE with corrections and some enhancements (move the mouse & paint the screen)
Last edit: Eugenio Di Lorenzo 2019-12-10
I cannot get the GCMousetest program to compile in MinGW GnuCOBOL. The compile fails on the call to the "curs_set" subprogram. Where or how do you get this subprogram?
Kind regards,
I'd have thought it would just work - it does on my PDC4199 Console using Gnu3.1 - what versions are you using.
curs_set is found in the pdcurses.dll
My cobc command line includes it automatically :
Cobc -F -x -d -O0 %PRG%.cod -lpdcurses 2>%~n1.ERR
Compile to .exe without any optimisation and any errors to prog.err.
sorry I took so long to reply.
Last edit: David Wall 2020-06-07
I suggest to add a note in the source header how to compile/run it, like CBL_OC_DUMP has:
Is the GCMOUSETEST in contrib already? @dilodilo If not - can you please add it with a "tectonics" note?
BTW: I've recheck with the GC31-r3577-VB build using
cobc -xj -debug -lpdcurses GCMOUSETEST.coband on WSL featuring Debian and latest GC 3.1-dev usingcobc -xj -debug -lncursesw GCMOUSETEST.cob, both compile and work - but the wsl version does not raise the mouse move events (not sure what part is to blame for this).Hi Simon, GCMOUSETEST is not in the " contrib " because it is just a "test".
I am waiting for a GnuCOBOL release that correctly manages the "MOVE" event because I am developing a working "drag & drop" program in a TUI screen
(mouse MOVE works fine with PDCURSES 4.1 but not with PDCURSES 3.9)
but Unfortunately pdcurses 4.1 has other problems on colors .
It seems to me that the colors issues were only because of "wrong built" GnuCOBOL with PDcurses 4.1. @arn79 Can you produce a newer one in one or two days allowing others to verify before both PDcurses has its 4.2 release and GC its 3.1rc?
See my other posting. It looks like there is a problem with the newest GC31-dev tarball. I can try PDCurses 4.1.99 (2020-06-10) with a version of GC3-devl that is a few days older, but that's probably not ideal...
Arnold - I've just (this morning) downloaded the latest 3.1 dev - together with the latest 4.1.99 and provided I don't try CHTYPE_64=Y in the gui mode it all works fine,
So - CHT 32 in console & gui & CHT64 in console all work fine.
The ./configure I've already told you about so that should be ok & the -lpdcurses in the cobc command is shown above.
What 'other' problems are there ??.
DiLo, 4.1.99 works fine for me with colours - provided 'at present' it's built with either CHTYPE_32=Y in console or graphic mode - OR - CHTYPE_64=Y in console mode only.
There 'does' seem to be a problem with CHTYPE_64 in graphic mode (no display at all) - but I've reported that to Bill Gray - #152.
I haven't investigated using WIDE=Y or UTF8=Y yet - because I don't use those modes.
I'm out at present (wife in hospital) but hope to be home later today & will try & drop a basic version somewhere useable.
GC99MOUSEDEMO.COB now in loaded at SVN/Contributions/trunk/tools/TUI-TOOLS.
It shows mouse programming in TUI mode with GnuCOBOL.