home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / p2demo21.exe / PEL / PVCS.PEL < prev    next >
Text File  |  1995-02-28  |  21KB  |  701 lines

  1. # $Header:   P:\source\wmacros\pvcs.pev   1.57   28 Feb 1995 13:47:12   PFHJXM0  $
  2.  
  3. ##############################################################################
  4. #
  5. #       Compuware Corporation
  6. #         31440 Northwestern Highway
  7. #           Farmington Hills, Michigan 48334-2564
  8. #
  9. #   This source code listing contains information that is
  10. #   proprietary to Compuware Corporation and may not be copied
  11. #   duplicated, translated, transmitted, stored, retrieved
  12. #   or in any manner or by any method conveyed or disclosed
  13. #   to a third party or parties without express written
  14. #   permission from Compuware Corporation.
  15. #
  16. #  
  17. ##############################################################################
  18.  
  19. #### $Workfile:   pvcs.pel  $: PVCS support
  20.  
  21. ### global variables
  22.  
  23. global  PVCS_DISABLED          = 0x00
  24. global  PVCS_ENABLE_MENU       = 0x01
  25. global  PVCS_ENABLE_GETS       = 0x02
  26. global  PVCS_ENABLE_EMPTY_GETS = 0x04
  27. local   IDC_VCS_ON_MOD        = 101;
  28. local   IDC_VCS_ON_NON        = 102;
  29.  
  30. global  PVCS_CUR_BUF = "{Current Buffer}"
  31.                 
  32. global default_get_command = "get -l $<";
  33. global default_put_command = "put -u $<";
  34. global get_command = default_get_command;
  35. global put_command = default_put_command;
  36.  
  37. ### local variables
  38.  
  39. global   pvcsEnabled
  40. local   pvcsPutEnabled
  41. #local   pvcsEmptyEnabled
  42. #local   pvcsMenuEnabled
  43. local   pvcsPutId
  44. local   pvcsGetId
  45. local   pvcsGetEmptyId
  46. local   pvcsBuffersGot
  47. #local   pvcsRevision = ""
  48.  
  49. # These are possible future PVCS ids.  They are commented out
  50. # because they produce warnings when not used.
  51. #local   IDM_PVCS        =  2999
  52. #local   IDM_GET         =  3000
  53. #local   IDM_PUT         =  3001
  54. #local   IDM_INDENT      =  3002
  55. #local   IDM_REGEN       =  3003
  56. #local   IDM_VCS         =  3004
  57. #local   IDM_VCOMPRESS   =  3005
  58. #local   IDM_VDEL        =  3006
  59. #local   IDM_VDIFF       =  3007
  60. #local   IDM_VJOURNAL    =  3008
  61. #local   IDM_VLOG        =  3009
  62. #local   IDM_VLOGIN      =  3010
  63. #local   IDM_VMRG        =  3011
  64. #local   IDM_VNAME       =  3012
  65.  
  66.  
  67. #
  68. ## pvcs() and
  69. ## toggle_pvcs()
  70. #
  71. #  Enable PVCS get and put.  The "on" argument can be set to one of 
  72. #  four values depending on the desired configuration:
  73. #
  74. #     PVCS_DISABLED          = 0 - disable PVCS
  75. #     PVCS_ENABLE_GETS       = 1 - enable get and put via existing file edits
  76. #     PVCS_ENABLE_EMPTY_GETS = 2 - enable get and put via non-existant 
  77. #                                  file reads
  78. #     PVCS_ENABLE_GETS +
  79. #     PVCS_ENABLE_EMPTY_GETS = 3 - enable get and put via existing and
  80. #                                  non-existant files
  81. #
  82. global function pvcs( on )
  83. {
  84.    if ( argcount() ) 
  85.       toggle_pvcs( on )
  86.    else
  87.       toggle_pvcs()
  88. }
  89.  
  90. global function toggle_pvcs( on )
  91. {
  92.    local hmenu
  93.  
  94.    if ( !argcount())
  95.    {
  96. #      on = not(and(pvcsEnabled, PVCS_ENABLE_GETS));
  97.  
  98.       if(and(pvcsEnabled, PVCS_ENABLE_GETS))
  99.          on = PVCS_DISABLED;
  100.       else
  101.          on = PVCS_ENABLE_GETS + PVCS_ENABLE_MENU;
  102.  
  103.       message( "PVCS " (on ? "Enabled." : "Disabled." ))
  104.    }
  105.    else
  106.       on = 0+on
  107.  
  108.    pvcs_menu( on )
  109.  
  110.    #
  111.    # enable puts for all files
  112.    #
  113.    if (on && !pvcsPutEnabled)
  114.    {
  115.       pvcsPutEnabled = 1
  116.       pvcsPutId      = function_id( "pvcs_put_buffer" )
  117.       attach_event_handler( EVENT.EDIT_FILE_SAVE, pvcsPutId )
  118.    }
  119.    else if (!on && pvcsPutEnabled)
  120.    {
  121.       pvcsPutEnabled = 0
  122.       delete_event( EVENT.EDIT_FILE_SAVE, pvcsPutId )
  123.    }
  124.  
  125.    #
  126.    # enable gets for existing files
  127.    #
  128.    if (and( on, PVCS_ENABLE_GETS ) && !and(pvcsEnabled, PVCS_ENABLE_GETS))
  129.    {
  130.       pvcsGetId   = function_id( "pvcs_get_existing_buffer" )
  131.       attach_event_handler( EVENT.READ_ONLY_MOD, pvcsGetId )
  132.    }
  133.    else if (!and( on, PVCS_ENABLE_GETS ) && and(pvcsEnabled, PVCS_ENABLE_GETS))
  134.    {
  135.       delete_event( EVENT.READ_ONLY_MOD, pvcsGetId )
  136.    }
  137.    pvcsEnabled = set_flag_bits(pvcsEnabled, PVCS_ENABLE_GETS, on);
  138.  
  139.    #
  140.    # enable gets for non-existing files
  141.    #
  142.    if (and( on, PVCS_ENABLE_EMPTY_GETS ) && !and(pvcsEnabled, PVCS_ENABLE_EMPTY_GETS))
  143.    {
  144.       pvcsGetEmptyId   = function_id( "pvcs_get_empty" )
  145.       attach_event_handler( EVENT.NEW_EDIT_FILE, pvcsGetEmptyId )
  146.    }
  147.    else if (!and( on, PVCS_ENABLE_EMPTY_GETS ) && and(pvcsEnabled, PVCS_ENABLE_EMPTY_GETS))
  148.    {
  149.       delete_event( EVENT.NEW_EDIT_FILE, pvcsGetEmptyId )
  150.    }
  151.    pvcsEnabled = set_flag_bits(pvcsEnabled, PVCS_ENABLE_EMPTY_GETS, on);
  152.  
  153.    #  Enable the pvcs menu without turning on the pvcs features;
  154.    pvcsEnabled = set_flag_bits(pvcsEnabled, PVCS_ENABLE_MENU, on);
  155. }
  156.  
  157. ###
  158. ### event handlers for PVCS
  159. ###
  160.  
  161. ### event handler invoked when attempting to edit a non-exisiting file
  162.  
  163. global function pvcs_get_empty()
  164. {
  165.    local prevPauseOnError   
  166.  
  167.    prevPauseOnError = pause_on_error
  168.    pause_on_error = 0
  169.  
  170.    if ( and(pvcsEnabled, PVCS_ENABLE_EMPTY_GETS) && filemode( buffer_filename ) < 0)
  171.    {
  172.       # file doesn't exist
  173.       pvcs_get_existing_buffer( 1 )
  174.    }
  175.  
  176.    pause_on_error = prevPauseOnError
  177. }
  178.  
  179.  
  180. ### event handler invoked when attempting to edit a read-only buffer
  181.  
  182. ## pvcs_get_existing_buffer()
  183. #
  184. # forceget instructs not to delete the buffer and reload, just perform
  185. # the PVCS command.
  186. #
  187. global function pvcs_get_existing_buffer( forceget )
  188. {
  189.    local cmd
  190.    local prevPauseOnError   
  191.    local fmode             = filemode( buffer_filename )
  192.    local read_only         = (fmode > 0 && and(fmode, _READ_ONLY))
  193.  
  194.    prevPauseOnError  = pause_on_error
  195.    pause_on_error    = 0
  196.    
  197.    # check the file's read-only status
  198.    
  199.    if ( forceget || (and(pvcsEnabled, PVCS_ENABLE_GETS) && read_only ) ) 
  200.    {
  201.       if (buffer_is_modified())
  202.       {
  203.          if (toupper(confirm(buffer_filename " has been MODIFIED, get anyway? [YN]", "YyNn")) \
  204.              != "Y")
  205.          {
  206.             pause_on_error = prevPauseOnError
  207.             return
  208.          }
  209.       }
  210.       else if (!read_only)
  211.       {
  212.          if (toupper(confirm("Any changes to " buffer_filename " will be lost, get anyway? [YN]", "YyNn")) \
  213.              != "Y")
  214.          {
  215.             pause_on_error = prevPauseOnError
  216.             return
  217.          }
  218.       }
  219.  
  220.       cmd = prompt_history("PVCSGET", "Enter a VCS \"get\" command: ",
  221. #                           get_command " " pvcsRevision buffer_filename,
  222.                            expand_command(get_command, buffer_filename),
  223.                            FALSE, FALSE, "pvcs_get_dialog" )
  224.       if ( cmd ) 
  225.       {
  226.          # perform the GET command
  227.          pvcsSystemCommand( cmd, forceget )
  228.  
  229.          # add this buffer to the list if we have it locked
  230.          if ( !and(buffer_flags, BUFFER_READ_ONLY) ) 
  231.             pvcsBuffersGot[ current_buffer ] = (cmd ~ /<-[Ll]/)
  232.       }
  233.    }
  234.    pause_on_error = prevPauseOnError
  235. }
  236.  
  237.  
  238. ### event handler invoked when attempting to write a buffer
  239.  
  240. global function pvcs_put_buffer( forceput )
  241. {
  242.    local   priorPvcsEnabled
  243.    local   cmd
  244.    local   temp_fname
  245.  
  246.    # see if the current buffer originated from a PVCS get
  247.  
  248.    if ( (pvcsEnabled && current_buffer in pvcsBuffersGot &&     \
  249.          pvcsBuffersGot[current_buffer] ) || forceput )
  250.    {
  251.       cmd = prompt_history( 
  252.                "PVCSPUT",
  253.                "Enter a VCS \"put\" command: ",
  254. #               put_command " " pvcsRevision buffer_filename,
  255.                expand_command(put_command, buffer_filename),
  256.                FALSE,
  257.                FALSE, "pvcs_put_dialog" )
  258.       
  259.       if ( cmd )
  260.       {
  261.          # write the current buffer to disk if necessary,
  262.          priorPvcsEnabled = pvcsEnabled
  263.          pvcsEnabled = 0         # prevent recursion
  264.          write_buffer_key()
  265.          pvcsEnabled = priorPvcsEnabled
  266.  
  267.          # perform the put command
  268.          pvcsSystemCommand( cmd )
  269.       }
  270.    }
  271. }
  272.  
  273. ## support functions for pvcs commands
  274.  
  275. local   bufferSavedState[]
  276.  
  277. local function pvcsSystemCommand( cmd, forceget )
  278. {
  279.    enable_buffer_change_error()
  280.  
  281.    # save the current state of the current buffer
  282.    saveBufferState()
  283.  
  284.    # change to the directory where the file is
  285.    push_dir( path_path( buffer_filename ))
  286.  
  287.    # run command in a separate session and disable redrawing of
  288.    # the editor window
  289.    # dos_box(cmd, SYS_NOEXPOSE + SYS_PROMPT, cmd)
  290.    system_pause(cmd, SYS_SESSION + SYS_NOEXPOSE)
  291.  
  292.    # restore the prior working directory
  293.    pop_dir()
  294.  
  295.    # re-edit the file and restore the state of the
  296.    # buffer to what it was, depending on the file's
  297.    # new read-write/read-only status, etc.
  298.    rereadNewBuffer()
  299.  
  300.    # if a wildcard GET or PUT was performed, check all buffers
  301.    # for conflicts
  302.    if ( cmd ~ /[*?][^ \t]*$/ )
  303.       checkAllFilemodes();
  304. }
  305.  
  306. local function checkAllFilemodes()
  307. {
  308.    #
  309.    # PVCS GET and PUT commands can result in changes to the filemodes
  310.    # of one or more files.  This function synchronizes the read-write/
  311.    # read-only status of all buffers currently in the editor with their
  312.    # corresponding disk files.
  313.    #
  314.    local   priorBuffer = current_buffer
  315.    local   sentinel = next_buffer("", 0, 1)
  316.    local   fmode
  317.  
  318.    do {
  319.       fmode = filemode( buffer_filename )
  320.       if ( fmode >= 0 )
  321.       {
  322.          if ( !and( fmode, _READ_ONLY ) !=       \
  323.               !and( buffer_flags, BUFFER_READ_ONLY ) )
  324.          {
  325.             # read only status differs:
  326.             saveBufferState()
  327.             bufferSavedState[ "filetime" ] = 0
  328.             rereadNewBuffer()
  329.          }
  330.       }
  331.    } while( next_buffer("", 0, 1) != sentinel )
  332.  
  333.    current_buffer = priorBuffer
  334. }
  335.  
  336. local function saveBufferState()
  337. {
  338.    #
  339.    # save salient info about the current buffer in an array
  340.    #
  341.    bufferSavedState[ "filename" ]  = buffer_filename
  342.    bufferSavedState[ "filetime" ]  = filetime( buffer_filename )
  343.    bufferSavedState[ "name" ]      = buffer_name
  344.    bufferSavedState[ "flags" ]     = buffer_flags
  345.    bufferSavedState[ "line" ]      = current_line
  346.    bufferSavedState[ "column" ]    = current_column
  347.    bufferSavedState[ "keymap" ]    = buffer_keymap
  348.    bufferSavedState[ "tabs" ]      = buffer_tabs
  349. }
  350.  
  351. local function rereadNewBuffer()
  352. {
  353.    local   fmode
  354.    local anything
  355.    local old_create_new_bufwin;
  356.  
  357.    #
  358.    # re-read a buffer which has possibly been changed by a system
  359.    # command, using the attributes saved by function saveBufferState()
  360.    #
  361. #  if ( anything in bufferSavedState )
  362.    if ( bufferSavedState["filename"] )
  363.    {
  364.       # has the disk file changed?
  365.       if ( bufferSavedState[ "filetime" ] != filetime( buffer_filename ))
  366.       {
  367.          # delete the current buffer without asking
  368.          #
  369.          buffer_flags = and( buffer_flags, not( BUFFER_MODIFIED ))
  370.  
  371.          old_create_new_bufwin = create_new_bufwin;
  372.          create_new_bufwin = 0;
  373.          delete_buffer();
  374.          create_new_bufwin = old_create_new_bufwin;
  375.           
  376.          # create a new buffer with the same attributes
  377.          # as before
  378.          #
  379.  
  380.          current_buffer = create_buffer( bufferSavedState[ "name" ],     \
  381.                                          bufferSavedState[ "filename" ], \
  382.                                          bufferSavedState[ "flags" ] )
  383.  
  384.          new_edit_file()
  385.  
  386.          current_line    = bufferSavedState[ "line" ]
  387.          current_column  = bufferSavedState[ "column" ]
  388.          buffer_keymap   = bufferSavedState[ "keymap" ]
  389.          buffer_tabs     = bufferSavedState[ "tabs" ]
  390.  
  391.          center_cursor()
  392.       }
  393.  
  394.       delete bufferSavedState
  395.    }
  396.  
  397.    # update the read-only bit of the buffer to match the disk file
  398.    #
  399.    fmode = filemode( buffer_filename )
  400.    if ( fmode >= 0 )
  401.       toggle_buffer_flags( BUFFER_READ_ONLY, and( fmode, _READ_ONLY ) )
  402.  
  403. #  warning("filetime(curr_buff) == %d", filetime( buffer_filename ) )
  404.    return fmode
  405. }
  406.  
  407. ## assemble a logfile revision or disk filename
  408. #
  409. global function pvcs_make_name( ver, name )
  410. {
  411.    ver   = trim( ltrim( ver ))
  412.    name  = trim( ltrim( name ))
  413.  
  414.    # check for version label or revision number or "*"
  415.    if ( ver )
  416.    {
  417.       if ( isalpha( substr( ver, 1, 1 )))
  418.          ver = "-v" "\"" ver "\""      # version label
  419.       else if ( substr( ver, 1, 1 ) == "*" )
  420.          ver = "-r" substr( ver, 2 )   # trunk tip revision
  421.       else if ( ver !~ /^-[rRvV]/ )
  422.          ver = "-r" ver                # revision number
  423.  
  424.       ver = ver " "
  425.    }
  426.  
  427.    # replace {current buffer} string with the name of a new temp file
  428.    if ( name == PVCS_CUR_BUF )
  429.    {
  430.       if ( ver )
  431.          name = buffer_filename
  432.       else
  433.       {
  434.          name = pvcs_create_temp_file()
  435.          write_buffer( name )
  436.       }
  437.    }
  438.  
  439.    return ver name
  440. }
  441.  
  442. ###
  443. # pvcs_create_temp_file() and
  444. # pvcs_cleanup_temp_files()
  445. #
  446. local pvcs_temp_files[]
  447.  
  448. ## create a temp file and add the name to the list
  449. #
  450. global function pvcs_create_temp_file()
  451. {
  452.    local fn = create_temp_name()
  453.    pvcs_temp_files[ fn ] = 0
  454.    return fn
  455. }
  456.  
  457.  
  458. ## remove any accumulated temporary files
  459. #
  460. global function pvcs_cleanup_temp_files()
  461. {
  462.    local fn
  463.    if ( pvcs_temp_files )
  464.    {
  465.       for ( fn in pvcs_temp_files )
  466.       {
  467.          unlink( fn )
  468.       }
  469.       delete( pvcs_temp_files )
  470.    }
  471. }
  472.  
  473. ## display the output from a system command in the current window
  474. #
  475. global function pvcs_system_output( bufName, outputFile, removeIt )
  476. {
  477.    if ( filesize( outputFile ))
  478.    {
  479.       # read the file into an empty buffer
  480.       create_buf_and_win( outputFile )
  481.       buffer_name = bufName
  482.       copy_buffer_internally()
  483.  
  484.       # if removeIt argument is TRUE, wait for any key then
  485.       # delete the buffer.
  486.       if ( removeIt )
  487.       {
  488.          goto_buffer_bottom()
  489.          message( "Hit any key to continue." )
  490.          display_update()
  491.          while ( !keyboard_input_pending )
  492.          {
  493.          }
  494.          getkey()
  495.          delete_buffer()
  496.       }
  497.    }
  498.    message( "" )
  499. }
  500.  
  501. ###
  502. ### put up a menu of PVCS system commands
  503. ###
  504. global function pvcs_menu(on)
  505. {
  506.    local   priorPvcsEnabled
  507.    local   mainmenu
  508.    
  509.    # get the main menu
  510.    mainmenu = menu_info(0, MI_MENUHANDLE)
  511.    
  512.    if ( mainmenu )
  513.    {
  514.       if ( on ) 
  515.       {
  516.          modify_menuitem( mainmenu, IDM_GET,   MI_ENABLED )
  517.          modify_menuitem( mainmenu, IDM_PUT,   MI_ENABLED )
  518.          modify_menuitem( mainmenu, IDM_VDIFF, MI_ENABLED )
  519.       }
  520.       else
  521.       {
  522.          modify_menuitem( mainmenu, IDM_GET,   MI_DISABLED )
  523.          modify_menuitem( mainmenu, IDM_PUT,   MI_DISABLED )
  524.          modify_menuitem( mainmenu, IDM_VDIFF, MI_DISABLED )
  525.       }
  526.    }
  527. }
  528.  
  529. ######## VCS SETTINGS PAGE #####################################################
  530. global function create_vcs_page(pageid, dlgid)
  531. {
  532.    local handle;
  533.  
  534.    handle = create_page(function_id( "vcs_settings_callback" ), 
  535.                                dlgid, IDD_VCS_SETTINGS, resource_dll)
  536.    attach_help(editor_helpfile, handle);
  537.    if(isWindows())
  538.       nbPagePrefix[pageid].help = "VCS Settings";
  539.    else
  540.       nbPagePrefix[pageid].help = "vcspage";
  541.    add_dialog_item( handle, IDB_UNDO, DCTRL_PUSH_BUTTON);
  542.    initialize_vcs_settings(handle);
  543.    set_notebook_page_dialog(dlgid, pageid, handle);
  544.    nbPagePrefix[pageid].dialog_handle = handle;
  545. }
  546.  
  547. local function initialize_vcs_settings(handle)
  548. {
  549.    nb_initializing = TRUE
  550.  
  551.    set_dialog_item( handle, IDE_GET_COMMAND, DAC_EDIT_TEXT, get_command "")
  552.    set_dialog_item( handle, IDE_PUT_COMMAND, DAC_EDIT_TEXT, put_command "")
  553.    
  554.    if(and(pvcsEnabled, PVCS_ENABLE_MENU))
  555.    {
  556.       set_dialog_item( handle, IDE_GET_COMMAND, DAC_ENABLE)
  557.       set_dialog_item( handle, IDE_PUT_COMMAND, DAC_ENABLE)
  558.       set_dialog_item( handle, IDC_VCS_ENABLE, DAC_CHECK)
  559.  
  560.       if(and(pvcsEnabled, PVCS_ENABLE_GETS))
  561.          set_dialog_item( handle, IDC_VCS_ON_MOD, DAC_CHECK)
  562.       else
  563.          set_dialog_item( handle, IDC_VCS_ON_MOD, DAC_UNCHECK)
  564.  
  565.       if(and(pvcsEnabled, PVCS_ENABLE_EMPTY_GETS))
  566.          set_dialog_item( handle, IDC_VCS_ON_NON, DAC_CHECK)
  567.       else
  568.          set_dialog_item( handle, IDC_VCS_ON_NON, DAC_UNCHECK)
  569.    }
  570.    else
  571.    {
  572.       set_dialog_item( handle, IDE_GET_COMMAND, DAC_DISABLE)
  573.       set_dialog_item( handle, IDE_PUT_COMMAND, DAC_DISABLE)
  574.       set_dialog_item( handle, IDC_VCS_ON_MOD,  DAC_DISABLE)
  575.       set_dialog_item( handle, IDC_VCS_ON_NON,  DAC_DISABLE)
  576.  
  577.       set_dialog_item( handle, IDC_VCS_ENABLE, DAC_UNCHECK)
  578.       set_dialog_item( handle, IDC_VCS_ON_MOD, DAC_UNCHECK)
  579.       set_dialog_item( handle, IDC_VCS_ON_NON, DAC_UNCHECK)
  580.    }
  581.    nb_initializing = FALSE;
  582. }
  583.  
  584. global function vcs_settings_callback()
  585.    local new_val, return_msg = DRC_CONTINUE;
  586.  
  587.    if(callback_msg == DM_HELPREQUESTED)
  588.    {
  589.       display_help(nbPagePrefix[current_nb_page].help, callback_dialog_handle);
  590.       return_msg = DRC_MSG_PROCESSED;
  591.  
  592.    }
  593.    else if( callback_msg == DM_CANCEL )
  594.    {
  595.       #  dialog_return_value = ""
  596.       nbPagePrefix[current_nb_page].modified = FALSE;
  597.       return_msg = DRC_MSG_PROCESSED
  598.    }
  599.    else if( (callback_msg == DM_CLICK) || (callback_msg == DM_DOUBLE_CLICK) )
  600.    {
  601.       if ( callback_index == IDB_UNDO  )
  602.       {
  603.          nbPagePrefix[current_nb_page].modified = FALSE;
  604.          initialize_vcs_settings(callback_dialog_handle)
  605.       }
  606.       else
  607.       {
  608.          enable_undo(callback_dialog_handle, callback_index);
  609.          nbPagePrefix[current_nb_page].modified = TRUE;
  610.  
  611.          if(callback_index == IDB_DEFAULT)
  612.          {
  613.             default_vcs_settings(callback_dialog_handle);
  614.          }
  615.          else if(callback_index == IDC_VCS_ENABLE)
  616.          {
  617.             if(query_dialog_item(callback_dialog_handle, callback_index, DAC_CHECK))
  618.             {
  619.                set_dialog_item(callback_dialog_handle, IDE_GET_COMMAND, DAC_ENABLE);
  620.                set_dialog_item(callback_dialog_handle, IDE_PUT_COMMAND, DAC_ENABLE);
  621.                set_dialog_item(callback_dialog_handle, IDC_VCS_ON_MOD,      DAC_ENABLE);
  622.                set_dialog_item(callback_dialog_handle, IDC_VCS_ON_NON,      DAC_ENABLE);
  623.             }
  624.             else
  625.             {
  626.                set_dialog_item(callback_dialog_handle, IDE_GET_COMMAND, DAC_DISABLE);
  627.                set_dialog_item(callback_dialog_handle, IDE_PUT_COMMAND, DAC_DISABLE);
  628.                set_dialog_item(callback_dialog_handle, IDC_VCS_ON_MOD,  DAC_UNCHECK);
  629.                set_dialog_item(callback_dialog_handle, IDC_VCS_ON_NON,  DAC_UNCHECK);
  630.                set_dialog_item(callback_dialog_handle, IDC_VCS_ON_MOD,  DAC_DISABLE);
  631.                set_dialog_item(callback_dialog_handle, IDC_VCS_ON_NON,  DAC_DISABLE);
  632.             }
  633.          }
  634.       }
  635.       return_msg = DRC_MSG_PROCESSED;
  636.    } 
  637.    else if ( callback_msg == DM_KILL_FOCUS )
  638.    {
  639.       if ( nb_initializing )
  640.          return_msg = DRC_CONTINUE;
  641.       else
  642.       {
  643.          nbPagePrefix[current_nb_page].modified = TRUE;
  644.          return_msg = DRC_MSG_PROCESSED;
  645.       }
  646.    }
  647.    else if(callback_msg == DM_CHANGE)
  648.       enable_undo(callback_dialog_handle, callback_index);
  649.  
  650.    return return_msg;
  651. }
  652.  
  653. global function assign_vcs_changes(handle)
  654. {
  655.    local on = 0;
  656.  
  657.    get_command = query_dialog_item(handle, IDE_GET_COMMAND, DAC_EDIT_TEXT);
  658.    put_command = query_dialog_item(handle, IDE_PUT_COMMAND, DAC_EDIT_TEXT);
  659.  
  660.    if(query_dialog_item(handle, IDC_VCS_ENABLE, DAC_CHECK))
  661.    {
  662.       on += PVCS_ENABLE_MENU;
  663.       
  664.       if(query_dialog_item(handle, IDC_VCS_ON_MOD, DAC_CHECK))
  665.          on += PVCS_ENABLE_GETS;
  666.  
  667.       if(query_dialog_item(handle, IDC_VCS_ON_NON, DAC_CHECK))
  668.          on += PVCS_ENABLE_EMPTY_GETS;
  669.    }
  670.    toggle_pvcs(on);
  671. }
  672.  
  673. local function default_vcs_settings( handle )
  674. {
  675.    nb_initializing = TRUE
  676.  
  677.    set_dialog_item( handle, IDE_GET_COMMAND, DAC_EDIT_TEXT, default_get_command "");
  678.    set_dialog_item( handle, IDE_PUT_COMMAND, DAC_EDIT_TEXT, default_put_command "");
  679.    
  680.    set_dialog_item( handle, IDE_GET_COMMAND, DAC_DISABLE);
  681.    set_dialog_item( handle, IDE_PUT_COMMAND, DAC_DISABLE);
  682.    set_dialog_item( handle, IDC_VCS_ENABLE,  DAC_UNCHECK);
  683.  
  684.    nb_initializing = FALSE;
  685. }
  686.  
  687. function pvcs_settings( settings_index, settings_data[] )
  688. {
  689.    local new_array;
  690.  
  691.    settings_data[ settings_index++ ] = sprintf( "SET_VCS %d,%s,%s\n",
  692.                                                 pvcsEnabled,
  693.                                                 quote_string(get_command),
  694.                                                 quote_string(put_command) )
  695.  
  696.    new_array.array = settings_data
  697.    new_array.index = settings_index
  698.    return new_array
  699. }
  700.