home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / p2demo21.exe / PEL / WRKFRAME.PEL < prev   
Text File  |  1995-04-05  |  7KB  |  254 lines

  1. # $Header:   P:\source\wmacros\wrkframe.pev   1.25   05 Apr 1995 13:54:54   WALKER  $
  2. ## $Tabs:4 7$
  3.  
  4. ##############################################################################
  5. #
  6. #       Compuware Corporation
  7. #         31440 Northwestern Highway
  8. #           Farmington Hills, Michigan 48334-2564
  9. #
  10. #   This source code listing contains information that is
  11. #   proprietary to Compuware Corporation and may not be copied
  12. #   duplicated, translated, transmitted, stored, retrieved
  13. #   or in any manner or by any method conveyed or disclosed
  14. #   to a third party or parties without express written
  15. #   permission from Compuware Corporation.
  16. #
  17. #  
  18. ##############################################################################
  19.  
  20. local wf_serverid = 0
  21. # error list buffer name by magic_cookie
  22. local wf_errors[]
  23. local wf_error_buffers[]
  24. local wf_current_error
  25. local wf_next_markid
  26.  
  27. local MIN_WF_MARKID =  100
  28. local MAX_WF_MARKID =  980
  29.  
  30. global function initialize_wf_dde()
  31. {
  32.    wf_current_error = 0
  33.    wf_next_markid   = MIN_WF_MARKID
  34.  
  35.  
  36.    if ( !wf_serverid ) {
  37.       wf_serverid = create_dde_server("WB Editor", function_id("wf_dde_callback"))
  38.       if ( !wf_serverid )
  39.       {
  40.          error("Unable to create DDE server WB Editor")
  41.          return;
  42.       }
  43.       
  44.       delete wf_errors
  45.       attach_event_handler(EVENT.DELETING_BUFFER, function_id("wf_delete_buffer"))
  46.    }
  47. }
  48.  
  49. global function wf_delete_buffer()
  50. {
  51.    local arr[]
  52.    local i
  53.  
  54.  
  55.    # this will delete all the marks contained in the errors array
  56.    # that were associated with this buffer
  57.    if ( buffer_filename in wf_error_buffers ) {
  58.       remove_dde_server_topic( wf_serverid, buffer_filename );
  59.  
  60.       while ( i in wf_errors ) {
  61.          if ( split( wf_errors[i], arr ) > 0 ) {
  62.             if ( arr[1] == buffer_filename ) {
  63.                delete_mark( arr[2] )
  64.                delete wf_errors[i]
  65.             }
  66.          }
  67.       }
  68.    }
  69. }
  70.  
  71. global function wf_goto_next_error()
  72. {
  73.    local stop_loop = 0
  74.    local i
  75.  
  76.    for ( i in wf_errors ) {
  77.       if ( stop_loop == 1 )
  78.          break
  79.  
  80.       if ( i == wf_current_error )
  81.          stop_loop = 1
  82.    }
  83.  
  84.    if ( ( wf_current_error == 0 && i ) || ( stop_loop == 1 && wf_current_error != i ) ) {
  85.       wf_current_error = i
  86.       get_workframe_error_info(wf_serverid, buffer_filename, wf_current_error)
  87.    }
  88.    else {
  89.       message("No more errors.")
  90.    }  
  91. }
  92.  
  93. global function wf_goto_prev_error()
  94. {
  95.    local stop_loop = 0
  96.    local i
  97.    local prev_error = 0
  98.  
  99.    for ( i in wf_errors ) {
  100.       if ( i == wf_current_error )
  101.          stop_loop = 1
  102.  
  103.       if ( stop_loop == 1 )
  104.          break
  105.  
  106.       prev_error = i
  107.    }
  108.  
  109. #   if ( stop_loop == 1 && prev_error != 0 ) {
  110.    if ( prev_error != 0 ) {
  111.       wf_current_error = prev_error
  112.       get_workframe_error_info(wf_serverid, buffer_filename, wf_current_error)
  113.    }
  114.    else {
  115.       message("No more errors.")
  116.    }  
  117. }
  118.  
  119. global function wf_dde_callback()
  120. {
  121.    local topicid, topicname
  122.    local arr[]
  123.    local ddename, numerrors, errorline, errortext, erroroffset, errorlength
  124.    local magic_cookie
  125.    local dde_data
  126.    local libraryname
  127.  
  128.    if ( dde_callback_action(wf_serverid) == DDE_INITIATE ) {
  129.  
  130.       topicid = create_dde_topic( dde_callback_topic(wf_serverid) )  
  131.       if ( !topicid ) {
  132.          warning("Unable to create dde topic");
  133.          return;
  134.       }
  135.  
  136.       if ( !add_dde_item(topicid, "Initialize") ) {
  137.          warning("Unable to add DDE item Initialize");
  138.          return;
  139.       }
  140.  
  141.       if ( !add_dde_item(topicid, "Goto") ) {
  142.          warning("Unable to add DDE item Goto");
  143.          return;
  144.       }
  145.  
  146.       if ( !add_dde_item(topicid, "SendGoto") ) {
  147.          warning("Unable to add DDE item SendGoto");
  148.          return;
  149.       }
  150.          
  151.       if ( !add_dde_server_topic(wf_serverid, topicid) ) {
  152.          warning("Unable to add DDE server topic");
  153.          return;
  154.       }
  155.    }
  156.    else if ( dde_callback_action(wf_serverid) == DDE_EXECUTE ) {
  157.       if ( dde_callback_item(wf_serverid) == "Goto" ) {
  158.  
  159.          if ( mdi_mode != 2 )
  160.             set_editwin_property( EWC_TO_TOP )  # bring editwin to top of window stack
  161.  
  162.          dde_data     = dde_callback_data(wf_serverid)
  163.  
  164.          ddename      = strtok(dde_data, ";")
  165.          errorline    = atoi(strtok())
  166.          erroroffset  = atoi(strtok()) + 1
  167.          magic_cookie = atoi(strtok())
  168.          errortext    = strtok()
  169.  
  170.          wf_current_error = magic_cookie
  171.  
  172.          # we have to loop through all our known topic names because the
  173.          # IBM WorkFrame does not send the topic name correctly
  174.          if ( magic_cookie in wf_errors ) {
  175.             if ( split( wf_errors[magic_cookie], arr ) > 0 )
  176.             {
  177.                unhilight_temp_selection()
  178.                update_current_view()
  179.  
  180.                create_buf_and_win(arr[1])
  181.                goto_mark(arr[2])
  182.  
  183.                update_current_view()
  184.  
  185.                create_linecol_selection(3, errorline, 0, errorline, 0)
  186.  
  187.                message(errortext)
  188.             }
  189.             else if ( ddename != "" )
  190.             {
  191.                unhilight_temp_selection()
  192.                update_current_view()
  193.  
  194.                create_buf_and_win(ddename)
  195.                update_current_view()
  196.  
  197.                create_linecol_selection(3, errorline, 0, errorline, 0)
  198.  
  199.                message(errortext)
  200.             }
  201.          }
  202.          else if ( ddename != "" )
  203.          {
  204.             unhilight_temp_selection()
  205.             update_current_view()
  206.  
  207.             create_buf_and_win(ddename)
  208.             update_current_view()
  209.  
  210.             create_linecol_selection(3, errorline, 0, errorline, 0)
  211.  
  212.             message(errortext)
  213.          }
  214.  
  215.          update_current_view()
  216.          #display_redraw()
  217.       }
  218.       else if ( dde_callback_item(wf_serverid) == "Initialize" )
  219.       {
  220.          dde_data = dde_callback_data(wf_serverid)
  221.  
  222.          numerrors = atoi( strtok(dde_data, ";") )
  223.  
  224.          while (numerrors > 0 ) {
  225.             errorline    = atoi( strtok() )
  226.             erroroffset  = atoi( strtok() ) + 1
  227.             errorlength  = strtok()
  228.             magic_cookie = atoi(strtok())
  229.  
  230.             wf_next_markid++
  231.  
  232.             while ( mark_defined(wf_next_markid) != 0 ) {
  233.                wf_next_markid++
  234.                if ( wf_next_markid > MAX_WF_MARKID )
  235.                   wf_next_markid = MIN_WF_MARKID
  236.             }
  237.  
  238.             create_mark(wf_next_markid, errorline, erroroffset)
  239.             wf_errors[magic_cookie] = buffer_filename FS wf_next_markid
  240.  
  241.             numerrors--
  242.          }
  243.  
  244.          # now get the help library name from the message
  245.          libraryname = strtok();
  246.  
  247.          # keep a list of buffers so we can free the marks easily later
  248.          wf_error_buffers[buffer_filename] = libraryname
  249.  
  250.          update_current_view()
  251.       }
  252.    }
  253. }
  254.