Menu

MOUSE TEST (& 2 bugs ?)

2019-12-09
2020-06-13
  • Eugenio Di Lorenzo

    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.

           >>SOURCE FORMAT IS FREE
           REPLACE ==:BCOL:== BY ==with BACKGROUND-COLOR==
                   ==:FCOL:== BY ==FOREGROUND-COLOR==.
    IDENTIFICATION DIVISION.
    Program-Id. GCMOUSETEST.
    *> *************************************************************
    *> COBOL TEST THE MOUSE
    *> Tectonics:  compile with GnuCOBOL 3.1
    *> Usage:      GCMOUSETEST
    *> Parameters: none
    *>
    *> Author:     Eugenio Di Lorenzo - Italia (DILO) - eugenio.dilo@gmail.com
    *> License:    Copyright 2019 E.Di Lorenzo - LGPL, 3.0 (or greater)
    *> Version:    1.0 2019.12.09
    *> Changelog:  1.0 first release.
    *> *************************************************************
    ENVIRONMENT DIVISION.
    CONFIGURATION SECTION.
    SPECIAL-NAMES.
       CRT STATUS IS wRetCode.  *> Return Code from Accept(es. PF Keys, Mouse Keys)
       CURSOR     IS wRowCol.   *> Cursor Position
    
    DATA DIVISION.
    FILE SECTION.
    WORKING-STORAGE SECTION.
    *>   mouse mask, apply to COB-MOUSE-FLAGS
    78  COB-AUTO-MOUSE-HANDLING          VALUE 1.
    78  COB-ALLOW-LEFT-DOWN              VALUE 2.
    78  COB-ALLOW-LEFT-UP                VALUE 4.
    78  COB-ALLOW-LEFT-DOUBLE            VALUE 8.
    78  COB-ALLOW-MIDDLE-DOWN            VALUE 16.
    78  COB-ALLOW-MIDDLE-UP              VALUE 32.
    78  COB-ALLOW-MIDDLE-DOUBLE          VALUE 64.
    78  COB-ALLOW-RIGHT-DOWN             VALUE 128.
    78  COB-ALLOW-RIGHT-UP               VALUE 256.
    78  COB-ALLOW-RIGHT-DOUBLE           VALUE 512.
    78  COB-ALLOW-MOUSE-MOVE             VALUE 1024.
    78  COB-ALLOW-ALL-SCREEN-ACTIONS     VALUE 16384. *> reserved
    
    *> Values that may be returned in CRT STATUS (or COB-CRT-STATUS)
    *>  Function keys - Values 1xxx
    78  COB-SCR-F3                       VALUE  1003.
    
    *>  Exception keys for mouse handling
    78  COB-SCR-MOUSE-MOVE               VALUE  2040.
    78  COB-SCR-LEFT-PRESSED             VALUE  2041.
    78  COB-SCR-LEFT-RELEASED            VALUE  2042.
    78  COB-SCR-LEFT-DBL-CLICK           VALUE  2043.
    78  COB-SCR-MID-PRESSED              VALUE  2044.
    78  COB-SCR-MID-RELEASED             VALUE  2045.
    78  COB-SCR-MID-DBL-CLICK            VALUE  2046.
    78  COB-SCR-RIGHT-PRESSED            VALUE  2047.
    78  COB-SCR-RIGHT-RELEASED           VALUE  2048.
    78  COB-SCR-RIGHT-DBL-CLICK          VALUE  2049.
    
    01  wDummy        PIC XXX.
    01  MOUSE-FLAGS   PIC 9(4).
    01  wRetCode      PIC 9(4) value 0000.
    01  wRetCodeDescr pic x(20).
    01  wRowCol       PIC 9(6) value 0000.
    01  redefines wRowCol .
        05 wRowR      Pic 9(3).
        05 wColR      Pic 9(3).
    
    01 black   constant as 0.
    01 blue    constant as 1.
    01 green   constant as 2.
    01 cyan    constant as 3.
    01 red     constant as 4.
    01 magenta constant as 5.
    01 yellow  constant as 6.  *> or Brown
    01 white   constant as 7.
    
    01   wInt         BINARY-SHORT SIGNED.
    01   wDashes1 pic x(80) value "1...+....10...+....20...+....30...+....40...+....50...+....60...+....70...+....0".
    01   wTitle      pic x(80) value '                          - GnuCOBOL MOUSE TEST -  '.
    01   wRow        pic 9(02) value  0.
    01   wRow2       pic 9(02) value  0.
    01   wCol        pic 9(02) value  0.
    01   wCol2       pic 9(02) value  0.
    01   wClicked    pic 9(02) value  0.
    
    *> **************************************************************
    *>           P R O C E D U R E   D I V I S I O N
    *> **************************************************************
    PROCEDURE DIVISION.
    MAIN1.
      perform InitialSettings thru InitialSettingsEx
    
      *> this is an infinite LOOP. the program detect if a mouse button is clicked
      perform forever
          accept wDummy at 025080 :BCOL: 2  :FCOL: 6
          *> accept omitted at 025080 :BCOL: 2  :FCOL: 6  *> this does not work !
    
          compute wRow = wRowR
          compute wCol = wColR + 1  *> (wColR is from 000 to 079 !)  
    
          display 'Return Code...:' at 004037 :BCOL: green :FCOL: white end-display
          display wRetCode          at 004053 :BCOL: green :FCOL: white end-display
    
          evaluate wRetCode
                   when 2040  move 'Mouse moved'        to wRetCodeDescr
                   when 2041  move 'Left Button'        to wRetCodeDescr
                   when 2047  move 'Right button'       to wRetCodeDescr
                   when 2044  move 'Middle button'      to wRetCodeDescr
                   when other move 'Unknown Ret.code '  to wRetCodeDescr
          end-evaluate
          display wRetCodeDescr  at 004059 :BCOL: green :FCOL: white end-display
    
          display 'Row & Col.....:' at 005037 :BCOL: green :FCOL: white end-display
          display wRowR             at 005053 :BCOL: green :FCOL: white end-display
          display wColR             at 005059 :BCOL: green :FCOL: white end-display
    
          if wRetCode =  COB-SCR-F3 accept omitted go to ENDPROG end-if
    
          *> test if mouse was on the OK button
          if  (wRow >= 21 and wRow <= 23) and (wCol >= 60 and wCol <= 70)
              then go to ENDPROG
          end-if
      end-perform
      continue.
    
    ENDPROG.
      *> display (1, 1)  ' ' ERASE
      display ' ' at 0101 with blank screen end-display. 
      goback.
    
    *>* *************************************************************
    *>*
    *>*
    *>* *************************************************************
    InitialSettings.
      *> sets in order to detect the PgUp, PgDn, PrtSc(screen print), Esc keys,
      set environment 'COB_SCREEN_EXCEPTIONS' TO 'Y'.
      set environment 'COB_SCREEN_ESC'        TO 'Y'.
      display ' ' at 0101 with blank screen end-display. *> initialize pdcurses
    
      *> make mouse active
      COMPUTE MOUSE-FLAGS = COB-AUTO-MOUSE-HANDLING + COB-ALLOW-LEFT-DOWN + COB-ALLOW-MIDDLE-DOWN
                          + COB-ALLOW-RIGHT-DOWN    + COB-ALLOW-MOUSE-MOVE
      SET environment     "COB_MOUSE_FLAGS"         to MOUSE-FLAGS.
    
      perform HideCursor thru HideCursorEx
      DISPLAY (1, 1)  ' ' ERASE
      display wTitle    at 001001 :BCOL: Red :FCOL: white
    
      display wDashes1  at 002001 :BCOL: Green :FCOL: White
      move    '10'      to wDashes1 (1:2)
      display wDashes1  at 010001 :BCOL: Green :FCOL: White
      move    '15'      to wDashes1 (1:2)
      display wDashes1  at 015001 :BCOL: Green :FCOL: White
      move    '20'      to wDashes1 (1:2)
      display wDashes1  at 020001 :BCOL: Green :FCOL: White
    
      *> button area to click for EXIT
      display (21, 60) '+---------+'
      display (22, 60) '|  EXIT   |'
      display (23, 60) '+---------+'
      display 'Press F3 or click on the EXIT button to exit' at 025001 :BCOL: Green :FCOL: White
      continue.
    InitialSettingsEx. exit.
    
    HideCursor.
        *> hide the cursor
        move 0 to wInt
        call static "curs_set" using by value wInt end-call
        continue.
    HideCursorEx. exit.
    
    END PROGRAM GCMOUSETEST.
    
     

    Last edit: Eugenio Di Lorenzo 2019-12-09
    • Mário Matos

      Mário Matos - 2019-12-10

      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:

                  if (MOUSE_MOVED)
                      waddstr(win, "moved: ");
                  else if (MOUSE_POS_REPORT)
                      waddstr(win, "Posn report: ");
                  else if (MOUSE_WHEEL_UP)
                      waddstr(win, "wheel up: ");
                  else if (MOUSE_WHEEL_DOWN)
                      waddstr(win, "wheel dn: ");
      \#ifdef MOUSE_WHEEL_LEFT
                  else if (MOUSE_WHEEL_LEFT)
                      waddstr(win, "wheel lt: ");
      \#endif
      \#ifdef MOUSE_WHEEL_RIGHT
                  else if (MOUSE_WHEEL_RIGHT)
                      waddstr(win, "wheel rt: ");
      \#endif
                  else if ((status & BUTTON_ACTION_MASK) == BUTTON_PRESSED)
                      waddstr(win, "pressed: ");
                  else if ((status & BUTTON_ACTION_MASK) == BUTTON_CLICKED)
                      waddstr(win, "clicked: ");
                  else if ((status & BUTTON_ACTION_MASK) == BUTTON_DOUBLE_CLICKED)
                      waddstr(win, "double: ");
                  else if ((status & BUTTON_ACTION_MASK) == BUTTON_TRIPLE_CLICKED)
                      waddstr(win, "triple: ");
                  else if( 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");
              }
              else if (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");
      
      \#ifdef PDC_KEY_MODIFIER_REPEAT
                  if (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
  • Eugenio Di Lorenzo

    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
    • cdg

      cdg - 2019-12-11

      Ciao Eugenio,

      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.

       
  • Simon Sobisch

    Simon Sobisch - 2019-12-10

    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

    1. 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"
    2. this "enter" does not change the program's cursor position which gets initialized by your ACCEPT at pos
    3. similar you don't get a release because you did not included the COB-ALLOW-LEFT-UP
    4. note to the code: ACCEPT OMITTED may raise errors in the future if you specify a color
    5. 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.
    6. 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.
    7. 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
    • Eugenio Di Lorenzo

      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)

             >>SOURCE FORMAT IS FREE
             REPLACE ==:BCOL:== BY ==with BACKGROUND-COLOR==
                     ==:FCOL:== BY ==FOREGROUND-COLOR==.
      IDENTIFICATION DIVISION.
      Program-Id. GCMOUSETEST.
      *> *************************************************************
      *> COBOL TEST THE MOUSE
      *> Tectonics:  compile with GnuCOBOL 3.1
      *> Usage:      GCMOUSETEST
      *> Parameters: none
      *>
      *> Author:     Eugenio Di Lorenzo - Italia (DILO) - eugenio.dilo@gmail.com
      *> License:    Copyright 2019 E.Di Lorenzo - LGPL, 3.0 (or greater)
      *> Version:    1.0 2019.12.09
      *> Changelog:  1.0 first release.
      *> *************************************************************
      ENVIRONMENT DIVISION.
      CONFIGURATION SECTION.
      SPECIAL-NAMES.
         CRT STATUS IS wRetCode.  *> Return Code from Accept(es. PF Keys, Mouse Keys)
         CURSOR     IS wRowCol.   *> Cursor Position
      
      DATA DIVISION.
      FILE SECTION.
      WORKING-STORAGE SECTION.
      *>   mouse mask, apply to COB-MOUSE-FLAGS
      78  COB-AUTO-MOUSE-HANDLING          VALUE 1.
      78  COB-ALLOW-LEFT-DOWN              VALUE 2.
      78  COB-ALLOW-LEFT-UP                VALUE 4.
      78  COB-ALLOW-LEFT-DOUBLE            VALUE 8.
      78  COB-ALLOW-MIDDLE-DOWN            VALUE 16.
      78  COB-ALLOW-MIDDLE-UP              VALUE 32.
      78  COB-ALLOW-MIDDLE-DOUBLE          VALUE 64.
      78  COB-ALLOW-RIGHT-DOWN             VALUE 128.
      78  COB-ALLOW-RIGHT-UP               VALUE 256.
      78  COB-ALLOW-RIGHT-DOUBLE           VALUE 512.
      78  COB-ALLOW-MOUSE-MOVE             VALUE 1024.
      78  COB-ALLOW-ALL-SCREEN-ACTIONS     VALUE 16384. *> reserved
      
      *> Values that may be returned in CRT STATUS (or COB-CRT-STATUS)
      *>  Function keys - Values 1xxx
      78  COB-SCR-F3                       VALUE  1003.
      
      *>  Exception keys for mouse handling
      78  COB-SCR-MOUSE-MOVE               VALUE  2040.
      78  COB-SCR-LEFT-PRESSED             VALUE  2041.
      78  COB-SCR-LEFT-RELEASED            VALUE  2042.
      78  COB-SCR-LEFT-DBL-CLICK           VALUE  2043.
      78  COB-SCR-MID-PRESSED              VALUE  2044.
      78  COB-SCR-MID-RELEASED             VALUE  2045.
      78  COB-SCR-MID-DBL-CLICK            VALUE  2046.
      78  COB-SCR-RIGHT-PRESSED            VALUE  2047.
      78  COB-SCR-RIGHT-RELEASED           VALUE  2048.
      78  COB-SCR-RIGHT-DBL-CLICK          VALUE  2049.
      
      01  wTTT          pic 9(15) value 0.
      01  wDummy        PIC XXX.
      01  MOUSE-FLAGS   PIC 9(4).
      01  wRetCode      PIC 9(4) value 0000.
      01  wRetCodeDescr pic x(23).
      01  wRowCol       PIC 9(6) value 0000.
      01  redefines wRowCol .
          05 wRowR      Pic 9(3).
          05 wColR      Pic 9(3).
      
      01 black   constant as 0.
      01 blue    constant as 1.
      01 green   constant as 2.
      01 cyan    constant as 3.
      01 red     constant as 4.
      01 magenta constant as 5.
      01 yellow  constant as 6.  *> or Brown
      01 white   constant as 7.
      
      01   wInt         BINARY-SHORT SIGNED.
      01   wDashes1 pic x(80) value "1...+....10...+....20...+....30...+....40...+....50...+....60...+....70...+....0".
      01   wTitle      pic x(80) value '                          - GnuCOBOL MOUSE TEST -  '.
      01   wRow        pic 9(02) value  0.
      01   wRow2       pic 9(02) value  0.
      01   wCol        pic 9(02) value  0.
      01   wCol2       pic 9(02) value  0.
      01   wClicked    pic 9(02) value  0.
      
      *> **************************************************************
      *>           P R O C E D U R E   D I V I S I O N
      *> **************************************************************
      PROCEDURE DIVISION.
      MAIN1.
        perform InitialSettings thru InitialSettingsEx
      
        *> this is an infinite LOOP. the program detect if a mouse button is clicked
        perform forever
            accept wDummy at 025080 :BCOL: 2  :FCOL: 6
            *> accept omitted at 025080 :BCOL: 2  :FCOL: 6  *> this does not work !
      
            compute wRow = wRowR
            compute wCol = wColR + 1  *> (wColR is from 000 to 079 !)
      
            display 'Return Code...:' at 004037 :BCOL: green :FCOL: white end-display
            display wRetCode          at 004053 :BCOL: green :FCOL: white end-display
      
            evaluate wRetCode
                     when 2040  move 'Mouse moved'                to wRetCodeDescr
                     when 2041  move 'Left Button pressed'        to wRetCodeDescr
                     when 2042  move 'Left Button released'       to wRetCodeDescr
                     when 2043  move 'Left Button doubleclick'    to wRetCodeDescr
                     when 2044  move 'Middle button pressed'      to wRetCodeDescr
                     when 2045  move 'Middle button released'     to wRetCodeDescr
                     when 2046  move 'Middle button doubleclick'   to wRetCodeDescr
                     when 2047  move 'Right button pressed'       to wRetCodeDescr
                     when 2048  move 'Right button released'      to wRetCodeDescr
                     when 2049  move 'Right button doubleclick'   to wRetCodeDescr
                     when other move 'Unknown Ret.code '          to wRetCodeDescr
            end-evaluate
            display wRetCodeDescr  at 004058 :BCOL: green :FCOL: white end-display
      
            display 'Row & Col.....:' at 005037 :BCOL: green :FCOL: white end-display
            display wRowR             at 005053 :BCOL: green :FCOL: white end-display
            display wColR             at 005058 :BCOL: green :FCOL: white end-display
      
            *> display a simbol (paint) the screen on mouse move
            if wRetCode = 2040
               display '*' at line wRowR col wColR :BCOL: red :FCOL: white end-display
            end-if
      
            if wRetCode =  COB-SCR-F3 accept omitted go to ENDPROG end-if
      
            *> test if mouse was on the OK button
            if  (wRow >= 21 and wRow <= 23) and (wCol >= 60 and wCol <= 70)
                display '+---------+' at 021060 :BCOL: red :FCOL: white end-display
                display '|  EXIT   |' at 022060 :BCOL: red :FCOL: white end-display
                display '+---------+' at 023060 :BCOL: red :FCOL: white end-display
                *>perform varying wTTT from 1 by 1 until wTTT = 1000000 continue end-perform     
                go to ENDPROG
            end-if
        end-perform
        continue.
      
      ENDPROG.
        *> display (1, 1)  ' ' ERASE
        *> display ' ' at 0101 with blank screen end-display.
        goback.
      
      *>* *************************************************************
      *>*
      *>*
      *>* *************************************************************
      InitialSettings.
        *> sets in order to detect the PgUp, PgDn, PrtSc(screen print), Esc keys,
        set environment 'COB_SCREEN_EXCEPTIONS' TO 'Y'.
        set environment 'COB_SCREEN_ESC'        TO 'Y'.
        display ' ' at 0101 with blank screen end-display. *> initialize pdcurses
      
        *> make mouse active
        COMPUTE MOUSE-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-MOVE
        SET environment     "COB_MOUSE_FLAGS"         to MOUSE-FLAGS.
      
        perform HideCursor thru HideCursorEx
        DISPLAY (1, 1)  ' ' ERASE
        display wTitle    at 001001 :BCOL: Red :FCOL: white
      
        display wDashes1  at 002001 :BCOL: Green :FCOL: White
        move    '10'      to wDashes1 (1:2)
        display wDashes1  at 010001 :BCOL: Green :FCOL: White
        move    '15'      to wDashes1 (1:2)
        display wDashes1  at 015001 :BCOL: Green :FCOL: White
        move    '20'      to wDashes1 (1:2)
        display wDashes1  at 020001 :BCOL: Green :FCOL: White
      
        *> button area to click for EXIT
        display '+---------+' at 021060 :BCOL: green :FCOL: white end-display
        display '|  EXIT   |' at 022060 :BCOL: green :FCOL: white end-display
        display '+---------+' at 023060 :BCOL: green :FCOL: white end-display
        display 'Press F3 or click on the EXIT button to exit' at 025001 :BCOL: Green :FCOL: White
        continue.
      InitialSettingsEx. exit.
      
      HideCursor.
          *> hide the cursor
          move 0 to wInt
          call static "curs_set" using by value wInt end-call
          continue.
      HideCursorEx. exit.
      
      END PROGRAM GCMOUSETEST.
      
       

      Last edit: Eugenio Di Lorenzo 2019-12-10
      • Arnold Trembley

        Arnold Trembley - 2020-06-07

        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,

         
        • David Wall

          David Wall - 2020-06-07

          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
          • Simon Sobisch

            Simon Sobisch - 2020-06-07

            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)
                  *>----------------------------------------------------------------
            
             
  • Simon Sobisch

    Simon Sobisch - 2020-06-10

    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).

     
    • Eugenio Di Lorenzo

      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 .

       
      • Simon Sobisch

        Simon Sobisch - 2020-06-10

        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?

         
        • Arnold Trembley

          Arnold Trembley - 2020-06-11

          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...

           
          • David Wall

            David Wall - 2020-06-11

            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 ??.

             
      • David Wall

        David Wall - 2020-06-10

        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.

         
    • Eugenio Di Lorenzo

      GC99MOUSEDEMO.COB now in loaded at SVN/Contributions/trunk/tools/TUI-TOOLS.
      It shows mouse programming in TUI mode with GnuCOBOL.

       

Log in to post a comment.